Search in sources :

Example 6 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class ToolRenderHelper method clAddInformation.

@Override
public void clAddInformation(ItemStack tool, World world, 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);
    }
    // UUID
    if (GemsConfig.DEBUG_MODE && controlDown && shiftDown) {
        UUID uuid = ToolHelper.hasUUID(tool) ? ToolHelper.getUUID(tool) : null;
        list.add(uuid == null ? "No UUID" : uuid.toString());
        uuid = ToolHelper.getSoulUUID(tool);
        list.add(uuid == null ? "No Soul UUID" : uuid.toString());
    }
    // Tool Soul
    ToolSoul soul = SoulManager.getSoul(tool);
    if (soul != null) {
        soul.addInformation(tool, world, list, advanced);
    }
    // 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"));
    }
    if (controlDown && tool.getTagCompound().getBoolean(ToolHelper.NBT_LOCK_STATS)) {
        list.add(loc.getMiscText("Tooltip.LockedStats"));
    }
    // Example tool?
    if (tool.hasTagCompound() && tool.getTagCompound().hasKey(ToolHelper.NBT_EXAMPLE_TOOL_TIER)) {
        EnumMaterialTier tier = EnumMaterialTier.values()[tool.getTagCompound().getInteger(ToolHelper.NBT_EXAMPLE_TOOL_TIER)];
        list.add(loc.getMiscText("Tooltip.ExampleTool", tier));
    } else // 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 = tool.getMaxDamage();
        int durability = durabilityMax - tool.getItemDamage();
        String s1 = String.format(durability > 9999 ? "%,d" : "%d", durability);
        String s2 = String.format(durabilityMax > 9999 ? "%,d" : "%d", durabilityMax);
        float durabilityBoost = ToolSoul.getDurabilityModifierForDisplay(soul);
        String durBoostLine = durabilityBoost == 0f ? "" : " (" + TooltipHelper.numberToPercent(durabilityBoost, 0, true) + TextFormatting.RESET + ")";
        line = loc.getMiscText("Tooltip.Durability", s1 + " / " + s2 + durBoostLine);
        list.add(color + "  " + line);
        if (isShield) {
            float magicProtection = (int) (ToolHelper.getMagicProtection(tool) * 100);
            list.add(color + getTooltipLine("MagicProtection", magicProtection, 0f));
        }
        if (isDigger) {
            // @formatter:off
            int harvestLevel = ToolHelper.getHarvestLevel(tool);
            String str = color + getTooltipLine("HarvestLevel", harvestLevel, 0f);
            String key = "Tooltip.level" + harvestLevel;
            String val = SilentGems.localizationHelper.getMiscText(key);
            if (!val.equals("misc.silentgems:" + key))
                str += " (" + val + ")";
            list.add(str);
            float harvestSpeedModifier = ToolSoul.getHarvestSpeedModifierForDisplay(soul);
            list.add(color + getTooltipLine("HarvestSpeed", ToolHelper.getDigSpeedOnProperMaterial(tool), harvestSpeedModifier));
        }
        if (isWeapon) {
            float meleeSpeed = 4 + ToolHelper.getMeleeSpeedModifier(tool);
            list.add(color + getTooltipLine("MeleeSpeed", meleeSpeed, 0f).replaceFirst("%", ""));
            float meleeDamage = 1 + ToolHelper.getMeleeDamageModifier(tool);
            float meleeModifier = ToolSoul.getMeleeDamageModifierForDisplay(soul);
            list.add(color + getTooltipLine("MeleeDamage", meleeDamage, meleeModifier));
            if (isCaster) {
                EnumMagicType magicType = EnumMagicType.getMagicType(tool);
                float damagePerShot = magicType.getDamagePerShot(tool);
                String damageString = damagePerShot == (int) damagePerShot ? Integer.toString((int) damagePerShot) : String.format(TooltipHelper.FORMAT_FLOAT, damagePerShot);
                String str = damageString + "" + TextFormatting.DARK_GRAY + "x" + magicType.getShotCount(tool);
                float magicModifier = ToolSoul.getMagicDamageModifierForDisplay(soul);
                list.add(color + getTooltipLine("MagicDamage", str, magicModifier));
            }
        }
        if (isBow) {
            ToolStats statsNoSoul = ToolHelper.getStats(tool, false);
            float drawSpeed = ModItems.bow.getDrawSpeedForDisplay(tool);
            float drawSpeedPreSoul = ItemGemBow.getDrawSpeedForDisplay(statsNoSoul.meleeSpeed, statsNoSoul.harvestSpeed);
            float drawSpeedBoost = (drawSpeed - drawSpeedPreSoul) / drawSpeedPreSoul;
            list.add(color + getTooltipLine("DrawSpeed", drawSpeed, drawSpeedBoost));
            float arrowDamage = ModItems.bow.getArrowDamageForDisplay(tool);
            float arrowDamagePreSoul = ItemGemBow.getArrowDamageForDisplay(statsNoSoul.meleeDamage);
            float arrowDamageBoost = (arrowDamage - arrowDamagePreSoul) / arrowDamagePreSoul;
            list.add(color + getTooltipLine("ArrowDamage", arrowDamage, arrowDamageBoost));
        }
        list.add(color + getTooltipLine("ChargeSpeed", ToolHelper.getChargeSpeed(tool), 0f));
    } 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), 0f));
        if (isDigger) {
            list.add(getTooltipLine("BlocksPlaced", ToolHelper.getStatBlocksPlaced(tool), 0f));
        }
        if (item instanceof ItemGemShovel) {
            list.add(getTooltipLine("PathsMade", ToolHelper.getStatPathsMade(tool), 0f));
        }
        if (item instanceof ItemGemHoe) {
            list.add(getTooltipLine("BlocksTilled", ToolHelper.getStatBlocksTilled(tool), 0f));
        }
        list.add(getTooltipLine("HitsLanded", ToolHelper.getStatHitsLanded(tool), 0f));
        if (isCaster || isBow)
            list.add(getTooltipLine("ShotsFired", ToolHelper.getStatShotsFired(tool), 0f));
        if (item instanceof ItemGemTomahawk)
            list.add(getTooltipLine("ThrownCount", ToolHelper.getStatThrownCount(tool), 0f));
        if (isWeapon)
            list.add(getTooltipLine("KillCount", ToolHelper.getStatKillCount(tool), 0f));
        list.add(getTooltipLine("Redecorated", ToolHelper.getStatRedecorated(tool), 0f));
        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);
        }
        ToolPart partRod = ToolHelper.getConstructionRod(tool);
        if (partRod != null) {
            list.add("  " + TextFormatting.YELLOW + partRod.getKey());
        }
        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);
        list.add("Render Layers");
        IModelData modelData = getModelCache(tool);
        if (modelData != null) {
            for (ToolPartPosition pos : ToolPartPosition.values()) {
                String key = "Layer" + pos.ordinal();
                String str = "  %s: %s, %X";
                ToolPart renderPart = ToolHelper.getRenderPart(tool, pos);
                ModelResourceLocation model = renderPart == null ? null : renderPart.getModel(tool, pos, 0);
                str = String.format(str, pos.name(), model == null ? "null" : model.toString(), modelData.getColor(pos, 0));
                list.add(str);
            }
        }
    }
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) Item(net.minecraft.item.Item) ToolPartTip(net.silentchaos512.gems.api.tool.part.ToolPartTip) ToolPartPosition(net.silentchaos512.gems.api.lib.ToolPartPosition) TextFormatting(net.minecraft.util.text.TextFormatting) EnumMaterialTier(net.silentchaos512.gems.api.lib.EnumMaterialTier) ItemGemShovel(net.silentchaos512.gems.item.tool.ItemGemShovel) UUID(java.util.UUID) ItemTool(net.minecraft.item.ItemTool) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) EnumMagicType(net.silentchaos512.gems.util.EnumMagicType) ItemGemAxe(net.silentchaos512.gems.item.tool.ItemGemAxe) LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper) IModelData(net.silentchaos512.gems.lib.client.IModelData) ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) ToolPart(net.silentchaos512.gems.api.tool.part.ToolPart) 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) ItemGemHoe(net.silentchaos512.gems.item.tool.ItemGemHoe) ToolStats(net.silentchaos512.gems.api.tool.ToolStats)

