summaryrefslogtreecommitdiffstats
path: root/nms-patches/BlockFlowing.patch
blob: 55906695feffcf18be3b6160ffe00dc6e8938e98 (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
--- a/net/minecraft/server/BlockFlowing.java
+++ b/net/minecraft/server/BlockFlowing.java
@@ -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;
@@ -85,12 +90,25 @@
             this.f(world, blockposition, iblockdata);
         }
 
+        org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
         IBlockData iblockdata2 = world.getType(blockposition.down());
 
         if (this.h(world, blockposition.down(), iblockdata2)) {
+            // CraftBukkit start
+            BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+            world.getServer().getPluginManager().callEvent(event);
+
+            if (event.isCancelled()) {
+                return;
+            }
+            // CraftBukkit end
+
             if (this.material == Material.LAVA && world.getType(blockposition.down()).getMaterial() == Material.WATER) {
-                world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
-                this.fizz(world, blockposition.down());
+                // CraftBukkit start
+                if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition.down(), Blocks.STONE.getBlockData(), null)) {
+                    this.fizz(world, blockposition.down());
+                }
+                // CraftBukkit end
                 return;
             }
 
@@ -116,14 +134,21 @@
             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));
+                world.getServer().getPluginManager().callEvent(event);
+
+                if (!event.isCancelled()) {
+                    this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
+                }
+                // CraftBukkit end
             }
         }
 
     }
 
     private void flow(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
-        if (this.h(world, blockposition, iblockdata)) {
+        if (world.isLoaded(blockposition) && this.h(world, blockposition, iblockdata)) { // CraftBukkit - add isLoaded check
             if (iblockdata.getMaterial() != Material.AIR) {
                 if (this.material == Material.LAVA) {
                     this.fizz(world, blockposition);