GregTechCEu / GregTech-Modern

GregTech CE Unofficial for modern versions
GNU Lesser General Public License v3.0
287 stars 170 forks source link

Crash when using electric furnace #5

Closed lonevox closed 1 year ago

lonevox commented 1 year ago

GregTech CEu Version

1.0.0 fabric

Recipe Viewer Installed

JEI

Environment

Singleplayer

Cross-Mod Interaction

No

Expected Behavior

Put an appropriate smeltable item into an electric furnace such as Raw Iron and it should smelt it.

Actual Behavior

The game crashes with an index out of bounds error: https://pastebin.com/wfTcZWyA

The following seems to be related. Upon loading any world, the console logs an error for each ingot smelting recipe. The one below is for beryllium.

 com.google.gson.JsonSyntaxException: Expected result to be a string, was an object ({"it...m"})
    at net.minecraft.util.GsonHelper.convertToString(GsonHelper.java:111) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.util.GsonHelper.getAsString(GsonHelper.java:117) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.world.item.crafting.SimpleCookingSerializer.fromJson(SimpleCookingSerializer.java:31) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.world.item.crafting.SimpleCookingSerializer.fromJson(SimpleCookingSerializer.java:11) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.world.item.crafting.RecipeManager.fromJson(RecipeManager.java:135) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.world.item.crafting.RecipeManager.apply(RecipeManager.java:56) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.world.item.crafting.RecipeManager.apply(RecipeManager.java:35) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.server.packs.resources.SimplePreparableReloadListener.m_neendbwx(SimplePreparableReloadListener.java:13) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) ~[?:?]
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
    at net.minecraft.server.packs.resources.SimpleReloadInstance.m_dpwubqro(SimpleReloadInstance.java:69) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:157) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:131) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:140) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.worldselection.WorldOpenFlows.loadWorldStem(WorldOpenFlows.java:136) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.worldselection.WorldOpenFlows.loadWorldStem(WorldOpenFlows.java:117) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.worldselection.WorldOpenFlows.doLoadLevel(WorldOpenFlows.java:150) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.worldselection.WorldOpenFlows.loadLevel(WorldOpenFlows.java:57) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.loadWorld(WorldSelectionList.java:528) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.joinWorld(WorldSelectionList.java:436) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.mouseClicked(WorldSelectionList.java:367) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.components.AbstractSelectionList.mouseClicked(AbstractSelectionList.java:372) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.components.events.ContainerEventHandler.mouseClicked(ContainerEventHandler.java:27) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.MouseHandler.redirect$zlj000$injectClick(MouseHandler.java:1036) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.MouseHandler.m_jzgvmppg(MouseHandler.java:94) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:489) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.MouseHandler.onPress(MouseHandler.java:94) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.MouseHandler.m_sljgmtqm(MouseHandler.java:165) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:103) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.MouseHandler.m_dmvalfre(MouseHandler.java:165) ~[minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:43) [lwjgl-glfw-3.3.1.jar:?]
    at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.3.1.jar:?]
    at org.lwjgl.glfw.GLFW.glfwWaitEventsTimeout(GLFW.java:3474) [lwjgl-glfw-3.3.1.jar:?]
    at com.mojang.blaze3d.systems.RenderSystem.limitDisplayFPS(RenderSystem.java:222) [minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1208) [minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:768) [minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.main.Main.run(Main.java:244) [minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.minecraft.client.main.Main.main(Main.java:51) [minecraft-project-@gtceu-fabric-merged-named.jar:?]
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461) [fabric-loader-0.14.11.jar:?]
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.14.11.jar:?]
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) [fabric-loader-0.14.11.jar:?]
    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.1+build.8.jar:?]
    at dev.architectury.transformer.TransformerRuntime.main(TransformerRuntime.java:217) [architectury-transformer-5.2.72-runtime.jar:5.2.72]

Steps to Reproduce

  1. Launch fabric with mod.
  2. Power an electric furnace.
  3. Place Raw Iron into furnace.

Additional Information

The electric furnace works with the forge version of the mod.

lonevox commented 1 year ago

Looking into this further, it seems like this mod is generating minecraft:smelting recipes wrong.

Here's the serialized vanilla Red Sandstone -> Smooth Red Sandstone smelting recipe (note that the result JSON is a string):

{"type":"minecraft:smelting","cookingtime":200,"experience":0.1,"ingredient":{"item":"minecraft:red_sandstone"},"result":"minecraft:smooth_red_sandstone"}

And here's the serialized gtceu Opal Ore -> Opal Gem smelting recipe:

{"type":"minecraft:smelting","ingredient":{"tag":"c:ores/opal"},"result":{"item":"gtceu:gem.opal","count":2},"experience":0.5,"cookingtime":0}

Because the Opal recipe's result JSON is an object and not a string that simply says the item output (which is what is expected because vanilla smelting only has a single item output), it causes the JsonSyntaxExceptions as a string is expected by Minecraft's SimpleCookingSerializer. Not sure how to solve this. Minecraft's SimpleCookingSerializer definitely can't be used though, so maybe minecraft:smelting recipes shouldn't be used like this?

Yefancy commented 1 year ago

It's easy to fix, just a simple mixin can add vanilla supports. It's just that I haven't dealt with it yet, because right now it's just missing functionality in fabric, and actually fabric lacks a lot of features that forge has, which I'll implement them later