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-10-26 00:04:29 +02:00
|
|
|
index a4a07dc11edf3738698deed929cc224ff7114684..73428cefa737e430c3c8c0d59e1fa763114b8c5a 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-10-23 23:12:09 +02:00
|
|
|
@@ -724,6 +724,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
ProfilerFiller gameprofilerfiller = Profiler.get();
|
2022-06-02 03:35:57 +02:00
|
|
|
|
2024-10-23 23:12:09 +02:00
|
|
|
gameprofilerfiller.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
|
2024-04-24 22:32:38 +02:00
|
|
|
this.inBlockState = null;
|
2022-06-02 03:35:57 +02:00
|
|
|
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-10-23 23:12:09 +02:00
|
|
|
index bf577b06707ff197f13f0b5e16620c09d4a69fa8..053d947c4cc00096dae422df36fb8351b3266215 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
|
2024-05-11 23:48:37 +02:00
|
|
|
@@ -45,24 +45,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) {
|
2024-04-24 22:32:38 +02:00
|
|
|
- Mob entityinsentient = (Mob) entity;
|
|
|
|
-
|
2024-05-11 23:48:37 +02:00
|
|
|
- this.setTarget(entityinsentient, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
2024-04-24 22:32:38 +02:00
|
|
|
- this.setLastHurtByMob(entityinsentient);
|
2022-06-02 03:35:57 +02:00
|
|
|
- }
|
|
|
|
-
|
2024-04-24 22:32:38 +02:00
|
|
|
- if (entity instanceof Player) {
|
|
|
|
- Player entityhuman = (Player) entity;
|
|
|
|
-
|
2024-05-11 23:48:37 +02:00
|
|
|
- this.setTarget(entityhuman, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
2024-04-24 22:32:38 +02:00
|
|
|
- this.setLastHurtByPlayer(entityhuman);
|
2022-06-02 03:35:57 +02:00
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
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-05-11 23:48:37 +02:00
|
|
|
@@ -136,4 +123,28 @@ 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) {
|
2024-04-24 22:32:38 +02:00
|
|
|
+ if (entity instanceof Mob mob) {
|
2024-05-11 23:48:37 +02:00
|
|
|
+ this.setTarget(mob, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
2024-04-24 22:32:38 +02:00
|
|
|
+ this.setLastHurtByMob(mob);
|
2022-06-02 03:35:57 +02:00
|
|
|
+ }
|
|
|
|
+
|
2024-04-24 22:32:38 +02:00
|
|
|
+ if (entity instanceof Player player) {
|
2024-05-11 23:48:37 +02:00
|
|
|
+ this.setTarget(player, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
2024-04-24 22:32:38 +02:00
|
|
|
+ this.setLastHurtByPlayer(player);
|
2022-06-02 03:35:57 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-18 18:52:00 +01:00
|
|
|
+ // Paper end - Prevent entity loading causing async lookups
|
2022-06-02 03:35:57 +02:00
|
|
|
}
|