Jump to content

Recommended Posts

Posted

I am having an issue where the player is desynced from the server when I teleport them from The End to a custom dimension.

 

Method I am calling to teleport player:

Spoiler

public static void TeleportEntityToDimension(Entity entityIn, World worldIn, int dimID, float x, float y, float z){
        if (!worldIn.isRemote && worldIn.provider.getDimension() != dimID) {
            WorldTeleporter teleporter = new WorldTeleporter(entityIn.getServer().getWorld(dimID), new BlockPos(x, y, z));
            if (entityIn instanceof EntityPlayerMP) {
                entityIn.setPosition(x, y, z);
                entityIn.getServer().getPlayerList().transferPlayerToDimension((EntityPlayerMP) entityIn, dimID, teleporter);
            } else {
                changeDimension(entityIn, dimID, teleporter);
            }
        }
    }

The changeDimension method I only use for non-player entities and it is based off of the Entity.changeDimension method, modified so that it works without a portal block. It does not work for players.

And here is my teleporter class:

Spoiler

public class WorldTeleporter extends Teleporter {

    BlockPos exit;
    WorldServer world;

 

    public WorldTeleporter(WorldServer worldIn, BlockPos exit) {
        super(worldIn);
        this.exit = exit;
        world = worldIn;
    }

 

    @Override
    public void placeInPortal(Entity entityIn, float rotationYaw) {
        entityIn.setLocationAndAngles(exit.getX(), exit.getY(), exit.getZ(), entityIn.rotationYaw, 0.0F);
        entityIn.motionX = 0.0D;
        entityIn.motionY = 0.0D;
        entityIn.motionZ = 0.0D;
    }
}

When the player is teleported from The End they can move around but cannot throw items, spawn entities. They can place blocks however.

 

The code works fine from the Nether or the Overworld, and I can't find what part of my code would be causing it. Is this a problem with the transferPlayerToDimension method? If so, is there another good way to teleport players between dimensions?

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.