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-04-12 21:14:06 +02:00
|
|
|
index f08908238cc9680310a2b37089b051bf6fdf5ee3..936ce33bffd93ed7210b6659c27c476e1db348bb 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
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -727,6 +727,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
|
|
|
}
|