Search in sources :

Example 26 with Color

use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.

the class GearElytraLayer method render.

@Override
public void render(@Nonnull PoseStack matrixStackIn, @Nonnull MultiBufferSource bufferIn, int packedLightIn, T entityIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
    ItemStack stack = entityIn.getItemBySlot(EquipmentSlot.CHEST);
    if (stack.getItem() instanceof GearElytraItem) {
        ResourceLocation resourcelocation;
        if (entityIn instanceof AbstractClientPlayer) {
            AbstractClientPlayer abstractclientplayerentity = (AbstractClientPlayer) entityIn;
            boolean hasElytra = abstractclientplayerentity.isElytraLoaded() && abstractclientplayerentity.getElytraTextureLocation() != null;
            boolean hasCape = abstractclientplayerentity.isCapeLoaded() && abstractclientplayerentity.getCloakTextureLocation() != null && abstractclientplayerentity.isModelPartShown(PlayerModelPart.CAPE);
            if (hasElytra) {
                resourcelocation = abstractclientplayerentity.getElytraTextureLocation();
            } else if (hasCape) {
                resourcelocation = abstractclientplayerentity.getCloakTextureLocation();
            } else {
                resourcelocation = TEXTURE;
            }
        } else {
            resourcelocation = TEXTURE;
        }
        matrixStackIn.pushPose();
        matrixStackIn.translate(0.0D, 0.0D, 0.125D);
        this.getParentModel().copyPropertiesTo(this.modelElytra);
        this.modelElytra.setupAnim(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
        VertexConsumer ivertexbuilder = ItemRenderer.getArmorFoilBuffer(bufferIn, this.modelElytra.renderType(resourcelocation), false, stack.isEnchanted());
        Color color = new Color(GearClientHelper.getColor(stack, PartType.MAIN));
        this.modelElytra.renderToBuffer(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
        matrixStackIn.popPose();
    }
}
Also used : AbstractClientPlayer(net.minecraft.client.player.AbstractClientPlayer) ResourceLocation(net.minecraft.resources.ResourceLocation) Color(net.silentchaos512.utils.Color) GearElytraItem(net.silentchaos512.gear.item.gear.GearElytraItem) VertexConsumer(com.mojang.blaze3d.vertex.VertexConsumer) ItemStack(net.minecraft.world.item.ItemStack)

Example 27 with Color

use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.

the class GearData method getBlendedColor.

@Deprecated
private static int getBlendedColor(ItemStack gear, List<PartData> parts) {
    int[] componentSums = new int[3];
    int maxColorSum = 0;
    int colorCount = 0;
    int partCount = parts.size();
    for (int i = 0; i < partCount; ++i) {
        PartData part = parts.get(i);
        int color = part.get().getColor(part, gear, 0, 0);
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        // Add earlier colors multiple times, to give them greater weight
        int colorWeight = (partCount - i) * (partCount - i);
        for (int j = 0; j < colorWeight; ++j) {
            maxColorSum += Math.max(r, Math.max(g, b));
            componentSums[0] += r;
            componentSums[1] += g;
            componentSums[2] += b;
            ++colorCount;
        }
    }
    if (colorCount > 0) {
        int r = componentSums[0] / colorCount;
        int g = componentSums[1] / colorCount;
        int b = componentSums[2] / colorCount;
        float maxAverage = (float) maxColorSum / (float) colorCount;
        float max = (float) Math.max(r, Math.max(g, b));
        r = (int) ((float) r * maxAverage / max);
        g = (int) ((float) g * maxAverage / max);
        b = (int) ((float) b * maxAverage / max);
        int finalColor = (r << 8) + g;
        finalColor = (finalColor << 8) + b;
        return finalColor;
    }
    return Color.VALUE_WHITE;
}
Also used : PartData(net.silentchaos512.gear.gear.part.PartData) IPartData(net.silentchaos512.gear.api.part.IPartData)

Example 28 with Color

use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.

the class MaterialBuilder method displayAdornment.

public MaterialBuilder displayAdornment(PartTextureSet textures, int color) {
    display(PartType.ADORNMENT, GearType.ALL, new MaterialLayerList(PartType.ADORNMENT, textures, color));
    display(PartType.ADORNMENT, GearType.PART, new MaterialLayer(SilentGear.getId("adornment"), color), new MaterialLayer(SilentGear.getId("adornment_highlight"), Color.VALUE_WHITE));
    return this;
}
Also used : MaterialLayerList(net.silentchaos512.gear.api.material.MaterialLayerList) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Example 29 with Color

use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.

the class MaterialBuilder method displayBowstring.

public MaterialBuilder displayBowstring(int color) {
    display(PartType.CORD, new MaterialLayer(PartTextures.BOWSTRING_STRING, color), // FIXME: Doesn't quite make sense to have this here
    new MaterialLayer(PartTextures.ARROW, Color.VALUE_WHITE));
    display(PartType.CORD, GearType.PART, new MaterialLayer(SilentGear.getId("bowstring"), color));
    return this;
}
Also used : MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Example 30 with Color

use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.

the class MaterialBuilder method displayCoating.

public MaterialBuilder displayCoating(PartTextureSet textures, int color) {
    display(PartType.COATING, GearType.ALL, new MaterialLayerList(PartType.MAIN, textures, color));
    display(PartType.COATING, GearType.PART, new MaterialLayer(SilentGear.getId("coating_material"), color), new MaterialLayer(SilentGear.getId("coating_jar"), Color.VALUE_WHITE));
    return this;
}
Also used : MaterialLayerList(net.silentchaos512.gear.api.material.MaterialLayerList) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Aggregations

Color (net.silentchaos512.lib.util.Color)12 Color (net.silentchaos512.utils.Color)9 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)8 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)7 TextComponent (net.minecraft.network.chat.TextComponent)6 TextFormatting (net.minecraft.util.text.TextFormatting)6 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)6 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)6 MutableComponent (net.minecraft.network.chat.MutableComponent)4 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)4 Random (java.util.Random)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Item (net.minecraft.item.Item)3 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)3 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)3 StatInstance (net.silentchaos512.gear.api.stats.StatInstance)3 ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)3 UUID (java.util.UUID)2 Minecraft (net.minecraft.client.Minecraft)2 FontRenderer (net.minecraft.client.gui.FontRenderer)2