2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 2 Jan 2020 12:25:07 -0600
Subject: [PATCH] Add effect to block break naturally
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
2021-11-24 08:37:09 +01:00
index 0408a72e801178375426edf3e1c1880774ca5478..00056d5b3426df121242de2ae01fca492d20089a 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
2021-11-24 08:37:09 +01:00
@@ -468,6 +468,18 @@ public class CraftBlock implements Block {
2021-06-11 14:02:28 +02:00
@Override
public boolean breakNaturally(ItemStack item) {
+ // Paper start
+ return breakNaturally(item, false);
+ }
+
+ @Override
2021-09-30 19:42:44 +02:00
+ public boolean breakNaturally(boolean triggerEffect) {
+ return breakNaturally(null, triggerEffect);
+ }
+
+ @Override
2021-06-11 14:02:28 +02:00
+ public boolean breakNaturally(ItemStack item, boolean triggerEffect) {
+ // 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();
2021-11-24 08:37:09 +01:00
@@ -477,6 +489,7 @@ public class CraftBlock implements Block {
2021-06-11 14:02:28 +02:00
// Modelled off EntityHuman#hasBlock
if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) {
2021-06-13 21:29:58 +02:00
net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), position, this.world.getBlockEntity(position), null, nmsItem);
2021-06-11 14:02:28 +02:00
+ if (triggerEffect) world.levelEvent(org.bukkit.Effect.STEP_SOUND.getId(), position, net.minecraft.world.level.block.Block.getId(block.defaultBlockState())); // Paper
result = true;
}