UniDict

UniDict

50M Downloads

CraftTweaker Integration: newShapedRecipeTemplate requires 3x3

Redfire75369 opened this issue ยท 0 comments

commented

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.

for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
final Object input = shapedRecipeTemplate.inputs[y][x];
if (input instanceof String && !input.equals(""))
trueInputs[y * 3 + x] = input;
else if (input instanceof MCItemStack && ((MCItemStack) input).getInternal() instanceof ItemStack)
trueInputs[y * 3 + x] = ((MCItemStack) input).getInternal();
else if (input instanceof MCOreDictEntry)
trueInputs[y * 3 + x] = ((MCOreDictEntry) input).getName();
}
}

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.