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

The Block class has a method removeBlockByPlayer which removes the block when a player breaks it. How to get the hitX, hitY, hitZ coordinates where the player hit the block? The given arguments are World world, EntityPlayer player, int x, int y, int z. I found the method EntityLiving.rayTrace(double reachDistance, float partialTickTime), but i don't know what the parameter partialTickTime is for, and as i set it to 1, I got different results on client and server side.

With hitX,hitY & hitZ are you reffering to which side of the block the player was hitting it, or?

I'm unsure about exactly what you want to get. If you want the side he hit, I believe you could cast a ray from the player to see what side of the block you hit.

 

Looking into the code for entityLiving.rayTrace(...);

It returns an "MovingObjectPosition" which has among other things the following properties:

 

typeOfHit - int which has 0 for Block and 1 for Entity.

sideHit - int which is Bottom = 0, Top = 1, East = 2, West = 3, North = 4, South = 5

                  or -1 if the RayTrace went the full length of it's trace.

 

Also it contains the entity you hit(if you hit one, else it's null of course). And the coordinates for the block etc.

Check out the code for it, I believe you could use that to solve your problem :)

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

  • Author

I refer to the exact coordinates the player was hitting. The problem with the rayTrace function is, that i don't know how to use it. It takes two arguments: reachDistance and partialTickTime. I can get the reachDistance, but i have no idea what the partialTickTime is for. When I start it and set partialTickTime to 1, i get different results on server and client side(very different).

And with exact coordinates you mean which pixel on the block's surface did he point at?

also client doesn't have all the information the server has, the server one should be the correct one :)

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

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.