summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockLeaves.patch
blob: bb3a479d134942b551ed76d1fb87bd4dd1fe1e92 (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
@@ -2,6 +2,8 @@
 
 import java.util.Random;
 
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
 public abstract class BlockLeaves extends Block {
 
     public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable");
@@ -132,6 +134,14 @@
     }
 
     private void b(World world, BlockPosition blockposition) {
+        // 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
         this.b(world, blockposition, world.getType(blockposition), 0);
         world.setAir(blockposition);
     }