Merith-TK / cc-restitched-unmaintained

CC: Tweaked ported for Fabric 1.16.x
Other
10 stars 11 forks source link

All disks are white in the recipe book #30

Closed Jummit closed 3 years ago

Jummit commented 3 years ago

All disks recipes show a white disk as result. This happens both in REI and in the vanilla recipe book.

Merith-TK commented 3 years ago

if you know a fix, please do make a PR

SquidDev commented 3 years ago

I think the issue here is that impostor recipes load using ShapedRecipe.itemStackFromJson, which ignores the "nbt" tag (this is something that Forge adds), which means they all get the default colour (though this should be blue - surprising!). Either way, switching to something like this should work (though also untested, sorry).


public class CraftingHelper
{
    private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();

    private CraftingHelper()
    {
    }

    @Nonnull
    public static ItemStack getItemStack( JsonObject object )
    {
        ItemStack stack = ShapedRecipe.itemStackFromJson( object );

        JsonElement element = object.get( "nbt" );
        if( element != null )
        {
            try
            {
                stack.setTag( TagParser.parseTag( element.isJsonObject() ? GSON.toJson( element ) : GsonHelper.getAsString( object, "nbt" ) ) );
            }
            catch( CommandSyntaxException e )
            {
                throw new JsonSyntaxException( "Invalid NBT entry: " + e.getMessage() );
            }
        }

        return stack;
    }
}

Apologies for MojMap.

Merith-TK commented 3 years ago

fixed with #75