mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-16 12:43:52 -07:00
Fix persistence on tamed pets. Fixes BUKKIT-3300
With the persistence api introduced, pets did not have their persistence flag updated to reflect their persistence. This caused tame ocelots to not persist under specific conditions.
This commit is contained in:
@@ -30,7 +30,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
public abstract class Entity {
|
||||
|
||||
// CraftBukkit start
|
||||
private static final int CURRENT_LEVEL = 1;
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
||||
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
}
|
||||
@@ -1162,6 +1162,11 @@ public abstract class Entity {
|
||||
if (!nbttagcompound.hasKey("Bukkit.MaxHealth")) {
|
||||
entity.maxHealth = entity.getMaxHealth();
|
||||
}
|
||||
|
||||
// Reset the persistence for tamed animals
|
||||
if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
|
||||
entity.persistent = !entity.bj();
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
|
Reference in New Issue
Block a user