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

CraftItemStacks of Damageable items are not similar to (Bukkit)ItemStacks

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-1d0aef7-b4bff6f (MC: 1.13-pre7) (Implementing API version 1.13-pre7-R0.1-SNAPSHOT)

      When a CraftItemStack is internally generated from a NMS ItemStack with a tag of "Damage: 0" (Damageable things in the inventory (sometimes?) have that tag) - it will have an empty ItemMeta (hasItemMeta() == true), Bukkit ItemStacks of damageable items do not have an item meta (if the item is not damaged) (hasItemMeta() == false), so isSimilar will return false.

       

      Reproduction: get the players Inventory and getItem() on some slot with a undamaged damageable item. check .isSimilar() with a new created bukkit itemstack 

       

       

      @EventHandler(priority = EventPriority.NORMAL)
      public void onJoin(PlayerJoinEvent e) {
        ItemStack shears = new ItemStack(Material.SHEARS);
        e.getPlayer().getInventory().setItem(1, shears);
        System.out.println(e.getPlayer().getInventory().getItem(1).isSimilar(shears));
      }
      

       

       

       

      Suggested fix: hasItemMeta() should return false if there is just a single tag of "Damage: 0" and nothing else.

       

       

      PPS: Bug reports which do not 1) contain a declaration of independence in Vanilla and without plugins, or 2) in the case of plugin API bugs, contain a minimal reproduction case (source + jar please) will be closed. Bug reports must contain step by step instructions to reproduce the bug from a clean server install with no assumptions or prior knowledge. Also make sure you include the full output of /version in your report. Please copy and paste this statement to the bottom of your report to indicate that you have read and understood it.

      PPPS: Failure to include the above statement will result in a 24 hour ban from the forums.

            md_5 md_5
            Brokkonaut Brokkonaut
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: