Paper/nms-patches/FluidTypeFlowing.patch
2018-12-06 10:00:00 +11:00

121 lines
6.9 KiB
Diff

--- 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.getFluid(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.getFluid(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) {