Search in sources :

Example 1 with ItemGemSickle

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

the class EquipmentTooltips method renderForTool.

private void renderForTool(RenderTooltipEvent.PostText event, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    FontRenderer fontRenderer = event.getFontRenderer();
    ItemStack currentEquip = mc.player.getHeldItemMainhand();
    boolean isAxe = stack.getItem() instanceof ItemAxe;
    boolean isDurabilityOnly = !(stack.getItem() instanceof ItemTool);
    // boolean isHoe = stack.getItem() instanceof ItemHoe;
    // boolean isSickle = stack.getItem() instanceof ItemGemSickle;
    // boolean isShears = stack.getItem() instanceof ItemShears;
    // boolean isFishingRod = stack.getItem() instanceof ItemFishingRod;
    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);
    int harvestLevel = getHarvestLevel(stack, 0);
    int equippedHarvestLevel = getHarvestLevel(currentEquip, harvestLevel);
    float harvestSpeed = getHarvestSpeed(stack, 0);
    float equippedHarvestSpeed = getHarvestSpeed(currentEquip, harvestSpeed);
    float meleeDamage = getMeleeDamage(stack, 0);
    float equippedMeleeDamage = getMeleeDamage(currentEquip, meleeDamage);
    float meleeSpeed = getMeleeSpeed(stack, 0);
    float equippedMeleeSpeed = getMeleeSpeed(currentEquip, meleeSpeed);
    GlStateManager.pushMatrix();
    GlStateManager.color(1f, 1f, 1f, 1f);
    GlStateManager.scale(scale, scale, scale);
    mc.renderEngine.bindTexture(TEXTURE);
    boolean currentIsDurabilityOnly = currentEquip.getItem() instanceof ItemHoe || currentEquip.getItem() instanceof ItemGemSickle || currentEquip.getItem() instanceof ItemFishingRod;
    boolean bothWeapons = (isWeapon(stack) || stack.getItem() instanceof ItemTool) && (isWeapon(currentEquip) || currentEquip.getItem() instanceof ItemTool);
    // Durability
    x = renderStat(mc, fontRenderer, 0, x, y, durability, equippedDurability, StackHelper.isValid(currentEquip));
    // Harvest Level
    if (!isAxe && !isDurabilityOnly && harvestLevel > -1) {
        x = renderStat(mc, fontRenderer, 1, x, y, harvestLevel, equippedHarvestLevel, !currentIsDurabilityOnly && currentEquip.getItem() instanceof ItemTool);
    }
    // Harvest Speed
    if (!isDurabilityOnly && harvestSpeed > 0)
        x = renderStat(mc, fontRenderer, 2, x, y, harvestSpeed, equippedHarvestSpeed, !currentIsDurabilityOnly && currentEquip.getItem() instanceof ItemTool);
    // Melee Damage and Speed
    if (isAxe) {
        x = renderStat(mc, fontRenderer, 3, x, y, meleeDamage, equippedMeleeDamage, bothWeapons);
        x = renderStat(mc, fontRenderer, 5, x, y, meleeSpeed, equippedMeleeSpeed, bothWeapons);
    }
    lastWidth = (int) (x * scale - event.getX());
    GlStateManager.popMatrix();
}
Also used : ItemAxe(net.minecraft.item.ItemAxe) ItemHoe(net.minecraft.item.ItemHoe) ItemTool(net.minecraft.item.ItemTool) ItemFishingRod(net.minecraft.item.ItemFishingRod) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) ItemGemSickle(net.silentchaos512.gems.item.tool.ItemGemSickle)

Aggregations

Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 ItemAxe (net.minecraft.item.ItemAxe)1 ItemFishingRod (net.minecraft.item.ItemFishingRod)1 ItemHoe (net.minecraft.item.ItemHoe)1 ItemStack (net.minecraft.item.ItemStack)1 ItemTool (net.minecraft.item.ItemTool)1 ItemGemSickle (net.silentchaos512.gems.item.tool.ItemGemSickle)1