BeansGalaxy / Beans-Backpacks-2

1.20 inventory management mod. Designed to solve inventory clutter and transferring items while belonging in vanilla Minecraft's aesthetic.
MIT License
21 stars 1 forks source link

[Bug] Broken EMI recipes #61

Closed nimbXnumb closed 2 months ago

nimbXnumb commented 5 months ago

Mod version: 20.1 - 0.12-v2 Minecraft version: 1.20.1 Fabric

Bug description: Broken recipes for all of the backpacks when using EMI

BeansGalaxy commented 5 months ago

I'll look into adding support for it, for now JEI is supported in Forge and REI is supported in Fabric but this mod looks super nice

SaltSouls commented 4 months ago

I would like to add to this as this seems to be specifically an issue with the NBT side of how the backpacks are rendered. I would like to ask, is there a reason for this? Why not just make each backpack have its own item, instead of the metal backpack sharing the same item but changing how it looks based on an NBT tag? I'm curious why this approach was chosen over just having basic items, as I feel that would be a lot simpler to implement and work with.

Besides that, it would seem the problem may lay in the fact that this mod has its own custom way have handling crafting using the base crafting table to allow for things like NBT to be added to items. The problem with this is that EMI isn't able to(or at least from what I can tell) properly read the information being passed through, specifically when a backpack is used as an ingredient in a recipe(though sometimes when it is an output as well). I've managed to get around this using KubeJS by forcing a hard NBT check using their strongNBT() function. This manages to fix the displayed backpack in EMI recipes. Maybe looking into how that is working and implementing it into your custom recipe handler would be a way to fix it?

BeansGalaxy commented 4 months ago

You can add custom backpacks through data packs so I just have a dyable item beansbackpacks:backpack, a trimmable item beansbackpacks:metal and a trimmable fire proof one beansbackpacks:upgraded. So the nbt tells my mod to read the list of added backpacks for its other properties.

Since looking into support I've gone down a rabbit hole of re-thinking this whole system since JEI & REI work but aren't perfect. Can you attach a link to the code you use to fix that, I'm unfamiliar with KubeJS so somewhere to start would help

Also after all this in the latest snapshot mojang decides to remove nbt and the new system has all the answers I'm looking for.

SaltSouls commented 4 months ago

Here is an example of what I mean when using KubeJS:

ServerEvents.recipes(event => {

    let MC = (id) => 'minecraft:' + id

    let leather_backpack = Item.of('beansbackpacks:backpack', '{display: {key:"leather"}}').strongNBT()
    let iron_backpack = Item.of('beansbackpacks:metal_backpack', '{display: {key:"iron"}}').strongNBT()

    event.shaped(leather_backpack, [
        'SLS',
        'LGL',
        'LLL'
    ], {
        L: 'kubejs:leather_sheet',
        S: 'kubejs:leather_strip',
        G: MC('gold_nugget')
    }).id('beansbackpacks:leather_backpack')

    event.shaped(iron_backpack, [
        'PDP',
        'IBI',
        'III'
    ], {
        I: MC('iron_ingot'),
        B: leather_backpack,
        D: MC('diamond'),
        P: MC('phantom_membrane')
    }).id('beansbackpacks:iron_backpack')

})

The part I refer to is the strongNBT() function being called. Somehow that is telling the recipe/EMI that it requires this item with this exact NBT data. I'm not sure how specifically that is working as I haven't looked through the KJS code, but I know that without strongNBT() the recipe will display a null texture square in place of the backpack and won't specify the NBT requirements when being used as an ingredient.

BeansGalaxy commented 2 months ago

Solved a LONG time ago and I guess I never closed it :) have a good day