Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.11] NullPointer on trying to get a list of dimensions.


Awesome_Spider
 Share

Recommended Posts

I am trying to make my mod create configurations for every dimension that is registered. However, I'm getting a null pointer exception and have tried many times in vain to fix it. Here is the code:

 

public static void loadAll() {
        //Dimensions
        Integer[] ids = DimensionManager.getStaticDimensionIDs();

        for (int id : ids) {
            WorldProvider dimension = DimensionManager.getProvider(id); //NullPointer

            String modId = ModIdentification.idFromObject(dimension);

            File file = new File(EnviroMineRevived.configDir, modId.toLowerCase() + "\\dimension.json");

            DimensionProperties.base.load(file);
        }
  ...
    }

 

I then call this method in my post-init method. It however throws a null pointer which leads me to believe that none of the dimensions are registered by then. Where should I be calling this?

 

If you need more code just ask. Following is the error:

 

Spoiler

---- Minecraft Crash Report ----
// Surprise! Haha. Well, this is awkward.

Time: 5/4/17 6:16 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from EnviroMine Revived (enviromine_revived)
Caused by: java.lang.NullPointerException
	at net.minecraftforge.common.DimensionManager.getProvider(DimensionManager.java:139)
	at wiseowl5.EnviroMineRevived.Properties.PropertyManager.loadAll(PropertyManager.java:32)
	at wiseowl5.EnviroMineRevived.Main.EnviroMineRevived.postInit(EnviroMineRevived.java:99)
	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:497)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:621)
	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:497)
	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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221)
	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:497)
	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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:801)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:331)
	at net.minecraft.client.Minecraft.init(Minecraft.java:560)
	at net.minecraft.client.Minecraft.run(Minecraft.java:385)
	at net.minecraft.client.main.Main.main(Main.java:118)
	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:497)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	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:497)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
	Minecraft Version: 1.11
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_60, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 114418296 bytes (109 MB) / 747634688 bytes (713 MB) up to 1415053312 bytes (1349 MB)
	JVM Flags: 0 total; 
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.35 Powered by Forge 13.19.1.2189 4 mods loaded, 4 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
	UCHIJ	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
	UCHIJ	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11-13.19.1.2189.jar) 
	UCHIJ	forge{13.19.1.2189} [Minecraft Forge] (forgeSrc-1.11-13.19.1.2189.jar) 
	UCHIE	enviromine_revived{1.11-0.0.0} [EnviroMine Revived] (EnviroMineRevived_main) 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.201.1151.1008' Renderer: 'AMD Radeon HD 5450'

 

 

Link to comment
Share on other sites

You first need to get all DimensionTypes: DimensionType.values(). Then for each one you need to get all it's dimension IDs using DimensionManager.getDimensions(DimensionType).

In one operation:

int[] dimensions = Stream.of(DimensionType.values()).flatMapToInt(t -> Stream.of(DimensionManager.getDimensions(t))).distinct();

 

  • Like 1
Link to comment
Share on other sites

I'm still not having any luck. Any other ideas? There is a null pointer on the same method as last time. :/

Spoiler

The method with the exception:


public static void loadAll() {
        //Dimensions
        List<Integer> ids = EnviroUtils.getDimensionIds();

        for (int id : ids) {
            WorldProvider dimension = DimensionManager.getProvider(id); //Null pointer

            String modId = ModIdentification.idFromObject(dimension);

            //File file = new File(EM_ConfigHandler.loadedProfile + EM_ConfigHandler.customPath + EnviroUtils.SafeFilename(modID) + ".cfg");
            File file = new File(EnviroMineRevived.configDir, modId.toLowerCase() + "\\dimension.json");

            DimensionProperties.base.load(file);
        }
  ...
}

 

The method I use to get all the ids:


...
  
public static List<Integer> getDimensionIds() {
        List<Integer> ids = Lists.newArrayList();

        DimensionType[] types = DimensionType.values();

        for (DimensionType type : types) {
            int[] idArray = DimensionManager.getDimensions(type);

            for (int id : idArray) {
                ids.add(id);
            }
        }

        return ids;
    }

...

 

The crash report:


---- Minecraft Crash Report ----
// Would you like a cupcake?

