Search in sources :

Example 36 with Color

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

the class ItemChaosRune method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
    ChaosBuff buff = getBuff(stack);
    if (buff != null) {
        LocalizationHelper loc = SilentGems.localizationHelper;
        // Name
        list.add(TextFormatting.GOLD + buff.getLocalizedName(1));
        // Description (may not have one)
        String desc = buff.getDescription();
        if (!desc.isEmpty())
            list.add(TextFormatting.DARK_GRAY + desc);
        list.add("  " + loc.getItemSubText(itemName, "maxLevel", buff.getMaxLevel()));
        list.add("  " + loc.getItemSubText(itemName, "slotsUsed", buff.getSlotsUsed(1)));
        list.add("  " + loc.getItemSubText(itemName, "chaosCost", buff.getChaosCost(1, null)));
        // Debug
        if (KeyTracker.isAltDown()) {
            list.add(TextFormatting.DARK_GRAY + String.format("Key: %s", buff.getKey()));
            list.add(TextFormatting.DARK_GRAY + String.format("Potion: %s", buff.getPotion()));
            list.add(TextFormatting.DARK_GRAY + String.format("Color: %X", buff.getColor()));
        }
    }
}
Also used : ChaosBuff(net.silentchaos512.gems.lib.ChaosBuff) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 37 with Color

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

the class ToolRenderHelper method addInformation.

