2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/BlockFire.java
|
|
|
|
+++ b/net/minecraft/server/BlockFire.java
|
2014-11-25 22:32:16 +01:00
|
|
|
@@ -4,6 +4,12 @@
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.block.BlockBurnEvent;
|
|
|
|
+import org.bukkit.event.block.BlockSpreadEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class BlockFire extends Block {
|
|
|
|
|
|
|
|
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
|
|
|
|
@@ -109,7 +115,7 @@
|
|
|
|
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
|
|
|
if (world.getGameRules().getBoolean("doFireTick")) {
|
|
|
|
if (!this.canPlace(world, blockposition)) {
|
|
|
|
- world.setAir(blockposition);
|
|
|
|
+ fireExtinguished(world, blockposition); // CraftBukkit - invalid place location
|
|
|
|
}
|
|
|
|
|
|
|
|
Block block = world.getType(blockposition.down()).getBlock();
|
|
|
|
@@ -120,7 +126,7 @@
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!flag && world.S() && this.e(world, blockposition)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- world.setAir(blockposition);
|
|
|
|
+ fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain
|
|
|
|
} else {
|
|
|
|
int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue();
|
|
|
|
|
2015-02-17 15:06:54 +01:00
|
|
|
@@ -133,14 +139,14 @@
|
|
|
|
if (!flag) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!this.f(world, blockposition)) {
|
2015-02-17 15:06:54 +01:00
|
|
|
if (!World.a((IBlockAccess) world, blockposition.down()) || i > 3) {
|
|
|
|
- world.setAir(blockposition);
|
|
|
|
+ fireExtinguished(world, blockposition); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.e((IBlockAccess) world, blockposition.down()) && i == 15 && random.nextInt(4) == 0) {
|
|
|
|
- world.setAir(blockposition);
|
|
|
|
+ fireExtinguished(world, blockposition); // CraftBukkit
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
@@ -186,7 +192,26 @@
|
|
|
|
l1 = 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
- world.setTypeAndData(blockposition1, iblockdata.set(BlockFire.AGE, Integer.valueOf(l1)), 3);
|
|
|
|
+ // CraftBukkit start - Call to stop spread of fire
|
|
|
|
+ if (world.getType(blockposition1) != Blocks.FIRE) {
|
2015-02-03 18:46:30 +01:00
|
|
|
+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ org.bukkit.Server server = world.getServer();
|
|
|
|
+ org.bukkit.World bworld = world.getWorld();
|
2015-02-03 18:46:30 +01:00
|
|
|
+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ blockState.setTypeId(Block.getId(this));
|
|
|
|
+ blockState.setData(new org.bukkit.material.MaterialData(Block.getId(this), (byte) l1));
|
|
|
|
+
|
2015-02-03 18:46:30 +01:00
|
|
|
+ BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ server.getPluginManager().callEvent(spreadEvent);
|
|
|
|
+
|
|
|
|
+ if (!spreadEvent.isCancelled()) {
|
|
|
|
+ blockState.update(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
@@ -224,6 +249,17 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (random.nextInt(i) < k) {
|
|
|
|
IBlockData iblockdata = world.getType(blockposition);
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
|
|
+
|
|
|
|
+ BlockBurnEvent event = new BlockBurnEvent(theBlock);
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
|
|
|
|
int l = j + random.nextInt(5) / 4;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2015-02-17 14:47:14 +01:00
|
|
|
@@ -233,7 +269,7 @@
|
|
|
|
|
|
|
|
world.setTypeAndData(blockposition, this.getBlockData().set(BlockFire.AGE, Integer.valueOf(l)), 3);
|
|
|
|
} else {
|
|
|
|
- world.setAir(blockposition);
|
|
|
|
+ fireExtinguished(world, blockposition); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iblockdata.getBlock() == Blocks.TNT) {
|
2014-11-25 22:32:16 +01:00
|
|
|
@@ -290,7 +326,7 @@
|
|
|
|
|
|
|
|
public void doPhysics(World world, BlockPosition blockposition, IBlockData iblockdata, Block block) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (!World.a((IBlockAccess) world, blockposition.down()) && !this.f(world, blockposition)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- world.setAir(blockposition);
|
|
|
|
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
@@ -298,7 +334,7 @@
|
|
|
|
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
2015-02-26 23:41:06 +01:00
|
|
|
if (world.worldProvider.getDimension() > 0 || !Blocks.PORTAL.e(world, blockposition)) {
|
|
|
|
if (!World.a((IBlockAccess) world, blockposition.down()) && !this.f(world, blockposition)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- world.setAir(blockposition);
|
|
|
|
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
|
|
|
|
} else {
|
|
|
|
world.a(blockposition, (Block) this, this.a(world) + world.random.nextInt(10));
|
|
|
|
}
|
|
|
|
@@ -320,4 +356,12 @@
|
|
|
|
protected BlockStateList getStateList() {
|
|
|
|
return new BlockStateList(this, new IBlockState[] { BlockFire.AGE, BlockFire.NORTH, BlockFire.EAST, BlockFire.SOUTH, BlockFire.WEST, BlockFire.UPPER, BlockFire.FLIP, BlockFire.ALT});
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private void fireExtinguished(World world, BlockPosition position) {
|
|
|
|
+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), Blocks.AIR).isCancelled()) {
|
|
|
|
+ world.setAir(position);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|