SynchedEntityData.Builder$define checks if id > this.itemsById.length, but if id == this.itemsById.length, the subsequent non-null check this.itemsById[id] != null will error with an IndexOutOfBoundsException. Similarly, the existing IllegalArgumentException for id being out of range states the max is this.itemsById.length, but it should be this.itemsById.length - 1.
Comments 4
As far as I can tell, all vanilla entities currently follow the implicit contract this method verifies, however this incorrect validation may end up causing problems in the future (or with mod developers who don't have the context of the implicit contract), and it's clearly designed to catch the problem, it just missed the boundary.
I understand if this gets closed as invalid for not impacting the game in the current state, but considering the fix is only 3 characters long, I do hope it gets implemented.
Thank you for your report!
However, this issue has been temporarily closed as Awaiting Response.
If reproducing this issue requires a datapack or a resource pack, then could you please attach one here?
To make your bug report as effective as possible, please try and include the following steps to reproduce the problem:
Steps to Reproduce:
1.
2.
3.Observed Results:
(Briefly describe what happens)Expected Results:
(Briefly describe what should happen)
If your ticket does not look like the example given here, then it's likely to be closed as incomplete.
This ticket will automatically reopen when you reply.
Quick Links:
π Issue Guidelines β π¬ Mojang Support β π§ Suggestions β π Minecraft Wiki
As stated before, it is a developer-only issue and does not affect datapacks/resource packs (unless there are plans to support implementing custom entities through them in the future).
Steps to Reproduce:
Implement and register a new Entity
In your entityβs
defineSynchedDatamethod,definean attribute that was defined with a different type usingdefineIdthat has the same index as the capacity of the current type (could happen by accident, because of a refactor, etc.)Spawn the entity in the game
Observed Results:
The code fails to get caught by the off-by-one check and throws an IndexOutOfBoundsException which requires digging through the code to figure out what exactly went wrong.
Expected Results:
The code is correctly caught by the check and throws an IllegalArgumentException with message βData value id is too big with [x]! (Max is [y])β.
Is there a way this can affect the game (e.g. a crash, an error message in the log)? If so, how can it be triggered?
This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.
Quick Links:
π Bug Tracker Guidelines β π¬ Community Support β π§ Mojang Support (Technical Issues) β π§ Microsoft Support (Account Issues)
π Project Summary β βοΈ Feedback and Suggestions β π Game Wiki