From d9b5003fa1eaf2306acc953d50e0fd0f254fa64b Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Mon, 14 Jul 2025 17:56:44 +0200 Subject: [PATCH] Dried Ghast events and Happy Ghast spawn reason (#12788) --- .../event/entity/CreatureSpawnEvent.java | 4 +++ .../level/block/DriedGhastBlock.java.patch | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java index 14fdb4184b7..759dbf714fd 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java @@ -222,6 +222,10 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { * {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED} */ POTION_EFFECT, + /** + * When a creature is spawned by being rehydrated + */ + REHYDRATION, /** * When a creature is spawned by plugins */ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch new file mode 100644 index 00000000000..2cef4d9a164 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DriedGhastBlock.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/world/level/block/DriedGhastBlock.java ++++ b/net/minecraft/world/level/block/DriedGhastBlock.java +@@ -104,10 +_,20 @@ + + private void tickWaterlogged(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { + if (!this.isReadyToSpawn(state)) { ++ // Paper start - Call BlockGrowEvent ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(HYDRATION_LEVEL, this.getHydrationLevel(state) + 1), 2)) { ++ return; ++ } ++ // Paper end - Call BlockGrowEvent + level.playSound(null, pos, SoundEvents.DRIED_GHAST_TRANSITION, SoundSource.BLOCKS, 1.0F, 1.0F); +- level.setBlock(pos, state.setValue(HYDRATION_LEVEL, this.getHydrationLevel(state) + 1), 2); ++ // level.setBlock(pos, state.setValue(HYDRATION_LEVEL, this.getHydrationLevel(state) + 1), 2); // Paper - handled above + level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state)); + } else { ++ // Paper start - Call BlockFadeEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, state.getFluidState().createLegacyBlock()).isCancelled()) { ++ return; ++ } ++ // Paper end - Call BlockFadeEvent + this.spawnGhastling(level, pos, state); + } + } +@@ -121,7 +_,7 @@ + float yRot = Direction.getYRot(state.getValue(FACING)); + happyGhast.setYHeadRot(yRot); + happyGhast.snapTo(bottomCenter.x(), bottomCenter.y(), bottomCenter.z(), yRot, 0.0F); +- level.addFreshEntity(happyGhast); ++ level.addFreshEntity(happyGhast, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REHYDRATION); // Paper - spawn reason + level.playSound(null, happyGhast, SoundEvents.GHASTLING_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F); + } + }