3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 07:10:10 +01: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.
Dieser Commit ist enthalten in:
feildmaster 2012-12-28 20:27:41 -06:00
Ursprung 509e3d2a32
Commit 538de63a03
3 geänderte Dateien mit 10 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -30,7 +30,7 @@ import org.bukkit.plugin.PluginManager;
public abstract class Entity { public abstract class Entity {
// CraftBukkit start // CraftBukkit start
private static final int CURRENT_LEVEL = 1; private static final int CURRENT_LEVEL = 2;
static boolean isLevelAtLeast(NBTTagCompound tag, int level) { static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
} }
@ -1162,6 +1162,11 @@ public abstract class Entity {
if (!nbttagcompound.hasKey("Bukkit.MaxHealth")) { if (!nbttagcompound.hasKey("Bukkit.MaxHealth")) {
entity.maxHealth = entity.getMaxHealth(); 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 // CraftBukkit end

Datei anzeigen

@ -76,7 +76,8 @@ public class EntityWolf extends EntityTameableAnimal {
} }
protected boolean bj() { protected boolean bj() {
return this.isAngry(); // CraftBukkit - added && !this.isTamed()
return this.isAngry() && !this.isTamed();
} }
protected String aY() { protected String aY() {

Datei anzeigen

@ -236,6 +236,8 @@ public class CraftEventFactory {
org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? (AnimalTamer) tamer.getBukkitEntity() : null); org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? (AnimalTamer) tamer.getBukkitEntity() : null);
CraftServer craftServer = (CraftServer) bukkitEntity.getServer(); CraftServer craftServer = (CraftServer) bukkitEntity.getServer();
entity.persistent = true;
EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer); EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
craftServer.getPluginManager().callEvent(event); craftServer.getPluginManager().callEvent(event);
return event; return event;