Jump to content

[1.7.10]Get the side of the block in which the player is pointing at


Recommended Posts

Posted

Well i made my 3x3 pickaxe based on player yaw and pitch. I am not happy though. Nit at all. After some testing i saw that the pickaxe is not very accurate. Sometimes instead of doing 3x3 when i am looking down it mines like iam looking forward. Is there a way to get ghe side of the block that i am pointing at. Like north, west, up, down. This way the mining would be pretty accurate without using the player yaw and pitch.

Posted

i dont know if there is a straight way of doing this, but you could try comparing the player's position with the block's position, instead of using the player's view...

 

this might not be the optimal way of achieving your goal, but it may help you get a new vision on the subject :/

Posted

That would still not be very accurate. Another way of doing it is raycasting but i dont know how to use it properly ao i just used a block and place it wherever i am destroying a block so i can get the right position however that brought me

Problems with the edges

Posted

Another option could be with Minecraft.getMinecraft().objectMouseOver which is the data type MovingObjectPosition. It can be used to reference not only the block position, but the side that was hit as well. I have used this to find the entity that a player is looking at, but should work just as well with blocks. Hope this helps ;D

Posted

    public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)

    {

        return false;

    }

 

found this in 1.8 . mb u can find it in 1.7 too

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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