Skip to content

Commit db11753

Browse files
Fix NPE when no world given to explosions (#1286)
1 parent 8c8c18b commit db11753

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

patches/server/0308-Config-to-remove-explosion-radius-clamp.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Subject: [PATCH] Config to remove explosion radius clamp
66
Co-authored-by: Encode42 <me@encode42.dev>
77

88
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
9-
index 1e2304347fc369e5d9fe5d4c3cca8856766f5c1a..84b230d979a91dd776e180e5b828b26bdc98ef12 100644
9+
index 1e2304347fc369e5d9fe5d4c3cca8856766f5c1a..d5aeaac49fcbc32d5276168d910f9e298ae97fd7 100644
1010
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
1111
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
1212
@@ -98,7 +98,7 @@ public class EnderDragon extends Mob implements Enemy {
@@ -22,20 +22,20 @@ index 1e2304347fc369e5d9fe5d4c3cca8856766f5c1a..84b230d979a91dd776e180e5b828b26b
2222

2323
public EnderDragon(EntityType<? extends EnderDragon> entitytypes, Level world) {
2424
super(EntityType.ENDER_DRAGON, world);
25-
+ this.explosionSource = new Explosion(this.level, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // Purpur - moved instantiation from field
25+
+ this.explosionSource = new Explosion(world, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // Purpur - moved instantiation from field
2626
this.subEntities = new EnderDragonPart[]{this.head, this.neck, this.body, this.tail1, this.tail2, this.tail3, this.wing1, this.wing2};
2727
this.setHealth(this.getMaxHealth());
2828
this.noPhysics = true;
2929
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
30-
index c0d39afe5b80159ed9aaca4ddd4763d707882f2e..3c9e0cee78deeae6b47a186f1bfc47f3956ec9c7 100644
30+
index de6050c867ac55dd6f0d8243289296781add7157..f74fad1a124daa888e0a05a8a707c4fd3384a6b9 100644
3131
--- a/src/main/java/net/minecraft/world/level/Explosion.java
3232
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
3333
@@ -86,7 +86,7 @@ public class Explosion {
3434
this.hitPlayers = Maps.newHashMap();
3535
this.level = world;
3636
this.source = entity;
3737
- this.radius = (float) Math.max(power, 0.0); // CraftBukkit - clamp bad values
38-
+ this.radius = (float) (world.purpurConfig.explosionClampRadius ? Math.max(power, 0.0) : power); // CraftBukkit - clamp bad values // Purpur
38+
+ this.radius = (float) (world == null || world.purpurConfig.explosionClampRadius ? Math.max(power, 0.0) : power); // CraftBukkit - clamp bad values // Purpur
3939
this.x = x;
4040
this.y = y;
4141
this.z = z;
@@ -44,7 +44,7 @@ index c0d39afe5b80159ed9aaca4ddd4763d707882f2e..3c9e0cee78deeae6b47a186f1bfc47f3
4444
public void explode() {
4545
// CraftBukkit start
4646
- if (this.radius < 0.1F) {
47-
+ if (this.level.purpurConfig.explosionClampRadius && this.radius < 0.1F) { // Purpur
47+
+ if ((this.level == null || this.level.purpurConfig.explosionClampRadius) && this.radius < 0.1F) { // Purpur
4848
return;
4949
}
5050
// CraftBukkit end

0 commit comments

Comments
 (0)