GregTech-Intergalactical / AntimatterAPI

The Antimatter API for GregTech
GNU Lesser General Public License v3.0
18 stars 20 forks source link

[Bug] AntimatterCraftTweaker has an error preventing registration #201

Closed jaredlll08 closed 1 year ago

jaredlll08 commented 2 years ago

What happened?

https://github.com/GregTech-Intergalactical/AntimatterAPI/blob/dev-1.18/common/src/main/java/muramasa/antimatter/integration/ct/AntimatterCraftTweaker.java#L39

The specific issue is that CraftTweaker doesn't work with wildcard generics like this MaterialType<?>

There are 2 solutions to this, either remove the generic completely. like so:

public static IIngredient ingredient(Material mat, MaterialType type, int count) 

or you could ask the user to specify the generic value like so:

public static <T> IIngredient ingredient(Class<T> tClass, Material mat, MaterialType<T> type, int count) 

which can then be used like:

import mods.antimatter.Api;
import crafttweaker.api.item.IItemStack;

Api.ingredient<IItemStack>(<material here>, <material type here>, <count here>);

Generics in ZenScript are reified, so you also get the actual class of the generic as well if you need it.

What mod loaders are you seeing the problem on?

Fabric, Forge

Relevant log output

[14:51:54.993][ERROR]: Error while registering class: 'muramasa.antimatter.integration.ct.AntimatterCraftTweaker', this is most likely a compatibility issue:
java.lang.IllegalStateException: Could not find type variable T on declaration: class muramasa.antimatter.material.MaterialType

Anything else?

No response

By submitting this issue, I have included the necessary logs by pasting the contents into the correct location or attaching the file as an upload.

By submitting this issue, I have confirmed Antimatter and Tesseract are up to date.

Trinsdar commented 2 years ago

I'll probably go with the first option since the generics don't even seem to really be used in that.

Trinsdar commented 1 year ago

turns out that did not fix it

Trinsdar commented 1 year ago

ok tried both methods, neither worked to fix it

jaredlll08 commented 1 year ago

Is there a log output like before? could have some more info

Trinsdar commented 1 year ago

just the same error as before:


