Fix slime pathfinding when loaded from NBT

GH-1507

The canWander property is initialized to true by default, however when
loaded from NBT, if the key doesn't exist the property will be set to
false. The correct solution is to ensure the key exists before setting
the property.
This commit is contained in:
Zach Brown 2018-09-29 16:00:55 -04:00
parent 5561f5dfdf
commit 10d1ebb3ab

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Slime Pathfinder Events
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
index 238f3c7926..cfa4710b78 100644
index 238f3c792..586b9a3a6 100644
--- a/src/main/java/net/minecraft/server/EntitySlime.java
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
@@ -0,0 +0,0 @@ public class EntitySlime extends EntityInsentient implements IMonster {
@ -20,7 +20,11 @@ index 238f3c7926..cfa4710b78 100644
this.setSize(i + 1, false);
this.bD = nbttagcompound.getBoolean("wasOnGround");
+ this.canWander = nbttagcompound.getBoolean("Paper.canWander"); // Paper
+ // Paper start - check exists before loading or this will be loaded as false
+ if (nbttagcompound.hasKey("Paper.canWander")) {
+ this.canWander = nbttagcompound.getBoolean("Paper.canWander");
+ }
+ // Paper end
}
public boolean dy() {
@ -115,7 +119,7 @@ index 238f3c7926..cfa4710b78 100644
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
index 18e7ef80ac..8403c1e01c 100644
index 18e7ef80a..8403c1e01 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
@@ -0,0 +0,0 @@ public class CraftSlime extends CraftMob implements Slime {