0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 13:56:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/BlockLeaves.patch
2024-10-23 02:15:00 +11:00

27 lines
1.2 KiB
Diff

--- a/net/minecraft/world/level/block/BlockLeaves.java
+++ b/net/minecraft/world/level/block/BlockLeaves.java
@@ -27,6 +27,8 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
public class BlockLeaves extends Block implements IBlockWaterlogged {
public static final MapCodec<BlockLeaves> CODEC = simpleCodec(BlockLeaves::new);
@@ -59,6 +61,14 @@
@Override
protected void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) {
if (this.decaying(iblockdata)) {
+ // CraftBukkit start
+ LeavesDecayEvent event = new LeavesDecayEvent(worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled() || worldserver.getBlockState(blockposition).getBlock() != this) {
+ return;
+ }
+ // CraftBukkit end
dropResources(iblockdata, worldserver, blockposition);
worldserver.removeBlock(blockposition, false);
}