Java Code Examples for net.minecraft.util.math.shapes.VoxelShape#rayTrace()
The following examples show how to use
net.minecraft.util.math.shapes.VoxelShape#rayTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RayTracer.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static BlockRayTraceResult retraceBlock(IBlockReader world, PlayerEntity player, BlockPos pos) { Vec3d startVec = getStartVec(player); Vec3d endVec = getEndVec(player); BlockState state = world.getBlockState(pos); VoxelShape baseShape = state.getShape(world, pos); BlockRayTraceResult baseTraceResult = baseShape.rayTrace(startVec, endVec, pos); if (baseTraceResult != null) { BlockRayTraceResult raytraceTraceShape = state.getRaytraceShape(world, pos).rayTrace(startVec, endVec, pos); if (raytraceTraceShape != null) { return raytraceTraceShape; } } return baseTraceResult; }
Example 2
Source File: SubHitVoxelShape.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
private CuboidRayTraceResult rayTrace(Vec3d start, Vec3d end, BlockPos pos, IndexedCuboid6 cuboid, VoxelShape shape) { BlockRayTraceResult hit = shape.rayTrace(start, end, pos); if (hit != null) { Vector3 hitVec = new Vector3(hit.getHitVec()); return new CuboidRayTraceResult(hitVec, hit.getFace(), pos, hit.isInside(), cuboid, hitVec.copy().subtract(start).magSquared()); } return null; }