Posted August 14, 201510 yr 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
August 14, 201510 yr 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.
August 14, 201510 yr 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/
August 14, 201510 yr Author 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
August 14, 201510 yr 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
August 16, 201510 yr Author It's a shame something that is kind of basic requires so much to achieve 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.