From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Tue, 18 Nov 2025 00:35:13 +0800 Subject: [PATCH] Leaves: Prevent loss of item drops due to update suppression when breaking blocks Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com> As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/ea91106ae57fc4cc14e2e0225009cf9919072f7f/leaves-server/minecraft-patches/features/0090-Servux-Protocol.patch) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java index 13e981bfd070d9351d8880478b5a86e39bcd73ad..d0ac2d15388e842ed56ec39ecdbc99994e0617bc 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java @@ -394,7 +394,18 @@ public class ServerPlayerGameMode { this.level.getCurrentWorldData().captureDrops = new java.util.ArrayList<>(); // Folia - region threading // CraftBukkit end BlockState adjustedState = block.playerWillDestroy(this.level, pos, state, this.player); - boolean changed = this.level.removeBlock(pos, false); + // Lophine start - preserve drops before update suppression + boolean changed; + org.leavesmc.leaves.util.UpdateSuppressionException updateSuppressionException = null; + try { + changed = this.level.removeBlock(pos, false); + } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) { + updateSuppressionException = exception; + updateSuppressionException.provideBlock(this.level, pos, block); + updateSuppressionException.providePlayer(this.player); + changed = false; + } + // Lophine end - preserve drops before update suppression if (SharedConstants.DEBUG_BLOCK_BREAK) { LOGGER.info("server broke {} {} -> {}", pos, adjustedState, this.level.getBlockState(pos)); } @@ -422,6 +433,11 @@ public class ServerPlayerGameMode { if (event.isDropItems()) { org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, bState, this.player, itemsToDrop); // Paper - capture all item additions to the world } + // Lophine start - preserve drops before update suppression + if (updateSuppressionException != null) { + throw updateSuppressionException; + } + // Lophine end - preserve drops before update suppression // Drop event experience if (changed) {