Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.7.10] [solved] Teleports 10 block lower than than the given Y value

Featured Replies

Posted

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);

  • Author

Adding 2-3 blocks.

 

I'd still be in the floor about 7-8 blocks lower than I teleported to though

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.

  • 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 :D

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.