diff options
Diffstat (limited to 'patches/server/0750-Prevent-entity-loading-causing-async-lookups.patch')
-rw-r--r-- | patches/server/0750-Prevent-entity-loading-causing-async-lookups.patch | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/patches/server/0750-Prevent-entity-loading-causing-async-lookups.patch b/patches/server/0750-Prevent-entity-loading-causing-async-lookups.patch new file mode 100644 index 0000000000..c9ec6cc4c0 --- /dev/null +++ b/patches/server/0750-Prevent-entity-loading-causing-async-lookups.patch @@ -0,0 +1,74 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Owen1212055 <[email protected]> +Date: Sun, 6 Mar 2022 11:09:09 -0500 +Subject: [PATCH] Prevent entity loading causing async lookups + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 3d0f7310840742a5b16f0c0a7115dc0c90202919..45712b358e97b65396f63b34c09debc1d42fdbb9 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -727,6 +727,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S + + public void baseTick() { + this.level().getProfiler().push("entityBaseTick"); ++ if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups + this.feetBlockState = null; + if (this.isPassenger() && this.getVehicle().isRemoved()) { + this.stopRiding(); +diff --git a/src/main/java/net/minecraft/world/entity/NeutralMob.java b/src/main/java/net/minecraft/world/entity/NeutralMob.java +index fa64c7baa7587f2cfe80b78ed83be011239618cf..47d5a0928f3c86d71f851738bfe7beedc98cfbb3 100644 +--- a/src/main/java/net/minecraft/world/entity/NeutralMob.java ++++ b/src/main/java/net/minecraft/world/entity/NeutralMob.java +@@ -42,18 +42,11 @@ public interface NeutralMob { + UUID uuid = nbt.getUUID("AngryAt"); + + this.setPersistentAngerTarget(uuid); +- Entity entity = ((ServerLevel) world).getEntity(uuid); +- +- if (entity != null) { +- if (entity instanceof Mob) { +- this.setLastHurtByMob((Mob) entity); +- } +- +- if (entity.getType() == EntityType.PLAYER) { +- this.setLastHurtByPlayer((Player) entity); +- } +- +- } ++ // Paper - Prevent entity loading causing async lookups; Moved diff to separate method ++ // If this entity already survived its first tick, e.g. is loaded and ticked in sync, actively ++ // tick the initial persistent anger. ++ // If not, let the first tick on the baseTick call the method later down the line. ++ if (this instanceof Entity entity && !entity.firstTick) this.tickInitialPersistentAnger(world); + } + } + } +@@ -127,4 +120,27 @@ public interface NeutralMob { + + @Nullable + LivingEntity getTarget(); ++ ++ // Paper start - Prevent entity loading causing async lookups ++ // Update last hurt when ticking ++ default void tickInitialPersistentAnger(Level level) { ++ UUID target = getPersistentAngerTarget(); ++ if (target == null) { ++ return; ++ } ++ ++ Entity entity = ((ServerLevel) level).getEntity(target); ++ ++ if (entity != null) { ++ if (entity instanceof Mob) { ++ this.setLastHurtByMob((Mob) entity); ++ } ++ ++ if (entity.getType() == EntityType.PLAYER) { ++ this.setLastHurtByPlayer((Player) entity); ++ } ++ ++ } ++ } ++ // Paper end - Prevent entity loading causing async lookups + } |