Posted December 19, 20195 yr Hi, I just build my mod using the gradle build task, and threw it into my mod pack to test on my client. The client fails silently and does not registered any of my mod. It fails when I try to set material to each block. I do not understand why in the dev environment this will work but in a modpack it will not. May anyone point me in the right direction? Offending code: private static Material translateMaterial(String material) throws IllegalAccessException { Material m = (Material) Arrays.stream(Material.class.getFields()) .filter( f-> f.getName().equalsIgnoreCase(material)) .findFirst() .get() .get(Material.class.getFields()); return m; } Logs: Spoiler Utils:translateModOptions:132]: default type: glass material: glass sound: glass renderLayer: translucent [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: java.util.NoSuchElementException: No value present [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at java.util.Optional.get(Optional.java:135) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.cilka.telgt.utils.Utils.translateMaterial(Utils.java:149) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.cilka.telgt.utils.Utils.translateModOptions(Utils.java:134) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.cilka.telgt.utils.Utils.Generate(Utils.java:38) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.cilka.telgt.Main.preInit(Main.java:32) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at java.lang.reflect.Method.invoke(Method.java:498) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at java.lang.reflect.Method.invoke(Method.java:498) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.EventBus.post(EventBus.java:217) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at java.lang.reflect.Method.invoke(Method.java:498) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at com.google.common.eventbus.EventBus.post(EventBus.java:217) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:629) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraft.client.main.Main.main(SourceFile:123) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at java.lang.reflect.Method.invoke(Method.java:498) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [21:47:41] [Client thread/INFO] [STDERR]: [com.cilka.telgt.utils.Utils:Generate:55]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [21:47:41] [Client thread/INFO] [unloader]: Unloader loaded!... Wait... What?
December 20, 20195 yr Author 17 hours ago, diesieben07 said: Minecraft is obfuscated outside the development environment, field and methods will have SRG names (func_12345_x, etc.). It looks like you are trying to get a material by name, which is not possible, since materials do not have names. Well that puts a hamper to my plan. I think I can get around it by explicitly stating the material (e.g. var mat = Material.ROCK) with switch statements, but that approach sounds ugly. EDIT: I can just populate my hash map with the values that are in my XML file if I can't use reflection. It would be a cleaner then my first idea. Thanks diesieben! Edited December 20, 20195 yr by Cilka Found a work around for my problem.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.