static void guiInstance(GuiOpenEvent e) { if (!(mc.currentScreen instanceof ScreenGUI)) { if (mc.currentScreen != e.gui) { if ((e.gui instanceof GuiIngameMenu) || ((e.gui instanceof GuiInventory) && (!OptionCore.DEFAULT_INVENTORY.getValue()))) { final boolean inv = (e.gui instanceof GuiInventory); if (mc.playerController.isInCreativeMode() && inv) e.gui = new GuiContainerCreative(mc.thePlayer); else { e.gui = new IngameMenuGUI((inv ? (GuiInventory) mc.currentScreen : null)); } } if ((e.gui instanceof GuiGameOver) && (!OptionCore.DEFAULT_DEATH_SCREEN.getValue())) { if (mc.ingameGUI instanceof IngameGUI) { e.gui = new DeathScreen(); } } } else e.setCanceled(true); } }
@Override public void onRender(float partialTicks) { boolean found = false; for(Object entity : WMinecraft.getWorld().loadedEntityList) if(entity instanceof EntityOtherPlayerMP) { EntityOtherPlayerMP player = (EntityOtherPlayerMP)entity; if(player.getName().equals(playerName)) { ChatUtils.message( "Showing inventory of " + player.getName() + "."); mc.displayGuiScreen(new GuiInventory(player)); found = true; } } if(!found) ChatUtils.error("Player not found."); playerName = null; wurst.events.remove(RenderListener.class, this); }
@EventTarget private void onTick(TickEvent event) { if (this.mc.currentScreen == null || this.mc.currentScreen instanceof GuiInventory || !this.mc.currentScreen.getClass().getName().contains("inventory")) { int slotID = -1; double maxProt = -1.0; int i = 9; while (i < 45) { double protValue; ItemStack stack = this.mc.thePlayer.inventoryContainer.getSlot(i).getStack(); if (stack != null && this.canEquip(stack) && (protValue = this.getProtValue(stack)) >= maxProt) { slotID = i; maxProt = protValue; } ++i; } if (slotID != -1) { this.mc.playerController.windowClick(this.mc.thePlayer.inventoryContainer.windowId, slotID, 0, 1, (EntityPlayer)this.mc.thePlayer); } } }
@SubscribeEvent public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { if (Minecraft.getMinecraft().player != null) { if ((event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative || event.getGui() instanceof GuiWearables) && !Minecraft.getMinecraft().player.getCapability(TF2weapons.INVENTORY_CAP, null).isEmpty()) { // GuiContainer gui = (GuiContainer) event.getGui(); event.getButtonList().add(new GuiButton(97535627, event.getGui().width / 2 - 10, event.getGui().height / 2 + 95, 20, 20, "W")); } if (event.getGui() instanceof GuiMerchant) if (((GuiMerchant) event.getGui()).getMerchant().getDisplayName().getUnformattedText().equals(I18n.format("entity.hale.name"))) { event.getButtonList().add(new GuiButton(7578, event.getGui().width / 2 - 100, event.getGui().height / 2 - 110, 100, 20, "Change Team")); event.getButtonList().add(new GuiButton(7579, event.getGui().width / 2, event.getGui().height / 2 - 110, 100, 20, "Recover Lost Items")); } Minecraft.getMinecraft().player.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 8; } }
@SubscribeEvent public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event) { if (event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative) if (event.getButton().id == 97535627) { // Minecraft.getMinecraft().displayGuiScreen(null); TF2weapons.network.sendToServer(new TF2Message.ShowGuiMessage(0)); } if (event.getGui() instanceof GuiWearables) if (event.getButton().id == 97535627) { event.getGui().mc.displayGuiScreen(new GuiInventory(event.getGui().mc.player)); } // PacketHandler.INSTANCE.sendToServer(new // PacketOpenNormalInventory(event.getGui().mc.player)); if (event.getGui() instanceof GuiMerchant && event.getButton().id == 7578) { ClientProxy.displayScreenJoinTeam(); } else if (event.getGui() instanceof GuiMerchant && event.getButton().id == 7579) { TF2weapons.network.sendToServer(new TF2Message.ActionMessage(18)); } }
/** * Returns if the current GUI should have the extra slots visible. */ boolean shouldDisplayGuiOverlay(GuiScreen gui) { if (gui == null) { return false; } if (Minecraft.getMinecraft().world == null) { return false; } if (!(gui instanceof GuiContainer)) { return false; } if (gui instanceof GuiInventory) { return false; } if (gui.mc.player.isSpectator()) { return false; } // Edge case for modders that use GuiContainer with no inventory (Y U do dis?) final GuiContainer guiWithStuff = (GuiContainer) gui; if (guiWithStuff.inventorySlots == null || guiWithStuff.inventorySlots.inventorySlots == null || guiWithStuff.inventorySlots.inventorySlots.size() == 0) { return false; } final InfoGuiOverlayDisplayParams displayParams = getDisplayParamsForGui(gui); return displayParams.getShouldDisplay(); }
public void setExternalGuiPosition(GuiScreen gui) { if (gui instanceof GuiContainer) { final int candidateGuiLeft = ((GuiContainer) gui).getGuiLeft(); final int candidateGuiTop = ((GuiContainer) gui).getGuiTop(); // -- NOTE -- // The creative inventory would cause this method to be fired twice, once for // net.minecraft.client.gui.inventory.GuiContainerCreative (with correct values) // and once for net.minecraft.client.gui.inventory.GuiInventory (with wrong values). // // I ignore the second call so the gui overlay preserves the correct values. if (gui instanceof GuiInventory && candidateGuiLeft == 0 && candidateGuiTop == 0) { return; } this._externalGuiLeft = candidateGuiLeft; this._externalGuiTop = candidateGuiTop; } else { this._externalGuiLeft = -1; this._externalGuiTop = -1; } LogHelper.trace("GuiExtraSlotsOverlay.setExternalGuiPosition() - left: %d, top: %d", this._externalGuiLeft, this._externalGuiTop); }
@SideOnly(Side.CLIENT) public static boolean shouldDisplayTankGui(GuiScreen gui) { if (FMLClientHandler.instance().getClient().gameSettings.hideGUI) { return false; } if (gui == null) { return true; } if (gui instanceof GuiInventory) { return false; } return gui instanceof GuiChat; }
private void drawCharacter(int x, int y, int size, int cursorX, int cursorY) { final float mouseX = (float) x - cursorX; final float mouseY = (float) y - size * 1.67F - cursorY; EntityLivingBase tmp = (EntityLivingBase)character.ridingEntity; IS_VIEWING = true; if (character.isRiding() && OptionCore.MOUNT_STAT_VIEW.getValue()) GuiInventory.drawEntityOnScreen(x, y, size, mouseX, mouseY, tmp); else GuiInventory.drawEntityOnScreen(x, y, size, mouseX, mouseY, character); IS_VIEWING = false; GLCore.glRescaleNormal(true); GLCore.glTexture2D(true); GLCore.glBlend(true); GLCore.tryBlendFuncSeparate(770, 771, 1, 0); }
@Override protected void keyTyped(char chr, int keySym) throws IOException { if (keySym == Keyboard.KEY_BACK || chr == 'z') { actionPerformed(backButton); } else if (keySym == Keyboard.KEY_NEXT || chr == ' ') { actionPerformed(nextPage); } else if (keySym == Keyboard.KEY_PRIOR) { actionPerformed(prevPage); } else if (keySym == Keyboard.KEY_HOME) { actionPerformed(homeButton); } else if (chr == 'r') { initGui(); } else if (chr == 's') { state.dark_color_scheme ^= true; } else if (keySym == mc.gameSettings.keyBindInventory.getKeyCode()) { mc.displayGuiScreen(new GuiInventory(mc.thePlayer)); } else if (chr == 'l') { RecipeViewer.resetCache(); initGui(); } else { super.keyTyped(chr, keySym); } }
@Override public void onRender() { boolean found = false; for (Object entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { if (entity instanceof EntityOtherPlayerMP) { EntityOtherPlayerMP player = (EntityOtherPlayerMP) entity; if (player.getName().equals(playerName)) { WurstClient.INSTANCE.chat.message("Showing inventory of " + player.getName() + "."); Minecraft.getMinecraft().displayGuiScreen(new GuiInventory(player)); found = true; } } } if (!found) WurstClient.INSTANCE.chat.error("Player not found."); playerName = null; WurstClient.INSTANCE.events.remove(RenderListener.class, this); }
@Override public void onEnable() { if (Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem() == null || !(Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().getItem() instanceof ItemNameTag)) { WurstClient.INSTANCE.chat.error("You are not holding a nametag in your hand."); setEnabled(false); return; } else if (!Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) { WurstClient.INSTANCE.chat.error("Creative mode only."); setEnabled(false); return; } String stackName = ""; for (int i = 0; i < 3000; i++) { StringBuilder builder = new StringBuilder().append(stackName); stackName = builder.append("############").toString(); } Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().setStackDisplayName(stackName); Minecraft.getMinecraft().displayGuiScreen(new GuiInventory(Minecraft.getMinecraft().thePlayer)); Minecraft.getMinecraft().thePlayer.closeScreen(); WurstClient.INSTANCE.chat.message("CrashItem created. Right click a mob with it."); setEnabled(false); }
@Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if(player.getEntityData().hasKey("craftingTable")) Core.bindTexture(UPPER_TEXTURE); else Core.bindTexture(UPPER_TEXTURE_2X2); int k = this.guiLeft; int l = this.guiTop; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, 102); //Draw the player avatar GuiInventory.drawEntityOnScreen(k + 51, l + 75, 30, k + 51 - this.xSizeLow, l + 75 - 50 - this.ySizeLow, this.mc.player); PlayerInventory.drawInventory(this, width, height, ySize - PlayerInventory.invYSize); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
@Override protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(textures); this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); // weight drawIconBar(cat.getWeight(), EntityFatCat.WEIGHT_STATUS_MAX, 10, guiLeft + 70, guiTop + 22, xSize, 3*8, xSize+8, 3*8); // health drawIconBar(cat.getHealth(), cat.getMaxHealth(), 5, guiLeft + 70, guiTop + 46, xSize, 1*8, xSize+8, 1*8); // hunger drawIconBar(cat.getHunger(), EntityFatCat.HUNGER_MAX, 5, guiLeft + 130, guiTop + 46, xSize, 2*8, xSize+8, 2*8); // bladder drawIconBar(cat.getBladder(), EntityFatCat.BLADDER_MAX, 5, guiLeft + 70, guiTop + 68, xSize, 0*8, xSize+8, 0*8); // tiredness drawIconBar(cat.getTiredness(), EntityFatCat.TIREDNESS_MAX, 5, guiLeft + 130, guiTop + 68, xSize, 8*4, xSize+8, 8*4); // friendship drawIconBar(cat.getFriendship(), EntityFatCat.FRIENDSHIP_MAX, 5, guiLeft + 70, guiTop + 90, xSize, 8*5, xSize+8, 8*5); // loveness drawIconBar(cat.getLoveness(), EntityFatCat.FRIENDSHIP_MAX, 5, guiLeft + 130, guiTop + 90, xSize, 8*6, xSize+8, 8*6); // !! change scale in the following method, so we should put this at last !! GuiInventory.drawEntityOnScreen(guiLeft + 36, guiTop + 55, 30, guiLeft + 24 - mouseX, guiTop + 5 - mouseY, cat); }
public static void drawPages(FontRenderer renderer, int mouseX, int mouseY, int currentPage, CATEGORY currentCategory, GuiScreen gui) { if (currentCategory == null) { drawCategoryModels(); } if (currentCategory == CATEGORY.DINOS) { if (currentPage == 0) { /* Page 1 / 2*/ GuiInventory.drawEntityOnScreen(getLeft() + 14, 90, 20, -350f, -5F, new EntityRaptor(Minecraft.getMinecraft().theWorld, 1)); drawTitle(renderer, DINO_NAME.UTAHRAPTOR); drawDiet(renderer, getLeft() + 40, 135, DINO_NAME.UTAHRAPTOR, gui); drawSpecies(renderer, getLeft() + 15, 150, DINO_NAME.UTAHRAPTOR); } else if (currentPage == 2) { } } }
@Override public void draw(final IDrawHelper offset, final Object object, final int offsetX, final int j, final int yOffset, final int k, final int mouseX, final int mouseY) { final EntityLivingBase entity = ((EntityLivingBase) object); boolean hovered = (mouseX >= 10 + (j * 32) && mouseX <= 9 + ((j + 1) * 32) && mouseY >= 40 && mouseY <= 120); if (hovered) { TOOLTIP.add("Localised: " + entity.getName()); TOOLTIP.add("Name: " + EntityHelper.getNameForEntity(entity)); } try { LAST.add(new Callable() { @Override public Object call() throws Exception { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F); //Using state manager doesn't fix this int entitySize = EntityHelper.getSizeForEntity(entity); int entityY = EntityHelper.getOffsetForEntity(entity); GuiInventory.drawEntityOnScreen(offsetX + 24 + (j * 32), CORE.screenTop + 105 + (k * 32) + yOffset + entityY, entitySize, 25F, -5F, entity); //BossStatus.bossName = null; //Reset boss return null; } }); } catch (Exception e) {} }
@Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(gui); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); for (int j1 = 0; j1 < 3; j1++) { for (int k1 = 0; k1 < 5; k1++) { drawTexturedModalRect(l + 78 + 18 * k1, i1 + 9 + 18 * j1 + 15, 197, 2, 18, 18); } } GuiInventory.func_147046_a(l + 42, i1 + 51, 30, (float)(l + 51) - xSize_wolf, (float)((i1 + 75) - 50) - ySize_wolf, this.entity); }
@Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(gui); int l = (width - xSize) / 2; int i1 = (height - ySize) / 2; drawTexturedModalRect(l, i1, 0, 0, xSize, ySize); for (int j1 = 0; j1 < 3; j1++) { for (int k1 = 0; k1 < 3; k1++) { drawTexturedModalRect(l + 78 + 18 * k1, i1 + 9 + 18 * j1 + 15, 197, 2, 18, 18); } } GuiInventory.func_110423_a(l + 42, i1 + 51, 30, (float)(l + 51) - xSize_wolf, (float)((i1 + 75) - 50) - ySize_wolf, this.dog); }
@SubscribeEvent public void onGuiOpenEvent(GuiOpenEvent event) { // Reset the scrolling modifier when the player opens a GUI. // Otherwise the key up event will get eaten and our scrolling mode will get stuck on // until the player sneaks again. // FIXME Apparently there are key input events for GUI screens in 1.8, // so this probably can be removed then. InputEventHandler.resetModifiers(); // Opening the player's Inventory GUI if (event.getGui() != null && event.getGui().getClass() == GuiInventory.class) { EntityPlayer player = FMLClientHandler.instance().getClientPlayerEntity(); if (this.handyBagShouldOpen && player != null && ItemHandyBag.getOpenableBag(player).isEmpty() == false) { if (event.isCancelable()) { event.setCanceled(true); } PacketHandler.INSTANCE.sendToServer(new MessageOpenGui(player.dimension, ReferenceGuiIds.GUI_ID_HANDY_BAG)); } } }
@Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(resSatchelContainer); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k + 61, l + 17, 0, this.ySize, (18 * this.getContainer().columns), (18 * this.getContainer().rows)); GuiInventory.drawEntityOnScreen(k + 34, l + 66, 24, (float)(k + 34) - this.field_147033_y, (float)(l + 95 - 66) - this.field_147032_z, this.player); }
protected void func_74185_a(float p_74185_1_, int p_74185_2_, int p_74185_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.field_73882_e.func_110434_K().func_110577_a(field_110414_t); int var4 = (this.field_73880_f - this.field_74194_b) / 2; int var5 = (this.field_73881_g - this.field_74195_c) / 2; this.func_73729_b(var4, var5, 0, 0, this.field_74194_b, this.field_74195_c); if(this.field_110411_w.func_110261_ca()) { this.func_73729_b(var4 + 79, var5 + 17, 0, this.field_74195_c, 90, 54); } if(this.field_110411_w.func_110259_cr()) { this.func_73729_b(var4 + 7, var5 + 35, 0, this.field_74195_c + 54, 18, 18); } GuiInventory.func_110423_a(var4 + 51, var5 + 60, 17, (float)(var4 + 51) - this.field_110416_x, (float)(var5 + 75 - 50) - this.field_110415_y, this.field_110411_w); }
public void func_73866_w_() { if(this.field_73882_e.field_71442_b.func_78758_h()) { super.func_73866_w_(); this.field_73887_h.clear(); Keyboard.enableRepeatEvents(true); this.field_74237_t = new GuiTextField(this.field_73886_k, this.field_74198_m + 82, this.field_74197_n + 6, 89, this.field_73886_k.field_78288_b); this.field_74237_t.func_73804_f(15); this.field_74237_t.func_73786_a(false); this.field_74237_t.func_73790_e(false); this.field_74237_t.func_73794_g(16777215); int var1 = field_74241_p; field_74241_p = -1; this.func_74227_b(CreativeTabs.field_78032_a[var1]); this.field_82324_x = new CreativeCrafting(this.field_73882_e); this.field_73882_e.field_71439_g.field_71069_bz.func_75132_a(this.field_82324_x); } else { this.field_73882_e.func_71373_a(new GuiInventory(this.field_73882_e.field_71439_g)); } }
protected void drawGuiContainerBackgroundLayer(float unused, int unused2, int unused3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(wolfGuiTextures); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); GL11.glPushMatrix(); int x = k+26; int y = l+70; int boxWidth = 52; int boxHeight = 52; ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); int scaleFactor = res.getScaleFactor(); GL11.glScissor(x*scaleFactor, (height-y)*scaleFactor, boxWidth*scaleFactor, boxHeight*scaleFactor); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glTranslatef(0, -14+(zoom/2), 0); GuiInventory.func_147046_a(k + 51, l + 60, zoom, (float)(k + 51) - this.mouseX, (float)(l + 75 - 50) - this.mouseY, this.wolf); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslatef(0, 0, 400); String s = "Zoom: \u00A7e"+((zoom-28)+100)+"%"; GL11.glScalef(0.5f, 0.5f, 1f); fontRendererObj.drawStringWithShadow(s, ((x+boxWidth)*2)-(fontRendererObj.getStringWidth(s)+2), (y*2)-10, 0xFFFFFF); GL11.glPopMatrix(); }
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); //this.mc.getTextureManager().bindTexture(camelGuiTextures); this.mc.renderEngine.bindTexture(camelGuiTextures); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); if (this.field_147034_x.isChested()) { this.drawTexturedModalRect(k + 79, l + 17, 0, this.ySize, 90, 54); } // if (this.field_147034_x.func_110259_cr()) for armor // { // this.drawTexturedModalRect(k + 7, l + 35, 0, this.ySize + 54, 18, 18); // } GuiInventory.func_147046_a(k + 51, l + 60, 17, (float)(k + 51) - this.field_147033_y, (float)(l + 75 - 50) - this.field_147032_z, this.field_147034_x); }
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(horseGuiTextures); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); if (this.field_147034_x.isChested()) { this.drawTexturedModalRect(k + 79, l + 17, 0, this.ySize, 90, 54); } if (this.field_147034_x.func_110259_cr()) { this.drawTexturedModalRect(k + 7, l + 35, 0, this.ySize + 54, 18, 18); } GuiInventory.func_147046_a(k + 51, l + 60, 17, (float)(k + 51) - this.field_147033_y, (float)(l + 75 - 50) - this.field_147032_z, this.field_147034_x); }
@Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case mainID: return new GuiInventory(player); case equipID: return new BattleEquipGUI(player, world.isRemote); case sigilEditor: return Battlegear.debug?new BattlegearSigilGUI(player, world.isRemote):null; case flagEditor: return new GuiFlagDesigner(player); default: return null; } }
@Override public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { boolean pressed = super.mousePressed(mc, mouseX - this.parentGui.getGuiLeft(), mouseY); if (pressed) if(directionToInventory) HarshenClientUtils.openInventory(); else mc.displayGuiScreen(new GuiInventory(mc.player)); return pressed; }
@Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { int i = (this.width - this.xSize) / 2; int j = (this.height - this.ySize) / 2; this.drawDefaultBackground(); this.mc.getTextureManager().bindTexture(background); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); for(EnumInventorySlots slot : EnumInventorySlots.values()) if(!inventorySlots.getSlot(slot.getId()).getHasStack()) HarshenClientUtils.drawTexture(slot.getPoint().x + this.guiLeft, slot.getPoint().y + this.guiTop, 13.26f, 9.89f + (slot.getId()), 1f, 1f, 16, 16, 16, 16); GuiInventory.drawEntityOnScreen(i + 30, j + 75, 30, (float)(i + 51) - this.oldMouseX, (float)(j + 75 - 50) - this.oldMouseY, this.mc.player); }
@SubscribeEvent public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { if (event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiPlayerInventoryExtended){ GuiContainer gui = (GuiContainer) event.getGui(); event.getButtonList().add(new GuiHarshenButton(8178, gui, 140, 51, 24, 24, I18n.translateToLocalFormatted((event.getGui() instanceof GuiInventory) ? "button.harsheninventory" : "button.normal"), event.getGui() instanceof GuiInventory)); } }
@SubscribeEvent public void onOpenGui(GuiOpenEvent event) { Minecraft mc = Minecraft.getMinecraft(); if (mc.player != null) { if (event.getGui() instanceof GuiGameOver && isKnockedOut && !acceptedDeath) { // Minor hack: isKnockedOut is always set AFTER the game over screen pops up, so we can abuse that here event.setGui(null); } else if (isKnockedOut && event.getGui() instanceof GuiInventory) { event.setGui(null); } } }
@Override public void onEnable() { // check gamemode if(!WMinecraft.getPlayer().capabilities.isCreativeMode) { ChatUtils.error("Creative mode only."); setEnabled(false); return; } // check held item ItemStack heldStack = WMinecraft.getPlayer().inventory.getCurrentItem(); if(heldStack == null || !(heldStack.getItem() instanceof ItemNameTag)) { ChatUtils.error("You need a nametag in your hand."); setEnabled(false); return; } // modify held item StringBuilder stackName = new StringBuilder(); for(int i = 0; i < 18000; i++) stackName.append('#'); heldStack.setStackDisplayName(stackName.toString()); // open & close the inventory // for some reason that's needed for the item to update mc.displayGuiScreen(new GuiInventory(WMinecraft.getPlayer())); WMinecraft.getPlayer().closeScreen(); ChatUtils.message("Nametag modified."); setEnabled(false); }
public static ItemStack getGridItem(int nr) { GuiContainer menu = (GuiContainer)getMenu(); Container slots = menu.inventorySlots; if (menu instanceof GuiCrafting) { return ((ContainerWorkbench)slots).craftMatrix.getStackInSlot(nr); } else if (menu instanceof GuiInventory) { return ((ContainerPlayer)slots).craftMatrix.getStackInSlot(nr); } return null; }