Jump to content

[1.8] [RESOLVED] return blockPos of clicked spot- even if it is air


Recommended Posts

Posted

I can use the objectMouseOver.hitvec to get a non-air hit, but how to get it if the spot is an air block ?

 

Maybe a better way to state that is to get the block clicked that is adjacent, regardless of what type it is...

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Posted

A line from the player's eyes to the cursor will pass through many air blocks. If you could somehow get a list of all of them, then you could choose the air block at the depth you want.

 

A non-air hit will be the first non air block encountered along the line from the player's eyes to the maximum hit depth.

Posted

If you just always want the block immediately in front of the player, then you can just add the look vector to the player position. You might have to adjust a bit for eye height and such. The look vector is by definiton one block in length, so probably the right length, but you might want to multiply it a bit to make sure you get the block you want.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Experimenting atm... Too bad they've don't have a left click air like RIGHT_CLICK_AIR..

 

Suppose I could just use right click instead (along with LeftControl of course)....

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Posted

Hi

 

I've had to do this a couple of times.  I essentially just copied the vanilla code and modified it slightly

https://gist.github.com/TheGreyGhost/db79ee859f15a9c238c3

 

The hardest part is to get vanilla to ignore the player's right click when you want the air block and not the solid block a bit further away.  I had to use a hack to do that (overwriting the KeyBinding instances in GameSettings.keyBindAttack with my own wrapper class that captures clicks and stops them from being passed to vanilla), you could also use ASM+Reflection.

 

-TGG

 

Posted

It's a shame something that is kind of basic requires so much to achieve :D

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

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.