ItemStack variable type

Published by znaxcy on
Issue description

tl;dr: create a "type" of variable whereby we can conveniently store itemstack data both locally and globally. It'd be a new setting for a string variable that could be easily programmed using the block editor.

 

An example, so you can tell me I'm doing it all wrong and this idea is dumb:

Ran into an issue recently while trying to create multiple custom blocks (each with a different model) that replace each other when a user changes the number of items in the block's inventory (ie: the user adds fruit to a crate and the crate appears to "fill" in stages as more fruit is added).

I take Block A and test for the number of items in an inventory. If it's within a certain range, I remove Block A and replace it with Block B. (Same as the common "crops" workaround (to the "we don't have blockstate control yet" issue.) The question though, becomes: how do I move the inventory of Block A to Block B? For the number of items, that's easy enough: establish an int variable for each slot, test for it before removing Block A and set the same slot on Block B to the value of the int variable.

But what about what the itemstack? I'm sure that with some coding I could make it happen, but wouldn't it be cool (and useful in many other procedures to code noobs like me) to have a shortcut that does this for us? Another "type" of variable that can store the itemstack info locally or globally and be called back later, even in another procedure.

The next issue to sort out is the fact that when I change the block I lose the GUI association, so really for this application I should just wait for blockstate control to be implemented or figure out how to code it myself, but I imagine the idea could be useful in a myriad of other ways.

Issue comments

Yes, this would indeed need to be solved using blockstates, not using variables for moving items. Itemstack variable type is still a nice idea so we will consider adding this in the future updates.

Yes please consider this Idea, lots could be created such as backpacks, and even custom Ender Chests as this variable would allow for even special machines that must check if components in other blocks are put in, all from one central block.