Posted March 29, 201510 yr Any help? I've been adding 10 to the newY value, but that causes unnecessary fall damage. here's the code: private static void teleportPlayer(EntityPlayerMP player){ int newX = (rand.nextInt(65536)-32768); int newY = 60; int newZ = (rand.nextInt(65536)-32768); boolean safe = safetyCheck(player.worldObj, newX, newY, newZ); while(!safe){ newY++; safe = safetyCheck(player.worldObj, newX, newY, newZ); //System.out.println("BlockExists: " + safe); } player.playerNetServerHandler.setPlayerLocation(newX, newY + 13, newZ, player.rotationYaw, player.rotationPitch); afterCheck(player, newX, newY, newZ); } --EDIT-- If you have the same problem as me, the code you need to use is player.setPositionAndUpdate(newX, newY, newZ);
March 29, 201510 yr Author Adding 2-3 blocks. I'd still be in the floor about 7-8 blocks lower than I teleported to though
March 29, 201510 yr EntityPlayer has the setPositionAndUpdate method. This is what I use to teleport players in my mod. player.setPositionAndUpdate(loc.posX, loc.posY, loc.posZ); player.fallDistance = 0F; They end up exactly where they're supposed to be, the fallDistance = 0F gaurantees if they were previously falling through the air before teleport they won't take fall damage.
March 29, 201510 yr Author EntityPlayer has the setPositionAndUpdate method. This is what I use to teleport players in my mod. player.setPositionAndUpdate(loc.posX, loc.posY, loc.posZ); player.fallDistance = 0F; They end up exactly where they're supposed to be, the fallDistance = 0F gaurantees if they were previously falling through the air before teleport they won't take fall damage. This fixed it thanks
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.