[Bug] Item dupe with upgrades
andriihorpenko opened this issue ยท 3 comments
Introduction
With the use of upgrades, it is easy to duplicate an item. I will demonstrate it on a video, but first small explanation why this works.
Explanation
Suppose you have a machine which converts 1 cobblestone into 1 scrap (basically a recycler). Normally this works fine until you place an upgrade while the machine is working. It is important that you place an upgrade while a recipe is processing (when the write arrow progresses).
The thing is that when you place an upgrade with mulInput = 8 and mulOutput = 8 while the recipe is processing, machine consumes only 1 cobblestone and outputs 8 scrap. Machine ignores mulInput when recipe is already processing, but still uses mulOutput.
I think there is one possible solution: reset recipe processing once there is a slot change in upgrade slot.
KubeJS upgrade creation
onEvent('cm_upgrades', event => {
event.create(Item.of('custom:upgrade_x8',1))
.machine("custom:metal_press", "custom:recycler",)
.modifier(CMRecipeModifierBuilder.mulInput('custommachinery:energy', 4))
.modifier(CMRecipeModifierBuilder.mulInput('custommachinery:item', 8))
.modifier(CMRecipeModifierBuilder.mulOutput('custommachinery:item', 8))
})
Video
Screen.Recording.2023-05-17.at.13.58.15.mov
Sounds awesome! Whenever you have a working version of the mod with a fix, I can test it right away under the same conditions ;)
That's an important bug, thanks for reporting it.
I don't really like the idea of resetting the process when an upgrade is applied or removed, that would mean losing the already consumed inputs.
Instead I could make it so upgrades are checked at the start of the recipe and non-tickables requirements will always use these upgrades even if the content of the upgrade slot changed.
For tickable requirements, (including the speed) I don't see any issue to let them work as they do currently and check the applied upgrades every ticks.