From d77ee030c2357be05421459c7b62e7abe95ff29a Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Sat, 28 Dec 2013 00:40:40 -0800 Subject: [PATCH] Modify Pipe RayTrace to better reflect EyeHeight --- .../transport/BlockGenericPipe.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index cd056b73..6f5398ea 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -260,22 +260,17 @@ public class BlockGenericPipe extends BlockBuildCraft { } } - private RaytraceResult doRayTrace(World world, int x, int y, int z, EntityPlayer entityPlayer) { - double pitch = Math.toRadians(entityPlayer.rotationPitch); - double yaw = Math.toRadians(entityPlayer.rotationYaw); - - double dirX = -Math.sin(yaw) * Math.cos(pitch); - double dirY = -Math.sin(pitch); - double dirZ = Math.cos(yaw) * Math.cos(pitch); - + private RaytraceResult doRayTrace(World world, int x, int y, int z, EntityPlayer player) { double reachDistance = 5; - if (entityPlayer instanceof EntityPlayerMP) { - reachDistance = ((EntityPlayerMP) entityPlayer).theItemInWorldManager.getBlockReachDistance(); + if (player instanceof EntityPlayerMP) { + reachDistance = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance(); } - Vec3 origin = Vec3.fakePool.getVecFromPool(entityPlayer.posX, entityPlayer.posY + 1.62 - entityPlayer.yOffset, entityPlayer.posZ); - Vec3 direction = origin.addVector(dirX * reachDistance, dirY * reachDistance, dirZ * reachDistance); + double eyeHeight = world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight(); + Vec3 lookVec = player.getLookVec(); + Vec3 origin = world.getWorldVec3Pool().getVecFromPool(player.posX, player.posY + eyeHeight, player.posZ); + Vec3 direction = origin.addVector(lookVec.xCoord * reachDistance, lookVec.yCoord * reachDistance, lookVec.zCoord * reachDistance); return doRayTrace(world, x, y, z, origin, direction); }