-
Notifications
You must be signed in to change notification settings - Fork 2
Custom Sector Coloring
Sector blocks in a waterslide can be dyed. Hold a dye item and right-click the slide.
The dye result comes from a rules file. The rules file is a resource pack asset:
assets/create_waterparked/waterslide_dye.json
The mod ships with built-in rules. They cover the vanilla dyeable block families.
Uncolored blocks become their colored variants:
- glass
- glass pane
- terracotta
- candle
- shulker box
Colored blocks in these families can be re-dyed:
- wool
- carpet
- concrete
- concrete powder
- terracotta
- stained glass
- stained glass pane
- bed
- candle
- candle cake
- shulker box
- banner
- wall banner
The dye lookup works in this order:
- Check the resource pack rules for the block id.
- If a rule exists, use it.
- If no rule exists, use the built-in rule.
- If neither exists, the block is not dyeable.
A rule with "dyeable": false always wins. It forbids the block even if another rule matches.
The result must exist in the block registry. If it does not exist, the block is not dyeable.
Create a resource pack with the file assets/create_waterparked/waterslide_dye.json.
{
"blocks": {
"minecraft:glass": {
"target": "minecraft:%s_stained_glass"
},
"create:framed_glass": {
"dyeable": false
},
"mymod:magic_glass": {
"mapping": {
"white": "mymod:white_magic_glass",
"yellow": "mymod:yellow_magic_glass",
"red": "mymod:red_magic_glass"
}
}
}
}Each entry uses the block id as the key. The value is a rule object.
target is a template. %s is replaced with the dye color name.
{
"minecraft:gray_concrete": {
"target": "minecraft:%s_concrete"
}
}Yellow dye on gray concrete gives minecraft:yellow_concrete.
Dye color names:
white, orange, magenta, light_blue, yellow, lime, pink, gray, light_gray, cyan, purple, blue, brown, green, red, black
mapping lists the result for each color explicitly. Use it for non-standard results.
{
"mymod:magic_glass": {
"mapping": {
"yellow": "mymod:yellow_magic_glass",
"red": "mymod:red_magic_glass"
}
}
}If a rule has both mapping and target, mapping wins.
"dyeable": false forbids the block.
{
"create:framed_glass": {
"dyeable": false
}
}If several packs define the same block, the pack with higher priority wins.
The default rules file is generated by data generation.
The base class is AssetJsonProvider in net.omori_sunny.create_waterparked.datagen.
class MyJsonProvider(output: PackOutput, modId: String) :
AssetJsonProvider(output, modId, "My assets") {
override fun gather(): Map<ResourceLocation, JsonObject> {
val obj = JsonObject()
obj.addProperty("hello", "world")
return mapOf(ResourceLocation.fromNamespaceAndPath(modId, "my_file") to obj)
}
}public class MyJsonProvider extends AssetJsonProvider {
public MyJsonProvider(PackOutput output, String modId) {
super(output, modId, "My assets");
}
@Override
protected Map<ResourceLocation, JsonObject> gather() {
JsonObject obj = new JsonObject();
obj.addProperty("hello", "world");
return Map.of(ResourceLocation.fromNamespaceAndPath(modId, "my_file"), obj);
}
}The provider writes each entry to assets/<namespace>/<path>.json.
Register the provider in CreateWaterparkedDataGen:
@JvmStatic
fun gatherData(event: GatherDataEvent) {
val generator = event.generator
generator.addProvider(true, MyJsonProvider(generator.packOutput, "create_waterparked"))
}public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
generator.addProvider(true, new MyJsonProvider(generator.getPackOutput(), "create_waterparked"));
}Run data generation:
./gradlew runDataGenerated files go to src/generated/resources.
A ready-to-use example pack is in examples/waterslide-dye-pack.