--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java +++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java @@ -17,6 +17,12 @@ import net.minecraft.world.level.material.FluidType; import net.minecraft.world.level.material.FluidTypes; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.block.CraftBlockStates; +import org.bukkit.event.block.CauldronLevelChangeEvent; +// CraftBukkit end + public class LayeredCauldronBlock extends AbstractCauldronBlock { public static final int MIN_FILL_LEVEL = 1; @@ -56,10 +62,14 @@ @Override public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!world.isClientSide && entity.isOnFire() && this.isEntityInsideContent(iblockdata, blockposition, entity)) { - entity.clearFire(); + // CraftBukkit start if (entity.mayInteract(world, blockposition)) { - this.handleEntityOnFireInside(iblockdata, world, blockposition); + if (!lowerFillLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) { + return; + } } + entity.clearFire(); + // CraftBukkit end } } @@ -69,20 +79,42 @@ } public static void lowerFillLevel(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start + lowerFillLevel(iblockdata, world, blockposition, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN); + } + + public static boolean lowerFillLevel(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { int i = (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) - 1; IBlockData iblockdata1 = i == 0 ? Blocks.CAULDRON.defaultBlockState() : (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, i); - world.setBlockAndUpdate(blockposition, iblockdata1); - world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + return changeLevel(iblockdata, world, blockposition, iblockdata1, entity, reason); } + // CraftBukkit start + public static boolean changeLevel(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) { + CraftBlockState newState = CraftBlockStates.getBlockState(world, blockposition); + newState.setData(newBlock); + + CauldronLevelChangeEvent event = new CauldronLevelChangeEvent( + world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), + (entity == null) ? null : entity.getBukkitEntity(), reason, newState + ); + world.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } + newState.update(true); + world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(newBlock)); + return true; + } + // CraftBukkit end + @Override public void handlePrecipitation(IBlockData iblockdata, World world, BlockPosition blockposition, BiomeBase.Precipitation biomebase_precipitation) { if (BlockCauldron.shouldHandlePrecipitation(world, biomebase_precipitation) && (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) != 3 && this.fillPredicate.test(biomebase_precipitation)) { IBlockData iblockdata1 = (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL); - world.setBlockAndUpdate(blockposition, iblockdata1); - world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + changeLevel(iblockdata, world, blockposition, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit } } @@ -101,8 +133,11 @@ if (!this.isFull(iblockdata)) { IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) + 1); - world.setBlockAndUpdate(blockposition, iblockdata1); - world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); + // CraftBukkit start + if (!changeLevel(iblockdata, world, blockposition, iblockdata1, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { + return; + } + // CraftBukkit end world.levelEvent(1047, blockposition, 0); } }