From 5409d05d3ac1ed77d8d96effd0864f5e3f9af455 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Tue, 4 Dec 2012 23:13:12 -0600 Subject: Ensure animals don't despawn due to old default setting. The old default for the persistent flag on mobs was false which was then written out to their NBT data when they were saved. We now use this data for all mobs, not just non-animal mobs. However, this means animals that spawned before that change will now start despawning like monsters do. To avoid this we add a new flag to the mob's saved data to mark if the data was saved before or after we started using it and ignore it if it was before. --- src/main/java/net/minecraft/server/EntityLiving.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main/java/net') diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index fff17a2d..b709cb60 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -1087,6 +1087,7 @@ public abstract class EntityLiving extends Entity { nbttagcompound.setShort("AttackTime", (short) this.attackTicks); nbttagcompound.setBoolean("CanPickUpLoot", this.canPickUpLoot); nbttagcompound.setBoolean("PersistenceRequired", this.persistent); + nbttagcompound.setBoolean("Bukkit.PersistenceUpdated", true); // CraftBukkit NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.equipment.length; ++i) { @@ -1134,7 +1135,13 @@ public abstract class EntityLiving extends Entity { this.deathTicks = nbttagcompound.getShort("DeathTime"); this.attackTicks = nbttagcompound.getShort("AttackTime"); this.canPickUpLoot = nbttagcompound.getBoolean("CanPickUpLoot"); - this.persistent = nbttagcompound.getBoolean("PersistenceRequired"); + // CraftBukkit start - if persistence is false only use it if it was set after we started using it + boolean data = nbttagcompound.getBoolean("PersistenceRequired"); + if (nbttagcompound.hasKey("Bukkit.PersistenceUpdated") || data) { + this.persistent = data; + } + // CraftBukkit end + NBTTagList nbttaglist; int i; -- cgit v1.2.3