ItemMeta#hasCustomModelData breaks backwards compatibility

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • Environment:

      N/A

    • 1.21.4
    • Yes

      ItemMeta#hasCustomModelData has existed in the game since 1.14.
      It could be used to guarantee a successful call to ItemMeta#getCustomModelData()int.

      WIth the addition of the CustomModelDataComponent, the method transitioned to a plain check if the component itself exists.
      getCustomModelData()int however has two requirements
      a) the component existing
      b) a single float being set

      Condition `b` is not actually checked by `hasCustomModelData` and hence leads plugins into `Preconditions.checkState(!floats.isEmpty(), "No numeric custom model data");` for items with custom model data but without floats, thus breaking the API expectations of plugins developed prior to 1.21.4.

      Resolving this is rough, the "has" method may have been used to check for the existence of the component by now, meaning fixing this is going to break something (or leave something broken).

            Assignee:
            Unassigned
            Reporter:
            Bjarne Koll
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: