mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 02:55:47 +01:00
70 lines
2.8 KiB
Diff
70 lines
2.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 9d2cac140f939559eba9149ce13334f8f178c962..41922c009f002a2ff27673743e29b32680961a14 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -782,6 +782,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
|
|
}
|