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.

Featured Replies

Posted

Let's suppose I have two stone blocks in the player's inventory. How can I now craft stone pressure plate without a human interaction?

Lets suppose you have two stone blocks, two plank blocks, a stick, and some coal.

What should get crafted?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

It should get crafted on some event. If that matters, I need it to get crafted on PlayerTickEvent when some conditions are satisfied. And the output should go to the player's inventory, preferably some empty slot in the hotbar.

  • Author

So the class EntityPlayer has the field inventoryContainer. That's what you're telling me about, right?

I've tried to do some manipulations with slots, however it seems that the server doesn't allow me to do that in such a way or doesn't know what I've done there.

//Take 2 items from the first slot in the hotbar. Just imagine you have 2 stone blocks in your first hotbar slot
ItemStack s1 = player.inventoryContainer.getSlotFromInventory(player.inventory, 0).decrStackSize(1);
ItemStack s2 = player.inventoryContainer.getSlotFromInventory(player.inventory, 0).decrStackSize(1);
//                                                                                       |1|2|
//Now put obtained ItemStacks to the crafting grid. It has the following slot numbering: |3|4|. Craft result slot is number 0
player.inventoryContainer.putStackInSlot(1, s1);
player.inventoryContainer.putStackInSlot(2, s2);

//Finally put the result to the first hotbar slot
player.inventory.addItemStackToInventory(player.inventoryContainer.getSlot(0).decrStackSize(0));

 

Edited by ZhabaKlava

maybe try looking at ItemBow how to consume items if they're in inventory and then just give player new item ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.