13
0
geforkt von Mirrors/Paper

#1045: Revert changes to persistence required checks

By: DerFrZocker <derrieple@gmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2022-05-03 23:13:03 +10:00
Ursprung 465b2801f1
Commit aba0972e9a
12 geänderte Dateien mit 58 neuen und 176 gelöschten Zeilen

Datei anzeigen

@ -336,21 +336,12 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1669,6 +1884,53 @@
@@ -1669,6 +1884,44 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
+
+ // CraftBukkit start
+ if (this instanceof EntityLiving) {
+ EntityLiving entity = (EntityLiving) this;
+
+ // Reset the persistence for tamed animals
+ if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
+ entityinsentient.setPersistenceRequired(!entityinsentient.removeWhenFarAway(0));
+ }
+ }
+ this.persist = !nbttagcompound.contains("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist");
+ // SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ if (nbttagcompound.contains("Bukkit.MaxAirSupply")) {
@ -390,7 +381,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1744,9 +2006,22 @@
@@ -1744,9 +1997,22 @@
} else if (this.level.isClientSide) {
return null;
} else {
@ -413,7 +404,7 @@
this.level.addFreshEntity(entityitem);
return entityitem;
}
@@ -1840,7 +2115,7 @@
@@ -1840,7 +2106,7 @@
this.setPose(EntityPose.STANDING);
this.vehicle = entity;
@ -422,7 +413,7 @@
entity.getIndirectPassengersStream().filter((entity2) -> {
return entity2 instanceof EntityPlayer;
}).forEach((entity2) -> {
@@ -1871,7 +2146,7 @@
@@ -1871,7 +2137,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@ -431,7 +422,7 @@
}
}
@@ -1880,10 +2155,31 @@
@@ -1880,10 +2146,31 @@
this.removeVehicle();
}
@ -464,7 +455,7 @@
if (this.passengers.isEmpty()) {
this.passengers = ImmutableList.of(entity);
} else {
@@ -1899,12 +2195,32 @@
@@ -1899,12 +2186,32 @@
}
}
@ -498,7 +489,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -1915,6 +2231,7 @@
@@ -1915,6 +2222,7 @@
entity.boardingCooldown = 60;
}
@ -506,7 +497,7 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -1977,14 +2294,20 @@
@@ -1977,14 +2285,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
@ -530,7 +521,7 @@
this.level.getProfiler().pop();
}
@@ -2102,6 +2425,13 @@
@@ -2102,6 +2416,13 @@
}
public void setSwimming(boolean flag) {
@ -544,7 +535,7 @@
this.setSharedFlag(4, flag);
}
@@ -2150,8 +2480,12 @@
@@ -2150,8 +2471,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@ -558,7 +549,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2170,7 +2504,7 @@
@@ -2170,7 +2495,7 @@
}
public int getMaxAirSupply() {
@ -567,7 +558,7 @@
}
public int getAirSupply() {
@@ -2178,7 +2512,18 @@
@@ -2178,7 +2503,18 @@
}
public void setAirSupply(int i) {
@ -587,7 +578,7 @@
}
public int getTicksFrozen() {
@@ -2205,11 +2550,41 @@
@@ -2205,11 +2541,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -631,7 +622,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2365,15 +2740,38 @@
@@ -2365,15 +2731,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@ -672,7 +663,7 @@
this.level.getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2382,9 +2780,17 @@
@@ -2382,9 +2771,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@ -692,7 +683,7 @@
}
this.removeAfterChangingDimensions();
@@ -2405,20 +2811,34 @@
@@ -2405,20 +2802,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@ -732,7 +723,7 @@
IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2435,8 +2855,8 @@
@@ -2435,8 +2846,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@ -743,7 +734,7 @@
}
} else {
BlockPosition blockposition1;
@@ -2446,8 +2866,15 @@
@@ -2446,8 +2857,15 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
@ -760,7 +751,7 @@
}
}
@@ -2455,8 +2882,23 @@
@@ -2455,8 +2873,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
@ -786,7 +777,7 @@
}
public boolean canChangeDimensions() {
@@ -2665,7 +3107,26 @@
@@ -2665,7 +3098,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@ -814,7 +805,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -2949,6 +3410,11 @@
@@ -2949,6 +3401,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}

Datei anzeigen

@ -29,22 +29,20 @@
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world);
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
@@ -139,7 +154,14 @@
this.registerGoals();
}
@@ -141,6 +156,12 @@
+ // CraftBukkit start - default persistance to type's persistance value
+ this.persistenceRequired = !removeWhenFarAway(0);
+ }
+
}
+ // CraftBukkit start
+ public void setPersistenceRequired(boolean persistenceRequired) {
+ this.persistenceRequired = persistenceRequired;
}
+ }
+ // CraftBukkit end
+
protected void registerGoals() {}
@@ -219,7 +241,38 @@
public static AttributeProvider.Builder createMobAttributes() {
@@ -219,7 +240,38 @@
}
public void setTarget(@Nullable EntityLiving entityliving) {
@ -83,7 +81,7 @@
}
@Override
@@ -446,16 +499,26 @@
@@ -446,16 +498,26 @@
nbttagcompound.putBoolean("NoAI", this.isNoAi());
}
@ -112,7 +110,7 @@
NBTTagList nbttaglist;
int i;
@@ -502,6 +565,11 @@
@@ -502,6 +564,11 @@
}
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
@ -124,7 +122,7 @@
}
@Override
@@ -565,7 +633,7 @@
@@ -565,7 +632,7 @@
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
@ -133,7 +131,7 @@
this.onItemPickup(entityitem);
this.take(entityitem, itemstack.getCount());
entityitem.discard();
@@ -574,15 +642,29 @@
@@ -574,15 +641,29 @@
}
public boolean equipItemIfPossible(ItemStack itemstack) {
@ -164,24 +162,7 @@
}
this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack);
@@ -699,14 +781,14 @@
int i = this.getType().getCategory().getDespawnDistance();
int j = i * i;
- if (d0 > (double) j && this.removeWhenFarAway(d0)) {
+ if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check
this.discard();
}
int k = this.getType().getCategory().getNoDespawnDistance();
int l = k * k;
- if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.removeWhenFarAway(d0)) {
+ if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check
this.discard();
} else if (d0 < (double) l) {
this.noActionTime = 0;
@@ -721,6 +803,7 @@
@@ -721,6 +802,7 @@
@Override
protected final void serverAiStep() {
++this.noActionTime;
@ -189,7 +170,7 @@
this.level.getProfiler().push("sensing");
this.sensing.tick();
this.level.getProfiler().pop();
@@ -1116,6 +1199,12 @@
@@ -1116,6 +1198,12 @@
if (!this.isAlive()) {
return EnumInteractionResult.PASS;
} else if (this.getLeashHolder() == entityhuman) {
@ -202,7 +183,7 @@
this.dropLeash(true, !entityhuman.getAbilities().instabuild);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
} else {
@@ -1134,6 +1223,12 @@
@@ -1134,6 +1222,12 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
@ -215,7 +196,7 @@
this.setLeashedTo(entityhuman, true);
itemstack.shrink(1);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
@@ -1149,7 +1244,7 @@
@@ -1149,7 +1243,7 @@
if (itemstack.getItem() instanceof ItemMonsterEgg) {
if (this.level instanceof WorldServer) {
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
@ -224,7 +205,7 @@
optional.ifPresent((entityinsentient) -> {
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
@@ -1199,12 +1294,19 @@
@@ -1199,12 +1293,19 @@
return this.restrictRadius != -1.0F;
}
@ -245,7 +226,7 @@
t0.copyPosition(this);
t0.setBaby(this.isBaby());
@@ -1236,7 +1338,12 @@
@@ -1236,7 +1337,12 @@
}
}
@ -259,7 +240,7 @@
if (this.isPassenger()) {
Entity entity = this.getVehicle();
@@ -1256,6 +1363,7 @@
@@ -1256,6 +1362,7 @@
if (this.leashHolder != null) {
if (!this.isAlive() || !this.leashHolder.isAlive()) {
@ -267,7 +248,7 @@
this.dropLeash(true, true);
}
@@ -1267,7 +1375,9 @@
@@ -1267,7 +1374,9 @@
this.leashHolder = null;
this.leashInfoTag = null;
if (!this.level.isClientSide && flag1) {
@ -277,7 +258,7 @@
}
if (!this.level.isClientSide && flag && this.level instanceof WorldServer) {
@@ -1317,6 +1427,7 @@
@@ -1317,6 +1426,7 @@
boolean flag1 = super.startRiding(entity, flag);
if (flag1 && this.isLeashed()) {
@ -285,7 +266,7 @@
this.dropLeash(true, true);
}
@@ -1341,7 +1452,9 @@
@@ -1341,7 +1451,9 @@
}
if (this.tickCount > 100) {
@ -295,7 +276,7 @@
this.leashInfoTag = null;
}
}
@@ -1412,7 +1525,14 @@
@@ -1412,7 +1524,14 @@
int i = EnchantmentManager.getFireAspect(this);
if (i > 0) {
@ -311,7 +292,7 @@
}
boolean flag = entity.hurt(DamageSource.mobAttack(this), f);
@@ -1480,9 +1600,10 @@
@@ -1480,9 +1599,10 @@
@Override
protected void removeAfterChangingDimensions() {
super.removeAfterChangingDimensions();

Datei anzeigen

@ -57,17 +57,7 @@
this.level.broadcastEntityEvent(this, (byte) 18);
}
@@ -220,11 +238,26 @@
EntityAgeable entityageable = this.getBreedOffspring(worldserver, entityanimal);
if (entityageable != null) {
+ // CraftBukkit start - set persistence for tame animals
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTame()) {
+ entityageable.setPersistenceRequired(true);
+ }
+ // CraftBukkit end
EntityPlayer entityplayer = this.getLoveCause();
@@ -225,6 +243,16 @@
if (entityplayer == null && entityanimal.getLoveCause() != null) {
entityplayer = entityanimal.getLoveCause();
}
@ -84,7 +74,7 @@
if (entityplayer != null) {
entityplayer.awardStat(StatisticList.ANIMALS_BRED);
@@ -235,12 +268,14 @@
@@ -235,12 +263,14 @@
entityanimal.setAge(6000);
this.resetLove();
entityanimal.resetLove();

Datei anzeigen

@ -1,18 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityChicken.java
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
@@ -75,6 +75,11 @@
@Override
public void aiStep() {
+ // CraftBukkit start
+ if (this.isChickenJockey()) {
+ this.setPersistenceRequired(!this.removeWhenFarAway(0));
+ }
+ // CraftBukkit end
super.aiStep();
this.oFlap = this.flap;
this.oFlapSpeed = this.flapSpeed;
@@ -94,7 +99,9 @@
@@ -94,7 +94,9 @@
this.flap += this.flapping * 2.0F;
if (!this.level.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);

Datei anzeigen

@ -1,19 +0,0 @@
--- a/net/minecraft/world/entity/animal/EntityFish.java
+++ b/net/minecraft/world/entity/animal/EntityFish.java
@@ -59,7 +59,7 @@
@Override
public boolean removeWhenFarAway(double d0) {
- return !this.fromBucket() && !this.hasCustomName();
+ return true; // CraftBukkit
}
@Override
@@ -81,6 +81,7 @@
@Override
public void setFromBucket(boolean flag) {
this.entityData.set(EntityFish.FROM_BUCKET, flag);
+ this.setPersistenceRequired(this.isPersistenceRequired()); // CraftBukkit - SPIGOT-4106 update persistence
}
@Override

Datei anzeigen

@ -1,14 +1,5 @@
--- a/net/minecraft/world/entity/animal/EntityOcelot.java
+++ b/net/minecraft/world/entity/animal/EntityOcelot.java
@@ -133,7 +133,7 @@
@Override
public boolean removeWhenFarAway(double d0) {
- return !this.isTrusting() && this.tickCount > 2400;
+ return !this.isTrusting() /*&& this.tickCount > 2400*/; // CraftBukkit
}
public static AttributeProvider.Builder createAttributes() {
@@ -182,7 +182,8 @@
if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) {
this.usePlayerItem(entityhuman, enumhand, itemstack);

Datei anzeigen

@ -28,15 +28,7 @@
}
public Axolotl.Variant getVariant() {
@@ -238,6 +245,7 @@
@Override
public void setFromBucket(boolean flag) {
this.entityData.set(Axolotl.FROM_BUCKET, flag);
+ this.setPersistenceRequired(this.isPersistenceRequired()); // CraftBukkit - SPIGOT-4106 update persistence
}
@Nullable
@@ -428,7 +436,7 @@
@@ -428,7 +435,7 @@
if (i < 2400) {
i = Math.min(2400, 100 + i);
@ -45,7 +37,7 @@
}
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
@@ -478,7 +486,7 @@
@@ -478,7 +485,7 @@
@Override
public BehaviorController<Axolotl> getBrain() {
@ -54,12 +46,3 @@
}
@Override
@@ -511,7 +519,7 @@
@Override
public boolean removeWhenFarAway(double d0) {
- return !this.fromBucket() && !this.hasCustomName();
+ return true; // CraftBukkit
}
public static boolean checkAxolotlSpawnRules(EntityTypes<? extends EntityLiving> entitytypes, WorldAccess worldaccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) {

Datei anzeigen

@ -50,21 +50,20 @@
}
@Override
@@ -191,8 +204,11 @@
@@ -191,8 +204,10 @@
this.conversionStarter = uuid;
this.villagerConversionTime = i;
this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true);
- this.removeEffect(MobEffects.WEAKNESS);
- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().getId() - 1, 0)));
+ // CraftBukkit start
+ 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().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
+ // CraftBukkit end
this.level.broadcastEntityEvent(this, (byte) 16);
}
@@ -209,7 +225,13 @@
@@ -209,7 +224,13 @@
}
private void finishConversion(WorldServer worldserver) {
@ -79,7 +78,7 @@
EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
int i = aenumitemslot.length;
@@ -224,7 +246,9 @@
@@ -224,7 +245,9 @@
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
if (d0 > 1.0D) {
@ -89,7 +88,7 @@
}
}
}
@@ -250,7 +274,7 @@
@@ -250,7 +273,7 @@
}
}

