Posted September 3, 201510 yr i need help finding how to get the pos X, Y and Z of the block the player is looking at from any distance. i think it has something to do with ray traces, i think.
September 3, 201510 yr MovingObjectPosition mop = player.rayTrace(distance, partialTickTime); mop.blockX/Y/Z; Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
September 4, 201510 yr Look in net.minecraft.gui.GuiOverlayDebug and then search for Looking at and see how it is done there.
September 4, 201510 yr Author ok found this code and it works MovingObjectPosition lastPosition = playerIn.rayTrace(100, 1.0F); playerIn.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "Position [ X: " + lastPosition.getBlockPos().getX() + " Y: " + lastPosition.getBlockPos().getY() + 1 + " Z: " + lastPosition.getBlockPos().getZ() + " ]"));
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.