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

Legacy isSimilar broken for colored glass panes with meta

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • CraftBukkit version git-Spigot-2440e18-6304ccd (MC: 1.13.1) (Implementing API version 1.13.1-R0.1-SNAPSHOT) - (latest at the time of writing)
    • Yes

      I create colored glass panes, add them to an Inventory and later have to check which slots are still taken by them. At that point calling ItemStack#isSimilar on a saved instance of the ItemStack and an ItemStack from the Inventory returns false.

      private void test(Player player) {
          ItemStack ownWater = new ItemStack(Material.STAINED_GLASS_PANE);
          ownWater.setDurability((short) 11);
          int slot = 0;
      
          player.getInventory().setItem(slot, ownWater);
          player.sendMessage("Both have meta? " + (ownWater.hasItemMeta() == player.getInventory().getItem(slot).hasItemMeta()));
          player.sendMessage("Meta same? " + Bukkit.getItemFactory().equals(ownWater.getItemMeta(), player.getInventory().getItem(slot).getItemMeta()));
          player.sendMessage("Durability same? " + (ownWater.getDurability() == player.getInventory().getItem(slot).getDurability()));
          player.sendMessage("Type same? " + (ownWater.getType() == player.getInventory().getItem(slot).getType()));
          player.sendMessage("Stack similar? " + player.getInventory().getItem(slot).isSimilar(ownWater));
      }

      (compiled with 1.12.2)

      The first 4 checks are true, the 5th one (isSimilar) is false.

      Without the durability it works correctly.

      I recreated all the checks from the current Implementation of isSimilar and they all return true. The only difference is, that in 1.13+ one of the materials that is compared comes from UnsaveValues#fromLegacy, so I guess that's where things go wrong.

            Unassigned Unassigned
            Nikl Niklas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: