WanionCane / UniDict

a mod about unifying all the things.
https://www.curseforge.com/minecraft/mc-mods/unidict
Mozilla Public License 2.0
39 stars 16 forks source link

CraftTweaker Integration: newShapedRecipeTemplate requires 3x3 #210

Open Redfire75369 opened 5 months ago

Redfire75369 commented 5 months ago

Describe the bug mods.unidict.api.newShapedRecipeTemplate requires a 3x3 array for the inputs. This means that shaped recipes with smaller areas like 2x1, 2x2, etc. can't be created and the game crashes if such recipes attempt to be created. Specifically the code below assumes the array is 3x3. https://github.com/WanionCane/UniDict/blob/1ef78eced4d2c5250a8c9f5f3fbeacf8568a657d/src/main/java/wanion/unidict/plugin/crafttweaker/UniDictCraftTweakerPlugin.java#L116-L126

To Reproduce

mods.unidict.api.newShapedRecipeTemplate("gear", 1, [["plate", "plate"], ["plate", "plate"]]);

Crash Stacktrace:

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from UniDict (unidict)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
    at wanion.unidict.plugin.crafttweaker.UniDictCraftTweakerPlugin.lambda$fetchShapedRecipeTemplates$3(UniDictCraftTweakerPlugin.java:118)
    at java.util.ArrayList.forEach(ArrayList.java:1259)
    at wanion.unidict.plugin.crafttweaker.UniDictCraftTweakerPlugin.fetchShapedRecipeTemplates(UniDictCraftTweakerPlugin.java:100)
    at wanion.unidict.plugin.crafttweaker.UniDictCraftTweakerPlugin.init(UniDictCraftTweakerPlugin.java:92)
    at wanion.unidict.proxy.CommonProxy.postInit(CommonProxy.java:68)
    at wanion.unidict.proxy.ClientProxy.postInit(ClientProxy.java:19)
    at wanion.unidict.UniDict.postInit(UniDict.java:97)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)
    at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
    at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:754)
    at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)
    at net.minecraft.client.Minecraft.init(MinecraftAccessor.java:535)
    at net.minecraft.client.Minecraft.run(MinecraftAccessor.java:9601)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:100)
    at org.prismlauncher.EntryPoint.listen(EntryPoint.java:129)
    at org.prismlauncher.EntryPoint.main(EntryPoint.java:70)

Expected behavior Shaped recipes for gears are added and can be crafted in the inventory with the 2x2 grid.