mojira.dev
MCPE-237576

Scripting property color in ItemDyeableComponent class not reflecting default color values

The @minecraft/server scripting API prototype method ItemDyeableComponent#color does not return the default color for a dyeable item before the item has been re-dyed.

This method should reflect the definition’s default_color property until the item has been re-dyed.

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 color property is logged. The item being tested has a default color that’s blue-ish.

This value reports as undefined when the item has not been re-dyed, as shown in the video.

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#color: ${JSON.stringify(dyeableComponent.color)}`
)

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.

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media][media]

Ciosciaa

(Unassigned)

Unconfirmed

Multiple

26.20.22 Preview

Retrieved