use of ivorius.ivtoolkit.blocks.BlockSurfaceArea in project RecurrentComplex by Ivorforce.
the class RayMatcher method cast.
@Override
public OptionalInt cast(WorldCache cache, StructurePlaceContext context, int y) {
BlockSurfaceArea surfaceArea = BlockSurfaceArea.from(context.boundingBox);
int height = cache.world.getHeight();
while (true) {
if (// Found none
y < 0 || y >= height)
return OptionalInt.empty();
if (matches(cache, surfaceArea, y, requiredRatio))
break;
y += up ? 1 : -1;
}
return OptionalInt.of(y);
}
use of ivorius.ivtoolkit.blocks.BlockSurfaceArea in project RecurrentComplex by Ivorforce.
the class CommandDecorate method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
Parameters parameters = Parameters.of(args, expect()::declare);
BlockSurfaceArea area = new BlockSurfaceArea(parameters.get(0).to(IvP.surfacePos(commandSender.getPosition(), false)).require(), parameters.get(2).to(IvP.surfacePos(commandSender.getPosition(), false)).require());
BlockSurfaceArea chunkArea = new BlockSurfaceArea(getChunkPos(area.getPoint1()), getChunkPos(area.getPoint2()));
Predicate<Structure> structurePredicate = parameters.get("exp").to(RCP::structurePredicate).optional().orElse(structureInfo -> true);
WorldServer world = (WorldServer) commandSender.getEntityWorld();
if (parameters.has("one")) {
BlockSurfacePos lower = area.getLowerCorner();
int[] size = area.areaSize();
BlockPos pos = new BlockPos(lower.x + world.rand.nextInt(size[0]), 0, lower.z + world.rand.nextInt(size[1]));
if (!WorldGenStructures.generateOneStructureInChunk(world.rand, new ChunkPos(pos), world, world.getBiome(pos)))
throw RecurrentComplex.translations.commandException("commands.rcdecorateone.none");
} else
chunkArea.forEach(coord -> WorldGenStructures.decorate(world, world.rand, new ChunkPos(coord.x, coord.z), structurePredicate));
}
Aggregations