summaryrefslogtreecommitdiffstats
path: root/nms-patches/FluidTypeFlowing.patch
blob: 13a30e10b27a4e1ba4a31993a71f3bd3291c8958 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
--- a/net/minecraft/server/FluidTypeFlowing.java
+++ b/net/minecraft/server/FluidTypeFlowing.java
@@ -14,13 +14,18 @@
 import java.util.function.IntFunction;
 import java.util.function.IntPredicate;
 import java.util.function.Supplier;
+// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockFromToEvent;
+// CraftBukkit end
 
 public abstract class FluidTypeFlowing extends FluidType {
 
     public static final BlockStateBoolean FALLING = BlockProperties.h;
     public static final BlockStateInteger LEVEL = BlockProperties.ag;
     private static final ThreadLocal<Object2ByteLinkedOpenHashMap<Block.a>> e = ThreadLocal.withInitial(() -> {
-        Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap(200) {
+        Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap<Block.a>(200) { // CraftBukkit - decompile error
             protected void rehash(int i) {}
         };
 
@@ -145,6 +150,15 @@
             Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1);
 
             if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.b(blockposition1), fluid1.c())) {
+                // CraftBukkit start
+                org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition);
+                BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+                generatoraccess.getMinecraftWorld().getServer().getPluginManager().callEvent(event);
+
+                if (event.isCancelled()) {
+                    return;
+                }
+                // CraftBukkit end
                 this.a(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1);
                 if (this.a((IWorldReader) generatoraccess, blockposition) >= 3) {
                     this.a(generatoraccess, blockposition, fluid, iblockdata);
@@ -175,6 +189,15 @@
                 IBlockData iblockdata1 = generatoraccess.getType(blockposition1);
 
                 if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.b(blockposition1), fluid1.c())) {
+                    // CraftBukkit start
+                    org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition);
+                    BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection));
+                    generatoraccess.getMinecraftWorld().getServer().getPluginManager().callEvent(event);
+
+                    if (event.isCancelled()) {
+                        continue;
+                    }
+                    // CraftBukkit end
                     this.a(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1);
                 }
             }
@@ -307,21 +330,25 @@
             if (enumdirection1 != enumdirection) {
                 BlockPosition blockposition2 = blockposition.shift(enumdirection1);
                 short short0 = a(blockposition1, blockposition2);
-                Pair pair = (Pair) short2objectmap.computeIfAbsent(short0, (i) -> {
-                    IBlockData iblockdata = iworldreader.getType(blockposition);
+                // CraftBukkit start - decompile errors
+                Pair pair = (Pair) short2objectmap.computeIfAbsent(short0, (ix) -> {
+                    IBlockData iblockdatax = iworldreader.getType(blockposition2);
 
-                    return Pair.of(iblockdata, iblockdata.s());
+                    return Pair.of(iblockdatax, iblockdatax.s());
                 });
+                // CraftBukkit end
                 IBlockData iblockdata1 = (IBlockData) pair.getFirst();
                 Fluid fluid = (Fluid) pair.getSecond();
 
                 if (this.a(iworldreader, this.e(), blockposition, iblockdata, enumdirection1, blockposition2, iblockdata1, fluid)) {
-                    boolean flag = short2booleanmap.computeIfAbsent(short0, (i) -> {
-                        BlockPosition blockposition = blockposition1.down();
-                        IBlockData iblockdata = iworldreader.getType(blockposition);
+                    // CraftBukkit start - decompile errors
+                    boolean flag = short2booleanmap.computeIfAbsent(short0, (ix) -> {
+                        BlockPosition blockpositionx = blockposition2.down();
+                        IBlockData iblockdatax = iworldreader.getType(blockpositionx);
 
-                        return this.a((IBlockAccess) iworldreader, this.e(), blockposition1, iblockdata1, blockposition, iblockdata);
+                        return this.a((IBlockAccess) iworldreader, this.e(), blockposition2, iblockdata1, blockpositionx, iblockdatax);
                     });
+                    // CraftBukkit end
 
                     if (flag) {
                         return i;
@@ -383,22 +410,26 @@
             EnumDirection enumdirection = (EnumDirection) iterator.next();
             BlockPosition blockposition1 = blockposition.shift(enumdirection);
             short short0 = a(blockposition, blockposition1);
-            Pair pair = (Pair) short2objectopenhashmap.computeIfAbsent(short0, (i) -> {
-                IBlockData iblockdata = iworldreader.getType(blockposition);
+            // CraftBukkit start - decompile errors
+            Pair pair = (Pair) short2objectopenhashmap.computeIfAbsent(short0, (ix) -> {
+                IBlockData iblockdatax = iworldreader.getType(blockposition1);
 
-                return Pair.of(iblockdata, iblockdata.s());
+                return Pair.of(iblockdatax, iblockdatax.s());
             });
+            // CraftBukkit end
             IBlockData iblockdata1 = (IBlockData) pair.getFirst();
             Fluid fluid = (Fluid) pair.getSecond();
             Fluid fluid1 = this.a(iworldreader, blockposition1, iblockdata1);
 
             if (this.a(iworldreader, fluid1.c(), blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, fluid)) {
                 BlockPosition blockposition2 = blockposition1.down();
-                boolean flag = short2booleanopenhashmap.computeIfAbsent(short0, (i) -> {
-                    IBlockData iblockdata = iworldreader.getType(blockposition);
+                // CraftBukkit start - decompile errors
+                boolean flag = short2booleanopenhashmap.computeIfAbsent(short0, (ix) -> {
+                    IBlockData iblockdatax = iworldreader.getType(blockposition2);
 
-                    return this.a((IBlockAccess) iworldreader, this.e(), blockposition1, iblockdata1, blockposition, iblockdata);
+                    return this.a((IBlockAccess) iworldreader, this.e(), blockposition1, iblockdata1, blockposition2, iblockdatax);
                 });
+                // CraftBukkit end
                 int j;
 
                 if (flag) {