Paper/nms-patches/FluidTypeFlowing.patch

77 Zeilen
3.9 KiB
Diff

2018-07-15 02:00:00 +02:00
--- a/net/minecraft/server/FluidTypeFlowing.java
+++ b/net/minecraft/server/FluidTypeFlowing.java
2019-01-08 11:23:11 +01:00
@@ -10,6 +10,14 @@
2018-12-25 22:00:00 +01:00
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
2018-07-15 02:00:00 +02:00
+// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.block.CraftBlock;
2019-01-08 11:23:11 +01:00
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
2018-07-15 02:00:00 +02:00
+import org.bukkit.event.block.BlockFromToEvent;
2019-01-08 11:23:11 +01:00
+import org.bukkit.event.block.FluidLevelChangeEvent;
2018-07-15 02:00:00 +02:00
+// CraftBukkit end
public abstract class FluidTypeFlowing extends FluidType {
2019-04-23 04:00:00 +02:00
@@ -134,6 +142,15 @@
2018-07-15 02:00:00 +02:00
Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1);
2019-04-23 04:00:00 +02:00
if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) {
2018-07-15 02:00:00 +02:00
+ // 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);
2019-04-23 04:00:00 +02:00
@@ -164,6 +181,15 @@
2018-07-15 02:00:00 +02:00
IBlockData iblockdata1 = generatoraccess.getType(blockposition1);
2019-04-23 04:00:00 +02:00
if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) {
2018-07-15 02:00:00 +02:00
+ // 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);
}
}
2019-04-23 04:00:00 +02:00
@@ -442,12 +468,23 @@
2019-01-08 11:23:11 +01:00
2019-04-23 04:00:00 +02:00
if (fluid1.isEmpty()) {
2019-01-08 11:23:11 +01:00
fluid = fluid1;
- world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
+ // CraftBukkit start
+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, Blocks.AIR.getBlockData());
+ if (event.isCancelled()) {
+ return;
+ }
+ world.setTypeAndData(blockposition, ((CraftBlockData) event.getNewData()).getState(), 3);
+ // CraftBukkit end
} else if (!fluid1.equals(fluid)) {
fluid = fluid1;
2019-04-23 04:00:00 +02:00
IBlockData iblockdata = fluid1.getBlockData();
2019-01-08 11:23:11 +01:00
-
- world.setTypeAndData(blockposition, iblockdata, 2);
+ // CraftBukkit start
+ FluidLevelChangeEvent event = CraftEventFactory.callFluidLevelChangeEvent(world, blockposition, iblockdata);
+ if (event.isCancelled()) {
+ return;
+ }
+ world.setTypeAndData(blockposition, ((CraftBlockData) event.getNewData()).getState(), 2);
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
world.getFluidTickList().a(blockposition, fluid1.getType(), i);
2019-01-08 11:23:11 +01:00
world.applyPhysics(blockposition, iblockdata.getBlock());
}