Jump to content

[1.14.4] how to use ItemHandler capability to insert item in slot?


Recommended Posts

Posted

Im exploring the 1.14.4 way of handle items with tileentities and containers. im able to build some chests for holding items etc., but i cant figure out how to generate items like a furnace in a result Slot.

i tried to use the insertItem method from the IItemHandler in the tick() method, but it takes no effect

handler.ifPresent(h -> h.insertItem(4, new ItemStack(Items.IRON_INGOT), false));

or

getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).map(h -> h.insertItem(4, new ItemStack(Items.IRON_INGOT), false));

 

 

whats the correct way?

 

thx for any hints

Posted

ah ok thx.

 

i figured out, it needs a true condition in the isItemValid() method from IItemHandler for the result slot as well as for the Input Slots.

 

now its working… 

 

(Im porting my stuff from 1.13.2 where i used the ISidedInventory implementation, but the ItemHandler stuff seems to be more comfortable)

 

 

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.