Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/FluidTypeFlowing.patch
2020-06-25 10:00:00 +10:00

77 Zeilen
3.9 KiB
Diff

--- a/net/minecraft/server/FluidTypeFlowing.java
+++ b/net/minecraft/server/FluidTypeFlowing.java
@@ -10,6 +10,14 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockFromToEvent;
+import org.bukkit.event.block.FluidLevelChangeEvent;
+// CraftBukkit end
public abstract class FluidTypeFlowing extends FluidType {
@@ -110,6 +118,15 @@
Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1);
if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) {
+ // 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);
@@ -140,6 +157,15 @@
IBlockData iblockdata1 = generatoraccess.getType(blockposition1);
if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) {
+ // 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);
}
}
@@ -418,12 +444,23 @@
if (fluid1.isEmpty()) {
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;
IBlockData iblockdata = fluid1.getBlockData();
-
- 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
world.getFluidTickList().a(blockposition, fluid1.getType(), i);
world.applyPhysics(blockposition, iblockdata.getBlock());
}