0

I tried making a ticket using:

    Ticket ticket = ForgeChunkManager.requestTicket(this, this.minecraftServer.entityWorld, ForgeChunkManager.Type.NORMAL);

The above code is in my main mod class. I get a NullPointerException when I try to run my mod.

Alsan Ali
  • 187
  • 2
  • 10

1 Answers1

0

in this case, either this.minecraftServer or this.minecraftServer.entityWorldis null.

try surrounding it with a if statement.

if (this.minecraftServer != null && this.minecraftServer.entityWorld != null){
    Ticket ticket = ForgeChunkManager.requestTicket(this, 
                                                    this.minecraftServer.entityWorld, 
                                                    ForgeChunkManager.Type.NORMAL);
}

and for the purpose of debugging, I would suggest you separate it in two conditions:

if (this.minecraftServer == null) {
    System.out.println("minecraftServer is null");
    //or do anything can to warn you
} else if(this.minecraftServer.entityWorld == null) {
    System.out.println("entityWorld is null");
    //or do anything can to warn you
} else {
    Ticket ticket = ForgeChunkManager.requestTicket(this, 
                                                    this.minecraftServer.entityWorld, 
                                                    ForgeChunkManager.Type.NORMAL);
}

Unless you can use a debugger to check the values.

But without the full code, it's impossible to know if there's any other error.

Sirmyself
  • 1,464
  • 1
  • 14
  • 29