Search in sources :

Example 1 with BlockSurfaceArea

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);
}
Also used : BlockSurfaceArea(ivorius.ivtoolkit.blocks.BlockSurfaceArea)

Example 2 with BlockSurfaceArea

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));
}
Also used : BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) MCE(ivorius.mcopts.commands.parameters.expect.MCE) Predicate(java.util.function.Predicate) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) CommandExpecting(ivorius.mcopts.commands.CommandExpecting) RCConfig(ivorius.reccomplex.RCConfig) RCE(ivorius.reccomplex.commands.parameters.expect.RCE) BlockSurfaceArea(ivorius.ivtoolkit.blocks.BlockSurfaceArea) RCP(ivorius.reccomplex.commands.parameters.RCP) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) Expect(ivorius.mcopts.commands.parameters.expect.Expect) ICommandSender(net.minecraft.command.ICommandSender) IvP(ivorius.reccomplex.commands.parameters.IvP) WorldGenStructures(ivorius.reccomplex.world.gen.feature.WorldGenStructures) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) WorldServer(net.minecraft.world.WorldServer) Nonnull(javax.annotation.Nonnull) Parameters(ivorius.mcopts.commands.parameters.Parameters) Parameters(ivorius.mcopts.commands.parameters.Parameters) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) BlockSurfaceArea(ivorius.ivtoolkit.blocks.BlockSurfaceArea) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) RCP(ivorius.reccomplex.commands.parameters.RCP)

Aggregations

BlockSurfaceArea (ivorius.ivtoolkit.blocks.BlockSurfaceArea)2 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 CommandExpecting (ivorius.mcopts.commands.CommandExpecting)1 Parameters (ivorius.mcopts.commands.parameters.Parameters)1 Expect (ivorius.mcopts.commands.parameters.expect.Expect)1 MCE (ivorius.mcopts.commands.parameters.expect.MCE)1 RCConfig (ivorius.reccomplex.RCConfig)1 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)1 IvP (ivorius.reccomplex.commands.parameters.IvP)1 RCP (ivorius.reccomplex.commands.parameters.RCP)1 RCE (ivorius.reccomplex.commands.parameters.expect.RCE)1 WorldGenStructures (ivorius.reccomplex.world.gen.feature.WorldGenStructures)1 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)1 Predicate (java.util.function.Predicate)1 Nonnull (javax.annotation.Nonnull)1 CommandException (net.minecraft.command.CommandException)1 ICommandSender (net.minecraft.command.ICommandSender)1 MinecraftServer (net.minecraft.server.MinecraftServer)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1