Jump to content

Check if player has at least a certain ammount of multiple items to do something.


Recommended Posts

Posted

I made a upgradable block similar to the "wooden frame" from 7 days to die. I want it when the player tries to upgrade a wooden frame, it searches the players inventory for if they have:

 

at least 10 oak boards (an item I will add to my mod)

and at least 5 iron nails (another item I plan to add)

 

If they have the items, they can then proceed to upgrade the block in which said items will be removed.

 

I am currently searching for a way to implement this.

Thanks for any help.

Posted

You can get the inventory of an EntityPlayer object, check through it for your ItemStacks, check if they're large enough, and, if those checks are passed, shrink the stacks by your amounts.

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

Posted
20 hours ago, diesieben07 said:

So what? You know how to write a for loop, right? This is basic programming.

I know about for loops, the thing is I do not know how to do the math/code behind "if the first slot runs out find another slot with the same item and use that".

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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