ItemStack isSimilar issue with component display names

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • None
    • Affects Version/s: None
    • 1.21.4
    • Yes

      If I name an item with an anvil, it becomes

      ItemStack\{EMERALD x 11, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name="special anvil"}}

      After calling setDisplayName or setItemMeta, the display name changes to

       ItemStack{EMERALD x 11, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"text":"","extra":["special anvil"]}}} 

      These two ItemStacks return false for isSimilar, which breaks logic unless you call setDisplayName or setItemMeta on every ItemStack before comparison.

      Code to reproduce (assuming you clicked on an appropriately named item in your inventory from an anvil).

      @EventHandler
      
      public void onInventoryClick(InventoryClickEvent evt) {
      
          System.out.println(evt.getCurrentItem());
      
          ItemStack stack = evt.getCurrentItem().clone();
      
          stack.setItemMeta(stack.getItemMeta());
      
          System.out.println(stack);
      
      }
      

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

              Created:
              Updated: