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

getItemMeta for Hanging Signs returns an unspecific item meta instead of BlockStateMeta

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • None
    • None
    • Not relevant

    • This server is running CraftBukkit version 4272-Spigot-34bd42b-76f59e3 (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
    • Yes

      Hanging sign items should return a BlockStateMeta (CraftMetaBlockState) when calling  ItemFactory#getItemMeta. However, they instead return an unspecific CraftItemMeta. This also affects ItemStack#getItemMeta and results in incorrect metadata being returned for hanging signs.
       
      In the class CraftItemMetas, hanging signs are not included in the condition to return a Block State Meta:

      if (itemType == ItemType.FURNACE || itemType == ItemType.CHEST
          ....
              || (itemType.hasBlockType() && Tag.SIGNS.isTagged(itemType.getBlockType().asMaterial())) || itemType == ItemType.SPAWNER
          ....
              || itemType == ItemType.TRIAL_SPAWNER || itemType == ItemType.VAULT) {
          return CraftItemMetas.asType(CraftItemMetas.BLOCK_STATE_META_DATA);
      }

      The SIGNS tag does not include hanging signs, and no hanging signs tag is included here. SIGNS should be replaced with ALL_SIGNS, or ALL_HANGING_SIGNS should be added to this list.
       
       
      Simple reproduction code:

      public void onEnable() {
          getLogger().info(Bukkit.getItemFactory().getItemMeta(Material.OAK_SIGN).getClass().getName());
          getLogger().info(Bukkit.getItemFactory().getItemMeta(Material.OAK_HANGING_SIGN).getClass().getName());
      } 

      Output on latest Spigot version:

      [21:11:19] [Server thread/INFO]: [] org.bukkit.craftbukkit.v1_21_R1.inventory.CraftMetaBlockState
      [21:11:19] [Server thread/INFO]: [] org.bukkit.craftbukkit.v1_21_R1.inventory.CraftMetaItem
      

      Both functions should return CraftMetaBlockState.

            md_5 md_5
            jtprince Joshua Prince
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: