The @minecraft/server scripting API prototype method ItemDyeableComponent#defaultColor does not function. It seemingly never returns any value other than undefined.
Demonstration
The attached video demonstrates the issue. A script is run whenever a button is pressed in the world. The script looks at the held item in the main hand slot of the first player in the roster. If an item is held and it has the dyeable component, the default color property is logged.
This value seemingly always reports as undefined, as shown in the video. This undefined value is reported whether the default dye color is still applied or if the item has been re-dyed manually.
Reproduction
This bug affects any item with the minecraft:dyeable component. The following definition was used in the video:
{
"format_version": "1.26.20",
"minecraft:item": {
"description": {"identifier": "bug_dyeable:custom_item"},
"components": {
"minecraft:icon": {
"textures": {"default": "snowball", "dyed": "snowball"}
},
"minecraft:dyeable": {"default_color": "#40A0FF"}
}
}
}The following script is sufficient for testing this bug:
const
player = world.getAllPlayers()[0],
itemSlot = player
.getComponent(EntityEquippableComponent.componentId)
?.getEquipmentSlot(EquipmentSlot.Mainhand)
if (!itemSlot) {console.warn("No equipment slot."); return}
const itemStack = itemSlot.getItem()
if (!itemStack) {console.warn("No held item."); return}
const dyeableComponent = itemStack.getComponent(ItemDyeableComponent.componentId)
if (!dyeableComponent) {console.warn("Held item not dyeable."); return}
console.warn(
`ItemDyeableComponent#defaultColor: ${JSON.stringify(dyeableComponent.defaultColor)}`
)The demo video and code are taken from the behavior pack in the attached world for convenience. This world can be opened (in Minecraft Preview) for inspection or unzipped to access the code associated with such. Ensure that content logs are enabled with at least the “Warn” log level.
Thank you for helping us improve Minecraft! We saved your files: