FabricMC / fabric

Essential hooks for modding with Fabric.
Apache License 2.0
2.33k stars 411 forks source link

Issues with fabric:components custom ingredient type #4170

Open vico93 opened 3 days ago

vico93 commented 3 days ago

I think i'm the only one that uses the very niche "fabric:type": "fabric:components" custom ingredient that Fabric introduces for .json recipes to fine-grained ingredient picking (basically, select only item with specific components - or NBT for older versions).

I did a recipe to make mud with a dirt block and a water bottle with the following .json:

{
    "type": "minecraft:crafting_shapeless",
    "ingredients": [
        {
            "item": "minecraft:dirt"
        },
        {
            "fabric:type": "fabric:components",
            "base": {
                "item": "minecraft:potion"
            },
            "components": {
                "minecraft:potion_contents": {
                    "potion": "minecraft:water"
                }
            },
          "strict": true
        }
    ],
    "result": {
        "id": "minecraft:mud",
        "count": 1
    }
}

Although it worked - shows in REI and when i manually put the dirt and the water bottle on the crafting it outputs the mud block - i noticed some issues with this recipe:

First thing is that the water potion isn't pulled to the crafting table (while the other "normal" ingredient - dirt - goes normally) when the recipe is select with either the vanilla recipe book or REI: 2024-10-16_15 04 07 While the recipe is shown normally on REI's recipe preview (but clicking on + gives the same issue of the recipe book): 2024-10-16_15 04 13

The other thing is that, at least with water bottles, an empty bottle isn't returned to the inventory when the crafting is done - similar to how crafting with water/lava/milk buckets works. Maybe adding another field to specify the "return" item could be a solution to achieve consistency between bottle and bucket recipes, or just defining internally that filled bottles should return empty ones would be enough.

MC 1.21.1, Fabric 0.16.7 and Fabric API 0.106.0+1.21.1

modmuss50 commented 3 days ago

Hi, this sounds like a valid problem, I do wonder how this behaves in 1.21.2 as the recipe book works quite diffrently now.

I expect REI has its own logic for this so might be worth seeing if anyone has had this issue before over there?

As for the empty bottle, this is up to the item to impliment [getRecipeRemainder()](https://maven.fabricmc.net/docs/yarn-1.21.2-pre5+build.2/net/minecraft/item/Item.html#getRecipeRemainder()) this is unlikely something we would do for potions.

vico93 commented 3 days ago

Hi, this sounds like a valid problem, I do wonder how this behaves in 1.21.2 as the recipe book works quite diffrently now.

I expect REI has its own logic for this so might be worth seeing if anyone has had this issue before over there?

As for the empty bottle, this is up to the item to impliment [getRecipeRemainder()](https://maven.fabricmc.net/docs/yarn-1.21.2-pre5+build.2/net/minecraft/item/Item.html#getRecipeRemainder()) this is unlikely something we would do for potions.

So for the water bottle to leave a empty bottle that would require a separate mod?