CraftTweaker

CraftTweaker

151M Downloads

[3.0.15] the return of .noReturn()

belathus opened this issue ยท 0 comments

commented

Alright, primal core adds a hatchet that is used in a lot of recipes where the hatchet does not get used up. Adding a custom recipe using it, I want it to get used up. Specifically, the recipe I am making would allow you to repair the hatchet using sticks in the crafting grid, and you get the repaired hatchet from the outlet slot.

recipes.addShapeless(<primal:flint_hatchet>, [<primal:flint_hatchet>.anyDamage().marked("hatchet"), <ore:stickWood>], function(output, inputs, crafting) { return inputs.hatchet.withDamage(max(0, inputs.hatchet.damage - 25)); });

This code works, but thanks to PrimalCore, the unrepaired hatchet is left in the crafting grid, basically allowing you to duplicate the hatchet. So, I added .noReturn().

recipes.addShapeless(<primal:flint_hatchet>, [<primal:flint_hatchet>.anyDamage().marked("hatchet").noReturn(), <ore:stickWood>], function(output, inputs, crafting) { return inputs.hatchet.withDamage(max(0, inputs.hatchet.damage - 25)); });

As expected, that destroys the hatchet, stopping the hatchet from being duplicated. Awesome. What happens instead, though, is the stack of sticks is almost doubled. Basically, it decrements the stack by 1, then doubles the stack, so a stack of 64 becomes a stack of 126. It works fine if you only put one stick in the crafting grid; you do get a stack of 0 sticks, though, which is deleted the moment you try to move it.