mojira.dev

Martmists

Assigned

No issues.

Comments

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:

  1. Implement and register a new Entity

  2. In your entity’s defineSynchedData method, define an attribute that was defined with a different type using defineId that has the same index as the capacity of the current type (could happen by accident, because of a refactor, etc.)

  3. 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])”.

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.