Search in sources :

Example 26 with ToolPart

use of net.silentchaos512.gems.api.tool.part.ToolPart in project SilentGems by SilentChaos512.

the class GemsClientEvents method onTooltipForToolRod.

private void onTooltipForToolRod(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();
    ToolPartRod.Stats stats = ((ToolPartRod) part).getStats();
    // Tool Rod indicator
    list.add(index++, loc.getMiscText("ToolPart.Rod"));
    if (ctrlDown) {
        // Compatible tiers
        String line = "";
        for (EnumMaterialTier tier : part.getCompatibleTiers()) {
            if (!line.isEmpty())
                line += ", ";
            line += tier.getLocalizedName();
        }
        list.add(index++, loc.getMiscText("ToolPart.ValidTiers"));
        list.add(index++, "  " + line);
        list.add(index++, sep);
        TextFormatting color = TextFormatting.GOLD;
        list.add(index++, color + TooltipHelper.getAsColoredPercentage("HarvestSpeed", stats.harvestSpeedMulti));
        // list.add(index++, color + TooltipHelper.get("HarvestLevel", part.getHarvestLevel()));
        color = TextFormatting.DARK_GREEN;
        list.add(index++, color + TooltipHelper.getAsColoredPercentage("MeleeDamage", stats.meleeDamageMulti));
        list.add(index++, color + TooltipHelper.getAsColoredPercentage("MagicDamage", stats.magicDamageMulti));
        // list.add(index++, color + TooltipHelper.get("MeleeSpeed", (int) (part.getMeleeSpeed() * 100)));
        color = TextFormatting.BLUE;
        list.add(index++, color + TooltipHelper.getAsColoredPercentage("Durability", stats.durabilityMulti));
        list.add(index++, color + TooltipHelper.getAsColoredPercentage("Enchantability", stats.enchantabilityMulti));
        list.add(index++, sep);
        // Debug info
        if (shiftDown) {
            list.add(index++, TextFormatting.DARK_GRAY + "* Part key: " + part.getKey());
        }
    } else {
        list.add(index++, loc.getMiscText("PressCtrl"));
    }
}
Also used : TextFormatting(net.minecraft.util.text.TextFormatting) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ToolPartRod(net.silentchaos512.gems.api.tool.part.ToolPartRod)

Example 27 with ToolPart

use of net.silentchaos512.gems.api.tool.part.ToolPart in project SilentGems by SilentChaos512.

the class GemsClientEvents method onTooltip.

@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
    boolean ctrlDown = KeyTracker.isControlDown();
    boolean shiftDown = KeyTracker.isShiftDown();
    ItemStack stack = event.getItemStack();
    ToolPart part = StackHelper.isValid(stack) ? ToolPartRegistry.fromStack(stack) : null;
    if (part != null && !part.isBlacklisted(stack)) {
        if (part instanceof ToolPartRod) {
            onTooltipForToolRod(event, stack, part, ctrlDown, shiftDown);
        } else if (part instanceof ToolPartMain) {
            onTooltipForToolMaterial(event, stack, part, ctrlDown, shiftDown);
        } else if (part instanceof ArmorPartFrame) {
            // TODO: Localization
            event.getToolTip().add(TextFormatting.GOLD + "Armor Frame");
        }
    }
}
Also used : ToolPartMain(net.silentchaos512.gems.api.tool.part.ToolPartMain) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) ItemStack(net.minecraft.item.ItemStack) ArmorPartFrame(net.silentchaos512.gems.api.tool.part.ArmorPartFrame) ToolPartRod(net.silentchaos512.gems.api.tool.part.ToolPartRod) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)22 ItemStack (net.minecraft.item.ItemStack)16 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)10 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)9 ToolPartMain (net.silentchaos512.gems.api.tool.part.ToolPartMain)8 ITool (net.silentchaos512.gems.api.ITool)6 TextFormatting (net.minecraft.util.text.TextFormatting)4 ToolPartRod (net.silentchaos512.gems.api.tool.part.ToolPartRod)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ToolStats (net.silentchaos512.gems.api.tool.ToolStats)3 ArmorPartFrame (net.silentchaos512.gems.api.tool.part.ArmorPartFrame)3 ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)3 ToolSoul (net.silentchaos512.gems.lib.soul.ToolSoul)3 LocalizationHelper (net.silentchaos512.lib.util.LocalizationHelper)3 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 Item (net.minecraft.item.Item)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 IArmor (net.silentchaos512.gems.api.IArmor)2