summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockLeaves.patch
blob: cce3360dca221ccc031707332d103a333307ab81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--- a/net/minecraft/server/BlockLeaves.java
+++ b/net/minecraft/server/BlockLeaves.java
@@ -3,6 +3,8 @@
 import java.util.Random;
 import javax.annotation.Nullable;
 
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
 public class BlockLeaves extends Block {
 
     public static final BlockStateInteger DISTANCE = BlockProperties.ab;
@@ -20,6 +22,14 @@
 
     public void b(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
         if (!((Boolean) iblockdata.get(BlockLeaves.PERSISTENT)).booleanValue() && ((Integer) iblockdata.get(BlockLeaves.DISTANCE)).intValue() == 7) {
+            // CraftBukkit start
+            LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+            world.getServer().getPluginManager().callEvent(event);
+
+            if (event.isCancelled() || world.getType(blockposition).getBlock() != this) {
+                return;
+            }
+            // CraftBukkit end
             iblockdata.a(world, blockposition, 0);
             world.setAir(blockposition);
         }