summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockFlowing.patch
blob: 9b22e0e18d02fdaafeb2346c2151ed303139a79d (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--- /home/matt/mc-dev-private//net/minecraft/server/BlockFlowing.java	2015-02-26 22:40:22.127608144 +0000
+++ src/main/java/net/minecraft/server/BlockFlowing.java	2015-02-26 22:40:22.127608144 +0000
@@ -5,6 +5,11 @@
 import java.util.Random;
 import java.util.Set;
 
+// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.event.block.BlockFromToEvent;
+// CraftBukkit end
+
 public class BlockFlowing extends BlockFluids {
 
     int a;
@@ -18,7 +23,12 @@
     }
 
     public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
-        int i = ((Integer) iblockdata.get(BlockFlowing.LEVEL)).intValue();
+        // CraftBukkit start
+        org.bukkit.World bworld = world.getWorld();
+        org.bukkit.Server server = world.getServer();
+        org.bukkit.block.Block source = bworld == null ? null : bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+        // CraftBukkit end
+        int i = ((Integer) iblockdata.get(LEVEL)).intValue();
         byte b0 = 1;
 
         if (this.material == Material.LAVA && !world.worldProvider.n()) {
@@ -88,6 +98,12 @@
         IBlockData iblockdata2 = world.getType(blockposition.down());
 
         if (this.h(world, blockposition.down(), iblockdata2)) {
+            // CraftBukkit start - Send "down" to the server
+            BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+            if (server != null) {
+                server.getPluginManager().callEvent(event);
+            }
+            if (!event.isCancelled()) {
             if (this.material == Material.LAVA && world.getType(blockposition.down()).getBlock().getMaterial() == Material.WATER) {
                 world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
                 this.fizz(world, blockposition.down());
@@ -99,6 +115,8 @@
             } else {
                 this.flow(world, blockposition.down(), iblockdata2, i + 8);
             }
+            }
+            // CraftBukkit end
         } else if (i >= 0 && (i == 0 || this.g(world, blockposition.down(), iblockdata2))) {
             Set set = this.f(world, blockposition);
 
@@ -116,7 +134,16 @@
             while (iterator1.hasNext()) {
                 EnumDirection enumdirection1 = (EnumDirection) iterator1.next();
 
-                this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
+                // CraftBukkit start
+                BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection1));
+                if (server != null) {
+                    server.getPluginManager().callEvent(event);
+                }
+
+                if (!event.isCancelled()) {
+                    this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
+                }
+                // CraftBukkit end
             }
         }