minetest-mods / i3

:rocket: A next-generation inventory for Minetest 5.6+
Other
41 stars 26 forks source link

Replacements do not work in quick crafting #92

Open GreenDirkfried opened 1 year ago

GreenDirkfried commented 1 year ago

When a recipe has a replacement defined, like for example the replacement of a bucket with water with an empty bucket (see for example the hemp fibre recipe in farming), then quick crafting does not give you this new item (e.g. the empty bucket) :-/

kilbith commented 1 year ago

Please follow the issue template.

It was supposedly fixed in https://github.com/minetest-mods/i3/issues/87

GreenDirkfried commented 1 year ago

Ok, I understand now that the bug is maybe another mods fault.

To reproduce: Use the latest MT release 5.6.1 and the currently latest versions of all of the following the mods from the minetest database. Use Minetest Game with the mods: i3, Farming Redo, HUD bars, Hunger with HUD bar, Armor HUD bar.

Then craft a "Hemp Fibre" per quick crafting, where the crafting recipe is given in https://notabug.org/TenPlus1/farming/src/master/crops/hemp.lua#L77

minetest.register_craft( {
    output = "farming:hemp_fibre 8",
    recipe = {
        {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"},
        {"farming:hemp_leaf", "group:water_bucket", "farming:hemp_leaf"},
        {"farming:hemp_leaf", "farming:hemp_leaf", "farming:hemp_leaf"}
    },
    replacements = {{"group:water_bucket", "bucket:bucket_empty"}}
})

The problem is now that there is no empty bucket left.

kilbith commented 1 year ago

Can you try this? https://github.com/minetest-mods/i3/commit/c9e02dfe094492ca23f5feab4c0d76a0a8fd6063

kilbith commented 1 year ago

To get the replacements from Quick Crafting safely, you have to declare your recipes after i3 has loaded in the mod initialization order. If your mod is named after "i" or have a dependency with i3, the replacements will work.

The problem is that craft recipe getters do not return replacements and I'm forced to override core.register_craft from i3 to create an index of replacements per recipe.

GreenDirkfried commented 1 year ago

I updated i3 from the database (your new commit is included there) and tried the quick crafting again as described before and it still does not work.

GreenDirkfried commented 1 year ago

Adding "i3" to the optional dependencies of farming solves the issue :-) But, sure, this replacement problem should not be solved by adding dependencies :-D