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

Can't set shield base color

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • CraftBukkit version 4248-Spigot-491f367-ae4f5a0 (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
    • Yes

      The following code worked on previous versions to set a shield's base color, but doesn't seem to work anymore as of 1.20.5/6:

      ItemStack shield = new ItemStack(Material.SHIELD);
      BlockStateMeta stateMeta = (BlockStateMeta) shield.getItemMeta();
      Banner banner = (Banner) stateMeta.getBlockState();
      banner.setBaseColor(DyeColor.BLUE);
      stateMeta.setBlockState(banner);
      shield.setItemMeta(stateMeta);
      player.getInventory().addItem(shield);

      A blue shield crafted in a crafting table is: {count: 1, Slot: 1b, components: {"minecraft:base_color": "blue", "minecraft:banner_patterns": [], "minecraft:block_entity_data": {components:

      {"minecraft:base_color": "blue"}

      , x: 0, y: 0, z: 0, id: "minecraft:banner"}}, id: "minecraft:shield"}

      The shield the code above creates is: {count: 1, Slot: 0b, components: {"minecraft:banner_patterns": [], "minecraft:block_entity_data": {x: 0, y: 0, z: 0, id: "minecraft:banner"}}, id: "minecraft:shield"}

       

      It seems like shield base color is stored in it's own component now as opposed to a banner block state on the item, especially seeing as one crafted in Vanilla is: {count: 1, Slot: 0b, components:

      {"minecraft:base_color": "blue"}

      , id: "minecraft:shield"}

      All the item data was grabbed with /data get entity @s Inventory[<slot>]

            Unassigned Unassigned
            Aya Tal K
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: