Paper/patches/server/0357-Add-effect-to-block-break-naturally.patch

33 lines
1.8 KiB
Diff
Raw Normal View History

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-06-13 21:29:58 +02:00
index 0a9ed9992a2fc97472a06591a5d129a767ce21af..ca95a6b1b156b37f839c6479733e5184691af66c 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-06-13 21:29:58 +02:00
@@ -632,6 +632,13 @@ 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
+ 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-06-13 21:29:58 +02:00
@@ -641,6 +648,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;
}