mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 07:17:46 +01:00
SPIGOT-7630: Fix crash saving unticked leashed entities
By: md_5 <git@md-5.net>
This commit is contained in:
parent
2c37043b7f
commit
b458583b23
@ -100,16 +100,19 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
@@ -486,7 +545,7 @@
|
||||
@@ -486,7 +545,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (either != null) {
|
||||
+ if (either != null && !this.leashHolder.pluginRemoved) { // CraftBukkit - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin
|
||||
+ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin
|
||||
+ Entity leashHolder = this.leashHolder;
|
||||
+ if (either != null && (leashHolder == null || !leashHolder.pluginRemoved)) {
|
||||
+ // CraftBukkit end
|
||||
nbttagcompound.put("leash", (NBTBase) either.map((uuid) -> {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
|
||||
@@ -507,16 +566,26 @@
|
||||
@@ -507,16 +569,26 @@
|
||||
nbttagcompound.putBoolean("NoAI", this.isNoAi());
|
||||
}
|
||||
|
||||
@ -138,7 +141,7 @@
|
||||
NBTTagList nbttaglist;
|
||||
NBTTagCompound nbttagcompound1;
|
||||
int i;
|
||||
@@ -565,7 +634,7 @@
|
||||
@@ -565,7 +637,7 @@
|
||||
if (nbttagcompound.contains("leash", 10)) {
|
||||
this.delayedLeashInfo = Either.left(nbttagcompound.getCompound("leash").getUUID("UUID"));
|
||||
} else if (nbttagcompound.contains("leash", 11)) {
|
||||
@ -147,7 +150,7 @@
|
||||
} else {
|
||||
this.delayedLeashInfo = null;
|
||||
}
|
||||
@@ -577,6 +646,11 @@
|
||||
@@ -577,6 +649,11 @@
|
||||
}
|
||||
|
||||
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
|
||||
@ -159,7 +162,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -651,20 +725,26 @@
|
||||
@@ -651,20 +728,26 @@
|
||||
|
||||
protected void pickUpItem(EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
@ -188,7 +191,7 @@
|
||||
EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack);
|
||||
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
|
||||
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1);
|
||||
@@ -675,11 +755,19 @@
|
||||
@@ -675,11 +758,19 @@
|
||||
flag = itemstack1.isEmpty();
|
||||
}
|
||||
|
||||
@ -209,7 +212,7 @@
|
||||
}
|
||||
|
||||
if (enumitemslot.isArmor() && itemstack.getCount() > 1) {
|
||||
@@ -813,7 +901,7 @@
|
||||
@@ -813,7 +904,7 @@
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
|
||||
@ -218,7 +221,7 @@
|
||||
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
|
||||
EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D);
|
||||
|
||||
@@ -823,14 +911,14 @@
|
||||
@@ -823,14 +914,14 @@
|
||||
int j = i * i;
|
||||
|
||||
if (d0 > (double) j && this.removeWhenFarAway(d0)) {
|
||||
@ -235,7 +238,7 @@
|
||||
} else if (d0 < (double) l) {
|
||||
this.noActionTime = 0;
|
||||
}
|
||||
@@ -844,6 +932,7 @@
|
||||
@@ -844,6 +935,7 @@
|
||||
@Override
|
||||
protected final void serverAiStep() {
|
||||
++this.noActionTime;
|
||||
@ -243,7 +246,7 @@
|
||||
GameProfilerFiller gameprofilerfiller = this.level().getProfiler();
|
||||
|
||||
gameprofilerfiller.push("sensing");
|
||||
@@ -1311,6 +1400,12 @@
|
||||
@@ -1311,6 +1403,12 @@
|
||||
if (!this.isAlive()) {
|
||||
return EnumInteractionResult.PASS;
|
||||
} else if (this.getLeashHolder() == entityhuman) {
|
||||
@ -256,7 +259,7 @@
|
||||
this.dropLeash(true, !entityhuman.hasInfiniteMaterials());
|
||||
this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman);
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
|
||||
@@ -1336,6 +1431,12 @@
|
||||
@@ -1336,6 +1434,12 @@
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
|
||||
@ -269,7 +272,7 @@
|
||||
this.setLeashedTo(entityhuman, true);
|
||||
itemstack.shrink(1);
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
|
||||
@@ -1351,7 +1452,7 @@
|
||||
@@ -1351,7 +1455,7 @@
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
if (this.level() instanceof WorldServer) {
|
||||
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
|
||||
@ -278,7 +281,7 @@
|
||||
|
||||
optional.ifPresent((entityinsentient) -> {
|
||||
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
|
||||
@@ -1401,12 +1502,19 @@
|
||||
@@ -1401,12 +1505,19 @@
|
||||
return this.restrictRadius != -1.0F;
|
||||
}
|
||||
|
||||
@ -299,7 +302,7 @@
|
||||
|
||||
if (t0 == null) {
|
||||
return null;
|
||||
@@ -1440,7 +1548,12 @@
|
||||
@@ -1440,7 +1551,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +316,7 @@
|
||||
if (this.isPassenger()) {
|
||||
Entity entity = this.getVehicle();
|
||||
|
||||
@@ -1448,7 +1561,7 @@
|
||||
@@ -1448,7 +1564,7 @@
|
||||
t0.startRiding(entity, true);
|
||||
}
|
||||
|
||||
@ -322,7 +325,7 @@
|
||||
return t0;
|
||||
}
|
||||
}
|
||||
@@ -1461,7 +1574,8 @@
|
||||
@@ -1461,7 +1577,8 @@
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
@ -332,7 +335,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1473,7 +1587,9 @@
|
||||
@@ -1473,7 +1590,9 @@
|
||||
this.delayedLeashInfo = null;
|
||||
this.clearRestriction();
|
||||
if (!this.level().isClientSide && flag1) {
|
||||
@ -342,7 +345,7 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide && flag && this.level() instanceof WorldServer) {
|
||||
@@ -1527,6 +1643,7 @@
|
||||
@@ -1527,6 +1646,7 @@
|
||||
boolean flag1 = super.startRiding(entity, flag);
|
||||
|
||||
if (flag1 && this.isLeashed()) {
|
||||
@ -350,7 +353,7 @@
|
||||
this.dropLeash(true, true);
|
||||
}
|
||||
|
||||
@@ -1555,7 +1672,9 @@
|
||||
@@ -1555,7 +1675,9 @@
|
||||
}
|
||||
|
||||
if (this.tickCount > 100) {
|
||||
@ -360,7 +363,7 @@
|
||||
this.delayedLeashInfo = null;
|
||||
}
|
||||
}
|
||||
@@ -1638,14 +1757,21 @@
|
||||
@@ -1638,14 +1760,21 @@
|
||||
int i = EnchantmentManager.getFireAspect(this);
|
||||
|
||||
if (i > 0) {
|
||||
@ -384,7 +387,7 @@
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
|
||||
}
|
||||
|
||||
@@ -1695,6 +1821,7 @@
|
||||
@@ -1695,6 +1824,7 @@
|
||||
@Override
|
||||
protected void removeAfterChangingDimensions() {
|
||||
super.removeAfterChangingDimensions();
|
||||
|
Loading…
Reference in New Issue
Block a user