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");
}
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();
});
}
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);
}
}
}
}
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;
}
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()));
}
}
Aggregations