summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockSoil.patch
blob: 3d1c4ae63bf528d016bacba0cfc8e63c1ab32452 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--- ../work/decompile-8eb82bde//net/minecraft/server/BlockSoil.java	2014-11-28 17:43:42.965707438 +0000
+++ src/main/java/net/minecraft/server/BlockSoil.java	2014-11-28 17:38:20.000000000 +0000
@@ -3,6 +3,11 @@
 import java.util.Iterator;
 import java.util.Random;
 
+// CraftBukkit start
+import org.bukkit.event.entity.EntityInteractEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
 public class BlockSoil extends Block {
 
     public static final BlockStateInteger MOISTURE = BlockStateInteger.of("moisture", 0, 7);
@@ -34,6 +39,12 @@
             if (i > 0) {
                 world.setTypeAndData(blockposition, iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2);
             } else if (!this.d(world, blockposition)) {
+                // CraftBukkit start
+                org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+                if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) {
+                    return;
+                }
+                // CraftBukkit end
                 world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
             }
         } else if (i < 7) {
@@ -49,6 +60,24 @@
                     return;
                 }
 
+                // CraftBukkit start - Interact soil
+                org.bukkit.event.Cancellable cancellable;
+                if (entity instanceof EntityHuman) {
+                    cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
+                } else {
+                    cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+                    world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+                }
+
+                if (cancellable.isCancelled()) {
+                    return;
+                }
+
+                if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.DIRT, 0).isCancelled()) {
+                    return;
+                }
+                // CraftBukkit end
+
                 world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
             }