Reimplement ItemStack Obfuscation #11817
Open
+459
−109
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Due to the amount of changes to items in the past updates, the previous configuration for obfuscation does not really fit today's representation of items.
This reimplements ItemStack obfuscation in a way that is built in mind to support the new 1.21.4 ItemModel format.
The following data components are obfuscated by default when enabled:
Unlike before, obfuscation for data components can now be configured on a per item model basis. So for example, items with the elytra item model will not obfuscate their damage component in order for their item model to properly read the damage value.
Tradeoff: No modifying the component map
Components like unbreakable will need to remain on the item, since this current approach ONLY swaps patched values sent to the client. And obviously, marker components don't really have any actual data on them. This keeps the implementation of this obfuscation simple and performant.
But because of this, we cannot add or remove any components.
Default Obfuscation Behavior
Due to the tradeoff listed above, we HAVE to supply a patched value if it is present.
Because of this, the following logic has been implemented:
Basically, for every component, we will try to send the prototype in order to keep the item looking identical to its vanilla counterpart.
(Note: The enchantment component forcibly will use an empty value rather than the prototype in order to retain the glint.)
QUESTION: Should this behavior be configurable? I know some people use this to save on bandwidth...
These are the current components that have default values, so when configured, will be hidden if not present on the prototype:
Finally
Please provide any feedback on this new system, as this is a bit different and want to make sure that it is the best for people migrating from the old system. And additionally which new components people would like obfuscated by default.😄
Download the paperclip jar for this pull request: paper-11817.zip