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.

Featured Replies

Posted

Hi  :),

 

I am trying to make the player orbit around a block.  I would like to have the player always face the block at the center of the orbit. I've been messing around with:

 

player.setPosition(x, y, z);
player.setPositionAndRotation(x, y, z, yaw, pitch);
player.setPositionAndUpdate(x, y, z);
player.setLocationAndAngles(x, y, z, yaw, pitch);

 

Setting the position seems to be working ok. I am having problems setting the direction the player is looking. Ideally I would be looking for something like:

 

player.setLocation(double x, double y, double z);
player.facePosition(BlockPos pos);

 

When you hit f5, minecraft behaves like this, except I want a block at the center of the view. Any help is appreciated :)

I suppose some mathematic calculations should be applyed to get pitch and yaw.

double x = player.posX - blockPos.getX() - 0.5;
double y = player.posY - blockPos.getY() - 0.5;
double z = player.posZ - blockPos.getZ() - 0.5;
double pitch = Math.atan2(-y, Math.sqrt(x*x+z*z));
double yaw = Math.atan2(z, -x);

I forget the sign before

x

and

y

. You may try twice and get the correct ones.

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

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.