Example 7 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class ToolPartGem method getColor.

@Override
public int getColor(ItemStack toolOrArmor, IPartPosition position, int animationFrame) {
    Item item = toolOrArmor.getItem();
    boolean isTextureUncolored = position == ToolPartPosition.ROD_DECO || item instanceof IArmor || item instanceof ItemGemShield || item instanceof ItemGemBow;
    if (isTextureUncolored || ToolHelper.isBroken(toolOrArmor)) {
        return gem.getColor();
    }
    return 0xFFFFFF;
}
Also used : Item(net.minecraft.item.Item) ItemGemShield(net.silentchaos512.gems.item.tool.ItemGemShield) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) IArmor(net.silentchaos512.gems.api.IArmor)

Example 8 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class EquipmentTooltips method renderForBow.

private void renderForBow(RenderTooltipEvent.PostText event, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    FontRenderer fontRenderer = event.getFontRenderer();
    ItemStack currentEquip = mc.player.getHeldItemMainhand();
    boolean itemsComparable = stack.getItem() instanceof ItemBow && currentEquip.getItem() instanceof ItemBow;
    double scale = 0.75;
    int x = (int) (event.getX() / scale);
    int y = (int) ((event.getY() - 16) / scale);
    int durability = getDurability(stack, 0);
    int equippedDurability = getDurability(currentEquip, durability);
    // We don't have anything to get stats for other mods' bows, do we? Guess we have to assume vanilla stats.
    // Arrow damage: display actual damage
    float arrowDamage = stack.getItem() instanceof ItemGemBow ? 2f + ((ItemGemBow) stack.getItem()).getArrowDamage(stack) : 2f;
    float equippedArrowDamage = currentEquip.getItem() instanceof ItemGemBow ? 2f + ((ItemGemBow) currentEquip.getItem()).getArrowDamage(currentEquip) : (currentEquip.getItem() instanceof ItemBow ? 2f : arrowDamage);
    // Draw speed: display the draw speed value used in tooltips.
    float drawSpeed = stack.getItem() instanceof ItemGemBow ? ((ItemGemBow) stack.getItem()).getDrawSpeedForDisplay(stack) : 1f;
    float equippedDrawSpeed = currentEquip.getItem() instanceof ItemGemBow ? ((ItemGemBow) currentEquip.getItem()).getDrawSpeedForDisplay(currentEquip) : (currentEquip.getItem() instanceof ItemBow ? 1f : drawSpeed);
    GlStateManager.pushMatrix();
    GlStateManager.color(1f, 1f, 1f, 1f);
    GlStateManager.scale(scale, scale, scale);
    mc.renderEngine.bindTexture(TEXTURE);
    // Durability
    x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
    // Arrow Damage
    x = renderStat(mc, fontRenderer, 8, x, y, arrowDamage, equippedArrowDamage, itemsComparable);
    // Draw Speed
    x = renderStat(mc, fontRenderer, 5, x, y, drawSpeed, equippedDrawSpeed, itemsComparable);
    lastWidth = (int) (x * scale - event.getX());
    GlStateManager.popMatrix();
}
Also used : ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) ItemBow(net.minecraft.item.ItemBow)

