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

I'm trying to make a staff kind of weapon. My plan is for it to cast lightning where ever the player is looking, but how would I get the block that the player is looking at?

Kain

You can try using 'getMovingObjectPositionFromPlayer' method to return a MovingObjectPosition, but that will only get you a tile if it is within reach distance. Otherwise, you will need to use vector's from the player's look position:

Vec3 vec3 = player.getPosition(1.0F);
Vec3 vec3a = player.getLook(1.0F);
Vec3 vec3b = vec3.addVector(vec3a.xCoord * distance, vec3a.yCoord * distance, vec3a.zCoord * distance);

MovingObjectPosition movingobjectposition = world.clip(vec3, vec3b);

There may be a better/simpler way than this, but this worked for my purposes. The MovingObjectPosition will contain information on the tile hit, if any. Be sure to null-check.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.