Search in sources :

Example 1 with ImbuementTiers

use of am2.api.items.armor.ImbuementTiers in project ArsMagica2 by Mithion.

the class GuiArmorImbuer method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    ItemStack stack = tileEntity.getStackInSlot(0);
    int startX = l + 22;
    int stepX = 52;
    int startY = i1 + 23;
    int stepY = 45;
    int drawX = startX;
    int drawY = startY;
    ArrayList<String> hoverLines = new ArrayList<String>();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    GL11.glColor3f(0, 0, 0);
    drawTexturedModalRect(l, i1, 0, 0, xSize, ySize);
    GL11.glColor3f(1, 1, 1);
    hoveredID = null;
    if (stack != null) {
        int armorType = -1;
        if (stack.getItem() instanceof ItemArmor) {
            armorType = ((ItemArmor) stack.getItem()).armorType;
        }
        mc.renderEngine.bindTexture(background_bw);
        for (ImbuementTiers tier : ImbuementTiers.values()) {
            IArmorImbuement[] infusions = ImbuementRegistry.instance.getImbuementsForTier(tier, armorType);
            for (IArmorImbuement infusion : infusions) {
                drawInfusionIconAt(drawX, drawY, infusion.getIconIndex());
                if (i >= drawX && i <= drawX + spriteWidth) {
                    if (j >= drawY && j <= drawY + spriteHeight) {
                        hoverLines.add(StatCollector.translateToLocal("am2.tooltip." + infusion.getID()));
                    }
                }
                drawX += stepX;
            }
            drawY += stepY;
            drawX = startX;
        }
        drawX = startX;
        drawY = startY;
        int highestSelectedTier = 0;
        mc.renderEngine.bindTexture(background);
        for (ImbuementTiers tier : ImbuementTiers.values()) {
            IArmorImbuement[] infusions = ImbuementRegistry.instance.getImbuementsForTier(tier, armorType);
            IArmorImbuement[] existingInfusions = ArmorHelper.getInfusionsOnArmor(stack);
            IArmorImbuement tierInfusion = null;
            for (IArmorImbuement infusion : existingInfusions) {
                if (infusion == null)
                    continue;
                if (infusion.getTier() == tier) {
                    tierInfusion = infusion;
                    if (tier.ordinal() >= highestSelectedTier)
                        highestSelectedTier = tier.ordinal() + 1;
                    break;
                }
            }
            for (IArmorImbuement infusion : infusions) {
                if ((tierInfusion == null && infusion.getTier().ordinal() <= highestSelectedTier)) {
                    if (tileEntity.isCreativeAllowed() || ArmorHelper.getArmorLevel(stack) >= ArmorHelper.getImbueCost(tier)) {
                        drawInfusionIconAt(drawX, drawY, infusion.getIconIndex());
                        if (i >= drawX && i <= drawX + spriteWidth) {
                            if (j >= drawY && j <= drawY + spriteHeight) {
                                hoveredID = infusion.getID();
                            }
                        }
                    }
                } else if (tierInfusion == infusion) {
                    drawInfusionIconAt(drawX, drawY, infusion.getIconIndex());
                }
                drawX += stepX;
            }
            drawY += stepY;
            drawX = startX;
        }
    }
    mc.renderEngine.bindTexture(foreground);
    drawTexturedModalRect(l, i1, 0, 0, xSize, ySize);
    if (hoverLines.size() > 0)
        AMGuiHelper.instance.drawHoveringText(hoverLines, i, j, fontRendererObj, width, height);
}
Also used : ImbuementTiers(am2.api.items.armor.ImbuementTiers) ItemArmor(net.minecraft.item.ItemArmor) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) IArmorImbuement(am2.api.items.armor.IArmorImbuement)

Aggregations

IArmorImbuement (am2.api.items.armor.IArmorImbuement)1 ImbuementTiers (am2.api.items.armor.ImbuementTiers)1 ArrayList (java.util.ArrayList)1 ItemArmor (net.minecraft.item.ItemArmor)1 ItemStack (net.minecraft.item.ItemStack)1