Started by
Linkdeous
on
Topic category: Help with Minecraft modding (Java Edition)
Hello! Im searching how to get a inventory's max number of slot from a tile entity !
What i'm trying to do is to make a entity that can grab/deposit from containers, and for that i need to check each slot of any given chest,hopper,container,modded,vanilla, .... and try to grab a item if there is one, or deposit one if there is space/a slot that fit the item the entity is holding
So far i'm trying to use custom code snippets, but as always, making them work is such a pain in the ass, i'm trying to make use of the getSizeInventory(), but so far, can't make it work at all
This is the code i had so far, but doesnt work
I would really like any help if possible !!!!
found a solution thanks to Van over discord, here's a custom snippet for anyone that would need to get the slot number !
say your local variable for max slot of block at x,y,z is named numb :
it will return slot 0 for a inventory with 1 slot (because the slot count starts at 0), and -1 if it doesnt have an inventory, usefull for checking if you should do or not your inventory checks !
(and of course it will return 26 for the max slot of a chest, 2 for the max slot of a furnace, any number of max slot for a modded container,...!)
if i tryed it, i cannot find out what i need to import. Can you say me what things i need to have imported?
Can you change the x y z to local variables? (I use Xpos Ypos Zpos)