3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

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.
Dieser Commit ist enthalten in:
Travis Watkins 2012-12-04 23:13:12 -06:00
Ursprung b854320fc8
Commit 5409d05d3a

Datei anzeigen

@ -1087,6 +1087,7 @@ public abstract class EntityLiving extends Entity {
nbttagcompound.setShort("AttackTime", (short) this.attackTicks); nbttagcompound.setShort("AttackTime", (short) this.attackTicks);
nbttagcompound.setBoolean("CanPickUpLoot", this.canPickUpLoot); nbttagcompound.setBoolean("CanPickUpLoot", this.canPickUpLoot);
nbttagcompound.setBoolean("PersistenceRequired", this.persistent); nbttagcompound.setBoolean("PersistenceRequired", this.persistent);
nbttagcompound.setBoolean("Bukkit.PersistenceUpdated", true); // CraftBukkit
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.equipment.length; ++i) { 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.deathTicks = nbttagcompound.getShort("DeathTime");
this.attackTicks = nbttagcompound.getShort("AttackTime"); this.attackTicks = nbttagcompound.getShort("AttackTime");
this.canPickUpLoot = nbttagcompound.getBoolean("CanPickUpLoot"); 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; NBTTagList nbttaglist;
int i; int i;