net.minecraft.util.math.shapes.VoxelShapes Java Examples
The following examples show how to use
net.minecraft.util.math.shapes.VoxelShapes.
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: MergedVoxelShapeHolder.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public VoxelShape update(Collection<T> things) { partCache.clear(); for (T thing : things) { partCache.add(extractor.apply(thing)); } if (!partCache.equals(shapeParts) || mergedShape == null) { shapeParts.clear(); shapeParts.addAll(partCache); //Same as VoxelShapes.or(VoxelShapes.empty(), shapeParts.toArray()); Except we skip useless array creation. VoxelShape merged = shapeParts.stream().reduce(VoxelShapes.empty(), VoxelShapes::or); mergedShape = postProcess.apply(merged); } return mergedShape; }
Example #2
Source File: RayTracer.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * Ray traces from start to end, if the ray intercepts the cuboid it returns a new CuboidRayTraceResult. * * @param pos The BlockPosition to subtract from the start and end vector. * @param start The vector to start RayTracing from. * @param end The vector to end RayTracing at. * @param cuboid The cuboid to check for an intercept. * @return A new CuboidRayTraceResult if successful, null if fail. */ public static CuboidRayTraceResult rayTrace(BlockPos pos, Vector3 start, Vector3 end, IndexedCuboid6 cuboid) { BlockRayTraceResult bbResult = VoxelShapes.create(cuboid.aabb()).rayTrace(start.vec3(), end.vec3(), pos); if (bbResult != null) { Vector3 hitVec = new Vector3(bbResult.getHitVec()); Direction sideHit = bbResult.getFace(); double dist = hitVec.copy().subtract(start).magSquared(); return new CuboidRayTraceResult(hitVec, sideHit, pos, bbResult.isInside(), cuboid, dist); } return null; }
Example #3
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static VoxelShape getShape(AxisAlignedBB aabb) { VoxelShape shape = bbToShapeCache.getIfPresent(aabb); if (shape == null) { shape = VoxelShapes.create(aabb); bbToShapeCache.put(aabb, shape); MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getLeft() == null) { entry.setLeft(aabb); } } return shape; }
Example #4
Source File: VoxelShapeCache.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
public static VoxelShape getShape(Cuboid6 cuboid) { VoxelShape shape = cuboidToShapeCache.getIfPresent(cuboid); if (shape == null) { shape = VoxelShapes.create(cuboid.min.x, cuboid.min.y, cuboid.min.z, cuboid.max.x, cuboid.max.y, cuboid.max.z); cuboidToShapeCache.put(cuboid, shape); MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape); if (entry.getRight() == null) { entry.setRight(cuboid); } } return shape; }
Example #5
Source File: MinersLight.java From MiningGadgets with MIT License | 4 votes |
@Override public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return VoxelShapes.empty(); }