Jump to content

[SOLVED][1.15.2] Container with ItemStackHandler


BastouP

Recommended Posts

Hey everyone !
I can't find a way to create a container with an ItemStackHandler, the only thins I find are with Inventories.
Does someone know how to do it or is there a good tutorial/explaination somewhere ?
Thanks ^^

Edited by BastouP
Link to comment
Share on other sites

16 hours ago, BastouP said:

Hey everyone !
I can't find a way to create a container with an ItemStackHandler, the only thins I find are with Inventories.
Does someone know how to do it or is there a good tutorial/explaination somewhere ?
Thanks ^^

Howdy

 

You could get some clues from the Botania mod, it uses ItemStackHandlers and Capabilities instead of IInventory eg ItemFlowerBag.

https://github.com/Vazkii/Botania/blob/master/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java

 

The only potential problem with SlotItemHandler and ItemStackhandler instead of IInventory is that IInventory is also used by vanilla to tell the source container (typically TileEntity) that the GUI has modified the slot contents (marked it as "dirty").  But SlotItemHandler and ItemStackhandler don't do that. 

 

There are some knowledgeable folks on this forum who think that it doesn't matter because the source container is marked as dirty in other ways; they might be right although I'm not convinced yet.  I haven't tested it empirically yet (on my to-do list).  Up until now I've played it safe and wrapped the ItemStackHandler in an IInventory.  If you decide to test it yourself, please let me know...

 

-TGG

 

Edited by TheGreyGhost
  • Like 1
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.

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.