Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Sided Inventories


Recommended Posts

Hello, I am interested in item handling, much like it is done by buildcraft and redpower. I am relatively new to modding, so here is what I know:

Blocks that are inventories typically are of the BlockContainer type

BlockContainers can have TileEntities tied to them, that can be used to run code for the block

They can also be tied to an IInventory, which handles the inventory of the block



What I want to find out:

What happens when someone 'pushes' an item into an inventory (e.g. pneumatic tube has an item land in it)

How do pneumatic tubes check whether or not inventories can accept items?


I expected to find functions sort of like 'void putItemInSide(ItemStack, int)' and 'bool canFitItemInSide(ItemStack, int), but no such luck

Link to comment
Share on other sites

Hello, I figured part of it out.


After looking at the source code of buildcraft (it is public!) I was able to find out the two following facts:

1) There exists a class net.minecraftforge.common.ISidedInventory, which should be extended by any inventories that are to have different sides.

2) There is no easy way to find whether or not an item can fit in an inventory. The way buildcraft does it, and I hope redpower does the same thing too, is it iterates in all Slots in an inventory, and if their contents are null, figures that it can put in some items, else it calls the finction ItemStack.isItemEqual(ItemStack) to determine whether or not it can place some or all of the stack in that slot. The reason why that is important is because if you wish to make an inventory only accept certain items the you can change the default value of your stacks from null to a custom ItemStack class that will 'equal' all items that you want to put in. This can be used to fix an issue that I have been running into with some buildcraft related mods, which allow you to push some items in slots where they don't belong, e.g. you can put an item in the bucket slots of a Hobbyist's Steam Engine (Railcraft) via pneumatic tubes (meybe bc tubes too, unsure).


I am making a mod that will interact a lot with inventories, so please post ANY information you have on the matter, it can't hurt.

Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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