Search in sources :

Example 31 with Color

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

the class MaterialBuilder method displayTip.

public MaterialBuilder displayTip(PartTextures texture, int color) {
    display(PartType.TIP, GearType.ALL, new MaterialLayer(texture, color));
    display(PartType.TIP, GearType.PART, new MaterialLayer(SilentGear.getId("tip_base"), Color.VALUE_WHITE), new MaterialLayer(SilentGear.getId("tip"), color), new MaterialLayer(SilentGear.getId("tip_shine"), Color.VALUE_WHITE));
    return this;
}
Also used : MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Example 32 with Color

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

the class ColorUtils method getBlendedColor.

public static int getBlendedColor(ICoreItem item, IPartData part, Collection<? extends IMaterialInstance> materials, int layer) {
    int[] componentSums = new int[3];
    int maxColorSum = 0;
    int colorCount = 0;
    int i = 0;
    for (IMaterialInstance mat : materials) {
        IMaterialDisplay model = mat.getDisplayProperties();
        int color = model.getLayerColor(item.getGearType(), part, mat, layer);
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        int colorWeight = (materials.size() - i) * (materials.size() - 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;
        }
        ++i;
    }
    return blendColors(componentSums, maxColorSum, colorCount);
}
Also used : IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay)

Example 33 with Color

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

the class ColorUtils method getBlendedColor.

public static int getBlendedColor(CompoundMaterialItem item, Collection<? extends IMaterialInstance> materials, int layer) {
    int[] componentSums = new int[3];
    int maxColorSum = 0;
    int colorCount = 0;
    int i = 0;
    for (IMaterialInstance mat : materials) {
        IMaterialDisplay model = mat.getDisplayProperties();
        List<MaterialLayer> layers = model.getLayerList(GearType.ALL, PartType.MAIN, mat).getLayers();
        if (layers.size() > layer) {
            int color = layers.get(layer).getColor();
            int r = (color >> 16) & 0xFF;
            int g = (color >> 8) & 0xFF;
            int b = color & 0xFF;
            int colorWeight = item.getColorWeight(i, materials.size());
            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;
            }
            ++i;
        }
    }
    return blendColors(componentSums, maxColorSum, colorCount);
}
Also used : IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance) IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer)

Example 34 with Color

use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.

the class EntityChaosProjectile method readSpawnData.

@Override
public void readSpawnData(ByteBuf data) {
    try {
        color = new Color(data.readInt());
        damage = data.readFloat();
        gravity = data.readBoolean();
    } catch (Exception ex) {
    }
}
Also used : Color(net.silentchaos512.lib.util.Color)

Example 35 with Color

use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.

the class EntityChaosProjectile method readEntityFromNBT.

@Override
public void readEntityFromNBT(NBTTagCompound tags) {
    super.readEntityFromNBT(tags);
    setColor(new Color(tags.getInteger(NBT_COLOR)));
    damage = tags.getFloat(NBT_DAMAGE);
    gravity = tags.getBoolean(NBT_GRAVITY);
    if (tags.hasKey(NBT_SHOOTER)) {
        shooter = world.getPlayerEntityByName(tags.getString(NBT_SHOOTER));
        if (shooter == null) {
            setDead();
        }
    }
}
Also used : Color(net.silentchaos512.lib.util.Color)

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