Fabric API

Fabric API

152M Downloads

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

sylv256 opened this issue ยท 2 comments

commented

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.

commented

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?

commented

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.