Search in sources :

Example 1 with BlockSurfacePos

use of ivorius.ivtoolkit.blocks.BlockSurfacePos in project RecurrentComplex by Ivorforce.

the class CommandDecorateOne method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    WorldServer entityWorld = (WorldServer) commandSender.getEntityWorld();
    BlockSurfacePos pos = parameters.iv().surfacePos(commandSender.getPosition(), false).require();
    if (!WorldGenStructures.generateRandomStructureInChunk(entityWorld.rand, pos.chunkCoord(), entityWorld, entityWorld.getBiome(pos.blockPos(0))))
        throw ServerTranslations.commandException("commands.rcdecorateone.none");
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) WorldServer(net.minecraft.world.WorldServer)

Example 2 with BlockSurfacePos

use of ivorius.ivtoolkit.blocks.BlockSurfacePos in project RecurrentComplex by Ivorforce.

the class WorldGenStructures method planStaticStructuresInChunk.

public static void planStaticStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, BlockPos spawnPos, @Nullable Predicate<Structure> structurePredicate) {
    StructureRegistry.INSTANCE.getStaticStructuresAt(chunkPos, world, spawnPos).forEach(triple -> {
        StaticGeneration staticGenInfo = triple.getMiddle();
        Structure<?> structure = triple.getLeft();
        BlockSurfacePos pos = triple.getRight();
        if (structurePredicate != null && !structurePredicate.test(structure))
            return;
        new StructureGenerator<>(structure).world(world).generationInfo(staticGenInfo).seed(random.nextLong()).randomPosition(pos, staticGenInfo.placer.getContents()).fromCenter(true).partially(RecurrentComplex.PARTIALLY_SPAWN_NATURAL_STRUCTURES, chunkPos).generate();
    });
}
Also used : StaticGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.StaticGeneration) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos)

Example 3 with BlockSurfacePos

use of ivorius.ivtoolkit.blocks.BlockSurfacePos in project RecurrentComplex by Ivorforce.

the class CommandNaturalFloor method fillSurface.

private static void fillSurface(MockWorld world, BlockArea area, double expansion, IBlockState floorBlock, BlockPos pos, Set<BlockSurfacePos> coords) {
    BlockSurfacePos surfacePos = BlockSurfacePos.from(pos);
    for (int expX = MathHelper.ceil(-expansion); expX <= expansion; expX++) {
        for (int expZ = MathHelper.ceil(-expansion); expZ <= expansion; expZ++) {
            if (expX * expX + expZ * expZ <= expansion * expansion) {
                BlockSurfacePos scoord = surfacePos.add(expX, expZ);
                setBlockIfAirInArea(world, scoord.blockPos(pos.getY()), floorBlock, area);
                coords.add(scoord);
            }
        }
    }
}
Also used : BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos)

Example 4 with BlockSurfacePos

use of ivorius.ivtoolkit.blocks.BlockSurfacePos in project RecurrentComplex by Ivorforce.

the class WorldGenStructures method planStructureInChunk.

// TODO Use !instantly to only plan structure but later generate
protected static boolean planStructureInChunk(ChunkPos chunkPos, WorldServer world, Structure<?> structure, NaturalGeneration naturalGenInfo, long seed) {
    String structureName = StructureRegistry.INSTANCE.id(structure);
    BlockSurfacePos genPos = randomSurfacePos(chunkPos, seed);
    if (!naturalGenInfo.hasLimitations() || naturalGenInfo.getLimitations().areResolved(world, structureName)) {
        StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).generationInfo(naturalGenInfo).seed(seed).maturity(StructureSpawnContext.GenerateMaturity.SUGGEST).randomPosition(genPos, naturalGenInfo.placer.getContents()).fromCenter(true).partially(RecurrentComplex.PARTIALLY_SPAWN_NATURAL_STRUCTURES, chunkPos);
        if (naturalGenInfo.getGenerationWeight(world.provider, generator.environment().biome) <= 0) {
            RecurrentComplex.logger.trace(String.format("%s failed to spawn at %s (incompatible biome edge)", structure, genPos));
            return false;
        }
        return generator.generate() != null;
    }
    return false;
}
Also used : BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos)

Example 5 with BlockSurfacePos

use of ivorius.ivtoolkit.blocks.BlockSurfacePos in project RecurrentComplex by Ivorforce.

the class CommandGenerateStructure method execute.

@Override
@ParametersAreNonnullByDefault
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args, "mirror", "select");
    String structureID = parameters.get().first().require();
    Structure<?> structure = parameters.rc().structure().require();
    WorldServer world = parameters.mc("dimension").dimension(server, sender).require();
    AxisAlignedTransform2D transform = parameters.transform("rotation", "mirror").optional().orElse(null);
    GenerationType generationType = parameters.rc("gen").generationType(structure).require();
    BlockSurfacePos pos = parameters.surfacePos("x", "z", sender.getPosition(), false).require();
    String seed = parameters.get("seed").first().optional().orElse(null);
    boolean select = parameters.has("select");
    Placer placer = generationType.placer();
    StructureGenerator<?> generator = new StructureGenerator<>(structure).world(world).generationInfo(generationType).seed(RCStrings.seed(seed)).structureID(structureID).randomPosition(pos, placer).fromCenter(true).transform(transform);
    Optional<StructureBoundingBox> boundingBox = generator.boundingBox();
    if (!boundingBox.isPresent())
        throw ServerTranslations.commandException("commands.strucGen.noPlace");
    if (structure instanceof GenericStructure && world == sender.getEntityWorld()) {
        GenericStructure genericStructureInfo = (GenericStructure) structure;
        BlockPos lowerCoord = StructureBoundingBoxes.min(boundingBox.get());
        OperationRegistry.queueOperation(new OperationGenerateStructure(genericStructureInfo, generationType.id(), generator.transform(), lowerCoord, false).withSeed(seed).withStructureID(structureID).prepare(world), sender);
    } else {
        if (generator.generate() == null)
            throw ServerTranslations.commandException("commands.strucGen.noPlace");
    }
    if (select) {
        SelectionOwner owner = RCCommands.getSelectionOwner(sender, null, false);
        owner.setSelection(RCBlockAreas.from(boundingBox.get()));
    }
}
Also used : OperationGenerateStructure(ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) Placer(ivorius.reccomplex.world.gen.feature.structure.Placer) WorldServer(net.minecraft.world.WorldServer) GenerationType(ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockPos(net.minecraft.util.math.BlockPos) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Aggregations

BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)7 BlockPos (net.minecraft.util.math.BlockPos)3 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)2 HashSet (java.util.HashSet)2 IBlockState (net.minecraft.block.state.IBlockState)2 WorldServer (net.minecraft.world.WorldServer)2 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)1 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)1 BlockGenericSpace (ivorius.reccomplex.block.BlockGenericSpace)1 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)1 OperationGenerateStructure (ivorius.reccomplex.world.gen.feature.structure.OperationGenerateStructure)1 Placer (ivorius.reccomplex.world.gen.feature.structure.Placer)1 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)1 GenerationType (ivorius.reccomplex.world.gen.feature.structure.generic.generation.GenerationType)1 StaticGeneration (ivorius.reccomplex.world.gen.feature.structure.generic.generation.StaticGeneration)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 Block (net.minecraft.block.Block)1 Vec3i (net.minecraft.util.math.Vec3i)1 StructureBoundingBox (net.minecraft.world.gen.structure.StructureBoundingBox)1