类net.minecraft.util.math.shapes.VoxelShape源码实例Demo

下面列出了怎么用net.minecraft.util.math.shapes.VoxelShape的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: EnderStorage   文件: BlockEnderTank.java
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
    VoxelShape shape = TANK_SHAPE;
    TileEntity t = worldIn.getTileEntity(pos);
    if (t instanceof TileEnderTank) {
        TileEnderTank tile = (TileEnderTank) t;
        shape = SHAPES[tile.rotation];
    }
    return shape;
}
 
源代码2 项目: EnderStorage   文件: BlockEnderChest.java
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
    VoxelShape shape = CHEST_SHAPE;
    TileEntity t = worldIn.getTileEntity(pos);
    if (t instanceof TileEnderChest) {
        TileEnderChest tile = (TileEnderChest) t;
        shape = SHAPES[tile.rotation][tile.getRadianLidAngle(0) >= 0 ? 0 : 1];
    }
    return shape;
}
 
源代码3 项目: CodeChickenLib   文件: MergedVoxelShapeHolder.java
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;
}
 
源代码4 项目: CodeChickenLib   文件: RayTracer.java
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;
}
 
源代码5 项目: CodeChickenLib   文件: SubHitVoxelShape.java
/**
 * @param shape   The base advertised VoxelShape. (Collision / w/e)
 * @param cuboids Any SubHit's.
 */
public SubHitVoxelShape(VoxelShape shape, List<IndexedCuboid6> cuboids) {
    super(shape.part);
    this.shape = shape;
    cuboidShapes = cuboids.stream()//
            .map(e -> Pair.of(e, VoxelShapeCache.getShape(e)))//
            .collect(Collectors.toList());
}
 
源代码6 项目: CodeChickenLib   文件: SubHitVoxelShape.java
@Nullable
@Override
public BlockRayTraceResult rayTrace(Vec3d start, Vec3d end, BlockPos pos) {
    CuboidRayTraceResult closest = null;
    double dist = Double.MAX_VALUE;
    for (Pair<IndexedCuboid6, VoxelShape> cuboidShape : cuboidShapes) {
        CuboidRayTraceResult hit = rayTrace(start, end, pos, cuboidShape.getLeft(), cuboidShape.getRight());
        if (hit != null && dist > hit.dist) {
            closest = hit;
            dist = hit.dist;
        }
    }
    return closest;
}
 
源代码7 项目: CodeChickenLib   文件: SubHitVoxelShape.java
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;
}
 
源代码8 项目: CodeChickenLib   文件: VoxelShapeCache.java
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;
}
 
源代码9 项目: CodeChickenLib   文件: VoxelShapeCache.java
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;
}
 
源代码10 项目: CodeChickenLib   文件: VoxelShapeCache.java
public static AxisAlignedBB getAABB(VoxelShape shape) {
    MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape);
    if (entry.getLeft() == null) {
        entry.setLeft(shape.getBoundingBox());
    }
    return entry.getLeft();
}
 
源代码11 项目: CodeChickenLib   文件: VoxelShapeCache.java
public static Cuboid6 getCuboid(VoxelShape shape) {
    MutablePair<AxisAlignedBB, Cuboid6> entry = getReverse(shape);
    if (entry.getRight() == null) {
        entry.setRight(new Cuboid6(// I hope this is okay, don't want to rely on AABB cache.
                shape.getStart(Direction.Axis.X), shape.getStart(Direction.Axis.Y), shape.getStart(Direction.Axis.Z),//
                shape.getEnd(Direction.Axis.X), shape.getEnd(Direction.Axis.Y), shape.getEnd(Direction.Axis.Z)//
        ));
    }
    return entry.getRight();
}
 
源代码12 项目: CodeChickenLib   文件: VoxelShapeCache.java
private static MutablePair<AxisAlignedBB, Cuboid6> getReverse(VoxelShape shape) {
    MutablePair<AxisAlignedBB, Cuboid6> entry = shapeToBBCuboid.getIfPresent(shape);
    if (entry == null) {
        entry = new MutablePair<>();
        shapeToBBCuboid.put(shape, entry);
    }
    return entry;
}
 
static boolean isSpawnable(World world, BlockPos pos, BlockState spawnBlockState, BlockState upperBlockState) {
    VoxelShape collisionShape = upperBlockState.getCollisionShape(world, pos);
    boolean isNether = world.dimension.isNether();
    return spawnBlockState.canEntitySpawn(world, pos.down(), isNether ? EntityType.ZOMBIE_PIGMAN : entityType) &&
            !Block.doesSideFillSquare(collisionShape, Direction.UP) &&
            !upperBlockState.canProvidePower() &&
            !upperBlockState.isIn(BlockTags.RAILS) &&
            collisionShape.getEnd(Direction.Axis.Y) <= 0 &&
            upperBlockState.getFluidState().isEmpty() &&
            (isNether || world.getLightFor(LightType.BLOCK, pos) <= 7);
}
 
源代码14 项目: MiningGadgets   文件: MinersLight.java
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
    return VoxelShapes.empty();
}
 
源代码15 项目: MiningGadgets   文件: MinersLight.java
/**
 * @deprecated call via {@link BlockState#getPushReaction()} whenever possible. Implementing/overriding is fine.
 */
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext selectionContext) {
    return SHAPE;
}
 
源代码16 项目: CodeChickenLib   文件: Cuboid6.java
public VoxelShape shape() {
    return VoxelShapeCache.getShape(this);
}
 
源代码17 项目: CodeChickenLib   文件: MergedVoxelShapeHolder.java
public MergedVoxelShapeHolder<T> setExtractor(Function<T, VoxelShape> extractor) {
    this.extractor = extractor;
    return this;
}
 
源代码18 项目: CodeChickenLib   文件: MergedVoxelShapeHolder.java
public MergedVoxelShapeHolder<T> setPostProcessHook(Function<VoxelShape, VoxelShape> postProcess) {
    this.postProcess = postProcess;
    return this;
}
 
源代码19 项目: Survivalist   文件: ChoppingBlock.java
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
{
    return SHAPE;
}
 
源代码20 项目: Survivalist   文件: DryingRackBlock.java
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
{
    return (state.get(FACING).getHorizontalIndex() % 2) == 0 ? shape1 : shape2;
}
 
 类所在包
 类方法
 同包方法