diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch index 3d51dab254..f9566481a6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/IceBlock.java.patch @@ -1,6 +1,18 @@ --- a/net/minecraft/world/level/block/IceBlock.java +++ b/net/minecraft/world/level/block/IceBlock.java -@@ -60,6 +60,11 @@ +@@ -36,6 +36,11 @@ + @Override + public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) { + super.playerDestroy(world, player, pos, state, blockEntity, tool); ++ // Paper start - Improve Block#breakNaturally API ++ this.afterDestroy(world, pos, tool); ++ } ++ public void afterDestroy(Level world, BlockPos pos, ItemStack tool) { ++ // Paper end - Improve Block#breakNaturally API + if (!EnchantmentHelper.hasTag(tool, EnchantmentTags.PREVENTS_ICE_MELTING)) { + if (world.dimensionType().ultraWarm()) { + world.removeBlock(pos, false); +@@ -60,6 +65,11 @@ } protected void melt(BlockState state, Level world, BlockPos pos) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index e5ac2d79b2..aae00320ab 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -452,6 +452,18 @@ public class CraftBlock implements Block { @Override public boolean breakNaturally(ItemStack item) { + // Paper start + return this.breakNaturally(item, false); + } + + @Override + public boolean breakNaturally(boolean triggerEffect, boolean dropExperience) { + return this.breakNaturally(null, triggerEffect, dropExperience); + } + + @Override + public boolean breakNaturally(ItemStack item, boolean triggerEffect, boolean dropExperience) { + // Paper end // Order matters here, need to drop before setting to air so skulls can get their data net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS(); net.minecraft.world.level.block.Block block = iblockdata.getBlock(); @@ -461,11 +473,35 @@ public class CraftBlock implements Block { // Modelled off EntityHuman#hasBlock if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) { net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem); + // Paper start - improve Block#breanNaturally + if (triggerEffect) { + if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.BaseFireBlock) { + this.world.levelEvent(net.minecraft.world.level.block.LevelEvent.SOUND_EXTINGUISH_FIRE, this.position, 0); + } else { + this.world.levelEvent(net.minecraft.world.level.block.LevelEvent.PARTICLES_DESTROY_BLOCK, this.position, net.minecraft.world.level.block.Block.getId(iblockdata)); + } + } + if (dropExperience) block.popExperience(this.world.getMinecraftWorld(), this.position, block.getExpDrop(iblockdata, this.world.getMinecraftWorld(), this.position, nmsItem, true)); + // Paper end result = true; } // SPIGOT-6778: Directly call setBlock instead of setTypeAndData, so that the tile entiy is not removed and custom remove logic is run. - return this.world.setBlock(this.position, Blocks.AIR.defaultBlockState(), 3) && result; + // Paper start - improve breakNaturally + boolean destroyed = this.world.removeBlock(this.position, false); + if (destroyed) { + block.destroy(this.world, this.position, iblockdata); + } + if (result) { + // special cases + if (block instanceof net.minecraft.world.level.block.IceBlock iceBlock) { + iceBlock.afterDestroy(this.world.getMinecraftWorld(), this.position, nmsItem); + } else if (block instanceof net.minecraft.world.level.block.TurtleEggBlock turtleEggBlock) { + turtleEggBlock.decreaseEggs(this.world.getMinecraftWorld(), this.position, iblockdata); + } + } + return destroyed && result; + // Paper end } @Override