Files
CatServer/patches/net/minecraft/block/BlockFire.java.patch

101 lines
4.7 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockFire.java
+++ ../src-work/minecraft/net/minecraft/block/BlockFire.java
@@ -4,6 +4,11 @@
import java.util.Map;
import java.util.Random;
import javax.annotation.Nullable;
+
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockBurnEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
@@ -136,7 +141,7 @@
{
if (!this.canPlaceBlockAt(worldIn, pos))
{
- worldIn.setBlockToAir(pos);
+ fireExtinguished(worldIn, pos); // CraftBukkit - invalid place location
}
Block block = worldIn.getBlockState(pos.down()).getBlock();
@@ -146,7 +151,7 @@
if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos) && rand.nextFloat() < 0.2F + (float)i * 0.03F)
{
- worldIn.setBlockToAir(pos);
+ fireExtinguished(worldIn, pos); // CraftBukkit - extinguished by rain
}
else
{
@@ -164,7 +169,7 @@
{
if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) || i > 3)
{
- worldIn.setBlockToAir(pos);
+ fireExtinguished(worldIn, pos); // CraftBukkit
}
return;
@@ -172,7 +177,7 @@
if (!this.canCatchFire(worldIn, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0)
{
- worldIn.setBlockToAir(pos);
+ fireExtinguished(worldIn, pos); // CraftBukkit
return;
}
}
@@ -228,7 +233,20 @@
i2 = 15;
}
- worldIn.setBlockState(blockpos, state.withProperty(AGE, Integer.valueOf(i2)), 3);
+ if ((worldIn.getBlockState(blockpos) != Blocks.FIRE) &&
+ (!CraftEventFactory.callBlockIgniteEvent(worldIn, blockpos.getX(), blockpos.getY(), blockpos.getZ(), pos.getX(), pos.getY(), pos.getZ()).isCancelled())) {
+ org.bukkit.Server server = worldIn.getServer();
+ org.bukkit.World bworld = worldIn.getWorld();
+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(blockpos.getX(), blockpos.getY(), blockpos.getZ()).getState();
+ blockState.setTypeId(Block.getIdFromBlock(this));
+ blockState.setData(new org.bukkit.material.MaterialData(Block.getIdFromBlock(this), (byte)i2));
+
+ BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), blockState);
+ server.getPluginManager().callEvent(spreadEvent);
+ if (!spreadEvent.isCancelled()) {
+ blockState.update(true);
+ }
+ }
}
}
}
@@ -277,6 +295,14 @@
{
IBlockState iblockstate = worldIn.getBlockState(pos);
+ org.bukkit.block.Block theBlock = worldIn.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
+
+ BlockBurnEvent event = new BlockBurnEvent(theBlock);
+ worldIn.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+
if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos))
{
int j = age + random.nextInt(5) / 4;
@@ -488,4 +514,12 @@
return world.getBlockState(pos).getBlock().isFlammable(world, pos, face);
}
/*================================= Forge Start ======================================*/
+
+ // CraftBukkit start
+ private void fireExtinguished(World world, BlockPos position) {
+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), Blocks.AIR).isCancelled()) {
+ world.setBlockToAir(position);
+ }
+ }
+ // CraftBukkit end
}