Search in sources :

Example 61 with IIcon

use of net.minecraft.util.IIcon in project ArsMagica2 by Mithion.

the class GuiSkillTrees method drawSkillTree.

private void drawSkillTree() {
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2 + GuiButtonSkillTreeTab.buttonHeight;
    SkillData sk = SkillData.For(Minecraft.getMinecraft().thePlayer);
    for (SkillTreeEntry entry : skillTree) {
        if (entry.prerequisites == null || entry.prerequisites.length == 0)
            continue;
        for (SkillTreeEntry prerequisite : entry.prerequisites) {
            int color = 0;
            if (sk.isEntryKnown(prerequisite) || sk.getLearnState(prerequisite, Minecraft.getMinecraft().thePlayer) == LearnStates.DISABLED) {
                color = 0x006600;
            } else {
                continue;
            }
            line2d(l + entry.x - offsetX * 2 + 16, i1 + entry.y - offsetY * 2 + 16, l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
            line2d(l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, l + prerequisite.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
        }
    }
    for (SkillTreeEntry entry : skillTree) {
        if (entry.prerequisites == null || entry.prerequisites.length == 0)
            continue;
        for (SkillTreeEntry prerequisite : entry.prerequisites) {
            int color = 0;
            LearnStates state = sk.getLearnState(entry, Minecraft.getMinecraft().thePlayer);
            if ((sk.isEntryKnown(prerequisite) && (state == LearnStates.CAN_LEARN || state == LearnStates.LEARNED)) || sk.getLearnState(prerequisite, Minecraft.getMinecraft().thePlayer) == LearnStates.DISABLED) {
                continue;
            } else {
                color = 0x220000;
            }
            line2d(l + entry.x - offsetX * 2 + 16, i1 + entry.y - offsetY * 2 + 16, l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
            line2d(l + entry.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, l + prerequisite.x - offsetX * 2 + 16, i1 + prerequisite.y - offsetY * 2 + 16, color);
        }
    }
    SkillTreeEntry hovered = null;
    for (SkillTreeEntry entry : skillTree) {
        if (entry.registeredItem == null)
            continue;
        String name = SkillManager.instance.getSkillName(entry.registeredItem);
        if (name == null)
            name = "";
        IIcon IIcon = SpellIconManager.instance.getIcon(name);
        LearnStates state = sk.getLearnState(entry, Minecraft.getMinecraft().thePlayer);
        if (state == LearnStates.LEARNED) {
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
        } else if (state == LearnStates.CAN_LEARN) {
            float min = 0.2f;
            float delta = 0.45f * (1f - (Math.abs(AMGuiHelper.instance.getFastTicker() - 20f) / 20f));
            float colorShift = 0.25f;
            SkillPointTypes type = SkillTreeManager.instance.getSkillPointTypeForPart(entry.registeredItem);
            if (type == SkillPointTypes.SILVER) {
                GL11.glColor3f(min + delta + colorShift, min + delta + colorShift, min + delta + colorShift);
            } else {
                GL11.glColor3f(min + delta + ((type == SkillPointTypes.RED) ? colorShift : 0f), min + delta + ((type == SkillPointTypes.GREEN) ? colorShift : 0f), min + delta + ((type == SkillPointTypes.BLUE) ? colorShift : 0f));
            }
        } else {
            GL11.glColor3f(0.1f, 0.1f, 0.1f);
        }
        DrawConstrainedIconAtXY(IIcon, l + entry.x - offsetX * 2, i1 + entry.y - offsetY * 2, IIcondims, IIcondims, false);
        if (state == LearnStates.LOCKED) {
            GL11.glColor4f(0.3f, 0.3f, 0.3f, 0.8f);
            DrawConstrainedIconAtXY(AMGuiIcons.padlock, l + entry.x - offsetX * 2 + 8.5f, i1 + entry.y - offsetY * 2 + 8, 15, 15, true);
        } else if (state == LearnStates.DISABLED) {
            GL11.glColor4f(1.0f, 0.3f, 0.3f, 0.8f);
            DrawConstrainedIconAtXY(AMGuiIcons.padlock, l + entry.x - offsetX * 2 + 8.5f, i1 + entry.y - offsetY * 2 + 8, 15, 15, true);
        }
        GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        if (lastMouseX > l && lastMouseX < l + xSize && lastMouseY > i1 && lastMouseY < i1 + ySize) {
            if (lastMouseX > l + entry.x - offsetX * 2 && lastMouseX < l + entry.x - offsetX * 2 + IIcondims) {
                if (lastMouseY > i1 + entry.y - offsetY * 2 && lastMouseY < i1 + entry.y - offsetY * 2 + IIcondims) {
                    hovered = entry;
                }
            }
        }
    }
    hoveredItem = hovered;
}
Also used : SkillData(am2.playerextensions.SkillData) LearnStates(am2.api.spell.enums.LearnStates) IIcon(net.minecraft.util.IIcon) SkillTreeEntry(am2.api.SkillTreeEntry) SkillPointTypes(am2.api.spell.enums.SkillPointTypes)

Example 62 with IIcon

use of net.minecraft.util.IIcon in project ArsMagica2 by Mithion.

the class GuiSkillTrees method drawAffinity.

private void drawAffinity() {
    hoveredAffinity = null;
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    int IIconsize = 16;
    int halfIconSize = IIconsize / 2;
    int cx = l + xSize / 2 - halfIconSize;
    int cy = i1 + ySize / 2 - halfIconSize;
    int angle = -90;
    int distance = 85;
    int smallDist = 15;
    float angleOffset = 17.5f;
    AffinityData ad = AffinityData.For(Minecraft.getMinecraft().thePlayer);
    for (Affinity aff : Affinity.getOrderedAffinities()) {
        IIcon IIcon = aff.representItem.getIconFromDamage(aff.representMeta);
        int newX = (int) (cx + Math.cos(Math.toRadians(angle)) * distance);
        int newY = (int) (cy + Math.sin(Math.toRadians(angle)) * distance);
        int cx1 = (int) (cx + Math.cos(Math.toRadians(angle + angleOffset)) * smallDist);
        int cx2 = (int) (cx + Math.cos(Math.toRadians(angle - angleOffset)) * smallDist);
        int cy1 = (int) (cy + Math.sin(Math.toRadians(angle + angleOffset)) * smallDist);
        int cy2 = (int) (cy + Math.sin(Math.toRadians(angle - angleOffset)) * smallDist);
        float depthDist = ((distance - smallDist) * ad.getAffinityDepth(aff)) + smallDist;
        int lx = (int) (cx + Math.cos(Math.toRadians(angle)) * depthDist);
        int ly = (int) (cy + Math.sin(Math.toRadians(angle)) * depthDist);
        int displace = (int) ((Math.max(cx1, cx2) - Math.min(cx1, cx2) + Math.max(cy1, cy2) - Math.min(cy1, cy2)) / 3f);
        if (ad.getAffinityDepth(aff) > 0.01f) {
            AMGuiHelper.instance.fractalLine2d(lx + halfIconSize, ly + halfIconSize, cx1 + halfIconSize, cy1 + halfIconSize, this.zLevel, aff.color, displace, 1.1f);
            AMGuiHelper.instance.fractalLine2d(lx + halfIconSize, ly + halfIconSize, cx2 + halfIconSize, cy2 + halfIconSize, this.zLevel, aff.color, displace, 1.1f);
            AMGuiHelper.instance.fractalLine2d(cx1 + halfIconSize, cy1 + halfIconSize, lx + halfIconSize, ly + halfIconSize, this.zLevel, aff.color, displace, 0.8f);
            AMGuiHelper.instance.fractalLine2d(cx2 + halfIconSize, cy2 + halfIconSize, lx + halfIconSize, ly + halfIconSize, this.zLevel, aff.color, displace, 0.8f);
        } else {
            AMGuiHelper.instance.line2d(lx + halfIconSize, ly + halfIconSize, cx1 + halfIconSize, cy1 + halfIconSize, this.zLevel, aff.color);
            AMGuiHelper.instance.line2d(lx + halfIconSize, ly + halfIconSize, cx2 + halfIconSize, cy2 + halfIconSize, this.zLevel, aff.color);
        }
        DrawIconAtXY(IIcon, "items", newX, newY, IIconsize, IIconsize, false);
        String depthString = String.format("%.2f", ad.getAffinityDepth(aff) * 100);
        fontRendererObj.drawString(depthString, newX + halfIconSize - fontRendererObj.getStringWidth(depthString) / 2, newY + IIconsize, aff.color, false);
        angle += 36;
        // if (lastMouseX > l && lastMouseX < l + xSize && lastMouseY > i1 && lastMouseY < i1 + ySize){
        if (lastMouseX > newX && lastMouseX < newX + IIconsize) {
            if (lastMouseY > newY && lastMouseY < newY + IIconsize) {
                hoveredAffinity = aff;
            }
        }
    // }
    }
}
Also used : IIcon(net.minecraft.util.IIcon) AffinityData(am2.playerextensions.AffinityData) Affinity(am2.api.spell.enums.Affinity)

Example 63 with IIcon

use of net.minecraft.util.IIcon in project ArsMagica2 by Mithion.

the class GuiSpellCustomization method initGui.

@Override
public void initGui() {
    super.initGui();
    int l = (width - xSize) / 2;
    int i1 = (height - ySize) / 2;
    if (AMCore.config.suggestSpellNames())
        spellName = new GuiTextField(fontRendererObj, l + 8, i1 + 8, xSize - 36, 16);
    else
        spellName = new GuiTextField(fontRendererObj, l + 8, i1 + 8, xSize - 16, 16);
    String suggestion = ((ContainerSpellCustomization) this.inventorySlots).getInitialSuggestedName();
    spellName.setText(suggestion);
    if (!suggestion.equals("")) {
        curName = suggestion;
        ((ContainerSpellCustomization) this.inventorySlots).setNameAndIndex(curName, curIndex);
    }
    btnPrev = new GuiButtonVariableDims(0, l + 8, i1 + 26, StatCollector.translateToLocal("am2.gui.prev")).setDimensions(48, 20);
    btnNext = new GuiButtonVariableDims(1, l + xSize - 56, i1 + 26, StatCollector.translateToLocal("am2.gui.next")).setDimensions(48, 20);
    btnRandomName = new GuiButtonVariableDims(2, l + xSize - 24, i1 + 5, "???");
    btnRandomName.setDimensions(20, 20);
    this.buttonList.add(btnPrev);
    this.buttonList.add(btnNext);
    if (AMCore.config.suggestSpellNames())
        this.buttonList.add(btnRandomName);
    int IIcon_start_x = l + 12;
    int IIcon_start_y = i1 + 50;
    int btnX = IIcon_start_x;
    int btnY = IIcon_start_y;
    int id = 3;
    int IIconCount = 0;
    int curPage = 0;
    for (IIcon icon : SpellTextureHelper.instance.getAllIcons()) {
        GuiSpellImageButton spellButton = new GuiSpellImageButton(id++, btnX, btnY, icon, IIconCount++, curPage);
        if (curPage != 0) {
            spellButton.visible = false;
        }
        this.buttonList.add(spellButton);
        btnX += 14;
        if (btnX > (l + xSize) - 15) {
            btnX = IIcon_start_x;
            btnY += 14;
            if (btnY > (i1 + ySize - 10)) {
                btnY = IIcon_start_y;
                curPage++;
            }
        }
    }
    this.numPages = curPage;
}
Also used : IIcon(net.minecraft.util.IIcon) GuiSpellImageButton(am2.guis.controls.GuiSpellImageButton) GuiTextField(net.minecraft.client.gui.GuiTextField) ContainerSpellCustomization(am2.containers.ContainerSpellCustomization) GuiButtonVariableDims(am2.guis.controls.GuiButtonVariableDims)

Example 64 with IIcon

use of net.minecraft.util.IIcon in project ArsMagica2 by Mithion.

the class RenderWhirlwind method renderWhirlwind.

private void renderWhirlwind(EntityWhirlwind whirlwind, double x, double y, double z, float f, float f1) {
    GL11.glPushMatrix();
    Minecraft.getMinecraft().renderEngine.bindTexture(rLoc);
    Tessellator tessellator = Tessellator.instance;
    IIcon IIcon = AMParticleIcons.instance.getIconByName("wind");
    GL11.glTranslated(x, y, z);
    float f4 = 1.0F;
    float f5 = 0.5F;
    float f6 = 0.25F;
    float min_u = IIcon.getMinU();
    float min_v = IIcon.getMinV();
    float max_u = IIcon.getMaxU();
    float max_v = IIcon.getMaxV();
    GL11.glRotatef(180F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.setBrightness(0xF00F0);
    tessellator.addVertexWithUV(0.0F - f5, 0.0F - f6, 0.0D, min_u, max_v);
    tessellator.addVertexWithUV(f4 - f5, 0.0F - f6, 0.0D, max_u, max_v);
    tessellator.addVertexWithUV(f4 - f5, f4 - f6, 0.0D, max_u, min_v);
    tessellator.addVertexWithUV(0.0F - f5, f4 - f6, 0.0D, min_u, min_v);
    tessellator.draw();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IIcon(net.minecraft.util.IIcon)

Example 65 with IIcon

use of net.minecraft.util.IIcon in project ArsMagica2 by Mithion.

the class AMIngameGUI method RenderArmorStatus.

private void RenderArmorStatus(int i, int j, Minecraft mc, FontRenderer fontRenderer) {
    if (!AMCore.config.showArmorUI())
        return;
    ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    for (int slot = 0; slot < 4; ++slot) {
        if (ArmorHelper.PlayerHasArmorInSlot(mc.thePlayer, 3 - slot)) {
            AMVector2 position = getArmorSlotPosition(slot, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());
            int blackoutTimer = AMGuiHelper.instance.getBlackoutTimer(3 - slot);
            int blackoutMaxTimer = AMGuiHelper.instance.getBlackoutTimerMax(3 - slot);
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
            ItemStack armor = mc.thePlayer.inventory.armorInventory[3 - slot];
            float lineweight = 4f;
            // durability
            if (armor.isItemDamaged() && armor.getMaxDamage() > 0) {
                float pct = 1 - (float) armor.getItemDamage() / (float) armor.getMaxDamage();
                AMGuiHelper.line2d(position.iX, position.iY + 10, position.iX + 10, position.iY + 10, this.zLevel + 100, lineweight, 0);
                int color = (int) (255.0f * (1 - pct)) << 16 | (int) (255.0f * pct) << 8;
                AMGuiHelper.line2d(position.iX, position.iY + 10, position.iX + (10 * pct), position.iY + 10, this.zLevel + 101, lineweight, color);
            }
            // cooldown
            if (blackoutMaxTimer > 0) {
                float pct = (float) (blackoutMaxTimer - blackoutTimer) / (float) blackoutMaxTimer;
                AMGuiHelper.line2d(position.iX, position.iY + 11, position.iX + 10, position.iY + 11, this.zLevel + 100, lineweight, 0);
                AMGuiHelper.line2d(position.iX, position.iY + 11, position.iX + (10 * pct), position.iY + 11, this.zLevel + 101, lineweight, 0xFF0000);
            } else {
                AMGuiHelper.line2d(position.iX, position.iY + 11, position.iX + 10, position.iY + 11, this.zLevel + 101, lineweight, 0x0000FF);
            }
            IIcon icon = mc.thePlayer.inventory.armorInventory[3 - slot].getIconIndex();
            if (icon != null) {
                AMGuiHelper.DrawIconAtXY(icon, position.iX, position.iY, this.zLevel, 10, 10, true);
            } else {
                AMGuiHelper.DrawItemAtXY(mc.thePlayer.inventory.armorInventory[3 - slot], position.iX, position.iY, this.zLevel, 0.63f);
            }
        }
    }
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IIcon(net.minecraft.util.IIcon) AMVector2(am2.api.math.AMVector2) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IIcon (net.minecraft.util.IIcon)79 Tessellator (net.minecraft.client.renderer.Tessellator)19 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)11 ItemStack (net.minecraft.item.ItemStack)6 EntityItem (net.minecraft.entity.item.EntityItem)5 Fluid (net.minecraftforge.fluids.Fluid)5 Rotation (uk.co.qmunity.lib.transform.Rotation)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 AMVector2 (am2.api.math.AMVector2)3 Block (net.minecraft.block.Block)3 EntityDiggingFX (net.minecraft.client.particle.EntityDiggingFX)3 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)2 IExplosiveHandler (com.builtbroken.mc.api.explosive.IExplosiveHandler)2 ITexturedExplosiveHandler (com.builtbroken.mc.api.explosive.ITexturedExplosiveHandler)2 IExplosiveContainerItem (com.builtbroken.mc.api.items.explosives.IExplosiveContainerItem)2 ItemStackWrapper (com.builtbroken.mc.prefab.items.ItemStackWrapper)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)2