@Override
public void addInformation(ItemStack tool, EntityPlayer player, List list, boolean advanced) {
    LocalizationHelper loc = SilentGems.instance.localizationHelper;
    boolean controlDown = KeyTracker.isControlDown();
    boolean altDown = KeyTracker.isAltDown();
    boolean shiftDown = KeyTracker.isShiftDown();
    String line;
    // Tipped upgrade
    ToolPartTip partTip = (ToolPartTip) ToolHelper.getConstructionTip(tool);
    if (partTip != null) {
        String tipName = partTip.getUnlocalizedName().replaceFirst("[^:]+:", "");
        tipName = loc.getMiscText("Tooltip." + tipName);
        line = loc.getMiscText("Tooltip.Tipped", tipName);
        list.add(line);
    }
    // Show original owner?
    if (controlDown) {
        String owner = ToolHelper.getOriginalOwner(tool);
        if (owner.equals(SilentGems.localizationHelper.getMiscText("Tooltip.OriginalOwner.Creative")))
            owner = TextFormatting.LIGHT_PURPLE + owner;
        if (!owner.isEmpty())
            list.add(loc.getMiscText("Tooltip.OriginalOwner", owner));
        else
            list.add(loc.getMiscText("Tooltip.OriginalOwner.Unknown"));
    }
    // Missing data?
    if (ToolHelper.hasNoConstruction(tool)) {
        list.add(loc.getMiscText("Tooltip.NoData1"));
        list.add(loc.getMiscText("Tooltip.NoData2"));
    } else // Broken?
    if (ToolHelper.isBroken(tool)) {
        line = loc.getMiscText("Tooltip.Broken");
        list.add(line);
    }
    final Item item = tool.getItem();
    final boolean isSword = item instanceof ItemGemSword;
    final boolean isAxe = item instanceof ItemGemAxe;
    final boolean isWeapon = isSword || isAxe;
    final boolean isCaster = isSword && ToolHelper.getToolTier(tool).ordinal() >= EnumMaterialTier.SUPER.ordinal();
    final boolean isBow = item instanceof ItemGemBow;
    final boolean isDigger = item instanceof ItemTool;
    final boolean isShield = item instanceof ItemGemShield;
    final String sep = loc.getMiscText("Tooltip.Separator");
    if (controlDown) {
        // Properties Header
        line = loc.getMiscText("Tooltip.Properties");
        list.add(line);
        TextFormatting color = TextFormatting.YELLOW;
        // Tier
        EnumMaterialTier tier = ToolHelper.getToolTier(tool);
        line = TextFormatting.RESET + loc.getMiscText("ToolTier." + tier);
        list.add("  " + color + loc.getMiscText("ToolTier", line));
        int durabilityMax = ToolHelper.getMaxDamage(tool);
        int durability = durabilityMax - tool.getItemDamage();
        String s1 = String.format(durability > 9999 ? "%,d" : "%d", durability);
        String s2 = String.format(durabilityMax > 9999 ? "%,d" : "%d", durabilityMax);
        line = loc.getMiscText("Tooltip.Durability", s1 + " / " + s2);
        list.add(color + "  " + line);
        if (isShield)
            list.add(color + getTooltipLine("BlockingPower", ToolHelper.getBlockingPower(tool)));
        if (isDigger) {
            // @formatter:off
            int harvestLevel = ToolHelper.getHarvestLevel(tool);
            String str = color + getTooltipLine("HarvestLevel", harvestLevel);
            String key = "Tooltip.level" + harvestLevel;
            String val = SilentGems.localizationHelper.getMiscText(key);
            if (!val.equals("misc.silentgems:" + key))
                str += " (" + val + ")";
            list.add(str);
            list.add(color + getTooltipLine("HarvestSpeed", ToolHelper.getDigSpeedOnProperMaterial(tool)));
        }
        if (isWeapon) {
            list.add(color + getTooltipLine("MeleeSpeed", ToolHelper.getMeleeSpeedModifier(tool) + 4).replaceFirst("%", ""));
            list.add(color + getTooltipLine("MeleeDamage", ToolHelper.getMeleeDamageModifier(tool)));
            if (isCaster)
                list.add(color + getTooltipLine("MagicDamage", ToolHelper.getMagicDamageModifier(tool)));
        }
        if (isBow) {
            list.add(color + getTooltipLine("DrawDelay", ModItems.bow.getDrawDelay(tool)));
            list.add(color + getTooltipLine("ArrowDamage", 2f + ModItems.bow.getArrowDamage(tool)));
        }
        list.add(color + getTooltipLine("ChargeSpeed", ToolHelper.getChargeSpeed(tool)));
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.CtrlForProp"));
    }
    if (altDown) {
        // Statistics Header
        list.add(sep);
        line = loc.getMiscText("Tooltip.Statistics");
        list.add(line);
        list.add(getTooltipLine("BlocksMined", ToolHelper.getStatBlocksMined(tool)));
        if (isDigger) {
            list.add(getTooltipLine("BlocksPlaced", ToolHelper.getStatBlocksPlaced(tool)));
        }
        if (item instanceof ItemGemShovel) {
            list.add(getTooltipLine("PathsMade", ToolHelper.getStatPathsMade(tool)));
        }
        if (item instanceof ItemGemHoe) {
            list.add(getTooltipLine("BlocksTilled", ToolHelper.getStatBlocksTilled(tool)));
        }
        list.add(getTooltipLine("HitsLanded", ToolHelper.getStatHitsLanded(tool)));
        if (isCaster || isBow)
            list.add(getTooltipLine("ShotsFired", ToolHelper.getStatShotsFired(tool)));
        if (item instanceof ItemGemTomahawk)
            list.add(getTooltipLine("ThrownCount", ToolHelper.getStatThrownCount(tool)));
        if (isWeapon)
            list.add(getTooltipLine("KillCount", ToolHelper.getStatKillCount(tool)));
        list.add(getTooltipLine("Redecorated", ToolHelper.getStatRedecorated(tool)));
        list.add(sep);
        line = loc.getMiscText("Tooltip.Construction");
        list.add(line);
        ToolPart[] parts = ToolHelper.getConstructionParts(tool);
        EnumMaterialGrade[] grades = ToolHelper.getConstructionGrades(tool);
        for (int i = 0; i < parts.length; ++i) {
            ToolPart part = parts[i];
            EnumMaterialGrade grade = grades[i];
            line = "  " + TextFormatting.YELLOW + part.getKey() + TextFormatting.GOLD + " (" + grade + ")";
            list.add(line);
        }
        list.add(sep);
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("Tooltip.AltForStat"));
    }
    // Debug render layers
    if (controlDown && shiftDown && tool.hasTagCompound()) {
        if (!altDown)
            list.add(sep);
        for (EnumPartPosition pos : EnumPartPosition.values()) {
            NBTTagCompound tags = tool.getTagCompound().getCompoundTag(NBT_MODEL_INDEX);
            if (tags != null) {
                String key = "Layer" + pos.ordinal();
                String str = "%s: %d, %X";
                str = String.format(str, key, tags.getInteger(key), tags.getInteger(key + "Color"));
                list.add(str);
            }
        }
    }
}
Also used : ItemTool(net.minecraft.item.ItemTool) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemGemAxe(net.silentchaos512.gems.item.tool.ItemGemAxe) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) Item(net.minecraft.item.Item) ToolPartTip(net.silentchaos512.gems.api.tool.part.ToolPartTip) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) EnumPartPosition(net.silentchaos512.gems.api.lib.EnumPartPosition) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) ItemGemTomahawk(net.silentchaos512.gems.item.tool.ItemGemTomahawk) ItemGemSword(net.silentchaos512.gems.item.tool.ItemGemSword) TextFormatting(net.minecraft.util.text.TextFormatting) ItemGemHoe(net.silentchaos512.gems.item.tool.ItemGemHoe) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ItemGemShovel(net.silentchaos512.gems.item.tool.ItemGemShovel)

