creative icon indicating copy to clipboard operation
creative copied to clipboard

feat: begin impl for Equipment

Open Boy0000 opened this issue 1 year ago • 2 comments

Currently missing a few things, if this is even wanted Wings property for using player-texture not added image

also not added color-field for leather etc image

Boy0000 avatar Nov 28 '24 01:11 Boy0000

Working on this now, do you think an enum would be better? (Seems like Mojang uses an enum too)

enum EquipmentLayerType {
    HUMANOID, // humanoid
    HUMANOID_LEGGINGS, // humanoid_leggings
    WINGS, // wings
    WOLF_BODY, // wolf_body
    HORSE_BODY, // horse_body
    LLAMA_BODY // llama_body
}

This would be more consistent with existing API (like with CubeFace and Element's faces()). Also for a complete implementation: Minecraft uses a List of layers instead, like

interface EquipmentLayer {
    Key texture(); // "texture" (seems like its required)

    @Nullable Dyeable dyeable(); // optional "dyeable"

    boolean usePlayerTexture(); // false by default "use_player_texture"
    
    interface Dyeable {
        @Nullable Integer colorWhenUndyed(); // optional, "color_when_undyed"
    }
}

so that Equipment is just a map of EquipmentLayerType -> List<EquipmentLayer> with various convenience methods

interface Equipment {
    Map<EquipmentLayerType, List<EquipmentLayer>> layers();
    
    ...
    interface Builder {
        ...
        Builder addLayer(EquipmentLayerType type, EquipmentLayer layer);
        
        default Builder addLayer(EquipmentLayerType type, Key texture) {
            return addLayer(type, EquipmentLayer.layer(texture));
        }
    }
}

yusshu avatar Dec 09 '24 10:12 yusshu

definetly makes more sense yep 👍

Boy0000 avatar Dec 09 '24 10:12 Boy0000