PaperMC/nms-patches/BlockLeaves.patch
2019-12-11 09:00:00 +11:00

26 lines
1.1 KiB
Diff

--- 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 class BlockLeaves extends Block {
public static final BlockStateInteger DISTANCE = BlockProperties.ah;
@@ -20,6 +22,14 @@
@Override
public void b(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
if (!(Boolean) iblockdata.get(BlockLeaves.PERSISTENT) && (Integer) iblockdata.get(BlockLeaves.DISTANCE) == 7) {
+ // CraftBukkit start
+ LeavesDecayEvent event = new LeavesDecayEvent(worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ worldserver.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled() || worldserver.getType(blockposition).getBlock() != this) {
+ return;
+ }
+ // CraftBukkit end
c(iblockdata, (World) worldserver, blockposition);
worldserver.a(blockposition, false);
}