use of net.minecraft.entity.player.ServerPlayerEntity in project BluePower by Qmunity.
the class MultipartUtils method getRayTraceVectors.
/**
* Returns the look vector and max reach distance vector relative to the multipart block position.
* based on MC Multipart
* @param entity
*/
public static Pair<Vector3d, Vector3d> getRayTraceVectors(Entity entity) {
float pitch = entity.xRot;
float yaw = entity.yRot;
Vector3d start = new Vector3d(entity.getX(), entity.getY() + entity.getEyeHeight(), entity.getZ());
float f1 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
float f2 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
float f3 = -MathHelper.cos(-pitch * 0.017453292F);
float f4 = MathHelper.sin(-pitch * 0.017453292F);
float f5 = f2 * f3;
float f6 = f1 * f3;
double d3 = 5.0D;
if (entity instanceof ServerPlayerEntity) {
d3 = ((ServerPlayerEntity) entity).getAttribute(net.minecraftforge.common.ForgeMod.REACH_DISTANCE.get()).getValue();
}
Vector3d end = start.add(f5 * d3, f4 * d3, f6 * d3);
return Pair.of(start, end);
}
Aggregations