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

The following examples show how to use net.minecraft.potion.Potion#shouldRender() . 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: GuiHandyBag.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void updateActivePotionEffects()
{
    boolean hasVisibleEffect = false;

    for (PotionEffect potioneffect : this.mc.player.getActivePotionEffects())
    {
        Potion potion = potioneffect.getPotion();

        if (potion.shouldRender(potioneffect))
        {
            hasVisibleEffect = true;
            break;
        }
    }

    if (this.mc.player.getActivePotionEffects().isEmpty() == false && hasVisibleEffect)
    {
        if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.PotionShiftEvent(this)))
        {
            this.guiLeft = (this.width - this.xSize) / 2;
        }
        else
        {
            this.guiLeft = 160 + (this.width - this.xSize - 200) / 2;
        }

        this.hasActivePotionEffects = true;
    }
    else
    {
        this.guiLeft = (this.width - this.xSize) / 2;
        this.hasActivePotionEffects = false;
    }
}
 
Example 2
Source File: CreativeMenuHandler.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent
public void handleCreativeInventory(BackgroundDrawnEvent event)
{
	if (event.getGui() instanceof GuiContainerCreative)
	{
		int selectedTabIndex = ReflectionHelper.getPrivateValue(GuiContainerCreative.class, (GuiContainerCreative) event.getGui(), 2);

		if (selectedTabIndex == Cyberware.creativeTab.getTabIndex())
		{
			GuiContainerCreative gui = (GuiContainerCreative) event.getGui();
			int i = (gui.width - 136) / 2;
			int j = (gui.height - 195) / 2;
			
			int xSize = 29;
			int ySize = 129;
			
			int xOffset = 0;
			boolean hasVisibleEffect = false;
			for(PotionEffect potioneffect : mc.thePlayer.getActivePotionEffects())
			{
				Potion potion = potioneffect.getPotion();
				if(potion.shouldRender(potioneffect)) {
					hasVisibleEffect = true; break;
				}
			}
			if (!this.mc.thePlayer.getActivePotionEffects().isEmpty() && hasVisibleEffect)
			{
				xOffset = 59;
			}
			salvaged.xPosition = salvaged.baseX + xOffset;
			manufactured.xPosition = manufactured.baseX + xOffset;

			
			GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
			this.mc.getTextureManager().bindTexture(CEX_GUI_TEXTURES);
			gui.drawTexturedModalRect(i + 166 + xOffset, j + 29, 0, 0, xSize, ySize);
			
			salvaged.visible = true;
			manufactured.visible = true;
		}
		else
		{
			salvaged.visible = false;
			manufactured.visible = false;
		}
	}
}
 
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;
        }
    }
}