Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7671

ItemStack.isSimilar is not longer working with Mojang Component

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • spigot 1.20.6 - Java 21 - Docker

    • 1.20.6
    • Yes

      Since the new 1.20.5/6, mojang now use Components to store Item properties.

      ItemFlag enum does not work as before.

       

      Plugin to reproduce: https://github.com/GrayR0ot/spigot-item-flags-bug

       

      Example:
      I create an ItemStack using spigot API:

      ItemStack{COBBLESTONE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"text":"Pierre","italic":false,"color":"white"}, lore=[{"text":"Ressource minière","italic":false,"color":"dark_gray"}, {"text":"Description en cours de rédaction","italic":false,"color":"white"}, "", {"text":"COMMUN","italic":false,"color":"white","bold":true}], ItemFlags=[HIDE_ENCHANTS, HIDE_ATTRIBUTES, HIDE_UNBREAKABLE, HIDE_DESTROYS, HIDE_PLACED_ON, HIDE_ADDITIONAL_TOOLTIP, HIDE_DYE, HIDE_ARMOR_TRIM, HIDE_STORED_ENCHANTS], PublicBukkitValues={
          "shfarmrun:id": "060f381e-f76f-4f5e-84a1-e1b0c82b961b"
      }}} 

      Now, when I give it to a player, here is what the player have in it's inventory:
       

      ItemStack{COBBLESTONE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"text":"Pierre","italic":false,"color":"white"}, lore=[{"text":"Ressource minière","italic":false,"color":"dark_gray"}, {"text":"Description en cours de rédaction","italic":false,"color":"white"}, "", {"text":"COMMUN","italic":false,"color":"white","bold":true}], ItemFlags=[HIDE_ADDITIONAL_TOOLTIP], PublicBukkitValues={
          "shfarmrun:id": "060f381e-f76f-4f5e-84a1-e1b0c82b961b"
      }}} 

      We can see, everything looks the same, but no, the ItemFlags property has been changed.
       

      A temporary fix, could be to skip the ItemFlags check in the isSimilar method of ItemStack

            Unassigned Unassigned
            grayr0ot Léo Moriceau
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: