[SPIGOT-7809] Can't set shield base color Created: 02/Jul/24  Updated: 25/Dec/24  Resolved: 20/Jul/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Tal K Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: Bug, ItemMeta, Shield

Issue Links:
Problem/Incident
causes SPIGOT-7812 Crafting colored shields broken Resolved
Version: CraftBukkit version 4248-Spigot-491f367-ae4f5a0 (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

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>]



 Comments   
Comment by md_5 [ 14/Jul/24 ]

Aya perhaps you could please test for completeness?

--rev 1.21 --pr bukkit:1042 --pr craftbukkit:1447

to BuildTools should do it

Comment by Doc [ 07/Jul/24 ]

A try to fix this by addding a new ItemMeta for Shields and not depend in BlockStateMeta

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/1042/overview https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1447/overview

Generated at Sat Dec 13 11:51:25 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.