aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOwen <[email protected]>2022-06-01 21:35:57 -0400
committerGitHub <[email protected]>2022-06-02 02:35:57 +0100
commitc5caee307e1dde9a9afc0fb3b401218dbbe901b2 (patch)
treee932c8eaf8327e1ad22c585a572313d329d4307f
parent2d17a50b8bc04b10a7dac14d725610155496dccf (diff)
downloadPaper-c5caee307e1dde9a9afc0fb3b401218dbbe901b2.tar.gz
Paper-c5caee307e1dde9a9afc0fb3b401218dbbe901b2.zip
Prevent entity loading causing async lookups (#7553)
-rw-r--r--patches/server/0909-Prevent-entity-loading-causing-async-lookups.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/patches/server/0909-Prevent-entity-loading-causing-async-lookups.patch b/patches/server/0909-Prevent-entity-loading-causing-async-lookups.patch
new file mode 100644
index 0000000000..edd92d33a0
--- /dev/null
+++ b/patches/server/0909-Prevent-entity-loading-causing-async-lookups.patch
@@ -0,0 +1,69 @@
+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 86a2eddf344503cbe75a5243a114f6fe1578185f..dfd1f37757af1bd808cc2e2d8bf97123adf638bb 100644
+--- a/src/main/java/net/minecraft/world/entity/Entity.java
++++ b/src/main/java/net/minecraft/world/entity/Entity.java
+@@ -725,6 +725,7 @@ 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 dedf76de5d6f46b9626ca4a98cfffe125b90dd0c..78632fd681049fbd49d0030c23ed204dbc515a44 100644
+--- a/src/main/java/net/minecraft/world/entity/NeutralMob.java
++++ b/src/main/java/net/minecraft/world/entity/NeutralMob.java
+@@ -42,18 +42,7 @@ 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
+ }
+ }
+ }
+@@ -127,4 +116,26 @@ 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
+ }