Jump to content

[SOLVED][1.13.2] NPE while getting any WorldServer


Recommended Posts

Posted (edited)

Hello! I am having some problem with teleporting player/entity to a new dimension. Whenever I try to get WorldServer (for my custom dimension or for Overworld) like that (because it's required argument to teleport player/entity)
 

                    WorldServer server = worldIn.getServer().getWorld(DimensionType.OVERWORLD);
                    WorldServer server = worldIn.getServer().getWorld(someFile.cusotm_Dimension_Type);

I am getting NPE crash which points at the line I am trying to get WorldServer. Am I doing sth wrong or is it forge fault? I am using forge 0.45

Note that 
 

                    WorldServer server = player.getServer().getWorld(DimensionType.OVERWORLD);

also doesn't work.


Here's my whole teleportation code 
 

Spoiler

    public void onEntityCollision(IBlockState state, World worldIn, BlockPos pos, Entity entityIn) {
        if (!entityIn.isPassenger() && !entityIn.isBeingRidden() && entityIn.isNonBoss())
        {
            entityIn.setPortal(pos);
            if(entityIn instanceof EntityPlayerMP){
                EntityPlayerMP player = (EntityPlayerMP) entityIn;
                entityIn.timeUntilPortal=10;
                if(player.dimension==Kathairis.kath_Dim_type){

                }else if(player.dimension==DimensionType.OVERWORLD){
                    WorldServer server = player.getServer().getWorld(DimensionType.OVERWORLD);
                    player.changeDimension(DimensionType.OVERWORLD,new TeleporterKathairis(server));
                }
            }else{
                entityIn.timeUntilPortal=10;
                if(entityIn.dimension== Kathairis.kath_Dim_type){
                    entityIn.changeDimension(DimensionType.OVERWORLD,new TeleporterKathairis(entityIn.getServer().getWorld(DimensionType.OVERWORLD)));
                }else if(entityIn.dimension == DimensionType.OVERWORLD){
                    WorldServer server = worldIn.getServer().getWorld(DimensionType.OVERWORLD);
                    Validate.notNull(server, "server is null!");

                    entityIn.changeDimension(DimensionType.OVERWORLD,new TeleporterKathairis(server));
                }
            }
        }
    }

 

 

Edited by Krevik

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.