From 68ef4d787890894f1525308bc1f6c42f862ddd43 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Wed, 1 Jun 2022 21:35:57 -0400 Subject: [PATCH] Prevent entity loading causing async lookups (#7553) --- ...entity-loading-causing-async-lookups.patch | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 patches/server/Prevent-entity-loading-causing-async-lookups.patch diff --git a/patches/server/Prevent-entity-loading-causing-async-lookups.patch b/patches/server/Prevent-entity-loading-causing-async-lookups.patch new file mode 100644 index 0000000000..97387b5528 --- /dev/null +++ b/patches/server/Prevent-entity-loading-causing-async-lookups.patch @@ -0,0 +1,69 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + + public void baseTick() { + this.level.getProfiler().push("entityBaseTick"); ++ if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Update last hurt when ticking + 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/NeutralMob.java ++++ b/src/main/java/net/minecraft/world/entity/NeutralMob.java +@@ -0,0 +0,0 @@ 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 - Moved diff to separate method + } + } + } +@@ -0,0 +0,0 @@ public interface NeutralMob { + + @Nullable + LivingEntity getTarget(); ++ ++ // Paper start - 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 + }