mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
e8c9836ec9
By: md_5 <git@md-5.net>
85 lines
4.3 KiB
Diff
85 lines
4.3 KiB
Diff
--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
|
+++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
|
@@ -17,6 +17,11 @@
|
|
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.event.block.CauldronLevelChangeEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class LayeredCauldronBlock extends AbstractCauldronBlock {
|
|
|
|
public static final int MIN_FILL_LEVEL = 1;
|
|
@@ -56,10 +61,14 @@
|
|
@Override
|
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
|
if (!world.isClientSide && entity.isBurning() && this.a(iblockdata, blockposition, entity)) {
|
|
- entity.extinguish();
|
|
+ // CraftBukkit start
|
|
if (entity.a(world, blockposition)) {
|
|
- this.d(iblockdata, world, blockposition);
|
|
+ if (!decreaseLevel(iblockdata, world, blockposition, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
|
|
+ return;
|
|
+ }
|
|
}
|
|
+ entity.extinguish();
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|
|
@@ -69,15 +78,38 @@
|
|
}
|
|
|
|
public static void e(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
|
+ // CraftBukkit start
|
|
+ decreaseLevel(iblockdata, world, blockposition, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
|
|
+ }
|
|
+
|
|
+ public static boolean decreaseLevel(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
|
|
int i = (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) - 1;
|
|
|
|
- world.setTypeUpdate(blockposition, i == 0 ? Blocks.CAULDRON.getBlockData() : (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, i));
|
|
+ return changeLevel(iblockdata, world, blockposition, i == 0 ? Blocks.CAULDRON.getBlockData() : iblockdata.set(LayeredCauldronBlock.LEVEL, i), entity, reason);
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public static boolean changeLevel(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData newBlock, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
|
|
+ CraftBlockState newState = CraftBlockState.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);
|
|
+ return true;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
@Override
|
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, BiomeBase.Precipitation biomebase_precipitation) {
|
|
if (BlockCauldron.a(world, biomebase_precipitation) && (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) != 3 && this.fillPredicate.test(biomebase_precipitation)) {
|
|
- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL));
|
|
+ changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit
|
|
}
|
|
}
|
|
|
|
@@ -94,7 +126,11 @@
|
|
@Override
|
|
protected void a(IBlockData iblockdata, World world, BlockPosition blockposition, FluidType fluidtype) {
|
|
if (!this.c(iblockdata)) {
|
|
- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) + 1));
|
|
+ // CraftBukkit start
|
|
+ if (!changeLevel(iblockdata, world, blockposition, (IBlockData) iblockdata.set(LayeredCauldronBlock.LEVEL, (Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) + 1), null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
world.triggerEffect(1047, blockposition, 0);
|
|
}
|
|
}
|