ItemStack variable type

Submitted by znaxcy on Sat, 06/22/2019 - 08:52
Upvotes: 2
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

Submitted by Klemen on Sat, 06/22/2019 - 09:08

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.