Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.11] NullPointer on trying to get a list of dimensions.
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Awesome_Spider

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

By Awesome_Spider, May 5, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Awesome_Spider    64

Awesome_Spider

Awesome_Spider    64

  • Dragon Slayer
  • Awesome_Spider
  • Forge Modder
  • 64
  • 892 posts
Posted May 5, 2017

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'

 

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6680

diesieben07

diesieben07    6680

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6680
  • 45687 posts
Posted May 5, 2017

Why are you using a method that is explicitly marked as "not-public API"?

  • Quote

Share this post


Link to post
Share on other sites

Awesome_Spider    64

Awesome_Spider

Awesome_Spider    64

  • Dragon Slayer
  • Awesome_Spider
  • Forge Modder
  • 64
  • 892 posts
Posted May 5, 2017

How am I supposed to do it?

  • Quote

Share this post


Link to post
Share on other sites

Awesome_Spider    64

Awesome_Spider

Awesome_Spider    64

  • Dragon Slayer
  • Awesome_Spider
  • Forge Modder
  • 64
  • 892 posts
Posted May 5, 2017

I found DimensionManager::getIds, is that right?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6680

diesieben07

diesieben07    6680

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6680
  • 45687 posts
Posted May 5, 2017

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
  • Quote

Share this post


Link to post
Share on other sites

Awesome_Spider    64

Awesome_Spider

Awesome_Spider    64

  • Dragon Slayer
  • Awesome_Spider
  • Forge Modder
  • 64
  • 892 posts
Posted May 5, 2017

Ok, thanks. :)

  • Quote

Share this post


Link to post
Share on other sites

Awesome_Spider    64

Awesome_Spider

Awesome_Spider    64

  • Dragon Slayer
  • Awesome_Spider
  • Forge Modder
  • 64
  • 892 posts
Posted May 5, 2017

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'

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6680

diesieben07

diesieben07    6680

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6680
  • 45687 posts
Posted May 5, 2017

Well, there obviously is no WorldProvider without a World. And there isn't a World in postInit.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • DaemonUmbra
      Can't see anything on minecraft menu screen except for the bottom left corner

      By DaemonUmbra · Posted 14 minutes ago

      Please don't Necro old threads, if you have an issue make your own.
    • DaemonUmbra
      Forge having problem loading mods

      By DaemonUmbra · Posted 14 minutes ago

      You changed "Game Directory" to your mods folder. The Game Directory is supposed to be the folder that contains the mods folder, .minecraft by default
    • Casual
      1.12.2 crash on game start

      By Casual · Posted 18 minutes ago

      Ok to add on, had to do manual library install due to failed library install thing, also there is never another window It just closes the launcher window and then reopens it with the error.
    • Cosmic_Cookie
      Can't see anything on minecraft menu screen except for the bottom left corner

      By Cosmic_Cookie · Posted 27 minutes ago

      Hey, I have the same problem except my screen is black instead of white and this doesn't work. I know it's years later but maybe someone can help.
    • Cosmic_Cookie
      [1.12.2] Forge Crashes While Just Loading Into Loading Screen

      By Cosmic_Cookie · Posted 40 minutes ago

      Nvm wrong topic
  • Topics

    • florgonn
      4
      Can't see anything on minecraft menu screen except for the bottom left corner

      By florgonn
      Started July 30, 2014

    • SilviaX_92
      3
      Forge having problem loading mods

      By SilviaX_92
      Started 3 hours ago

    • Casual
      1
      1.12.2 crash on game start

      By Casual
      Started 43 minutes ago

    • PulseBeat_02
      14
      [1.12.2] Forge Crashes While Just Loading Into Loading Screen

      By PulseBeat_02
      Started December 13, 2018

    • GeokitFX
      1
      Minecraft Custom mod pack crashing i need help

      By GeokitFX
      Started 1 hour ago

  • Who's Online (See full list)

    • Casual
    • Vorquel
    • JMAS
    • Epicmoofish
    • creepaaa
    • DaemonUmbra
    • yuusha
    • Darren Hayden
    • AtlasTheFirst
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.11] NullPointer on trying to get a list of dimensions.
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community