Problem Server Crash - Need Help

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord
C

ConfusedGiraffe

Guest
I've been getting this crash for weeks now. It is particularly prevalent when generating new chunks.

Code:
Description: Exception ticking world

java.lang.NullPointerException: Exception ticking world
    at codechicken.lib.world.WorldExtension.unloadChunk(WorldExtension.java:52)
    at codechicken.lib.world.WorldExtensionManager$WorldExtensionEventHandler.onChunkUnLoad(WorldExtensionManager.java:67)
    at cpw.mods.fml.common.eventhandler.ASMEventHandler_995_WorldExtensionEventHandler_onChunkUnLoad_Unload.invoke(.dynamic)
    at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
    at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140)
    at net.minecraft.world.chunk.Chunk.func_76623_d(Chunk.java:1087)
    at net.minecraft.world.gen.ChunkProviderServer.func_73156_b(ChunkProviderServer.java:561)
    at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:265)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:963)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:432)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:841)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:693)
    at java.lang.Thread.run(Unknown Source)


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

-- Head --
Stacktrace:
    at codechicken.lib.world.WorldExtension.unloadChunk(WorldExtension.java:52)
    at codechicken.lib.world.WorldExtensionManager$WorldExtensionEventHandler.onChunkUnLoad(WorldExtensionManager.java:67)
    at cpw.mods.fml.common.eventhandler.ASMEventHandler_995_WorldExtensionEventHandler_onChunkUnLoad_Unload.invoke(.dynamic)
    at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
    at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140)
    at net.minecraft.world.chunk.Chunk.func_76623_d(Chunk.java:1087)
    at net.minecraft.world.gen.ChunkProviderServer.func_73156_b(ChunkProviderServer.java:561)
    at net.minecraft.world.WorldServer.func_72835_b(WorldServer.java:265)

I think that I've narrowed down what is causing it but am unsure how to go about fixing it.

Code:
package codechicken.lib.world;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;

import java.util.HashMap;

public abstract class WorldExtension
{
    public final World world;
    public HashMap<Chunk, ChunkExtension> chunkMap = new HashMap<Chunk, ChunkExtension>();
 
    public WorldExtension(World world)
    {
        this.world = world;
    }
 
    public void load()
    {
    }
 
    public void unload()
    {
    }
 
    public void save()
    {
    }
 
    public void preTick()
    {
    }
 
    public void postTick()
    {
    }
     
    protected final void addChunk(ChunkExtension extension)
    {
        chunkMap.put(extension.chunk, extension);
    }
 
    protected final void loadChunk(Chunk chunk)
    {
        chunkMap.get(chunk).load();
    }
 
   protected final void unloadChunk(Chunk chunk)
    {
        chunkMap.get(chunk).unload();
    }
 
    protected final void loadChunkData(Chunk chunk, NBTTagCompound tag)
    {
        chunkMap.get(chunk).loadData(tag);
    }
 
    protected final void saveChunkData(Chunk chunk, NBTTagCompound tag)
    {
        chunkMap.get(chunk).saveData(tag);
    }
 
    protected final void remChunk(Chunk chunk)
    {
        chunkMap.remove(chunk);
    }

    protected final void watchChunk(Chunk chunk, EntityPlayerMP player)
    {
        chunkMap.get(chunk).watchPlayer(player);
    }

    protected final void unwatchChunk(Chunk chunk, EntityPlayerMP player)
    {
        ChunkExtension extension = chunkMap.get(chunk);
        if(extension != null)
            extension.unwatchPlayer(player);
    }

    protected final void sendChunkUpdates(Chunk chunk)
    {
        chunkMap.get(chunk).sendUpdatePackets();
    }

    public boolean containsChunk(Chunk chunk)
    {
        return chunkMap.containsKey(chunk);
    }

    public ChunkExtension getChunkExtension(int chunkXPos, int chunkZPos)
    {
        if(!world.isBlockLoaded(new BlockPos(chunkXPos<<4, 128, chunkZPos<<4)))
            return null;
     
        return chunkMap.get(world.getChunkFromChunkCoords(chunkXPos, chunkZPos));
    }
}

Code:
   protected final void unloadChunk(Chunk chunk)
    {
        chunkMap.get(chunk).unload();
    }

Any help would be greatly appreciated.