i3 icon indicating copy to clipboard operation
i3 copied to clipboard

Replacements do not work in quick crafting

Open GreenDirkfried opened this issue 2 years ago • 6 comments

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) :-/

GreenDirkfried avatar Feb 17 '23 08:02 GreenDirkfried

Please follow the issue template.

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

kilbith avatar Feb 17 '23 12:02 kilbith

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.

GreenDirkfried avatar Feb 17 '23 15:02 GreenDirkfried

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

kilbith avatar Mar 05 '23 13:03 kilbith

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.

kilbith avatar Mar 05 '23 14:03 kilbith

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 avatar Mar 06 '23 08:03 GreenDirkfried

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

GreenDirkfried avatar Mar 06 '23 08:03 GreenDirkfried