From 7d7f123e98e63d466f771e63eff33b9d615544fe Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sun, 11 Aug 2024 00:19:54 +0200 Subject: [PATCH] Fix wrong spawn reason for trial spawners (#11229) --- patches/server/0141-Entity-fromMobSpawner.patch | 14 +++++++++++++- ...xes-and-additions-to-the-spawn-reason-API.patch | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/patches/server/0141-Entity-fromMobSpawner.patch b/patches/server/0141-Entity-fromMobSpawner.patch index 0f1ce9369a..4afd9e1ed2 100644 --- a/patches/server/0141-Entity-fromMobSpawner.patch +++ b/patches/server/0141-Entity-fromMobSpawner.patch @@ -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 diff --git a/patches/server/0281-Fixes-and-additions-to-the-spawn-reason-API.patch b/patches/server/0281-Fixes-and-additions-to-the-spawn-reason-API.patch index 223d99ce64..944ab1ff65 100644 --- a/patches/server/0281-Fixes-and-additions-to-the-spawn-reason-API.patch +++ b/patches/server/0281-Fixes-and-additions-to-the-spawn-reason-API.patch @@ -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