Search in sources :

Example 1 with BlockRedstoneOre

use of net.minecraft.block.BlockRedstoneOre in project Cavern2 by kegare.

the class OreCompass method findOrePos.

@Nullable
public static BlockPos findOrePos(@Nullable IBlockAccess world, @Nullable BlockPos origin, int range) {
    if (world == null || origin == null || range <= 0) {
        return null;
    }
    int dist = 0;
    while (++dist < range) {
        BlockPos from = origin.add(dist, 3, dist);
        BlockPos to = origin.add(-dist, -3, -dist);
        for (BlockPos pos : BlockPos.getAllInBoxMutable(from, to)) {
            if (world.isAirBlock(pos)) {
                continue;
            }
            IBlockState state = world.getBlockState(pos);
            if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockRedstoneOre) {
                return new BlockPos(pos);
            }
            if (MinerStats.getPointAmount(state) > 0) {
                return new BlockPos(pos);
            }
        }
    }
    return null;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockOre(net.minecraft.block.BlockOre) BlockRedstoneOre(net.minecraft.block.BlockRedstoneOre) BlockPos(net.minecraft.util.math.BlockPos) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)1 BlockOre (net.minecraft.block.BlockOre)1 BlockRedstoneOre (net.minecraft.block.BlockRedstoneOre)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1