@Override public void onPreDraw(GuiContainer gui) { if (!isHidden() && isEnabled() && gui instanceof InventoryEffectRenderer)//Reset the gui to the center of the screen, for potion effect offsets etc { gui.guiLeft = (gui.width - gui.xSize) / 2; gui.guiTop = (gui.height - gui.ySize) / 2; if (gui instanceof GuiContainerCreative && gui.buttonList.size() >= 2) { GuiButton button1 = (GuiButton) gui.buttonList.get(0); GuiButton button2 = (GuiButton) gui.buttonList.get(1); button1.xPosition = gui.guiLeft; button2.xPosition = gui.guiLeft + gui.xSize - 20; } } }
@Override public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { GuiScreen screen = minecraft.currentScreen; if (screen instanceof InventoryEffectRenderer) { this.lastRequestedStack = ItemStack.EMPTY; itemdash.onTick(); } if (inGame) { pbh.handleMouse(this.survivalPick); } if (this.pickSlot) { InventoryPlayer inv = minecraft.player.inventory; // inv.setPickedItemStack but doesn't give the item (just in case) int slot = inv.getSlotFor(this.lastRequestedStack); if (InventoryPlayer.isHotbar(slot)) { inv.currentItem = slot; } else if (slot != -1) { mc.playerController.pickItem(slot); } else { // happens with items on the server that had nbt. LOGGER.warn("Inventory didn't have {}?", this.lastRequestedStack); } this.lastRequestedStack = ItemStack.EMPTY; this.pickSlot = false; } }
@SubscribeEvent(priority = EventPriority.LOW) public void postInitGui(GuiScreenEvent.InitGuiEvent.Post event){ if (Battlegear.battlegearEnabled && event.getGui() instanceof InventoryEffectRenderer) { if(!ClientProxy.tconstructEnabled || Minecraft.getMinecraft().player.capabilities.isCreativeMode) { onOpenGui(event.getButtonList(), ((InventoryEffectRenderer) event.getGui()).getGuiLeft()-30, ((InventoryEffectRenderer) event.getGui()).getGuiTop()); } } }
@Override public void drawButton(@Nonnull Minecraft mc, int mouseX, int mouseY){ if (this.visible) { if(mc.currentScreen instanceof InventoryEffectRenderer) { if (deltaY != 0) { this.yPosition -= deltaY; deltaY = 0; } int size = mc.player.getActivePotionEffects().size(); if (size > 0) { int off = 33; if (size > 4) { off = -2 * height; size = 1; } deltaY = off * size; this.yPosition += deltaY; } } this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; int k = this.getHoverState(this.hovered); drawTextureBox(k); this.mouseDragged(mc, mouseX, mouseY); int color = 14737632; if (packedFGColour != 0) { color = packedFGColour; } else if (!this.enabled) { color = 10526880; } else if (this.hovered) { color = 16777120; } this.drawCenteredString(mc.fontRenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, color); } }
@SubscribeEvent public void onGuiDrawScreen(GuiScreenEvent.DrawScreenEvent.Post event) { Minecraft mc = Minecraft.getMinecraft(); if (!(event.gui instanceof InventoryEffectRenderer)) { return; } int i = this.guiLeft - 124; int j = this.guiTop; Collection collection = mc.thePlayer.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 = mc.thePlayer.getActivePotionEffects().iterator(); iterator.hasNext(); j += k) { PotionEffect potioneffect = (PotionEffect) iterator.next(); if (potioneffect instanceof BaublePotionEffect) { mc.getTextureManager().bindTexture(INVENTORY); Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); event.gui.drawTexturedModalRect(i, j, 0, 166, 140, 32); if (potion.hasStatusIcon()) { int l = potion.getStatusIconIndex(); event.gui.drawTexturedModalRect(i + 6, j + 7, l % 8 * 18, 198 + l / 8 * 18, 18, 18); } String s1 = I18n.format(potion.getName()); if (potioneffect.getAmplifier() == 1) { s1 = s1 + " II"; } else if (potioneffect.getAmplifier() == 2) { s1 = s1 + " III"; } else if (potioneffect.getAmplifier() == 3) { s1 = s1 + " IV"; } mc.fontRenderer.drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215); mc.fontRenderer.drawStringWithShadow("Bauble", i + 10 + 18, j + 6 + 10, 8355711); } } } }