Java Code Examples for net.minecraft.potion.Potion#getStatusIconIndex()

The following examples show how to use net.minecraft.potion.Potion#getStatusIconIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowArmor.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
private void drawPotionEffects(EntityLiving entity) {
    int i = 100;
    int j = 10;
    boolean flag = true;
    Collection collection = entity.getActivePotionEffects();
    if (!collection.isEmpty()) {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_LIGHTING);
        int k = 33;

        if (collection.size() > 5) {
            k = 132 / (collection.size() - 1);
        }

        for (Iterator iterator = entity.getActivePotionEffects().iterator(); iterator.hasNext(); j += k) {
            PotionEffect potioneffect = (PotionEffect) iterator.next();
            Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            Wrapper.INSTANCE.mc().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png"));
            this.drawTexturedModalRect(i, j, 0, 166, 140, 32);

            if (potion.hasStatusIcon()) {
                int l = potion.getStatusIconIndex();
                this.drawTexturedModalRect(i + 6, j + 7, l % 8 * 18, 198 + l / 8 * 18, 18, 18);
            }

            potion.renderInventoryEffect(i, j, potioneffect, Wrapper.INSTANCE.mc());
            String s1 = I18n.format(potion.getName());

            s1 += " " + potioneffect.getAmplifier();

            Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215);
            String s = Potion.getDurationString(potioneffect);
            Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711);
        }
    }
}
 
Example 2
Source File: PotionEffects.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void draw(int x, double y, boolean isConfig) {
    int row = 0;
    double scale = ElementRenderer.getCurrentScale();
    Collection<PotionEffect> effects = new ArrayList<>();

    if (isConfig) {
        effects.add(new PotionEffect(1, 100, 1));
        effects.add(new PotionEffect(3, 100, 2));
    } else {
        effects = Minecraft.getMinecraft().thePlayer.getActivePotionEffects();
    }

    List<String> tmp = new ArrayList<>();

    for (PotionEffect potioneffect : effects) {
        Potion potion = Potion.potionTypes[potioneffect.getPotionID()];

        if (potionIcon) {
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png"));

            if (potion.hasStatusIcon()) {
                int potionStatusIconIndex = potion.getStatusIconIndex();
                drawTexturedModalRect(!ElementRenderer.getCurrent().isRightSided() ? (int) (x / scale) - 20 :
                        (int) (x / scale), (int) ((y + row * 16)) - 4, potionStatusIconIndex % 8 * 18,
                    198 + potionStatusIconIndex / 8 * 18, 18, 18);
            }
        }

        StringBuilder s1 = new StringBuilder(I18n.format(potion.getName()));

        switch (potioneffect.getAmplifier()) {
            case 1:
                s1.append(" ").append(I18n.format("enchantment.level.2"));
                break;
            case 2:
                s1.append(" ").append(I18n.format("enchantment.level.3"));
                break;
            case 3:
                s1.append(" ").append(I18n.format("enchantment.level.4"));
                break;
        }

        String s = Potion.getDurationString(potioneffect);
        String text = s1 + " - " + s;
        tmp.add(text);
        ElementRenderer.draw((int) (x / scale), ((y + row * 16)), text);
        row++;
    }

    width = isConfig ? ElementRenderer.maxWidth(tmp) : 0;
    height = row * 16;
}
 
Example 3
Source File: GuiHandyBag.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void drawActivePotionEffects()
{
    int x = this.guiLeft - 124;
    int y = this.guiTop;

    Collection<PotionEffect> collection = this.mc.player.getActivePotionEffects();

    if (collection.isEmpty() == false)
    {
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableLighting();
        int entryHeight = 33;

        if (collection.size() > 5)
        {
            entryHeight = 132 / (collection.size() - 1);
        }

        for (PotionEffect potioneffect : Ordering.natural().sortedCopy(collection))
        {
            Potion potion = potioneffect.getPotion();

            if (potion.shouldRender(potioneffect) == false)
            {
                continue;
            }

            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.getTextureManager().bindTexture(INVENTORY_BACKGROUND);
            this.drawTexturedModalRect(x, y, 0, 166, 140, 32);

            if (potion.hasStatusIcon())
            {
                int i1 = potion.getStatusIconIndex();
                this.drawTexturedModalRect(x + 6, y + 7, 0 + i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
            }

            potion.renderInventoryEffect(potioneffect, this, x, y, this.zLevel);

            if (potion.shouldRenderInvText(potioneffect) == false)
            {
                y += entryHeight;
                continue;
            }

            String s1 = I18n.format(potion.getName());
            int amp = potioneffect.getAmplifier();

            if (amp >= 1 && amp <= 3)
            {
                s1 = s1 + " " + I18n.format("enchantment.level." + (amp + 1));
            }

            this.fontRenderer.drawStringWithShadow(s1, (float)(x + 10 + 18), (float)(y + 6), 16777215);
            String s = Potion.getPotionDurationString(potioneffect, 1.0F);
            this.fontRenderer.drawStringWithShadow(s, (float)(x + 10 + 18), (float)(y + 6 + 10), 8355711);
            y += entryHeight;
        }
    }
}