From 1e5d1db2b75fc240f71068f384487300044a9aad Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Mon, 4 Jul 2022 16:20:43 +0200 Subject: [PATCH] Call StructureGrowEvent for mangrove propagule (#8023) --- ...tureGrowEvent-for-mangrove-propagule.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 patches/server/0922-Call-StructureGrowEvent-for-mangrove-propagule.patch diff --git a/patches/server/0922-Call-StructureGrowEvent-for-mangrove-propagule.patch b/patches/server/0922-Call-StructureGrowEvent-for-mangrove-propagule.patch new file mode 100644 index 000000000..b332c9254 --- /dev/null +++ b/patches/server/0922-Call-StructureGrowEvent-for-mangrove-propagule.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Noah van der Aa +Date: Mon, 20 Jun 2022 15:46:46 +0200 +Subject: [PATCH] Call StructureGrowEvent for mangrove propagule + + +diff --git a/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java b/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java +index 4eaf75ef7362ee781762f5e8def6bc4d986e9db7..0a60918ec9b2374cd9ae375a8d36ed1a212c19ae 100644 +--- a/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java +@@ -90,7 +90,28 @@ public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterl + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + if (!isHanging(state)) { + if (random.nextInt(7) == 0) { ++ world.captureTreeGeneration = true; // Paper + this.advanceTree(world, pos, state, random); ++ // Paper start ++ world.captureTreeGeneration = false; ++ if (world.capturedBlockStates.size() > 0) { ++ org.bukkit.TreeType treeType = SaplingBlock.treeType; ++ SaplingBlock.treeType = null; ++ org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()); ++ java.util.List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); ++ world.capturedBlockStates.clear(); ++ org.bukkit.event.world.StructureGrowEvent event = null; ++ if (treeType != null) { ++ event = new org.bukkit.event.world.StructureGrowEvent(location, treeType, false, null, blocks); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event == null || !event.isCancelled()) { ++ for (org.bukkit.block.BlockState blockstate : blocks) { ++ blockstate.update(true); ++ } ++ } ++ } ++ // Paper end + } + + } else {