Datei anzeigen

@ -56,15 +56,6 @@
}
@VisibleForDebug
@@ -172,7 +200,7 @@
@Override
public boolean removeWhenFarAway(double d0) {
- return !this.isPersistenceRequired();
+ return true; // CraftBukkit - SPIGOT-6278
}
@Override
@@ -205,7 +233,7 @@
@Override

Datei anzeigen

@ -14,17 +14,7 @@
public final class SpawnerCreature {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -73,7 +80,8 @@
if (entity instanceof EntityInsentient) {
EntityInsentient entityinsentient = (EntityInsentient) entity;
- if (entityinsentient.isPersistenceRequired() || entityinsentient.requiresCustomPersistence()) {
+ // CraftBukkit - Split out persistent check, don't apply it to special persistent mobs
+ if (entityinsentient.removeWhenFarAway(0) && entityinsentient.isPersistenceRequired()) {
continue;
}
}
@@ -111,10 +119,25 @@
@@ -111,10 +118,25 @@
EnumCreatureType[] aenumcreaturetype = SpawnerCreature.SPAWNING_CATEGORIES;
int i = aenumcreaturetype.length;
@ -51,7 +41,7 @@
Objects.requireNonNull(spawnercreature_d);
SpawnerCreature.c spawnercreature_c = spawnercreature_d::canSpawn;
@@ -199,10 +222,14 @@
@@ -199,10 +221,14 @@
entityinsentient.moveTo(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F);
if (isValidPositionForMob(worldserver, entityinsentient, d2)) {
groupdataentity = entityinsentient.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);
@ -70,7 +60,7 @@
if (j >= entityinsentient.getMaxSpawnClusterSize()) {
return;
}
@@ -383,7 +410,7 @@
@@ -383,7 +409,7 @@
if (entityinsentient.checkSpawnRules(worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.checkSpawnObstruction(worldaccess)) {
groupdataentity = entityinsentient.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null);
@ -79,7 +69,7 @@
flag = true;
}
}
@@ -504,8 +531,10 @@
@@ -504,8 +530,10 @@
return this.unmodifiableMobCategoryCounts;
}

Datei anzeigen

@ -76,7 +76,6 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager {
if (time < 0) {
getHandle().villagerConversionTime = -1;
getHandle().getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, false);
getHandle().setPersistenceRequired(false); // CraftBukkit - SPIGOT-4684 update persistence
getHandle().conversionStarter = null;
getHandle().removeEffect(MobEffects.DAMAGE_BOOST, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
} else {

Datei anzeigen

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