From 23aba25572f3ca2b6bec718d56e17fbafde14f06 Mon Sep 17 00:00:00 2001 From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Mon, 10 Mar 2025 20:34:35 +0100 Subject: [PATCH] Fix dropped items looking like 1 item with item sanitation --- .../paper/util/ItemComponentSanitizer.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/paper-server/src/main/java/io/papermc/paper/util/ItemComponentSanitizer.java b/paper-server/src/main/java/io/papermc/paper/util/ItemComponentSanitizer.java index 74d658d2ff78..1476811e5bfd 100644 --- a/paper-server/src/main/java/io/papermc/paper/util/ItemComponentSanitizer.java +++ b/paper-server/src/main/java/io/papermc/paper/util/ItemComponentSanitizer.java @@ -66,11 +66,21 @@ private static ItemEnchantments dummyEnchantments() { public static int sanitizeCount(final ItemObfuscationSession obfuscationSession, final ItemStack itemStack, final int count) { if (obfuscationSession.obfuscationLevel() != ItemObfuscationSession.ObfuscationLevel.ALL) return count; // Ignore if we are not obfuscating - if (GlobalConfiguration.get().anticheat.obfuscation.items.binding.getAssetObfuscation(itemStack).sanitizeCount()) { - return 1; - } else { + if (!GlobalConfiguration.get().anticheat.obfuscation.items.binding.getAssetObfuscation(itemStack).sanitizeCount() || count <= 1) { return count; } + + // See https://minecraft.wiki/w/Item_(entity)#Appearance for reference, this returns the lowest possible count + // for the item to keep it looking the same. + if (count <= 16) { // 2 - 16 + return 2; + } else if (count <= 32) { // 17 - 32 + return 17; + } else if (count <= 48) { // 33 - 48 + return 33; + } else { // 49+ + return 49; + } } public static boolean shouldDrop(final ItemObfuscationSession obfuscationSession, final DataComponentType key) {