Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

billybobpumpkin

Members
  • Joined

  • Last visited

Everything posted by billybobpumpkin

  1. What does this setLivingAnimations do? I have look through the vanilla code and I'm still stumped!
  2. What does this setLivingAnimations do (in side ModelBase)? I have look through the vanilla code and I'm still stumped!
  3. Can someone help me on this? I have really worked hard to try and find a solution but to no avail. What I want: What I have (player inventory): Code, RIP clean code: Tab class: public static final ResourceLocation TEXTURE_LOCATION = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); ItemStack renderStack; protected RenderItem itemRender; int guiLeft; int guiTop; int ySize; int xSize; GuiButton currentButton; public void setCurrentButton(GuiButton button) { this.currentButton = button; } public GuiButton getButton() { return this.currentButton; } public void setItem(ItemStack item) { this.renderStack = item; } public ItemStack getItem() { return this.renderStack; } public AbstractTab(int buttonId, int x, int y, ItemStack renderStack) { super(buttonId, x, y, 28, 32, ""); this.ySize = 136; this.xSize = 195; this.renderStack = renderStack; this.itemRender = FMLClientHandler.instance().getClient().getRenderItem(); this.guiLeft = (this.width - this.xSize) / 2; this.guiTop = (this.height - this.ySize) / 2; } @Override public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { if(visible) { drawInventoryTab(mc, mouseX, mouseY, partialTicks); } } protected void drawInventoryTab(Minecraft mc, int mouseX, int mouseY, float partialTicks) { CreativeTabs tab = CreativeTabs.INVENTORY; //mc.renderEngine.bindTexture(TEXTURE_LOCATION); mc.getTextureManager().bindTexture(TEXTURE_LOCATION); boolean flag = true;//tab.getTabIndex() == selectedTabIndex; boolean flag1 = tab.isTabInFirstRow(); int i = 32; int j = i * 28; int k = 0; int l = this.guiLeft + 28 * i; int i1 = this.guiTop; int j1 = 32; if (flag) { k += 32; } if (tab.isAlignedRight()) { l = this.guiLeft + this.xSize - 28 * (6 - i); } else if (i > 0) { l += i; } if (flag1) { i1 = i1 - 28; } else { k += 64; i1 = i1 + (this.ySize - 4); } //for(AbstractTab abstractTab : RegisterTabs.tabList) //{ //int p = 0; //int index = (RegisterTabs.tabList.get(0).getId() + 150); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.color(1F, 1F, 1F); //Forge: Reset color in case Items change it. GlStateManager.enableBlend(); //Forge: Make sure blend is enabled else tabs show a white border. GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); //130, 10, 112, 32, 28, 32 for(AbstractTab abstractTab : RegisterTabs.tabList) { int index = 105 + (abstractTab.getId() * 28); if(this.currentButton == abstractTab) { this.zLevel = 100f; this.drawTexturedModalRect(index, 10, 112, 32, 28, 32); //l, i1, j, k, 28, 32 } else { this.zLevel = 0f; this.drawTexturedModalRect(index, 10, 112, 0, 28, 32); } } //this.zLevel = 100.0F; this.itemRender.zLevel = 100.0F; l = l + 6; i1 = i1 + 8 + (flag1 ? 1 : -1); GlStateManager.enableLighting(); GlStateManager.enableRescaleNormal(); GlStateManager.disableBlend(); this.itemRender.renderItemAndEffectIntoGUI(new ItemStack(Blocks.CRAFTING_TABLE), 138, 19); this.itemRender.renderItemOverlays(mc.fontRenderer, new ItemStack(Blocks.CRAFTING_TABLE), 138, 19); this.itemRender.renderItemAndEffectIntoGUI(new ItemStack(ItemInit.WRITTEN_PAPAR), 167, 19); this.itemRender.renderItemOverlays(mc.fontRenderer, new ItemStack(ItemInit.WRITTEN_PAPAR), 167, 19); GlStateManager.disableLighting(); this.itemRender.zLevel = 0.0F; //this.zLevel = 0.0F; GlStateManager.popMatrix(); // p++; //} } public abstract int getId(); public void setSelected(GuiButton s) { this.currentButton = s; } Register class: public static List<AbstractTab> tabList = new ArrayList<AbstractTab>(); private static final Minecraft minecraft = Minecraft.getMinecraft(); private static void addTabToList(List<GuiButton> buttonList) { for(AbstractTab tab : tabList) { buttonList.add(tab); } } private static void updateTabValues(int cornerX, int cornerY) { for (int i = 0; i < tabList.size(); i++) { int id = 2; AbstractTab tab = tabList.get(i); tab.guiLeft = cornerX + (id - 2) * 28; tab.guiTop = cornerY - 28; tab.setSelected(tabList.get(0)); id++; } } @SideOnly(Side.CLIENT) @SubscribeEvent public static void guiPostInitialize(GuiScreenEvent.InitGuiEvent.Post event) { tabList.clear(); tabList.add(new InventoryTab()); tabList.add(new InventoryQuests()); tabList.get(0).setItem(new ItemStack(Blocks.CRAFTING_TABLE)); tabList.get(1).setItem(new ItemStack(ItemInit.WRITTEN_PAPAR)); if(event.getGui() instanceof GuiInventory) { GuiInventory guiInventory = (GuiInventory)event.getGui(); int guiLeft = guiInventory.width - 176 / 2; int guiTop = guiInventory.height - 166 / 2; updateTabValues(guiLeft, guiTop); addTabToList(event.getButtonList()); } } @SubscribeEvent public static void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event) { GuiButton button = event.getButton(); if(button instanceof AbstractTab) { AbstractTab abstractTab = (AbstractTab)button; switch (abstractTab.getId()) { case 1: for (int i = 0; i < tabList.size(); i++) { tabList.get(i).setCurrentButton(tabList.get(0)); tabList.get(i).setItem(new ItemStack(Blocks.CRAFTING_TABLE)); } event.getGui().mc.displayGuiScreen(new GuiInventory(event.getGui().mc.player)); break; case 2: for (int i = 0; i < tabList.size(); i++) { tabList.get(i).setCurrentButton(tabList.get(1)); tabList.get(i).setItem(new ItemStack(ItemInit.WRITTEN_PAPAR)); } break; default: break; } } } I know it is extremely messy and some places can be changed but I am only looking for how to draw a tab behind the inventory GUI.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.