KubeJS-Mods / KubeJS

https://kubejs.com
GNU Lesser General Public License v3.0
309 stars 91 forks source link

Recipe Event Listener Makes "Rope Arrows" From Supplementaries Uncraftable #797

Open Alvin21Bon opened 8 months ago

Alvin21Bon commented 8 months ago

Minecraft Version

1.20.1

KubeJS Version

2001.6.4-build.107

Rhino Version

2001.2.2-build.18

Architectury Version

9.2.14

Forge/Fabric Version

Fabric 0.15.7

Describe your issue

Issue

Initially there is no conflict, but after adding ServerEvents.recipes(event => {}) in server_scripts and reloading the game rope arrows become uncraftable. I have also tested this on most versions of KubeJS for 1.20.1 and the bug still persists.

image

Steps to Reproduce

  1. Fresh instance with Supplementaries, KubeJS, and dependencies
  2. Load into world and notice how rope arrow recipes are functioning as normal
  3. Add ServerEvents.recipes(event => {}) to server_scripts and reload the game

More Info on Rope Arrows

For more info, any amount of rope in the crafting grid should be a valid recipe. Rope arrows have a repairable durability that is repaired by crafting it with more rope. In the image, the output should have been a rope arrow item with a durability of 4.

Crash report/logs

No response

ChiefArug commented 8 months ago

This is so weird. Usually this is caused by mod using mixins to the recipe manager to add recipes which fails because KJS cancels that, but this appears to be a normal custom recipe type (code for reference).

Alvin21Bon commented 8 months ago

Definetely is weird, the author of Supplementaries also said there shouldn't be any issues to their knowledge since their implementation is all standard. I was trying to find other recipes that might break in my modpack, but I was unable to.

ChiefArug commented 8 months ago

Does the other special recipe type break too? (iirc its adding rope to a rope arrow)

Alvin21Bon commented 8 months ago

Oh yes, that also does not work for me. If you have a rope arrow of let's say twelve durability, it is unable to be repaired with more ropes when crafting

On Wed, Mar 6, 2024, 1:07 AM ChiefArug @.***> wrote:

Does the other special recipe type break too? (iirc its adding rope to a rope arrow)

— Reply to this email directly, view it on GitHub https://github.com/KubeJS-Mods/KubeJS/issues/797#issuecomment-1980151287, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZWJ7RWFLH3N5523ZSDNV2TYW2XBNAVCNFSM6AAAAABD6O3S5SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBQGE2TCMRYG4 . You are receiving this because you authored the thread.Message ID: @.***>

MaxNeedsSnacks commented 8 months ago

Q: what happens if you add

ServerEvents. specialRecipeSerializers(event => {
  event.addSpecialMod("supplementaries");
})

to your server scripts?

Alvin21Bon commented 8 months ago

With the following file in server scripts:

ServerEvents.recipes(event => {})

ServerEvents. specialRecipeSerializers(event => {
    event.addSpecialMod("supplementaries");
})

The issue still persists with both forms of crafting rope arrows. The issue is again fixed when the recipe event listener is removed:

// ServerEvents.recipes(event => {})

ServerEvents. specialRecipeSerializers(event => {
    event.addSpecialMod("supplementaries");
})
MaxNeedsSnacks commented 8 months ago

Okay so it's not because KubeJS doesn't see the recipe as special... eugh

Alvin21Bon commented 8 months ago

Must be one of those extremely annoying bugs that crop up 🙃

kkempfer commented 4 months ago

I am facing the exact same issue with Minecraft 1.19.2 using the latest versions of all the mods mentioned above. The bug is reported in my modpack: https://github.com/kkempfer/Create-Survive-Explore/issues/1

I found a workaround by hiding the existing broken rope arrow recipe and creating a fresh recipe using KubeJS. See below:

instance/kubejs/server_scripts/recipes.js

ServerEvents.recipes(event => {

    // Fix broken rope arrow recipes
    // We are not able to fix and remove rope arrow recipes, so we hide them. See `kubejs/client_scripts/rei.js`
    // event.remove({ id: 'supplementaries:rope_arrow_create_display' })
    // event.remove({ id: 'supplementaries:rope_arrow_add_display' })
    const MAX_DAMAGE_ROPE_ARROW = Item.of('supplementaries:rope_arrow').getMaxDamage()
    // Define the recipe for creating the rope arrow
    for (let i = 1; i <= 8; i++) {
        event.shapeless(
            Item.of('supplementaries:rope_arrow', { Damage: MAX_DAMAGE_ROPE_ARROW - i }),
            ['minecraft:arrow', `${i}x supplementaries:rope`]
        );
    }

});

instance/kubejs/client_scripts/rei.js

// Hide multiple recipes from REI. This does not remove recipes
REIEvents.removeRecipes(event => {
    const recipesToHide = [

        // Supplementaries

        // We are not able to remove broken rope arrow recipes, so we hide them
        'supplementaries:rope_arrow_create_display',
        'supplementaries:rope_arrow_add_display',

    ];

    event.removeFromAll(recipesToHide);
});

I am still working on a workaround to be able to repair a rope arrow. Does someone have a solution ?

kkempfer commented 4 months ago

I found a workaround to repair the rope arrow. I basically create custom recipes for each NBT state. It's not the cleanest approach, but it does the job. If someone has a more efficient solution, I would be happy to see it.

ServerEvents.recipes(event => {

    // Fix broken rope arrow recipes
    // We are not able to fix or remove rope arrow recipes, so we hide them. See `kubejs/client_scripts/rei.js`
    // event.remove({ id: 'supplementaries:rope_arrow_create_display' })
    // event.remove({ id: 'supplementaries:rope_arrow_add_display' })
    const MAX_DAMAGE_ROPE_ARROW = Item.of('supplementaries:rope_arrow').getMaxDamage();
    // Define the recipe for creating the rope arrow
    for (let i = 1; i <= 8; i++) {
        event.shapeless(
            Item.of('supplementaries:rope_arrow', { Damage: MAX_DAMAGE_ROPE_ARROW - i }),
            ['minecraft:arrow', `${i}x supplementaries:rope`]
        );
    };
    // Define the recipe for repairing the rope arrow
    for (let j = 1; j <= MAX_DAMAGE_ROPE_ARROW; j++) {
        for (let i = 1; i <= Math.min(j, 8); i++) {
            let damagedRopeArrow = Item.of('supplementaries:rope_arrow', { Damage: j }).strongNBT();
            let repairedRopeArrow = Item.of('supplementaries:rope_arrow', { Damage: j - i });
            event.shapeless(
                repairedRopeArrow,
                [damagedRopeArrow, `${i}x supplementaries:rope`]
            );
        };
    };

});

NB: If you replace the "supplementaries:rope" by another kind of rope, e.g. "farmersdelight:rope", you will get a similar result.

darceno commented 2 months ago

Weirdly, this issue also affects all colored Presents variants (but not the normal one?) in 1.20.1.

And I just noticed that the common factor between the two is that both has "display" in their recipe id.