Block Inventory Handling

Started by Shadetree on

Topic category: Feature requests and ideas for MCreator

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Block Inventory Handling

using 2021.2 for 1.16.5 currently

A couple of procedure blocks that would come in very handy, at least in my own little project having to do with block inventories.  And there may be ways to do these simply that I just have not figured out and if that's the case educate me please!

 

"Add <number> <itemstack> to block at <x> <y> <z> if it has inventory" :Similar to the player procedure.  As it stands you need to know how many slots the block has and write code to loop through them all to put an item in a block inventory.  This would be useful for many reasons but mostly for sided output and compatibility with other mods. iron chests, barrels, etc.

"Get max stack size of <itemstack>"  Especially without something like the above when I'm testing an inventory slot it would be nice to know what the stack size is of something you are attempting to put into that slot.  As it stands I have to check for stack sizes manually and if i could do a code block like

IF ("get copy of item in slot....." = <myItemstack>) AND (get number of items in slot..." < "Max stack size of <myItemstack>")

it would be way more compact and useful than writing multiple IF statements checking for say enderpearls, or waterbuckets.  where I've come into the most difficulty without something like this is say I want to generate a random item from a forge tag.  there is no way to check for mod compatibility of the hundreds of other mods that might be using that tag and knowing what they set the stack sizes of their items to be.

 

The following would just be QOL

Grow Slot and Shrink Slot procedure blocks for Block management.  I know you can do "set (get + 1)" which is the same functionality but at the end of the day I'm a lazy person who likes clean, readable procedures.

 

There may be plugins that have these procedures or similar but I haven't found them, or they are discontinued, and I'd like to future-proof my mod to port to 1.17 and beyond.  The only plugin I'm currently using is the Random one cause those procedures are super useful to me and my sanity.

 

And again, If I'm missing something obvious, I've only been using MCreator for a few months and maybe I'm doing things the hard way.

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
currently for the first one…
Wed, 11/17/2021 - 00:58

currently for the first one what I do is make a local variable called slotID, then I repeat it the number of slots the gui has. then if slotID slot is free or non 64, I send the items and finish the loop, however if it's not free I increase slotID + 1

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Right its exactly what i do…
Sat, 11/20/2021 - 18:07

Right its exactly what i do.  you have to loop through every slot. compare the itemstack to the slot contents. add them to the slot. but what if youre trying to add an amount that takes it bigger than 64 or the stack size is different, so you have to deal with the remainder and move on to the next slot, etc, etc.  breaking out when your itemstack is 0.  It ends up being a large procedure just to "Put this item into a chest"  The codes already there to do it in minecraft.  so why reinvent the wheel everytime? what takes a simple shift+click in the gui takes like 18+ PB's in a procedure.

 

Its a pain, but it's doable IF you know the number of inventory slots that block has.  What if I have a machine that I want to output to adjacent inventory?  What if I want it to be compatible with other mods that have chests or machines that have nonstandard inventory sizes, like Iron Chests?  you can't, that I've found. So Im asking to Either simplify block inventory management with a single procedure that handles it OR give us the ability to enumerate a blocks inventory slots so we can do it ourselves.

Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if you have tile entities…
Sun, 12/19/2021 - 17:58

if you have tile entities with non-standerdized inventory sizes you can use Get number of items in provided itemstack with a less than or equal to 0 in an if statment that removes 1 of those items

Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you can also get the total…
Mon, 05/02/2022 - 18:43

you can also get the total number of slots of a block in a given position