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;
}
Aggregations