Jump to content

Way to get Block-Side player is pointing at ?


Maexx

Recommended Posts

Hi all,

I need to make a tool that breaks a 3x3 area around the block you break.

For that I need to know which side of the block the player is pointing at, but I haven't found a way to do it.

 

I know that onItemUse has a way to do it, but I want to make the tool be used with the left mouse button, not with the right one.

 

Is there any way to do that ?

 

Thanks,

Max

Link to comment
Share on other sites

There is a way to know if player look at +X -X +Z -Z

 

I do this:

int var6 = MathHelper.floor_double((double)(EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

The variable can take 4 values, from 0 to 3, each case is a direction that the player is looking at (can't remember which is everyone, just try them).

 

Hope this help :)

If yo want to say thanks, push the button!

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

There is a way to know if player look at +X -X +Z -Z

 

I do this:

int var6 = MathHelper.floor_double((double)(EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

The variable can take 4 values, from 0 to 3, each case is a direction that the player is looking at (can't remember which is everyone, just try them).

 

Hope this help :)

Sorry for my noob question, how do i get the blocks in a 3x3 in a wall? , i mean, i know how to do it on the floor but i had the same problem as Maexx

 

Link to comment
Share on other sites

  • 6 years later...
On 1/25/2013 at 5:09 AM, Maexx said:

I used VictorZombies method, and it works great :D

I added the check for up and down and packed it into a playerUtil, so I can refer to it from everywhere ;)

 

Thanks a lot,

Max

What did you do do make it work up and down?

Link to comment
Share on other sites

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

Announcements



×
×
  • Create New...

Important Information

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