1
0
mirror of https://github.com/GeyserMC/Rainbow.git synced 2025-12-21 07:49:33 +00:00

Should probably save attachables to JSON files

This commit is contained in:
Eclipse
2025-07-01 11:51:41 +00:00
parent ca16aa08f6
commit 8f3c947679

View File

@@ -33,19 +33,27 @@ public record BedrockAttachable(BedrockVersion formatVersion, AttachableInfo inf
} }
public static BedrockAttachable equipment(ResourceLocation identifier, EquipmentSlot slot, String texture) { public static BedrockAttachable equipment(ResourceLocation identifier, EquipmentSlot slot, String texture) {
String script = switch (slot) {
case HEAD -> "v.helmet_layer_visible = 0.0;";
case CHEST -> "v.chest_layer_visible = 0.0;";
case LEGS -> "v.leg_layer_visible = 0.0;";
case FEET -> "v.boot_layer_visible = 0.0;";
default -> "";
};
return builder(identifier) return builder(identifier)
.withMaterial(DisplaySlot.DEFAULT, "armor") .withMaterial(DisplaySlot.DEFAULT, "armor")
.withMaterial(DisplaySlot.ENCHANTED, "armor_enchanted") .withMaterial(DisplaySlot.ENCHANTED, "armor_enchanted")
.withTexture(DisplaySlot.DEFAULT, texture) .withTexture(DisplaySlot.DEFAULT, texture)
.withTexture(DisplaySlot.ENCHANTED, VanillaTextures.ENCHANTED_ACTOR_GLINT) .withTexture(DisplaySlot.ENCHANTED, VanillaTextures.ENCHANTED_ACTOR_GLINT)
.withGeometry(DisplaySlot.DEFAULT, VanillaGeometries.fromEquipmentSlot(slot)) .withGeometry(DisplaySlot.DEFAULT, VanillaGeometries.fromEquipmentSlot(slot))
.withScript("parent_setup", script)
.withRenderController(VanillaRenderControllers.ARMOR) .withRenderController(VanillaRenderControllers.ARMOR)
.build(); .build();
} }
public void save(Path attachablesPath) throws IOException { public void save(Path attachablesPath) throws IOException {
// Get a save attachable path by using Geyser's way of getting icons // Get a save attachable path by using Geyser's way of getting icons
CodecUtil.trySaveJson(CODEC, this, attachablesPath.resolve(GeyserMapping.iconFromResourceLocation(info.identifier))); CodecUtil.trySaveJson(CODEC, this, attachablesPath.resolve(GeyserMapping.iconFromResourceLocation(info.identifier) + ".json"));
} }
public static class Builder { public static class Builder {