Topic category: Help with Minecraft modding (Java Edition)
I'm making a machine which takes in an item, waits, and then outputs another time. However, there is a large amount of 'recipes' for this machine. I made a local itemstack variable named "output".
The code does a lot of if statements to find what item is in the input slot; and the output variable is changed depending on which recipe it detected.
Then, I made a piece of code that detects if the output variable has been set to anything, removes 1 of the input, then waits using the wait () ticks then block. In the wait block, I finally set the output item in the output slot.
However, you can't use local variables in the wait () ticks then block.
Using a custom timer for this isn't possible because while and repeat loops don't loop every tick, and because output is a local variable the setting of it and placing the item in the output slot has to be in the same run of the code. There is also no itemstack nbt, so I can't set the output variable to an nbt. The only solution I see for this would be to set the output variable to a string nbt, and then convert it back to an itemstack in the same line that it places the output in the slot, but there is no block for that.
The procedure is called every tick, from the machine.
I have provided an example of the predicament. This code errors.
You could still do this with custom tick based timers and simply not use the items until the timer is done. This way you'll always know which recipe is currently in the works and no items will be lost in case someone breaks the block while it's working.
Thanks for the help. I'm gonna try again with your advice.