Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe first check count? Seems like a free performance gain for most equipment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reality, it most likely does not matter that much and honestly, branch prediction taking the wrong path might be worse.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's indeed not worth big discussion as the gain is minimal, so won't continue past this message explaining my thoughts. If someone could mark this as resolved would be glad

Since the check is already present, it makes sense to make the easy check first that already has all the data on stack instead of the pointer chasing through all the ram, especially since in current implementation the majority of items passing here will be from entiy equipment, which is mostly either 1 for unstackable items (armor) or 0 for empty slots, so since it's true it's not gonna even need to check the config

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) {
Expand Down