transformConsume and onlyStack consuming other items in recipe
0xebjc opened this issue ยท 2 comments
Intro:
I'm trying to create a crafting recipe that retains some of the ingredients, consumes some of the other ones to include a multiple size stack in one the ingredient slots, and deducts experience.
Issue Description:
Other items marked as ".reuse()" are getting consumed "seemingly randomly depending the amount of their stack size.
What happens:
The recipe only works correctly if I put double or more of the amount of diamonds in the second slot. After taking the output item there is exactly the "onlyStack" size of diamonds or more remaining. If I set both the transformConsume and onlyStack to 4, then 8 or more will make the recipe work.
If I put less then then double the transformConsume and onlyStack amount. say I set them both to 4. then if I put 4, 5 ,6 or 7 diamonds in the second slot, by taking the output item the other items get consumed as well to include items that I've marked as ".reuse()"
Also when the recipie doesn't behave correctly, I still get the output item, but no experience is removed.
In one case I got some kind of integer (under or over flow) and the number of anvils went to 112, even though the stack size max is 64.
I've tried the above with moded items and only vanilla items and the same effect.
What you expected to happen:
I should be able to put 4 or more diamonds in the second slot only consume 4 diamonds and the sword in the middle and the ".reuse()" items should not be consumed ever.
Script used (Please Pastebin or gist your script, posting an unpasted or ungist'd script will automatically close this issue):
crafttweaker.log file (Please Pastebin or gist your file, posting an unpasted or ungist'd file will automatically close this issue):
Affected Versions (Do not use "latest"):
- Minecraft: 1.12.2
- Forge: forge-1.12.2-14.23.5.2768-universal
- Crafttweaker: CraftTweaker2-1.12-4.1.17
- Using a server: No
- If yes, does the client have the exact same scripts?
Your most recent log file where the issue was present:
[pastebin/gist/etc link here]
https://pastebin.com/EcpDUTNS
https://pastebin.com/ehiWjdCj
https://pastebin.com/4Rxdc2EG
https://pastebin.com/rf0QGZnw
https://pastebin.com/KNzmL1fg
https://pastebin.com/AexNdxqu
https://pastebin.com/CdXK6Wu9
https://pastebin.com/SDS7Nnu6
https://pastebin.com/YnM0e1yw
I have more logs, but pastebin will not allow me as a guest to paste more in right now. I don't think this is pertinent though because the log did not show anything out of the ordinary regarding the recipe.
multiple size stack in one the ingredient slots
We don't, vanilla doesn't and most mods don't support stacked crafting like you're trying to do.
Here's the code I can create the issue with:
recipes.addShaped("Enchanted_Anvil", <minecraf:diamond_sword>, [
[null, <minecraf:diamond>.transformConsume(4).onlyStack(4) * 4, <tp:stone_hammer>.reuse()],
[null, <minecraft:golden_sword:*>.marked("input_item"), null],
[null, <minecraft:anvil>.reuse(), null]],
function(out, ins, crafting) {
if crafting.player.xp >= 8 {
crafting.player.sendChat("Players Level is " ~ crafting.player.xp);
if(ins.input_item.tag has "ench") {
return out.withTag({ench: ins.input_item.tag.ench});
} else {
return out;
}
} else {
return null;
}
}, function(output, crafting, player) {
var xpLevelCost = 8;
player.xp -= xpLevelCost;
player.sendChat("Removed " ~ xpLevelCost ~ " XP Levels.");
});