2022-06-02 03:35:57 +02:00
|
|
|
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
|
2024-01-23 12:06:27 +01:00
|
|
|
index a0bd8a9ac362b5131ada29fc999a02003d47f990..b0822dcc819a4001e8a6db83ec6931b44a2b040b 100644
|
2022-06-02 03:35:57 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-01-23 12:06:27 +01:00
|
|
|
@@ -768,6 +768,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
2022-06-02 03:35:57 +02:00
|
|
|
|
|
|
|
public void baseTick() {
|
2023-06-08 10:47:19 +02:00
|
|
|
this.level().getProfiler().push("entityBaseTick");
|
2024-01-18 18:52:00 +01:00
|
|
|
+ if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups
|
2022-06-02 03:35:57 +02:00
|
|
|
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
|
2024-01-18 18:52:00 +01:00
|
|
|
index fa64c7baa7587f2cfe80b78ed83be011239618cf..47d5a0928f3c86d71f851738bfe7beedc98cfbb3 100644
|
2022-06-02 03:35:57 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/NeutralMob.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/NeutralMob.java
|
2022-12-02 18:09:41 +01:00
|
|
|
@@ -42,18 +42,11 @@ public interface NeutralMob {
|
2022-06-02 03:35:57 +02:00
|
|
|
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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
2024-01-18 18:52:00 +01:00
|
|
|
+ // Paper - Prevent entity loading causing async lookups; Moved diff to separate method
|
2022-12-02 18:09:41 +01:00
|
|
|
+ // 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);
|
2022-06-02 03:35:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-18 18:52:00 +01:00
|
|
|
@@ -127,4 +120,27 @@ public interface NeutralMob {
|
2022-06-02 03:35:57 +02:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
LivingEntity getTarget();
|
|
|
|
+
|
2024-01-18 18:52:00 +01:00
|
|
|
+ // Paper start - Prevent entity loading causing async lookups
|
|
|
|
+ // Update last hurt when ticking
|
2022-06-02 03:35:57 +02:00
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-18 18:52:00 +01:00
|
|
|
+ // Paper end - Prevent entity loading causing async lookups
|
2022-06-02 03:35:57 +02:00
|
|
|
}
|