mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
c6aa61ee18
Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: b9df8e9f SPIGOT-7933: Improve custom Minecart max speed fc496179 Fix InstrumentTest 7c0ec598 PR-1075: Make Art an interface c389f5a4 PR-1074: Make Sound an interface CraftBukkit Changes: df1efc0bb SPIGOT-7945: `Bukkit#dispatchCommand` throws `UnsupportedOperationException` 285df6e85 SPIGOT-7933: Improve custom Minecart max speed a0f3d4e50 SPIGOT-7940: Recipe book errors after reload 9e0618ec2 SPIGOT-7937: Cannot spawn minecart during world generation with minecart_improvements enabled 1eb4d28da SPIGOT-7941: Fix resistance over 4 amplify causing issues in damage 52b99158a PR-1504: Make Art an interface e18ae35f1 PR-1502: Make Sound an interface Spigot Changes: e65d67a7 SPIGOT-7934: Item entities start "bouncing" under certain conditions
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 612abe47627f0e7c69aa8bfaeee1de4fda528a57..828535741f9e39693fe9055ae1f5af2258668ae3 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -725,6 +725,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
ProfilerFiller gameprofilerfiller = Profiler.get();
|
|
|
|
gameprofilerfiller.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 bf577b06707ff197f13f0b5e16620c09d4a69fa8..053d947c4cc00096dae422df36fb8351b3266215 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
|
|
}
|