Posted August 27, 20214 yr I'm trying to get the position of the block the player is aiming at: private BlockRayTraceResult rayTrace(PlayerEntity playerIn, float reach) { Vector3d pos = playerIn.getPositionVec(); Vector3d forward = playerIn.getLookVec(); Vector3d rayVector = forward.scale(reach); return playerIn.world.rayTraceBlocks(pos, rayVector, ?, ?, ?); } I understand what the vectors are doing. My only 2 questions are simple: 1.- For the vector i call 'pos', should i be using player.getEyePosition instead? if so, it's argument is a float called partialTicks, what does this argument represent? 2.- what are the three last arguments for world.rayTraceBlocks? i understand the first one is the start of the ray, and the second the end of it. But no clue about what the others are supposed to be I've tried looking for info on this method and i found nothing. Edited August 27, 20214 yr by Tryhard
August 28, 20214 yr 1. Depends what you want to do. 2. The method you are using is for raytracing a single block, the last three parameters are BlockPos, VoxelShape, and BlockState
August 28, 20214 yr Author Nevermind, i figured it out. I simply wanted to get the position the player is aiming at, and summon lightning at that point, to do so i needed to raytrace. I solved my previous problem by using RayTracingContext. Code looks like this now. Then, from the method in which i spawn lightning: This works as i want it, right now. Any advice from the pros on what could be done better?
August 28, 20214 yr Minecraft.java is a class only exists on client, so does getEyePosition and partial ticks, these will crash the server.
August 28, 20214 yr Author getEyePosition is not annotated with @OnlyIn(Dist.CLIENT), is it sitll going to make the server crash?
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.