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

38 Zeilen
1.9 KiB
Diff

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
2022-03-01 06:43:03 +01:00
index 7f1d4015ba795db7404669d931bd44060116bcc9..7eb8f37f493a83058a6e96f2e134a204b3304015 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
2022-03-01 06:43:03 +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
+ 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();
2022-03-01 06:43:03 +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;
}