Time: 5/4/17 7:32 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from EnviroMine Revived (enviromine_revived)
Caused by: java.lang.NullPointerException
	at net.minecraftforge.common.DimensionManager.getProvider(DimensionManager.java:139)
	at wiseowl5.EnviroMineRevived.Properties.PropertyManager.loadAll(PropertyManager.java:27)
	at wiseowl5.EnviroMineRevived.Main.EnviroMineRevived.postInit(EnviroMineRevived.java:99)
	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:497)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:621)
	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:497)
	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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221)
	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:497)
	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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:801)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:331)
	at net.minecraft.client.Minecraft.init(Minecraft.java:560)
	at net.minecraft.client.Minecraft.run(Minecraft.java:385)
	at net.minecraft.client.main.Main.main(Main.java:118)
	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:497)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	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:497)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
	Minecraft Version: 1.11
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_60, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 424596288 bytes (404 MB) / 757596160 bytes (722 MB) up to 1415053312 bytes (1349 MB)
	JVM Flags: 0 total; 
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.35 Powered by Forge 13.19.1.2189 4 mods loaded, 4 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
	UCHIJ	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
	UCHIJ	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11-13.19.1.2189.jar) 
	UCHIJ	forge{13.19.1.2189} [Minecraft Forge] (forgeSrc-1.11-13.19.1.2189.jar) 
	UCHIE	enviromine_revived{1.11-0.0.0} [EnviroMine Revived] (EnviroMineRevived_main) 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.201.1151.1008' Renderer: 'AMD Radeon HD 5450'

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # #      102.54.94.97     rhino.acme.com          # source server #       38.25.63.10     x.acme.com              # x client host # localhost name resolution is handled within DNS itself. #    127.0.0.1       localhost #    ::1             localhost 127.0.0.1 checkhost.local 127.0.0.1 checkhost.local 109.94.209.70      *.fitgirl-repacks.xyz           # Fake FitGirl site 127.0.0.1 checkhost.local 127.0.0.1 checkhost.local 109.94.209.70      *.fitgirl-repacks.xyz           # Fake FitGirl site 109.94.209.70      fitgirlrepacks.in               # Fake FitGirl site 109.94.209.70      www.fitgirlrepacks.in           # Fake FitGirl site 109.94.209.70      fitgirlrepacks.co               # Fake FitGirl site 109.94.209.70      fitgirl-repacks.cc              # Fake FitGirl site 109.94.209.70      fitgirl-repacks.to              # Fake FitGirl site 109.94.209.70      fitgirl-repack.com              # Fake FitGirl site 109.94.209.70      fitgirl-repacks.website         # Fake FitGirl site 109.94.209.70      fitgirlrepack.games             # Fake FitGirl site 109.94.209.70      www.fitgirlrepacks.co           # Fake FitGirl site 109.94.209.70      www.fitgirl-repacks.cc          # Fake FitGirl site 109.94.209.70      www.fitgirl-repacks.to          # Fake FitGirl site 109.94.209.70      www.fitgirl-repack.com          # Fake FitGirl site 109.94.209.70      www.fitgirl-repacks.website     # Fake FitGirl site 109.94.209.70      ww9.fitgirl-repacks.xyz         # Fake FitGirl site 109.94.209.70      www.fitgirlrepack.games         # Fake FitGirl site 109.94.209.70      *.fitgirl-repacks.xyz           # Fake FitGirl site 109.94.209.70      fitgirl-repacks.xyz             # Fake FitGirl site 109.94.209.70      fitgirl-repack.net              # Fake FitGirl site 109.94.209.70      www.fitgirl-repack.net          # Fake FitGirl site 109.94.209.70      fitgirlpack.site                # Fake FitGirl site 109.94.209.70      www.fitgirlpack.site            # Fake FitGirl site 51.68.172.243 authserver.mojang.com 51.68.172.243 sessionserver.mojang.com 51.68.172.243 launchermeta.mojang.com  
    • Oh, I just found a similar question. I'll check it out.
    • I am trying to implement Mana. If I can add it to the Player after creating the Manadata, I think I can create it Is there a way to solve this or a class I can refer to?
    • I opened and waht is the next?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.