Quilted Fabric API (QFAPI) / Quilt Standard Libraries (QSL)

Quilted Fabric API (QFAPI) / Quilt Standard Libraries (QSL)

441k Downloads

All items can be crafted into charcoal when BetterEnd for Fabric is installed

quiqueck opened this issue ยท 5 comments

commented

When BetterEnd (for Fabric) is used with Quilted Fabric API all items in the game can be crafted into charcoal.

If I remember correct, a charcoal result did mean, that something about the recipe was not working correct. But this does not only affect the custom recipes our Mod creates, but also vanilla Items (like a crafting table).

Running everything in Fabric works just fine. Unfortunately I am unsure how to narrow this down. The logs do not contain any indication of failing code or the oddities. Any hints/help would be appreciated.

For Reference, this is the issue on our mod: quiqueck/BetterEnd#41

commented

Hello! I've tested with only BCLib, BetterEnd and QFAPI installed, and unfortunately, I couldn't reproduce this; With the long list of mods used on the original issue, I believe that it could be a different mod that's conflicting somewhere, or perhaps not even conflicting with QFAPI at all;
I'll keep this issue open since yeah, it's still a possibility that this involves QFAPI, however, I don't think it's BetterEnd's fault

commented

Thanks for the fast reply. I really appreciate it. In the meantime I got another issue quiqueck/BetterEnd#44 that appears to have the same issue with just BCLib/BetterEnd.

commented

I think I found the Problem:

FuelRegistry.INSTANCE.add(block, 16000);

When the BlockItem for that block is not yet registered/created it will get created by that call in Quilt. Whenever I call .asItem()on that Block, it will return the default AIR-Item. When this Block is used as an Recipe Ingredient (which it is in a recipe that turns this CharCoalBlock into 9 Charcoal), the Recipe will be matched for everything. Which is what players are seeing.

With the regular Fabric API, the above call will not create an empty Item.

Looking at the code, that empty item is probably generated here:

The item.asItem() will (for a Block) result in a call to Item.fromBlock, which in turn will return (Item)BY_BLOCK.getOrDefault(block, Items.AIR);. So this call is basically generating a new entry for a block before it was created.

commented

Wow that is a super niche bug! I'm surprised that it wasn't an issue on Fabric, since the API is very similar

commented

This does explain why out of everything, the charcoal block is the one affected; Considering that this is the item content registry that you're touching and that the fuel times should be registered after the block's block item is registered, I'm considering this to be an external issue that can't reasonably be fixed by us (although if it turns out to be widespread, we could perhaps attempt a hacky workaround, which I doubt that it's the case)

The backbone of the Quilt Item Content Registry API, the Quilt Registry Entry Attachment API (REA), requires the item to be registered beforehand so it can, well, attach the relevant value to the registry entry, and yeah, the old approach to adding the charcoal block's fuel time is one that could very well fail if the block doesn't have an equivalent block item in the first place;

So, yeah, I'll be considering this an external issue caused by hacky shenanigans; Your fix to the solution (moving the fuel time registration to after the items were registered) is pretty much the equivalent of what the other mods do and it should be a more stable solution in the long run