Jump to content

[SOLVED] [1.13.2] getWorld for custom dimension type always returns null


Krevik

Recommended Posts

Hello! Whenever I try to teleport player to custom dimension using custom block I am getting error:

Spoiler

[05:52:37.336] [Server thread/FATAL] [minecraft/MinecraftServer]: Error executing task
java.util.concurrent.ExecutionException: net.minecraft.crash.ReportedException: Colliding entity with block
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_162]
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_162]
    at net.minecraft.util.Util.runTask(SourceFile:200) [?:?]
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:715) [?:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [?:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:115) [?:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:565) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_162]
Caused by: net.minecraft.crash.ReportedException: Colliding entity with block
    at net.minecraft.entity.Entity.move(Entity.java:769) ~[?:?]
    at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:704) ~[?:?]
    at net.minecraft.network.play.client.CPacketPlayer.processPacket(SourceFile:126) ~[?:?]
    at net.minecraft.network.play.client.CPacketPlayer$Position.processPacket(SourceFile:57) ~[?:?]
    at net.minecraft.network.PacketThreadUtil.func_210405_a(SourceFile:10) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_162]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_162]
    at net.minecraft.util.Util.runTask(SourceFile:199) ~[?:?]
    ... 5 more
Caused by: java.lang.NullPointerException
    at net.minecraft.world.storage.WorldSavedDataStorage.func_212426_a(SourceFile:31) ~[?:?]
    at net.minecraft.world.ISaveDataAccess.func_212411_a(SourceFile:20) ~[?:?]
    at net.minecraft.world.WorldServerMulti.func_212251_i__(WorldServerMulti.java:55) ~[?:?]
    at net.minecraftforge.common.DimensionManager.initWorld(DimensionManager.java:196) ~[?:?]
    at net.minecraftforge.common.DimensionManager.getWorld(DimensionManager.java:159) ~[?:?]
    at net.minecraft.server.MinecraftServer.getWorld(MinecraftServer.java:920) ~[?:?]
    at mod.krevik.kathairis.world.dimension.KathairisTeleportManager.tele(KathairisTeleportManager.java:191) ~[?:?]
    at mod.krevik.kathairis.blocks.BlockKathairisPortal.onEntityCollision(BlockKathairisPortal.java:230) ~[?:?]
    at net.minecraft.block.state.IBlockState.onEntityCollision(IBlockState.java:269) ~[?:?]
    at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:835) ~[?:?]
    at net.minecraft.entity.Entity.move(Entity.java:764) ~[?:?]
    at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:704) ~[?:?]
    at net.minecraft.network.play.client.CPacketPlayer.processPacket(SourceFile:126) ~[?:?]
    at net.minecraft.network.play.client.CPacketPlayer$Position.processPacket(SourceFile:57) ~[?:?]
    at net.minecraft.network.PacketThreadUtil.func_210405_a(SourceFile:10) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_162]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_162]
    at net.minecraft.util.Util.runTask(SourceFile:199) ~[?:?]
    ... 5 more

 

I've been checking and it seems that the problem is:

Spoiler

mcServer.getWorld(Kathairis.kath_Dim_type)

 

It's firing the NPE. 

So my first idea was that I am registing my custom dimension in the wrong way. Am I missing something?
Main mod file:

Spoiler

    public static final ModDimension kath_Mod_Dim = new ModDimensionKathairis();
    public static final DimensionType kath_Dim_type = new DimensionType(kath_DIM_ID , Kathairis.MODID, Kathairis.MODID, DimensionKathairis::new).setRegistryName(Kathairis.MODID);
    
    public Kathairis() {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
        DimensionManager.registerDimension(new ResourceLocation(Kathairis.MODID), kath_Mod_Dim,kath_Dim_type.getData());
    }

 


RegistryHelper:

Spoiler

@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
public class RegistryHelper {


@SubscribeEvent
public static void registerDimensionTypes(final RegistryEvent.Register<DimensionType> event){
    final IForgeRegistry<DimensionType> registry = event.getRegistry();
    registry.register(Kathairis.kath_Dim_type);
}

@SubscribeEvent
public static void registerDimensionMod(final RegistryEvent.Register<ModDimension> event){
    final IForgeRegistry<ModDimension> registry = event.getRegistry();
    registry.register(Kathairis.kath_Mod_Dim);
}

}


ModDimensionKathairis

Spoiler

public class ModDimensionKathairis extends ModDimension {

    public ModDimensionKathairis(){
        setRegistryName(Kathairis.MODID);
    }

    @Override
    public Function<DimensionType, ? extends Dimension> getFactory() {
        return new FunctionType<DimensionType, Dimension>() {
            @Nonnull
            @Override
            public Dimension apply(@Nonnull DimensionType dimensionType) {
                return Kathairis.kath_Dim_type.create();
            }
        };
    }
}

 


DimensionKathairis

Spoiler

public class DimensionKathairis extends OverworldDimension {
    public DimensionKathairis() {
        super(Kathairis.kath_Dim_type);
    }

