From 2cb0061b0a452bbfc61f73fe26ff4573c8528c57 Mon Sep 17 00:00:00 2001 From: okx-code Date: Thu, 8 Sep 2022 16:13:50 +0100 Subject: [PATCH] Allow preventing BlockDestroyEvent from dropping items (#8349) --- patches/api/BlockDestroyEvent.patch | 9 ++++++++- patches/server/BlockDestroyEvent.patch | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/patches/api/BlockDestroyEvent.patch b/patches/api/BlockDestroyEvent.patch index ddd2ddcae8..c06e0c0d26 100644 --- a/patches/api/BlockDestroyEvent.patch +++ b/patches/api/BlockDestroyEvent.patch @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static final HandlerList handlers = new HandlerList(); + + @NotNull private final BlockData newState; -+ private final boolean willDrop; ++ private boolean willDrop; + private boolean playEffect = true; + + private boolean cancelled = false; @@ -68,6 +68,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** ++ * @param willDrop If the server is going to drop the block in question with this destroy event ++ */ ++ public void setWillDrop(boolean willDrop) { ++ this.willDrop = willDrop; ++ } ++ ++ /** + * @return If the server is going to play the sound effect for this destruction + */ + public boolean playEffect() { diff --git a/patches/server/BlockDestroyEvent.patch b/patches/server/BlockDestroyEvent.patch index 8fd9320d2d..49d3d20865 100644 --- a/patches/server/BlockDestroyEvent.patch +++ b/patches/server/BlockDestroyEvent.patch @@ -36,6 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return false; + } + playEffect = event.playEffect(); ++ drop = event.willDrop(); + } + // Paper end