Search in sources :

Example 1 with MaterialLayer

use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.

the class MaterialLayer method read.

public static MaterialLayer read(FriendlyByteBuf buffer) {
    ResourceLocation texture = buffer.readResourceLocation();
    int color = buffer.readVarInt();
    PartType partType = PartType.getNonNull(buffer.readResourceLocation());
    return new MaterialLayer(texture, partType, color, true);
}
Also used : PartType(net.silentchaos512.gear.api.part.PartType) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 2 with MaterialLayer

use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.

the class CompoundMaterialDisplay method getLayerColor.

@Override
public int getLayerColor(GearType gearType, IPartData part, IMaterialInstance materialIn, int layer) {
    List<MaterialLayer> layers = getLayerList(gearType, part, materialIn).getLayers();
    if (layer < layers.size()) {
        ItemStack stack = materialIn.getItem();
        if (stack.getItem() instanceof CompoundMaterialItem) {
            List<IMaterialInstance> subMaterials = CompoundMaterialItem.getSubMaterials(stack);
            int color = ColorUtils.getBlendedColor((CompoundMaterialItem) stack.getItem(), subMaterials, layer);
            // return layers.get(layer).getColor();
            return color;
        }
    }
    return Color.VALUE_WHITE;
}
Also used : ItemStack(net.minecraft.world.item.ItemStack) CompoundMaterialItem(net.silentchaos512.gear.item.CompoundMaterialItem)

Example 3 with MaterialLayer

use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.

the class GearModelOverrideList method addWithBlendedColor.

private static void addWithBlendedColor(List<MaterialLayer> list, PartData part, MaterialInstance material, ItemStack stack) {
    IMaterialDisplay model = material.getDisplayProperties();
    GearType gearType = GearHelper.getType(stack);
    List<MaterialLayer> layers = model.getLayerList(gearType, part, material).getLayers();
    addColorBlendedLayers(list, part, stack, layers);
}
Also used : GearType(net.silentchaos512.gear.api.item.GearType) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Example 4 with MaterialLayer

use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.

the class GearModelOverrideList method addColorBlendedLayers.

private static void addColorBlendedLayers(List<MaterialLayer> list, PartData part, ItemStack stack, List<MaterialLayer> layers) {
    for (int i = 0; i < layers.size(); i++) {
        MaterialLayer layer = layers.get(i);
        if ((layer.getColor() & 0xFFFFFF) < 0xFFFFFF) {
            int blendedColor = part.getColor(stack, i, 0);
            MaterialLayer coloredLayer = layer.withColor(blendedColor);
            list.add(coloredLayer);
            if (isDebugLoggingEnabled()) {
                debugLogLayer(coloredLayer, Color.format(blendedColor));
            }
        } else {
            list.add(layer);
            if (isDebugLoggingEnabled()) {
                debugLogLayer(layer, "colorless");
            }
        }
    }
}
Also used : MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Example 5 with MaterialLayer

use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.

the class CompoundPartModel method buildFakeModel.

private void buildFakeModel(Function<Material, TextureAtlasSprite> spriteGetter, ImmutableList.Builder<BakedQuad> builder, Transformation rotation, IMaterial material) {
    // This method will display an example item for items with no data (ie, for advancements)
    MaterialInstance mat = MaterialInstance.of(material);
    IMaterialDisplay model = mat.getDisplayProperties();
    MaterialLayer exampleMain = model.getLayerList(this.gearType, this.partType, mat).getFirstLayer();
    if (exampleMain != null) {
        builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleMain.getTexture(this.texturePath, 0))), rotation, exampleMain.getColor()));
    }
    builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, new StaticLayer(PART_MARKER_TEXTURE).getTexture(this.gearType, 0))), rotation, Color.VALUE_WHITE));
}
Also used : IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) IMaterial(net.silentchaos512.gear.api.material.IMaterial) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) LazyMaterialInstance(net.silentchaos512.gear.gear.material.LazyMaterialInstance) StaticLayer(net.silentchaos512.gear.api.material.StaticLayer)

Aggregations

MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)27 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)12 IMaterial (net.silentchaos512.gear.api.material.IMaterial)9 ResourceLocation (net.minecraft.resources.ResourceLocation)6 MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)6 ArrayList (java.util.ArrayList)4 ImmutableList (com.google.common.collect.ImmutableList)3 Transformation (com.mojang.math.Transformation)3 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)3 StaticLayer (net.silentchaos512.gear.api.material.StaticLayer)3 PartType (net.silentchaos512.gear.api.part.PartType)3 BakedPerspectiveModel (net.silentchaos512.gear.client.model.BakedPerspectiveModel)3 LazyMaterialInstance (net.silentchaos512.gear.gear.material.LazyMaterialInstance)3 GearType (net.silentchaos512.gear.api.item.GearType)2 MaterialLayerList (net.silentchaos512.gear.api.material.MaterialLayerList)2 IPartDisplay (net.silentchaos512.gear.api.part.IPartDisplay)2 PartTextures (net.silentchaos512.gear.client.model.PartTextures)2 PartData (net.silentchaos512.gear.gear.part.PartData)2