diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/world/level/block/LayeredCauldronBlock.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/world/level/block/LayeredCauldronBlock.patch | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/level/block/LayeredCauldronBlock.patch b/patch-remap/og/net/minecraft/world/level/block/LayeredCauldronBlock.patch new file mode 100644 index 0000000000..d9702e0b22 --- /dev/null +++ b/patch-remap/og/net/minecraft/world/level/block/LayeredCauldronBlock.patch @@ -0,0 +1,93 @@ +--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java ++++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java +@@ -16,6 +16,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 MapCodec<LayeredCauldronBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { +@@ -61,10 +67,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 + } + + } +@@ -79,20 +89,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 && biomebase_precipitation == this.precipitationType) { + 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 + } + } + +@@ -111,8 +143,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); + } + } |