mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-06 02:42:14 +01:00
f17519338b
* Expose server build information * squash patches * final tweaks --------- Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: masmc05 <masmc05@gmail.com>
82 lines
3.8 KiB
Diff
82 lines
3.8 KiB
Diff
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 d689f02150fa55ffcfb03adb5955f190ffdcc0de..5a6041ca0a787a945629066477f94d48ea1f1f19 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -740,6 +740,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
public void baseTick() {
|
|
this.level().getProfiler().push("entityBaseTick");
|
|
+ if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups
|
|
this.inBlockState = 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 3b08905ddc3c2506779ce0eac1a53a4d89442ddc..b55633bf4e26dc00e27ab28c7739c274e48b74c3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/NeutralMob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/NeutralMob.java
|
|
@@ -45,24 +45,11 @@ public interface NeutralMob {
|
|
UUID uuid = nbt.getUUID("AngryAt");
|
|
|
|
this.setPersistentAngerTarget(uuid);
|
|
- Entity entity = ((ServerLevel) world).getEntity(uuid);
|
|
-
|
|
- if (entity != null) {
|
|
- if (entity instanceof Mob) {
|
|
- Mob entityinsentient = (Mob) entity;
|
|
-
|
|
- this.setTarget(entityinsentient, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
|
- this.setLastHurtByMob(entityinsentient);
|
|
- }
|
|
-
|
|
- if (entity instanceof Player) {
|
|
- Player entityhuman = (Player) entity;
|
|
-
|
|
- this.setTarget(entityhuman, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
|
- this.setLastHurtByPlayer(entityhuman);
|
|
- }
|
|
-
|
|
- }
|
|
+ // Paper - Prevent entity loading causing async lookups; Moved diff to separate method
|
|
+ // 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);
|
|
}
|
|
}
|
|
}
|
|
@@ -136,4 +123,28 @@ public interface NeutralMob {
|
|
|
|
@Nullable
|
|
LivingEntity getTarget();
|
|
+
|
|
+ // Paper start - Prevent entity loading causing async lookups
|
|
+ // 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 mob) {
|
|
+ this.setTarget(mob, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
|
+ this.setLastHurtByMob(mob);
|
|
+ }
|
|
+
|
|
+ if (entity instanceof Player player) {
|
|
+ this.setTarget(player, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
|
|
+ this.setLastHurtByPlayer(player);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Prevent entity loading causing async lookups
|
|
}
|