Add support for bedrock's dyeable component in the custom item API#6392
Add support for bedrock's dyeable component in the custom item API#6392eclipseisoffline wants to merge 1 commit into
Conversation
onebeastchris
left a comment
There was a problem hiding this comment.
Looks good, thanks for the PR! Just as a note - Bedrock seems to also support a default dyed icon for dyed items; do we need to set that?
| * @return the default colour of the item if it is dyeable, and if not, an empty optional | ||
| * @since 2.10.1 | ||
| */ | ||
| OptionalInt dyeable(); |
There was a problem hiding this comment.
Personally, I'd make this a nullable Integer... or are we using OptionalInts anywhere these days?
There was a problem hiding this comment.
They are used in the now deprecated CustomItemOptions - personally, I really don't like nullable integers, they are very prone to NPEs as soon as they are casted to a primitive int.
|
What are you referring to with "default dyed icon"? |
I think he's referring to the this, not sure though I could be wrong |
|
Ah, I see, I was unaware. I will look into it. |
|
Wouldn't it be better to turn the "bedrock_options": {
"dyeable": {
"default_color": "aceace"
"dyed_icon": "cloth:tshirt_dyed"
}
}I'll write a PR to @eclipseisoffline's fork for the |
|
Sorry for the late reply, I've opened a PR in @eclipseisoffline's fork regarding the changes I made. I've tested it and everything works perfectly ⭐⭐ Screen_Recording_20260513_194146_Minecraft.mp4 |
This PR adds support for bedrock's
minecraft:dyeableitem component in the custom item API. This closes #6391.The PR adds this option to
CustomItemBedrockOptions, as on Java, this property is not defined through item components, but through theminecraft:crafting_dyerecipe type. Note that Java does haveminecraft:dyeandminecraft:dyed_colorcomponents, but, these hold the item's dye (used in the aforementioned recipe), and the item's dyed colour (the colour of e.g. leather armour), respectively.The
minecraft:dyeableitem component on bedrock holds a single colour, the default colour of the item. This is represented in the API as anOptionalInt: when present, the item is marked as dyeable, and the value is the item's default colour (in single-integer RGB24 format). When empty, the item is not marked as dyeable. In the interface's builder, the default colour can be specified as a single integer, or as 3 separate R, G, and B components, for convenience.In item mappings, the component is read as a hexadecimal string, which may or may not be prefixed with a
#. For example:or,
The new API methods are noted in the Javadocs as
@since 2.10.1, however, the version of Geyser has not yet been bumped, as I expect this will be done in a future update.Note that we are not including this component by default for items that override vanilla dyeable items, like leather armour, since on Java, dyeable items are defined through recipes. As such, we don't know whether a vanilla item could be dyeable when registering all custom items and creating their components. The vanilla item could've been removed from the vanilla dyeable recipe for example, thus, we have to rely on users putting this component in their mappings.
Also, please note that this PR also adds a
@NonNegativeannotation toCustomItemBedrockOptions#protectionValue, and appropriate checks for it. This is technically a breaking change - however, passing a negative protection value never was supported.Reviews are welcome - personally, I feel like it may be wise to turn the
dyeablekey in the mappings into an object, to make it clearer what its value represents:This is up for discussion though.