Fix wrong spawn reason for trial spawners (#11229)

This commit is contained in:
Lulu13022002 2024-08-11 00:19:54 +02:00 committed by GitHub
parent 1cecc24cad
commit 7d7f123e98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 1 deletions

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Entity#fromMobSpawner()
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 46a21ed2408a42aafd16647e17e556730e799cbd..946f289e0e681524c6fde696921965dbdedda372 100644
index 85d8c4865b65792b99f812b579d7c23823d76e52..0e800e3aeeec84f5f7ed0a391c9b66ae5689bd40 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -402,6 +402,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@ -48,6 +48,18 @@ index aa54237205989f619ac6a3faa2e4285427b9e31d..43d399e1a0ba2fb0541f851a28032fa6
// CraftBukkit start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) {
continue;
diff --git a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java
index 571756dacfa16f6755b67457e17969c35104f971..52d71a03cd5b2af56704f265ce5b5f14d3236ebb 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java
@@ -225,6 +225,7 @@ public final class TrialSpawner {
optional1.ifPresent(entityinsentient::equip);
}
+ entity.spawnedViaMobSpawner = true; // Paper
// CraftBukkit start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, pos).isCancelled()) {
return Optional.empty();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index df6da730134da754d0ff23bd1b57c82486b9ab73..69b5946625a53a1351ffc4bdf61c6874949bbeae 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java

View file

@ -201,6 +201,18 @@ index dbc0b69603dcffbf3d41d79719aa0f2b7da4a131..dd86f5ec5b2051aeea4e19ff97146362
.isPresent();
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java
index 52d71a03cd5b2af56704f265ce5b5f14d3236ebb..ffca6563c20f53c92b162054fec727d83e54e58a 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java
@@ -226,6 +226,7 @@ public final class TrialSpawner {
}
entity.spawnedViaMobSpawner = true; // Paper
+ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER; // Paper - Entity#getEntitySpawnReason
// CraftBukkit start
if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, pos).isCancelled()) {
return Optional.empty();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index bddf98bdf60473eb1d2e533cf533ed7eee797aaa..ce70c8fddbe63d0af2b1f988ce9a2b40c5d48066 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java