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.

Kargo

Members
  • Joined

  • Last visited

  1. I am new to coding a minecraft mod, so apologize if I miss some knowledge. Currently, I am trying to create a mod that takes items from the inventory of the player, puts them into a workbench and takes the crafted result. So far everything seems to work fine, I take the item put it in the workbench. So for every item, but when I try to take the craft result or click on of the golden nuggets everything gets moved back to the original slot. Any help for me out there? Thanks in advance! Here is my code: private boolean turn; private boolean gold; protected Minecraft mc = Minecraft.getMinecraft(); public TimeHelper time = new TimeHelper(); public void onUpdate(EventUpdate event) { if (time.hasReached(1000L)) { if (mc.thePlayer.openContainer != null && mc.thePlayer.openContainer instanceof ContainerWorkbench) { ContainerWorkbench workbench = (ContainerWorkbench) mc.thePlayer.openContainer; if (!gold) gold = hasEnoughGold(); takeItemFromInv(workbench); craft(); } time.reset(); } } private void takeItemFromInv(ContainerWorkbench workbench) { int nuggetSlot = 404; int workbenchSlot = 404; if (gold) { if (nuggetSlot == 404) { nuggetSlot = getNuggetSlot(); } if (workbenchSlot == 404) workbenchSlot = getWorkbenchSlot(workbench); if (nuggetSlot != 404 && workbenchSlot != 404) { if (!turn) { mc.playerController.windowClick(0, nuggetSlot, 0, 0, mc.thePlayer); turn = true; } else { mc.playerController.windowClick(workbench.windowId, workbenchSlot, 0, 0, mc.thePlayer); turn = false; } } } } private boolean hasEnoughGold() { int goldAmount = 0; for (int i = 0; i < mc.thePlayer.inventory.getSizeInventory(); i++) { if (mc.thePlayer.inventory.getStackInSlot(i) != null) { if (hasNugget(i)) { goldAmount++; } } } if (goldAmount >= 9) return true; else return false; } private boolean hasNugget(int i) { return mc.thePlayer.inventory.getStackInSlot(i).getDisplayName().equals("Gold Nugget") && mc.thePlayer.inventory.getStackInSlot(i).stackSize == 64; } private int getNuggetSlot() { for (int i = 0; i < mc.thePlayer.inventory.getSizeInventory(); i++) { if (i < 9) { continue; } if (mc.thePlayer.inventory.getStackInSlot(i) != null) { if (mc.thePlayer.inventory.getStackInSlot(i).getDisplayName().equals("Gold Nugget") && mc.thePlayer.inventory.getStackInSlot(i).stackSize == 64) { return i + 1; } } } return 404; } private int getWorkbenchSlot(ContainerWorkbench workbench) { for (int i = 0; i < workbench.craftMatrix.getSizeInventory(); i++) { if (workbench.craftMatrix.getStackInSlot(i) != null) { continue; } else { return i + 1; } } return 404; } private void craft() { ContainerWorkbench workbench = (ContainerWorkbench) mc.thePlayer.openContainer; if (workbench.getSlot(0).getStack() != null) { if (workbench.getSlot(0).getStack().getDisplayName().equals("Gold Ingot")) { mc.playerController.windowClick(workbench.windowId, 0, 0, 1, mc.thePlayer); } } } It is minecraft version 1.8.8

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.