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-09-30 19:42:44 +02:00
index bfacffcb39d0c4e6992df282b5b28bd7ca8d5398..d15dda75952269addf0aa2a028c6552217bef312 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-09-30 19:42:44 +02:00
@@ -634,6 +634,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-09-30 19:42:44 +02:00
@@ -643,6 +655,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;
}