Example 38 with Color

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

the class ItemGemArmor method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
    LocalizationHelper loc = SilentGems.instance.localizationHelper;
    ToolRenderHelper helper = ToolRenderHelper.getInstance();
    boolean controlDown = KeyTracker.isControlDown();
    boolean altDown = KeyTracker.isAltDown();
    String line;
    // Show original owner?
    if (controlDown) {
        String owner = ArmorHelper.getOriginalOwner(stack);
        if (!owner.isEmpty())
            list.add(loc.getMiscText("Tooltip.OriginalOwner", owner));
        else
            list.add(loc.getMiscText("Tooltip.OriginalOwner.Unknown"));
    }
    // TODO: Remove me
    if (altDown) {
        list.add(TextFormatting.RED + "Armor models WIP.");
    }
    // Broken?
    if (ArmorHelper.isBroken(stack)) {
        list.add(loc.getMiscText("Tooltip.Broken"));
    }
    final String sep = loc.getMiscText("Tooltip.Separator");
    if (controlDown) {
        // Properties header
        list.add(loc.getMiscText("Tooltip.Properties"));
        TextFormatting color = TextFormatting.YELLOW;
        list.add(color + helper.getTooltipLine("Durability", getMaxDamage(stack)));
        list.add(color + helper.getTooltipLine("Protection", getProtection(stack)));
        // Statistics Header
        list.add(sep);
        list.add(loc.getMiscText("Tooltip.Statistics"));
        list.add(helper.getTooltipLine("DamageTaken", ArmorHelper.getStatDamageTaken(stack)));
        list.add(helper.getTooltipLine("Redecorated", ArmorHelper.getStatRedecorated(stack)));
        list.add(sep);
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("PressCtrl"));
    }
    if (altDown) {
        list.add(loc.getMiscText("Tooltip.Construction"));
        ToolPart[] parts = ArmorHelper.getConstructionParts(stack);
        EnumMaterialGrade[] grades = ArmorHelper.getConstructionGrades(stack);
        for (int i = 0; i < parts.length; ++i) {
            ToolPart part = parts[i];
            EnumMaterialGrade grade = grades[i];
            line = "  " + TextFormatting.YELLOW + part.getKey() + TextFormatting.GOLD + " (" + grade + ")";
            list.add(line);
        }
        list.add(sep);
    } else {
        list.add(TextFormatting.GOLD + loc.getMiscText("PressAlt"));
    }
}
Also used : ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ToolRenderHelper(net.silentchaos512.gems.item.ToolRenderHelper) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) TextFormatting(net.minecraft.util.text.TextFormatting) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 39 with Color

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

the class BlockPhantomLight method randomDisplayTick.

