Roughly Enough Items Fabric/Forge/NeoForge (REI)

Roughly Enough Items Fabric/Forge/NeoForge (REI)

40M Downloads

[Bug] Registering custom CraftingRecipe displays do not take effect / non-ShapedRecipe shaped recipes do not display correctly.

jaredlll08 opened this issue ยท 3 comments

commented

Describe the bug
On 6.0.267-alpha (pre custom crafting display release):
So I have a custom CraftingRecipe that is effectively just a clone of the ShapedRecipe class (but does not extend it), I noticed that REI wasn't automatically showing the recipe and after further inspection, it seems that I need to register Display for it, I copied the DefaultShapedDisplay class which does seem to work well for most things (https://i.blamejared.com/Wst00.png, all of those are my custom recipe class), but the bottom two recipes there are shown incorrectly, they should actually be like this: https://i.blamejared.com/A4OIK.png and like this: https://i.blamejared.com/Q2evW.png (the bottom recipe accepts any item, not the fence specifically).

However, using REI to automatically move the items does move them into their correct place...

This is my Display class, it really is just a clone of the DefaultShapedDisplay https://gist.github.com/jaredlll08/dc6bcaf380e27e4994dc6d3c2db06b54

I also debugged into it see what data it was getting, everything does appear to be correct, at-least for me:
https://i.blamejared.com/zCbmO.png

Of note, the recipe has the correct width and height, and it is getting an empty ingredient where it should be.

On 7.1.357 (post custom crafting display release):
The recipe is shown like this:
https://cdn.discordapp.com/attachments/860230149996150824/928710283755683911/unknown.png
and https://i.blamejared.com/oTfPX.txt is spammed in the log while looking at it.

Steps to Reproduce
Steps to reproduce the behavior:

  • Install a mod with a custom CraftingRecipe that imitates ShapedRecipe
  • Look at a recipe in REI

Screenshots
Linked above.

Environment (please complete the following information with the version):

  • Minecraft: 1.17 - 1.18
  • Mod Loader: Fabric

Logs
Linked above

Additional context
I am currently shipping a workaround for this in CraftTweaker that imitates the behaviour of versions pre the custom crafting display, so no log spam, but the recipe does not have the correct shape.

I am more than happy to build a custom version without the workaround for testing if needed

commented

I changed how REI handles crafting recipes in inputs, can you try again on this? If it doesn't fix the issue, please do build a custom version without the workaround for testing, that would be helpful, ideally with an example CT script as well.

commented

How the recipe is meant to be crafted:
image

Without registering custom displays:
image

With my custom display registered:
image
(so same as if it wasn't registered)

Something to note though, before it would show the items in the correct slot when you hovered over it (So if you didn't have apples, the middle slot would have the red overlay), but now it shows it on the slot it thinks it should be in.

Also previously if you clicked the "move items" button, it would put them in the correct slot, but now it puts them in the slots as shown in REI.

Here are some built jars if you want to test, I hope the file names are descriptive enough.
https://imja.red/rei/CraftTweaker-fabric-1.18.1-9.0.0-no-rei-workaround.jar
https://imja.red/rei/CraftTweaker-fabric-1.18.1-9.0.0-no-rei-workaround-no-rei-displays.jar

You will need the Fabric API and the IngredientExtensionApi
https://maven.blamejared.com/com/faux/ingredientextension/IngredientExtensionAPI-fabric-1.18.1/2.0.1/

In the first file, I simply moved:

        registry.registerFiller(CTShapedRecipeBase.class, DefaultCTShapedDisplay::new);
        registry.registerFiller(CTShapelessRecipeBase.class, DefaultCTShapelessDisplay::new);

out of this block https://github.com/CraftTweaker/CraftTweaker/blob/f802eba9fff3fb98510ec199d3ea030c091fd8ec/Fabric/src/main/java/com/blamejared/crafttweaker/impl/compat/rei/CraftTweakerPlugin.java#L24 and then commented that block out.

In the second file I just commented all the code inside registerDisplays out.

If you would like me to put them on a maven somewhere to easily pull them in just let me know.

As for a script to reproduce:

import crafttweaker.api.recipe.MirrorAxis;

craftingTable.addShapedMirrored("mirrored", MirrorAxis.ALL, <item:minecraft:stick>, [[<item:minecraft:glass>, <item:minecraft:air>], [<item:minecraft:air>, <item:minecraft:apple>]]);

If there is anything else you need, please let me know

commented

I have added a function in DefaultCraftingDisplay to register a recipe size provider, please statically register it in your plugin.
Otherwise I have fixed the layout in DefaultCraftingCategory, so your existing hackery to use your own filler will also now layout properly.

static {
        // Example Forge impl
        DefaultCraftingDisplay.registerSizeProvider(recipe -> {
            if (recipe instanceof IShapedRecipe) {
                return new CraftingRecipeSizeProvider.Size(((IShapedRecipe<?>) recipe).getRecipeWidth(), ((IShapedRecipe<?>) recipe).getRecipeHeight());
            }
            
            return null;
        });
}