Paper
Paper copied to clipboard
Setting Zombified_Piglins AngryAt Data Doesn't Make Them Angry
Expected behavior
I am trying to make zombified piglins attack cows. With the command bellow:
"/data modify entity @e[type=minecraft:zombified_piglin,limit=1] AngryAt set from entity @e[type=cow,limit=1] UUID"
Observed/Actual behavior
But when i use this command on a repeating command block the zombified piglin does not attack or rarely attacks only one cow and stops afterwards. I tried the same command on singleplayer and spigot and they both worked. Also i checked the papers config files but couldn't find anything about this. Possibly a bug?
Steps/models to reproduce
The problem:
https://www.youtube.com/watch?v=up0R-nz46-o
Plugin and Datapack List
Skript 2.6.2 and worldedit-bukkit-7.2.11-beta-01
Paper version
The server is running Paper version git-Paper-52 (MC: 1.19) (Implementing API version 1.19-R0.1-SNAPSHOT) (Git: 6ea73e7)
Other
I explained everything above.
I can replicate this. To blame is this patch, which moves the logic needed here into the first tick of an entity as it usually only occurs when loading the entity from disk.
The data command however uses the same technique, so the usual first tick application of the loaded values is not executed for data changed post loading via the readAdditionalSaveData
method.
I sadly don't have much time tonight as I am leaving for a social event, but
diff --git a/patches/server/0861-Prevent-entity-loading-causing-async-lookups.patch b/patches/server/0861-Prevent-entity-loading-causing-async-lookups.patch
index 10ec349b28..dffa5fc768 100644
--- a/patches/server/0861-Prevent-entity-loading-causing-async-lookups.patch
+++ b/patches/server/0861-Prevent-entity-loading-causing-async-lookups.patch
@@ -17,10 +17,10 @@ index d81ee5367205ba96eb23f885ec648a27f2cf62f8..7bb45ae3ed51975972e013aaf66acc35
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
+index dedf76de5d6f46b9626ca4a98cfffe125b90dd0c..7dac62b6370dae3ad6d098857c3136d5acf2bd74 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 {
+@@ -42,18 +42,11 @@ public interface NeutralMob {
UUID uuid = nbt.getUUID("AngryAt");
this.setPersistentAngerTarget(uuid);
@@ -37,10 +37,14 @@ index dedf76de5d6f46b9626ca4a98cfffe125b90dd0c..78632fd681049fbd49d0030c23ed204d
-
- }
+ // Paper - 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);
}
}
}
-@@ -127,4 +116,26 @@ public interface NeutralMob {
+@@ -127,4 +120,26 @@ public interface NeutralMob {
@Nullable
LivingEntity getTarget();
should resolve this. Another alternative might be a new field in the Entity class that tracks if additional data has to be parsed/applied next tick after a load. That solution has its up and downsides as the field is useless for most mobs and would need a larger diff, however technically a bit more future proof in the case that down the line more data like this is loaded that requires access to the main thread.