@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    if (rand.nextInt(2 * (1 + 2 * SilentGems.proxy.getParticleSettings())) == 0) {
        final float meanSpeed = 0.025f;
        final double motionX = rand.nextGaussian() * meanSpeed;
        final double motionY = rand.nextGaussian() * meanSpeed;
        final double motionZ = rand.nextGaussian() * meanSpeed;
        Color color = new Color(0xFFFFAA);
        SilentGems.proxy.spawnParticles(EnumModParticles.PHANTOM_LIGHT, color, worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, motionX, motionY, motionZ);
    }
}
Also used : Color(net.silentchaos512.lib.util.Color) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 40 with Color

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

the class ToolHelper method recalculateStats.

/**
 * Recalculate all stats and properties, including the rendering cache for the given tool. In general, this should be
 * called any time changes are made to a tool (aside from incrementing statistics, or something like that). For
 * example, this is called during construction, decoration, and for all tools in the players inventory during login.
 *
 * @param tool
 */
public static void recalculateStats(ItemStack tool) {
    ToolPart[] parts = getConstructionParts(tool);
    EnumMaterialGrade[] grades = getConstructionGrades(tool);
    if (parts.length == 0)
        return;
    ToolStats stats = new ToolStats(tool, parts, grades).calculate();
    // Reset render cache
    for (EnumPartPosition pos : EnumPartPosition.values()) {
        NBTTagCompound compound = tool.getTagCompound().getCompoundTag(ToolRenderHelper.NBT_MODEL_INDEX);
        String str = "Layer" + pos.ordinal();
        for (int frame = 0; frame < (tool.getItem() instanceof ItemGemBow ? 4 : 1); ++frame) compound.removeTag(str + (frame > 0 ? "_" + frame : ""));
        compound.removeTag(str + "Color");
    }
    // Set color for parts
    ToolPart renderHeadM = getRenderPart(tool, EnumPartPosition.HEAD_MIDDLE);
    ToolPart renderHeadL = getRenderPart(tool, EnumPartPosition.HEAD_LEFT);
    ToolPart renderHeadR = getRenderPart(tool, EnumPartPosition.HEAD_RIGHT);
    ToolPart renderRodDeco = getRenderPart(tool, EnumPartPosition.ROD_DECO);
    ToolPart renderRod = getRenderPart(tool, EnumPartPosition.ROD);
    if (renderHeadM != null)
        setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_HEAD_M + "Color", renderHeadM.getColor(tool));
    if (renderHeadL != null)
        setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_HEAD_L + "Color", renderHeadL.getColor(tool));
    if (renderHeadR != null)
        setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_HEAD_R + "Color", renderHeadR.getColor(tool));
    if (renderRodDeco != null)
        setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_ROD_DECO + "Color", renderRodDeco.getColor(tool));
    if (renderRod != null)
        setTagInt(tool, ToolRenderHelper.NBT_MODEL_INDEX, "Layer" + ToolRenderHelper.PASS_ROD + "Color", renderRod.getColor(tool));
    setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_PROP_DURABILITY, (int) stats.durability);
    setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_HARVEST_SPEED, stats.harvestSpeed);
    setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_MELEE_DAMAGE, stats.meleeDamage);
    setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_MAGIC_DAMAGE, stats.magicDamage);
    setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_MELEE_SPEED, stats.meleeSpeed);
    setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_CHARGE_SPEED, stats.chargeSpeed);
    setTagFloat(tool, NBT_ROOT_PROPERTIES, NBT_PROP_BLOCKING_POWER, stats.blockingPower);
    setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_PROP_ENCHANTABILITY, (int) stats.enchantability);
    setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_PROP_HARVEST_LEVEL, stats.harvestLevel);
    setTagInt(tool, NBT_ROOT_PROPERTIES, NBT_TOOL_TIER, parts[0].getTier().ordinal());
}
Also used : ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) EnumPartPosition(net.silentchaos512.gems.api.lib.EnumPartPosition) EnumMaterialGrade(net.silentchaos512.gems.api.lib.EnumMaterialGrade) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ToolStats(net.silentchaos512.gems.api.tool.ToolStats)

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