    public IChunkGenerator<? extends IChunkGenSettings> createChunkGenerator() {
        WorldType worldtype = this.world.getWorldInfo().getTerrainType();
        BiomeProviderType<SingleBiomeProviderSettings, SingleBiomeProvider> biomeprovidertype = BiomeProviderType.FIXED;

        SingleBiomeProviderSettings singlebiomeprovidersettings2 = biomeprovidertype.createSettings().setBiome(Biomes.OCEAN);
        BiomeProvider biomeprovider = biomeprovidertype.create(singlebiomeprovidersettings2);

        ChunkGeneratorType<OverworldGenSettings, ChunkGeneratorOverworld> chunkgeneratortype4 = ChunkGeneratorType.SURFACE;
        OverworldGenSettings overworldgensettings1 = chunkgeneratortype4.createSettings();
        overworldgensettings1.setDefautBlock(KBlocks.KATHARIAN_STONE.getDefaultState());
        overworldgensettings1.setDefaultFluid(Blocks.WATER.getDefaultState());
        return chunkgeneratortype4.create(this.world, biomeprovider, overworldgensettings1);
    }
}

 


Custom BlockPortal colliding method

Spoiler

    @Override
    public void onEntityCollision(IBlockState state, World worldIn, BlockPos pos, Entity entityIn) {
        if(entityIn!=null) {
            if(entityIn instanceof EntityPlayerMP){
                KathairisTeleportManager.tele((EntityPlayerMP)entityIn);
            }else{
                KathairisTeleportManager.teleEntity(entityIn);
            }
        }
	}

 


KathairisTeleportManager teleport method

Spoiler

    public static void tele(EntityPlayer player)
    {
        if(!player.world.isRemote) {
            if ((player.getRidingEntity() == null) && ((player instanceof EntityPlayerMP))) {

                EntityPlayerMP player1 = (EntityPlayerMP) player;
                MinecraftServer mcServer = player1.getServer();
                player1.setPortal(new BlockPos(player1.posX, player1.posY, player1.posZ));

                if (player1.timeUntilPortal > 0) {

                    player1.timeUntilPortal = 10;

                } else if (player1.dimension != Kathairis.kath_Dim_type) {

                    // notify everyone that Kathairis is loading (because it currently takes so long)
                    // this can be removed when the world gen is fixed
                    /*if(!dimensionKathairisHasBeenLoadedBefore()) {
                        notifyAllPlayersThatKathairisIsLoading();
                    }*/

                    player1.timeUntilPortal = 10;

                    if (prevX2 == 0.0 && prevY2 == 0.0 && prevZ2 == 0.0) {
                        player1.timeUntilPortal = 10;
                        setDme21();

                        Validate.notNull(Kathairis.kath_Dim_type,"Kath Dim Type is null");
                        Validate.notNull(player1.getServerWorld(),"Server is null");
                        setOverworldXYZ(player1.posX, player1.posY, player1.posZ);
                        mcServer.getPlayerList().transferEntityToWorld(player1,DimensionType.OVERWORLD, player1.getServerWorld(), mcServer.getWorld(Kathairis.kath_Dim_type),new TeleporterKathairis(player1.getServerWorld()));
                        //player.changeDimension(Kathairis.kath_Dim_type, new TeleporterKathairis(player1.getServerWorld()));
                        setTestXYZ(player1.posX, player1.posY, player1.posZ);


                    } else if (prevX2 != 0.0 && prevY2 != 0.0 && prevZ2 != 0.0) {
                        player1.timeUntilPortal = 10;
                        setDme22();
                        setOverworldXYZ(player1.posX, player1.posY, player1.posZ);
                        player.changeDimension(Kathairis.kath_Dim_type, new TeleporterKathairis(player1.getServerWorld()));

                    }

                } else if (player1.dimension == Kathairis.kath_Dim_type) {

                    player1.timeUntilPortal = 10;
                    setDme22();
                    setTestXYZ(player1.posX, player1.posY, player1.posZ);
                    player.changeDimension(DimensionType.OVERWORLD, new TeleporterKathairis(player1.getServerWorld()));

                }

            }
        }
    }

 


I think that I might be registrying my dimension wrongly, so I am asking you guys for some help :D Thanks, Krevik.

Edited by Krevik
Link to comment
Share on other sites

Quote

mcServer.getWorld(Kathairis.kath_Dim_type)

 

mcServer is probaby null here.

Edited by larsgerrits

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

I fixed this in 1.12.2 by copy/pasting a McJty tutorial. I was getting a slightly different crash there. Something like "I tried to tick this entity that stopped existing mid-tick? Weird?"

 

I had to implement a short CustomTeleporter class to make the inter-dimensional travel official. https://wiki.mcjty.eu/modding/index.php?title=Commands-1.12

 

And if this doesn't work in 1.13.2 then please tell me because I wanted to release the first version of my mod on 1.13.2.

 

 

Link to comment
Share on other sites

7 minutes ago, Catastrophe said:

I fixed this in 1.12.2 by copy/pasting a McJty tutorial. I was getting a slightly different crash there. Something like "I tried to tick this entity that stopped existing mid-tick? Weird?"

 

I had to implement a short CustomTeleporter class to make the inter-dimensional travel official. https://wiki.mcjty.eu/modding/index.php?title=Commands-1.12

 

And if this doesn't work in 1.13.2 then please tell me because I wanted to release the first version of my mod on 1.13.2.

 

 

Unfortunatelly It won't help. The crash is fired before custom Teleporter class is even loaded, so... it's not problem with teleporter class (at least now xD)
EDIT: Anyway I see that teleportation code is in teleporter class, so checked it for another mcServer getting method - also doesn't work :/

Edited by Krevik
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.