mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 02:35:49 +01:00
SPIGOT-6663: Chicken Jockeys chickens don't despawn
By: md_5 <git@md-5.net>
This commit is contained in:
parent
bfc74e8628
commit
2ccd460e09
10 changed files with 43 additions and 29 deletions
|
@ -322,7 +322,7 @@
|
|||
+ // Reset the persistence for tamed animals
|
||||
+ if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
|
||||
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
+ entityinsentient.persistenceRequired = !entityinsentient.isTypeNotPersistent(0);
|
||||
+ entityinsentient.setPersistenceRequired(!entityinsentient.isTypeNotPersistent(0));
|
||||
+ }
|
||||
+ }
|
||||
+ this.persist = !nbttagcompound.hasKey("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist");
|
||||
|
|
|
@ -20,6 +20,15 @@
|
|||
public abstract class EntityInsentient extends EntityLiving {
|
||||
|
||||
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.BYTE);
|
||||
@@ -101,7 +114,7 @@
|
||||
private final NonNullList<ItemStack> armorItems;
|
||||
public final float[] armorDropChances;
|
||||
private boolean canPickUpLoot;
|
||||
- public boolean persistenceRequired;
|
||||
+ private boolean persistenceRequired;
|
||||
private final Map<PathType, Float> pathfindingMalus;
|
||||
public MinecraftKey lootTable;
|
||||
public long lootTableSeed;
|
||||
@@ -113,6 +126,8 @@
|
||||
private BlockPosition restrictCenter;
|
||||
private float restrictRadius;
|
||||
|
@ -29,17 +38,22 @@
|
|||
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
this.handItems = NonNullList.a(2, ItemStack.EMPTY);
|
||||
@@ -136,6 +151,9 @@
|
||||
@@ -136,7 +151,14 @@
|
||||
this.initPathfinder();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - default persistance to type's persistance value
|
||||
+ this.persistenceRequired = !isTypeNotPersistent(0);
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
+ public void setPersistenceRequired(boolean persistenceRequired) {
|
||||
+ this.persistenceRequired = persistenceRequired;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
protected void initPathfinder() {}
|
||||
@@ -216,7 +234,38 @@
|
||||
|
||||
@@ -216,7 +238,38 @@
|
||||
}
|
||||
|
||||
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
||||
|
@ -78,7 +92,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -443,16 +492,26 @@
|
||||
@@ -443,16 +496,26 @@
|
||||
nbttagcompound.setBoolean("NoAI", this.isNoAI());
|
||||
}
|
||||
|
||||
|
@ -107,7 +121,7 @@
|
|||
NBTTagList nbttaglist;
|
||||
int i;
|
||||
|
||||
@@ -499,6 +558,11 @@
|
||||
@@ -499,6 +562,11 @@
|
||||
}
|
||||
|
||||
this.setNoAI(nbttagcompound.getBoolean("NoAI"));
|
||||
|
@ -119,7 +133,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -562,7 +626,7 @@
|
||||
@@ -562,7 +630,7 @@
|
||||
protected void b(EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
|
||||
|
@ -128,7 +142,7 @@
|
|||
this.a(entityitem);
|
||||
this.receive(entityitem, itemstack.getCount());
|
||||
entityitem.die();
|
||||
@@ -571,15 +635,29 @@
|
||||
@@ -571,15 +639,29 @@
|
||||
}
|
||||
|
||||
public boolean j(ItemStack itemstack) {
|
||||
|
@ -159,7 +173,7 @@
|
|||
}
|
||||
|
||||
this.b(enumitemslot, itemstack);
|
||||
@@ -692,18 +770,18 @@
|
||||
@@ -692,18 +774,18 @@
|
||||
EntityHuman entityhuman = this.level.findNearbyPlayer(this, -1.0D);
|
||||
|
||||
if (entityhuman != null) {
|
||||
|
@ -181,7 +195,7 @@
|
|||
this.die();
|
||||
} else if (d0 < (double) l) {
|
||||
this.noActionTime = 0;
|
||||
@@ -718,6 +796,7 @@
|
||||
@@ -718,6 +800,7 @@
|
||||
@Override
|
||||
protected final void doTick() {
|
||||
++this.noActionTime;
|
||||
|
@ -189,7 +203,7 @@
|
|||
this.level.getMethodProfiler().enter("sensing");
|
||||
this.sensing.a();
|
||||
this.level.getMethodProfiler().exit();
|
||||
@@ -1101,6 +1180,12 @@
|
||||
@@ -1101,6 +1184,12 @@
|
||||
if (!this.isAlive()) {
|
||||
return EnumInteractionResult.PASS;
|
||||
} else if (this.getLeashHolder() == entityhuman) {
|
||||
|
@ -202,7 +216,7 @@
|
|||
this.unleash(true, !entityhuman.getAbilities().instabuild);
|
||||
return EnumInteractionResult.a(this.level.isClientSide);
|
||||
} else {
|
||||
@@ -1119,6 +1204,12 @@
|
||||
@@ -1119,6 +1208,12 @@
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
if (itemstack.a(Items.LEAD) && this.a(entityhuman)) {
|
||||
|
@ -215,7 +229,7 @@
|
|||
this.setLeashHolder(entityhuman, true);
|
||||
itemstack.subtract(1);
|
||||
return EnumInteractionResult.a(this.level.isClientSide);
|
||||
@@ -1134,7 +1225,7 @@
|
||||
@@ -1134,7 +1229,7 @@
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
if (this.level instanceof WorldServer) {
|
||||
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
|
||||
|
@ -224,7 +238,7 @@
|
|||
|
||||
optional.ifPresent((entityinsentient) -> {
|
||||
this.a(entityhuman, entityinsentient);
|
||||
@@ -1184,12 +1275,19 @@
|
||||
@@ -1184,12 +1279,19 @@
|
||||
return this.restrictRadius != -1.0F;
|
||||
}
|
||||
|
||||
|
@ -245,7 +259,7 @@
|
|||
|
||||
t0.s(this);
|
||||
t0.setBaby(this.isBaby());
|
||||
@@ -1221,7 +1319,12 @@
|
||||
@@ -1221,7 +1323,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +273,7 @@
|
|||
if (this.isPassenger()) {
|
||||
Entity entity = this.getVehicle();
|
||||
|
||||
@@ -1241,6 +1344,7 @@
|
||||
@@ -1241,6 +1348,7 @@
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
|
@ -267,7 +281,7 @@
|
|||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -1252,7 +1356,9 @@
|
||||
@@ -1252,7 +1360,9 @@
|
||||
this.leashHolder = null;
|
||||
this.leashInfoTag = null;
|
||||
if (!this.level.isClientSide && flag1) {
|
||||
|
@ -277,7 +291,7 @@
|
|||
}
|
||||
|
||||
if (!this.level.isClientSide && flag && this.level instanceof WorldServer) {
|
||||
@@ -1302,6 +1408,7 @@
|
||||
@@ -1302,6 +1412,7 @@
|
||||
boolean flag1 = super.a(entity, flag);
|
||||
|
||||
if (flag1 && this.isLeashed()) {
|
||||
|
@ -285,7 +299,7 @@
|
|||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -1397,7 +1504,14 @@
|
||||
@@ -1397,7 +1508,14 @@
|
||||
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
||||
|
||||
if (i > 0) {
|
||||
|
@ -301,7 +315,7 @@
|
|||
}
|
||||
|
||||
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
|
||||
@@ -1465,9 +1579,10 @@
|
||||
@@ -1465,9 +1583,10 @@
|
||||
@Override
|
||||
protected void cc() {
|
||||
super.cc();
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
if (entityageable != null) {
|
||||
+ // CraftBukkit start - set persistence for tame animals
|
||||
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) {
|
||||
+ entityageable.persistenceRequired = true;
|
||||
+ entityageable.setPersistenceRequired(true);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityPlayer entityplayer = this.getBreedCause();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
public void movementTick() {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.isChickenJockey()) {
|
||||
+ this.persistenceRequired = !this.isTypeNotPersistent(0);
|
||||
+ this.setPersistenceRequired(!this.isTypeNotPersistent(0));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
super.movementTick();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
@Override
|
||||
public void setFromBucket(boolean flag) {
|
||||
this.entityData.set(EntityFish.FROM_BUCKET, flag);
|
||||
+ this.persistenceRequired = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence
|
||||
+ this.setPersistenceRequired(this.isPersistent()); // CraftBukkit - SPIGOT-4106 update persistence
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
@Override
|
||||
public void setFromBucket(boolean flag) {
|
||||
this.entityData.set(Axolotl.FROM_BUCKET, flag);
|
||||
+ this.persistenceRequired = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence
|
||||
+ this.setPersistenceRequired(this.isPersistent()); // CraftBukkit - SPIGOT-4106 update persistence
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
- this.removeEffect(MobEffects.WEAKNESS);
|
||||
- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0)));
|
||||
+ // CraftBukkit start
|
||||
+ this.persistenceRequired = true; // CraftBukkit - SPIGOT-4684 update persistence
|
||||
+ this.setPersistenceRequired(true); // CraftBukkit - SPIGOT-4684 update persistence
|
||||
+ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().a() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
+ // CraftBukkit end
|
||||
|
|
|
@ -491,13 +491,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
|
||||
@Override
|
||||
public boolean getRemoveWhenFarAway() {
|
||||
return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).persistenceRequired;
|
||||
return getHandle() instanceof EntityInsentient && !((EntityInsentient) getHandle()).isPersistent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoveWhenFarAway(boolean remove) {
|
||||
if (getHandle() instanceof EntityInsentient) {
|
||||
((EntityInsentient) getHandle()).persistenceRequired = !remove;
|
||||
((EntityInsentient) getHandle()).setPersistenceRequired(!remove);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager {
|
|||
if (time < 0) {
|
||||
getHandle().villagerConversionTime = -1;
|
||||
getHandle().getDataWatcher().set(EntityZombieVillager.DATA_CONVERTING_ID, false);
|
||||
getHandle().persistenceRequired = false; // CraftBukkit - SPIGOT-4684 update persistence
|
||||
getHandle().setPersistenceRequired(false); // CraftBukkit - SPIGOT-4684 update persistence
|
||||
getHandle().conversionStarter = null;
|
||||
getHandle().removeEffect(MobEffects.DAMAGE_BOOST, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
} else {
|
||||
|
|
|
@ -661,7 +661,7 @@ public class CraftEventFactory {
|
|||
org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? tamer.getBukkitEntity() : null);
|
||||
CraftServer craftServer = (CraftServer) bukkitEntity.getServer();
|
||||
|
||||
entity.persistenceRequired = true;
|
||||
entity.setPersistenceRequired(true);
|
||||
|
||||
EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
|
|
Loading…
Reference in a new issue