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

The following examples show how to use net.minecraft.potion.Potion#renderInventoryEffect() . 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: 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;
        }
    }
}