PaperMC/nms-patches/BlockFlowing.patch

67 lines
2.8 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- 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;
2016-12-09 02:56:49 +01:00
@@ -85,12 +90,25 @@
this.f(world, blockposition, iblockdata);
}
2016-12-09 02:56:49 +01:00
+ 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)) {
2016-12-09 02:56:49 +01:00
+ // CraftBukkit start
+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
2016-12-09 02:56:49 +01:00
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
2016-12-09 02:56:49 +01:00
+ // CraftBukkit end
+
2016-02-29 22:32:46 +01:00
if (this.material == Material.LAVA && world.getType(blockposition.down()).getMaterial() == Material.WATER) {
- world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
2016-12-09 02:56:49 +01:00
- this.fizz(world, blockposition.down());
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition.down(), Blocks.STONE, null)) {
+ this.fizz(world, blockposition.down());
+ }
2016-12-09 02:56:49 +01:00
+ // CraftBukkit end
return;
}
2016-12-09 02:56:49 +01:00
@@ -116,14 +134,21 @@
while (iterator1.hasNext()) {
EnumDirection enumdirection1 = (EnumDirection) iterator1.next();
2015-02-26 23:41:06 +01:00
- 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));
2016-12-09 02:56:49 +01:00
+ world.getServer().getPluginManager().callEvent(event);
2015-02-26 23:41:06 +01:00
+
+ 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
2016-06-09 03:43:49 +02:00
if (iblockdata.getMaterial() != Material.AIR) {
if (this.material == Material.LAVA) {
this.fizz(world, blockposition);