Troelsen Posted July 7, 2016 Posted July 7, 2016 Hey guys. I've been trying to make a mod that allows for a player to be in creative mode within a given area. To do that, I need to set up "borders". This works perfectly fine when hardcoding in the area, but that's not very server-owner-friendly. So I wanted to make a config file they can access, and through that, set the given coordinates. However, I get this error when trying to load Minecraft with my current code. (classes posted below error) Error: Time: 07-07-16 16:00 Description: Initializing game java.lang.IllegalArgumentException: Can not set static net.minecraftforge.common.config.Configuration field com.troelsen.buildingarea.BuildingArea.config to com.troelsen.buildingarea.BuildingArea at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeStaticObjectFieldAccessorImpl.set(Unknown Source) at java.lang.reflect.Field.set(Unknown Source) at cpw.mods.fml.common.FMLModContainer.parseSimpleFieldAnnotation(FMLModContainer.java:427) at cpw.mods.fml.common.FMLModContainer.processFieldAnnotations(FMLModContainer.java:358) at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:513) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.loadMods(Loader.java:513) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeStaticObjectFieldAccessorImpl.set(Unknown Source) at java.lang.reflect.Field.set(Unknown Source) at cpw.mods.fml.common.FMLModContainer.parseSimpleFieldAnnotation(FMLModContainer.java:427) at cpw.mods.fml.common.FMLModContainer.processFieldAnnotations(FMLModContainer.java:358) at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:513) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.loadMods(Loader.java:513) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_91, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 776753864 bytes (740 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UC mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UC FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UC Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UC examplemod{1.0} [Example Mod] (bin) UE Building Area{1.2} [building Area] (bin) GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 365.19' Renderer: 'GeForce GTX 970/PCIe/SSE2' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: GeForce GTX 970/PCIe/SSE2 GL version 4.5.0 NVIDIA 365.19, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Anisotropic filtering is supported and maximum anisotropy is 16. Shaders are available because OpenGL 2.1 is supported. Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1) [16:00:35] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Rasmus T\Desktop\forge-1.7.10-10.13.4.1614-1.7.10-src\eclipse\.\crash-reports\crash-2016-07-07_16.00.35-client.txt Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release Main class package com.troelsen.buildingarea; import java.lang.ref.Reference; import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.WorldSettings.GameType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.event.entity.player.PlayerEvent; @Mod(modid = BuildingArea.MODID, version = BuildingArea.VERSION) public class BuildingArea { public static final String MODID = "Building Area"; public static final String VERSION = "1.2"; public static Block creativeBlock; @Mod.Instance(MODID) public static Configuration config; public static BuildingArea instance; @EventHandler public void preinit(FMLPreInitializationEvent event) { creativeBlock = new BlockTutorial(); creativeBlock.setHardness(10000); GameRegistry.registerBlock(creativeBlock, "CreativeBlock"); EventHandlerCommon handler = new EventHandlerCommon(); MinecraftForge.EVENT_BUS.register(handler); FMLCommonHandler.instance().bus().register(handler); config = new Configuration(event.getSuggestedConfigurationFile()); ConfigurationThing.syncConfig(); } @SubscribeEvent public void onConfigChange(ConfigChangedEvent.OnConfigChangedEvent event){ if(event.modID.equals(MODID)){ ConfigurationThing.syncConfig(); } } @EventHandler public void Init(FMLInitializationEvent event) { FMLCommonHandler.instance().bus().register(instance); } } ConfigurationClass: package com.troelsen.buildingarea; import com.typesafe.config.Config; import cpw.mods.fml.common.FMLCommonHandler; public class ConfigurationThing { public static int xMin = 246; public static final int XMIN_DEFAULT = 0; public static final String minimumx = "Set X minimum for BuildingArea"; public static void syncConfig() { FMLCommonHandler.instance().bus().register(BuildingArea.instance); final String COORDINATES = BuildingArea.config.CATEGORY_GENERAL + BuildingArea.config.CATEGORY_SPLITTER + "Xmin"; BuildingArea.config.addCustomCategoryComment(COORDINATES, "Set coordinates"); xMin = BuildingArea.config.get(COORDINATES, minimumx, XMIN_DEFAULT).getInt(XMIN_DEFAULT); if(BuildingArea.config.hasChanged()) { BuildingArea.config.save(); } } } GuiFactory package com.troelsen.buildingarea; import java.util.Set; import cpw.mods.fml.client.IModGuiFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; public class BAGuiFactory implements IModGuiFactory { @Override public void initialize(Minecraft minecraftInstance) { // TODO Auto-generated method stub } @Override public Class<? extends GuiScreen> mainConfigGuiClass() { return ConfigGui.class; } @Override public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { return null; } @Override public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } } GuiConfig package com.troelsen.buildingarea; import java.util.List; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.IConfigElement; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; public class ConfigGui extends GuiConfig { public ConfigGui(GuiScreen guiScreen) { super(guiScreen, new ConfigElement(BuildingArea.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), BuildingArea.MODID, false, false, GuiConfig.getAbridgedConfigPath(BuildingArea.config.toString())); } } I've been searching a bit around, and can't seem to find a fix. Any help would be greatly appreciated Thanks! Quote
Choonster Posted July 7, 2016 Posted July 7, 2016 java.lang.IllegalArgumentException: Can not set static net.minecraftforge.common.config.Configuration field com.troelsen.buildingarea.BuildingArea.config to com.troelsen.buildingarea.BuildingArea at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source) at sun.reflect.UnsafeStaticObjectFieldAccessorImpl.set(Unknown Source) at java.lang.reflect.Field.set(Unknown Source) at cpw.mods.fml.common.FMLModContainer.parseSimpleFieldAnnotation(FMLModContainer.java:427) at cpw.mods.fml.common.FMLModContainer.processFieldAnnotations(FMLModContainer.java:358) at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:513) @Mod(modid = BuildingArea.MODID, version = BuildingArea.VERSION) public class BuildingArea { ... @Mod.Instance(MODID) public static Configuration config; public static BuildingArea instance; ... You've annotated the config field with @Mod.Instance , so FML tries to set it to your mod's instance. This throws an exception because the field and value are of incompatible types ( Configuration is unrelated to BuildingArea ). Move the annotation to the instance field. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Recommended Posts
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.