Shadows-of-Fire / FastWorkbench

Caching recipes in the crafting table
MIT License
23 stars 17 forks source link

Able to dupe items while crafting by using hotbar first #62

Closed leemmcc closed 3 years ago

leemmcc commented 3 years ago

Whether player crafting or on a table, on a clean forge install on 35.1.28, with FastWorkbench-1.16.3-4.4.1 and Placebo-1.16.3-4.3.3 you can duplicate items while crafting if you press a hotbar space first. For example with torches:

Have an empty spot on your hotbar (for this example lets use slot 3) Place 3 sets of sticks/coal in the crafting window. Press 3 on your target item to put 1 craft of torches into the hotbar slot, then shift-click the rest of craft result - you get 4 total crafts (16 torches)

If you do this with 4 stacks of mats, you get 8 crafts, 5 stacks = 16 crafts, 6 stacks = 32 crafts, and so on. This even works with single mats like logs into planks.

Shadows-of-Fire commented 3 years ago

Well this was hell to track. Turns out pressing a number key doesn't take a copy of the stack in the slot, and attempts to swap the LITERAL stack in there, which for a crafting result isn't "real" so it ends up modifying the underlying result stack, which is terrible.

This causes not only the dupe issue, but if you were to, say, attempt to craft something by placing the items in, and hitting 1,2,3,4,5,6,7,8 in that order, and then attempt to click on one of those slots, ALL of those slots (and the result slot) are holding the same itemstack object, and so clicking on one will delete all of them.

In short, there's a reference leak. There's, weirdly enough, a strange little hook in vanilla at this exact call site that should allow me to negate it.