[15:42:33.990][ERROR]: Error while registering class: 'muramasa.antimatter.integration.ct.AntimatterCraftTweaker', this is most likely a compatibility issue:
java.lang.IllegalStateException: Could not find type variable T on declaration: class muramasa.antimatter.material.MaterialType
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.TypeVariableContext.get(TypeVariableContext.java:21)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadClass(JavaNativeTypeConverter.java:187)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadType(JavaNativeTypeConverter.java:113)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadAnnotatedType(JavaNativeTypeConverter.java:163)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadType(JavaNativeTypeConverter.java:111)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadType(JavaNativeTypeConverter.java:98)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadType(JavaNativeTypeConverter.java:85)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadType(JavaNativeTypeConverter.java:70)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadStoredType(JavaNativeTypeConverter.java:56)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeTypeConverter.loadStoredType(JavaNativeTypeConverter.java:60)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeHeaderConverter.getHeader(JavaNativeHeaderConverter.java:99)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeHeaderConverter.getHeader(JavaNativeHeaderConverter.java:58)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeMemberConverter.asMethod(JavaNativeMemberConverter.java:49)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeClassConverter.fillAnnotatedMethods(JavaNativeClassConverter.java:243)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeClassConverter.fillDefinition(JavaNativeClassConverter.java:177)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeClassConverter.convertClass(JavaNativeClassConverter.java:62)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.converters.JavaNativeConverter.addClass(JavaNativeConverter.java:47)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.natives.CtJavaNativeConverter.addClass(CtJavaNativeConverter.java:42)
    at TRANSFORMER/crafttweaker@9.1.207/org.openzen.zencode.java.module.JavaNativeModule.addClass(JavaNativeModule.java:87)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.DefaultScriptRunModuleConfigurator.lambda$createModule$3(DefaultScriptRunModuleConfigurator.java:126)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.runner.ScriptRunner.createNativeModule(ScriptRunner.java:138)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.runner.ScriptRunner.lambda$gatherModules$3(ScriptRunner.java:122)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.DefaultScriptRunModuleConfigurator.createModule(DefaultScriptRunModuleConfigurator.java:124)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.DefaultScriptRunModuleConfigurator.createModule(DefaultScriptRunModuleConfigurator.java:105)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.DefaultScriptRunModuleConfigurator.lambda$createOtherModules$1(DefaultScriptRunModuleConfigurator.java:60)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1707)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
    at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
    at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
    at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
    at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.DefaultScriptRunModuleConfigurator.createOtherModules(DefaultScriptRunModuleConfigurator.java:69)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.DefaultScriptRunModuleConfigurator.populateModules(DefaultScriptRunModuleConfigurator.java:43)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.runner.ScriptRunner.gatherModules(ScriptRunner.java:119)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.runner.ScriptRunner.populateModules(ScriptRunner.java:104)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.runner.ScriptRunner.initializeEngine(ScriptRunner.java:77)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.runner.ScriptRunner.run(ScriptRunner.java:68)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.DecoratedRunKind$DecoratedScriptRunner.run(DecoratedRunKind.java:27)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.ScriptRun.executeRun(ScriptRun.java:88)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.scriptrun.ScriptRun.execute(ScriptRun.java:54)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.ScriptReloadListener.apply(ScriptReloadListener.java:78)
    at TRANSFORMER/crafttweaker@9.1.207/com.blamejared.crafttweaker.impl.script.ScriptReloadListener.apply(ScriptReloadListener.java:37)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.server.packs.resources.SimplePreparableReloadListener.method_18790(SimplePreparableReloadListener.java:13)
    at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718)
    at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.server.packs.resources.SimpleReloadInstance.method_18365(SimpleReloadInstance.java:69)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:157)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:131)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:140)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.Minecraft.makeWorldStem(Minecraft.java:2081)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.Minecraft.doLoadLevel(Minecraft.java:1908)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.Minecraft.loadLevel(Minecraft.java:1872)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.loadWorld(WorldSelectionList.java:473)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.joinWorld(WorldSelectionList.java:330)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.gui.screens.worldselection.WorldSelectionList$WorldListEntry.mouseClicked(WorldSelectionList.java:257)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.gui.components.AbstractSelectionList.mouseClicked(AbstractSelectionList.java:323)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.gui.components.events.ContainerEventHandler.mouseClicked(ContainerEventHandler.java:27)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.MouseHandler.method_1611(MouseHandler.java:88)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:528)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.MouseHandler.onPress(MouseHandler.java:85)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.MouseHandler.method_22686(MouseHandler.java:185)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:103)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.MouseHandler.method_22684(MouseHandler.java:184)
    at MC-BOOTSTRAP/org.lwjgl.glfw/org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36)
    at MC-BOOTSTRAP/org.lwjgl/org.lwjgl.system.JNI.invokeV(Native Method)
    at MC-BOOTSTRAP/org.lwjgl.glfw/org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101)
    at TRANSFORMER/minecraft@1.18.2/com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:197)
    at TRANSFORMER/minecraft@1.18.2/com.mojang.blaze3d.platform.Window.updateDisplay(Window.java:333)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.Minecraft.runTick(Minecraft.java:1067)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.Minecraft.run(Minecraft.java:664)
    at TRANSFORMER/minecraft@1.18.2/net.minecraft.client.main.Main.main(Main.java:205)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at MC-BOOTSTRAP/fmlloader@1.18.2-40.1.73/net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:24)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149)
    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
    at dev.architectury.transformer.TransformerRuntime.main(TransformerRuntime.java:217)```
jaredlll08 commented 1 year ago

Huh, I'm not sure how I didn't catch this the first time.

Your classes aren't registered, the scripting engine doesn't know what Material or MaterialType is.

They would need to either add the annotations onto the class directly, or what you should probably do is something along these lines: https://github.com/CraftTweaker/CraftTweaker/blob/1.19/Common/src/main/java/com/blamejared/crafttweaker/natives/entity/ExpandEntity.java#L33-L35

You can ignore the @Document annotation, but those other 2 will tell the scripting engine about your classes, and you can register the methods onto them