第121批续13:违禁品没收副手双计数修复(getContents已含slot40,删副手独立块)
Auto Release / build (push) Successful in 2m45s

This commit is contained in:
youpaishidifu
2026-11-12 22:12:15 +08:00
parent a3744ac6d9
commit 2ff99fee74
+3 -10
View File
@@ -13147,16 +13147,9 @@ public class AreaProtection implements Listener {
} }
} }
p.getInventory().setContents(all); p.getInventory().setContents(all);
// ★ 第121批续13:副手(slot 40)已被 getContents() 45 格覆盖(0-35背包+36-39盔甲+40副手),
ItemStack off = p.getInventory().getItemInOffHand(); // 旧代码在 setContents 后额外扫 getItemInOffHand() → 副手物品被捕获两次 → 数量翻倍 + 双暂存。
if (off != null && off.getType() == mat) { // 删除副手独立块,副手物品只计一次。
count += off.getAmount();
ItemStack capOff = off.clone();
final long batchTagOff = confBatch;
capOff.editPersistentDataContainer(view -> view.set(CONFISCATE_BATCH_KEY, PersistentDataType.LONG, Long.valueOf(batchTagOff)));
captured.add(capOff);
p.getInventory().setItemInOffHand(null);
}
if (count > 0) { if (count > 0) {
totalRemoved += count; totalRemoved += count;