Search in sources :

Example 16 with Color

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

the class ModelGemArmor method setRenderColor.

private void setRenderColor(int color) {
    Color c = new Color(color);
    GlStateManager.color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
}
Also used : Color(net.silentchaos512.lib.util.Color)

Example 17 with Color

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

the class ItemDrawingCompass method spawnParticles.

public boolean spawnParticles(ItemStack stack, EntityPlayer player, World world) {
    BlockPos pos1 = getBlock1(stack);
    BlockPos pos2 = getBlock2(stack);
    if (pos1.getY() <= 0 || pos2.getY() <= 0 || pos1.equals(pos2)) {
        return false;
    }
    Color color = getColor(stack);
    // Spawn circle.
    BlockPos center = new BlockPos(pos1.getX(), pos2.getY(), pos1.getZ());
    float radius = (float) Math.sqrt(center.distanceSq(pos2));
    int count = (int) (5 * radius);
    float increment = (float) (2 * Math.PI / count);
    float start = increment * (world.getTotalWorldTime() % 30) / 30f;
    Vec3d vec;
    for (float angle = start; angle < 2 * Math.PI + start; angle += increment) {
        vec = new Vec3d(radius, 0, 0).rotateYaw(angle);
        particle(player, world, color, center.getX() + 0.5 + vec.xCoord, center.getY() + 0.5 + vec.yCoord, center.getZ() + 0.5 + vec.zCoord);
    }
    // Spawn line.
    double distance = Math.sqrt(pos1.distanceSq(pos2));
    count = (int) (2 * distance);
    double dx = (double) (pos2.getX() - pos1.getX()) / count;
    double dy = (double) (pos2.getY() - pos1.getY()) / count;
    double dz = (double) (pos2.getZ() - pos1.getZ()) / count;
    for (int i = 0; i < count; ++i) {
        vec = new Vec3d(pos1.getX() + 0.5 + i * dx, pos1.getY() + 0.5 + i * dy, pos1.getZ() + 0.5 + i * dz);
        particle(player, world, color, vec.xCoord, vec.yCoord, vec.zCoord);
    }
    return true;
}
Also used : EnumDyeColor(net.minecraft.item.EnumDyeColor) Color(net.silentchaos512.lib.util.Color) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Example 18 with Color

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

the class GemsClientEvents method onTooltipForToolMaterial.

private void onTooltipForToolMaterial(ItemTooltipEvent event, ItemStack stack, ToolPart part, boolean ctrlDown, boolean shiftDown) {
    int index = 1;
    final String sep = loc.getMiscText("Tooltip.Separator");
    List<String> list = event.getToolTip();
    // Material grade
    EnumMaterialGrade grade = EnumMaterialGrade.fromStack(stack);
    if (grade != EnumMaterialGrade.NONE) {
        list.add(index++, loc.getMiscText("ToolPart.Grade", grade.getLocalizedName()));
    }
    // Material tier
    EnumMaterialTier tier = part.getTier();
    list.add(index++, loc.getMiscText("ToolPart.Tier", tier.getLocalizedName()));
    // Show stats?
    if (ctrlDown) {
        int multi = 100 + EnumMaterialGrade.fromStack(stack).bonusPercent;
        // @formatter:off
        list.add(index++, sep);
        TextFormatting color = TextFormatting.GOLD;
        list.add(index++, color + TooltipHelper.get("HarvestSpeed", part.getHarvestSpeed() * multi / 100));
        list.add(index++, color + TooltipHelper.get("HarvestLevel", part.getHarvestLevel() * multi / 100));
        list.add(index++, sep);
        color = TextFormatting.DARK_GREEN;
        list.add(index++, color + TooltipHelper.get("MeleeSpeed", (int) (part.getMeleeSpeed() * multi)));
        list.add(index++, color + TooltipHelper.get("MeleeDamage", part.getMeleeDamage() * multi / 100));
        list.add(index++, color + TooltipHelper.get("MagicDamage", part.getMagicDamage() * multi / 100));
        list.add(index++, color + TooltipHelper.get("Protection", part.getProtection() * multi / 100));
        list.add(index++, sep);
        color = TextFormatting.BLUE;
        list.add(index++, color + TooltipHelper.get("Durability", part.getDurability() * multi / 100));
        list.add(index++, color + TooltipHelper.get("ChargeSpeed", part.getChargeSpeed() * multi / 100));
        list.add(index++, color + TooltipHelper.get("Enchantability", part.getEnchantability() * multi / 100));
        list.add(index++, sep);
        // Debug info
        if (shiftDown) {
            event.getToolTip().add(index++, TextFormatting.DARK_GRAY + "* Part key: " + part.getKey());
        }
    // @formatter:on
    } else {
        list.add(index++, TextFormatting.GOLD + loc.getMiscText("PressCtrl"));
    }
}
Also used : EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) TextFormatting(net.minecraft.util.text.TextFormatting) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier)

Example 19 with Color

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

the class StatInstance method formatMul1.

private MutableComponent formatMul1(ItemStat stat, @Nonnegative int decimalPlaces, boolean addColor) {
    int percent = Math.round(100 * this.value);
    Color color = getFormattedColor(percent, 0f, addColor);
    String text = trimNumber(String.format("%s%d%%", percent < 0 ? "" : "+", percent));
    return TextUtil.withColor(new TextComponent(text), color);
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) Color(net.silentchaos512.utils.Color)

Example 20 with Color

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

the class StatInstance method formatAvg.

private MutableComponent formatAvg(ItemStat stat, @Nonnegative int decimalPlaces, boolean addColor) {
    Color color = getFormattedColor(this.value, 0f, addColor);
    String text;
    if (stat.getDisplayFormat() == ItemStat.DisplayFormat.PERCENTAGE) {
        text = Math.round(this.value * 100) + "%";
    } else {
        // v (or vx for multiplier stats like armor durability)
        String format = "%s" + ("%." + decimalPlaces + "f") + "%s";
        String ret = trimNumber(String.format(format, "", this.value, ""));
        text = stat.getDisplayFormat() == ItemStat.DisplayFormat.MULTIPLIER ? ret + "x" : ret;
    }
    return TextUtil.withColor(new TextComponent(text), color);
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) Color(net.silentchaos512.utils.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