KubeJS

KubeJS

61M Downloads

Recipe Event Listener Makes "Rope Arrows" From Supplementaries Uncraftable

Alvin21Bon opened this issue · 11 comments

commented

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

commented

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).

commented

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.

commented

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

commented
commented

Q: what happens if you add

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

to your server scripts?

commented

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");
})
commented

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

commented

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

commented

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: kkempfer/Create-Survive-Explore#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 ?

commented

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.

commented

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.