Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

teleporting players between dimensions and to new location with command


Recommended Posts

I'm able to teleport the player when they collide with a block, but when I use the same method (or similar) with custom commands and/or a tick handler, it doesn't work. and by doesn't work, I mean it does absolutely nothing. any help would be appreciated. here's the relevant code.

https://github.com/code-lyoko-modding/CodeLyokoMod/blob/master/matt/lyoko/handlers/ServerTickHandler.java

https://github.com/code-lyoko-modding/CodeLyokoMod/blob/master/matt/lyoko/handlers/CommandHandler.java

the variables in PlayerInformation are being stored and retrieved correctly btw.

Link to post
Share on other sites

Here's the code I use with an item, if this helps:

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (par3EntityPlayer instanceof EntityPlayerMP)
        {
            WorldServer worldserver = (WorldServer)par2World;
            EntityPlayerMP var4 = (EntityPlayerMP)par3EntityPlayer;

            if (par3EntityPlayer.ridingEntity == null && par3EntityPlayer.riddenByEntity == null && par3EntityPlayer instanceof EntityPlayer && var4.dimension != Registration.dimID)
            {
                var4.mcServer.getConfigurationManager().transferPlayerToDimension(var4, Registration.dimID, new TutorialTeleporter(worldserver));
            }
            if (par3EntityPlayer.ridingEntity == null && par3EntityPlayer.riddenByEntity == null && par3EntityPlayer instanceof EntityPlayer && var4.dimension == Registration.dimID)
            {
                var4.mcServer.getConfigurationManager().transferPlayerToDimension(var4, 0, new TutorialTeleporter(worldserver));
            }
        }
        return par1ItemStack;
    }

Link to post
Share on other sites

set a breakpoint at the player.dimension = pi.scannerDim;

Line and see that it executes correctly, then after the player.setPositionAndRotation() is done, check what cordinates the player really is at, did it the player object's coords change?

 

 

also I haven't used Player information before, but "pi.getScannerPosX()" is this the X pos you want him to end up at or the location he currently is at? Just wondering since I have no idea what it is ;)

 

 

If you guys dont get it.. then well ya.. try harder...

Link to post
Share on other sites

set a breakpoint at the player.dimension = pi.scannerDim;

Line and see that it executes correctly, then after the player.setPositionAndRotation() is done, check what cordinates the player really is at, did it the player object's coords change?

 

also I haven't used Player information before, but "pi.getScannerPosX()" is this the X pos you want him to end up at or the location he currently is at? Just wondering since I have no idea what it is ;)

 

for the most part this works. all I had to do was send a packet. but my new problem, is that I don't change dimensions when I teleport. I have to log-out and then log back in to be in the correct dimension. and pi.getScannerPosX() gives the target x coordinate.

 

EDIT: I've also tried "player.travelToDimension(pi.ScannerDim);" and it teleports me to the correct dimension, but it then teleports me to the nether. I can't figure out why.

Link to post
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.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.