Example 9 with ItemGemBow

use of net.silentchaos512.gems.item.tool.ItemGemBow in project SilentGems by SilentChaos512.

the class ToolModel method handlePerspective.

// @Override
// public VertexFormat getFormat() {
// 
// return DefaultVertexFormats.ITEM;
// }
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
    boolean isBow = tool != null && tool.getItem() instanceof ItemGemBow;
    Matrix4f matrix = new Matrix4f();
    switch(cameraTransformType) {
        case FIRST_PERSON_RIGHT_HAND:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().firstperson_right);
            break;
        case FIRST_PERSON_LEFT_HAND:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().firstperson_left);
            break;
        case GUI:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().gui);
            isGui = true;
            break;
        case HEAD:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().head);
            break;
        case THIRD_PERSON_RIGHT_HAND:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().thirdperson_right);
            if (isBow)
                matrix.setTranslation(new javax.vecmath.Vector3f(0f, 0f, 0.2f));
            break;
        case THIRD_PERSON_LEFT_HAND:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().thirdperson_left);
            if (isBow)
                matrix.setTranslation(new javax.vecmath.Vector3f(0f, 0f, 0.2f));
            break;
        case GROUND:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().ground);
            matrix.setScale(matrix.getScale() * 0.5f);
            break;
        case FIXED:
            matrix = ForgeHooksClient.getMatrix(getItemCameraTransforms().fixed);
            // Fix item frame rotation
            matrix.rotY((float) Math.PI);
            break;
        default:
            break;
    }
    // TODO: Getter function for scale?
    if (tool != null && tool.getItem() == ModItems.katana) {
        if (cameraTransformType != TransformType.GUI) {
            matrix.setScale(matrix.getScale() * 1.3f);
        }
    } else if (tool != null && tool.getItem() == ModItems.scepter) {
        if (cameraTransformType != TransformType.GUI) {
            matrix.setScale(matrix.getScale() * 1.2f);
        }
    } else if (tool != null && tool.getItem() == ModItems.paxel) {
        if (cameraTransformType != TransformType.GUI) {
            if (cameraTransformType == TransformType.FIRST_PERSON_LEFT_HAND || cameraTransformType == TransformType.FIRST_PERSON_RIGHT_HAND)
                matrix.setScale(matrix.getScale() * 1.1f);
            else
                matrix.setScale(matrix.getScale() * 1.2f);
        }
    } else if (tool != null && tool.getItem() == ModItems.dagger) {
        if (cameraTransformType != TransformType.GUI) {
            matrix.setScale(matrix.getScale() * 0.85f);
        }
    }
    return Pair.of((IBakedModel) this, matrix);
}
Also used : Matrix4f(javax.vecmath.Matrix4f) ItemGemBow(net.silentchaos512.gems.item.tool.ItemGemBow) Vector3f(org.lwjgl.util.vector.Vector3f)

Aggregations

ItemGemBow (net.silentchaos512.gems.item.tool.ItemGemBow)9 Item (net.minecraft.item.Item)4 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)3 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)3 ItemGemShield (net.silentchaos512.gems.item.tool.ItemGemShield)3 ItemStack (net.minecraft.item.ItemStack)2 IArmor (net.silentchaos512.gems.api.IArmor)2 ToolPartPosition (net.silentchaos512.gems.api.lib.ToolPartPosition)2 IModelData (net.silentchaos512.gems.lib.client.IModelData)2 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 Matrix4f (javax.vecmath.Matrix4f)1 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemBow (net.minecraft.item.ItemBow)1 ItemTool (net.minecraft.item.ItemTool)1 TextFormatting (net.minecraft.util.text.TextFormatting)1 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)1 EnumMaterialTier (net.silentchaos512.gems.api.lib.EnumMaterialTier)1