Inconsistencies with Vanilla CraftTweaker recipes
copygirl opened this issue · 5 comments
Issue Description
CraftTweaker recipes function differently in Vanilla crafting tables and AW worktables.
Steps To Reproduce
/give @p pyrotech:bucket_wood
/give @p clay_ball 64
- Craft empty bucket with clay ball in any AW worktable.
- A partially damaged wooden bucket is left behind in the crafting grid.
- Place the resulting partially filled bucket (with 4 units of clay) into the grid.
(Make sure to not leave clay behind in the crafting grid, or... #240.) - The crafting result is a clay ball as expected.
- The recipe puts an empty bucket into the player's inventory.
- The partially filled bucket in the crafting grid now has 3 units of clay in it.
This could be the result from applyinggetContainerItem
..?
What You Expect to Happen
I expect the same behavior as in the Vanilla crafting table.
Script
Affected Versions / Used Mods
- Minecraft: 1.12.2
- Forge: 14.23.5.2854
- CraftTweaker: 4.1.20.576
- Artisan Worktables: 1.23.2
- Athenaeum: 1.18.1
- Pyrotech: 1.4.29
- Dropt: 1.18.0
- Hardcore Bytes Mod: 0.1.0-SNAPSHOT+8da5861
- Immersive Engineering: 92
how does that have anything to do with artisan worktable? 🤔
what you linked is just about pyrotech and vanilla crafting table recipes
@Mrthomas20121: If you try crafting the same recipes in a Vanilla crafting table (or the 2x2 inventory grid), you get a different result. The bold highlighted points are what differs in AW tables.
Can we simplify the reproduction? Can it be reproduced with just Minecraft, Forge, CrT, and AW (and lib)?
This was caused because Artisan Worktables (AW) incorrectly handled remaining items. The call to getRemainingItems
allowed returning items to the crafting grid, but did not allow explicitly declaring a slot empty. Items in the remaining items list were merged back into the crafting grid after all slots were reduced, while empty slots in the remaining items list were simply ignored.
The call to getRemainingItems
now returns an authoritative list of the remaining items. Responsibility for reducing item slots has also been transferred to the getRemainingItems
method.
This solves the issue and reveals another.
When removing a clay ball from a wooden bucket, the remaining wooden bucket always has 7 / 8 durability. With a vanilla table, the remaining wooden bucket is always 8 / 8.
I believe this discrepancy in behavior is caused by the order of operations.
Pyrotech (Pt) uses the PlayerEvent.ItemCraftedEvent
to damage remaining buckets and CraftTweaker (CrT) also uses the same event. Both mods use the event at the same priority level which means dispatch order is undefined.
My assumption is that when crafted in the vanilla table, the event is received first by Pt, then by CrT, and when crafted in the AW tables, the transforms are always applied before the event is fired. When fired from the AW tables, the event will be ignored by the CrT stuff because its inventory isn't an instance of vanilla's InventoryCrafting
, which is expected behavior. Pt still picks up the event, though, and damages the bucket after the transforms have been applied.
This is, however, an entirely new issue and shouldn't be tacked onto this one.