fabric icon indicating copy to clipboard operation
fabric copied to clipboard

`ExtraModelKey` has no `equals` or `hashCode`

Open sylv256 opened this issue 8 months ago • 2 comments

Description

ExtraModelKey has no equals or hashCode methods meaning HashMap differentiates only by == a.k.a. instance.

Reproduction

  1. Register an Extra Model.
  2. Get the model using a new ExtraModelKey with the same Identifier.
  3. Null jumpscare!

Additional Details

This is a serious issue when dealing with extra models, because it means you must store your ExtraModelKeys somewhere as a constant.

sylv256 avatar Aug 11 '25 22:08 sylv256

ExtraModelKeys are intended to be stored as constants, and it is intentional that ExtraModelKeys are compared only by identity. The Supplier<String> is only meant for debug purposes. Is there some reason that you cannot store your keys as constants, or at least values in a map?

PepperCode1 avatar Aug 11 '25 23:08 PepperCode1

ExtraModelKeys are intended to be stored as constants, and it is intentional that ExtraModelKeys are compared only by identity. The Supplier<String> is only meant for debug purposes. Is there some reason that you cannot store your keys as constants, or at least values in a map?

That's my bad. To be fair, it should be more abundantly clear that that's the intended behavior.

sylv256 avatar Aug 12 '25 00:08 sylv256