Search in sources :

Example 6 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class CommandContaining method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    BlockExpression matcher = parameters.rc().expression(new BlockExpression(RecurrentComplex.specialRegistry)).require();
    CommandSearchStructure.postResultMessage(commandSender, RCTextStyle::structure, CommandSearchStructure.search(StructureRegistry.INSTANCE.ids(), name -> containedBlocks(StructureRegistry.INSTANCE.get(name), matcher)));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) IvBlockCollection(ivorius.ivtoolkit.blocks.IvBlockCollection) BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) RCConfig(ivorius.reccomplex.RCConfig) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) List(java.util.List) ICommandSender(net.minecraft.command.ICommandSender) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Nullable(javax.annotation.Nullable) RCTextStyle(ivorius.reccomplex.commands.RCTextStyle) BlockExpression(ivorius.reccomplex.utils.expression.BlockExpression)

Example 7 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class CommandDecorate method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    BlockSurfaceArea area = new BlockSurfaceArea(parameters.iv().surfacePos(commandSender.getPosition(), false).require(), parameters.iv().move(2).surfacePos(commandSender.getPosition(), false).require());
    BlockSurfaceArea chunkArea = new BlockSurfaceArea(getChunkPos(area.getPoint1()), getChunkPos(area.getPoint2()));
    Predicate<Structure> structurePredicate = parameters.rc("exp").structurePredicate().optional().orElse(structureInfo -> true);
    WorldServer world = (WorldServer) commandSender.getEntityWorld();
    chunkArea.forEach(coord -> WorldGenStructures.decorate(world, world.rand, new ChunkPos(coord.x, coord.z), structurePredicate));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) BlockSurfaceArea(ivorius.ivtoolkit.blocks.BlockSurfaceArea) WorldServer(net.minecraft.world.WorldServer) ChunkPos(net.minecraft.util.math.ChunkPos) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure)

Example 8 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class RCParameter method genericStructure.

public Result<GenericStructure> genericStructure() {
    return first().map(id -> {
        Structure structure = StructureRegistry.INSTANCE.get(id);
        if (structure == null)
            throw ServerTranslations.commandException("commands.structure.notRegistered", id);
        GenericStructure genericStructureInfo = structure.copyAsGenericStructure();
        if (genericStructureInfo == null)
            throw ServerTranslations.commandException("commands.structure.notGeneric", id);
        return genericStructureInfo;
    });
}
Also used : GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)

Example 9 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class RCSaplingGenerator method growSapling.

public static void growSapling(WorldServer world, BlockPos pos, Random random, Structure<?> structure, SaplingGeneration saplingGenInfo) {
    int[] strucSize = structure.size();
    Multimap<AxisAlignedTransform2D, BlockPos> placeables = saplingGenInfo.pattern.testAll(world, pos, strucSize, structure.isRotatable(), structure.isMirrorable());
    // Use keys() here to get the correct distribution
    AxisAlignedTransform2D transform = Lists.newArrayList(placeables.keys()).get(random.nextInt(placeables.keys().size()));
    Collection<BlockPos> transformedPositions = placeables.get(transform);
    BlockPos startPos = Lists.newArrayList(transformedPositions).get(random.nextInt(transformedPositions.size()));
    Map<BlockPos, IBlockState> before = new HashMap<>();
    IBlockState air = Blocks.AIR.getDefaultState();
    saplingGenInfo.pattern.copy(transform, strucSize).forEach(i -> i.delete, entry -> {
        BlockPos ePos = entry.getKey().add(startPos);
        before.put(ePos, world.getBlockState(ePos));
        world.setBlockState(ePos, air, 4);
    });
    BlockPos spawnPos = transform.apply(saplingGenInfo.spawnShift, new int[] { 1, 1, 1 }).add(startPos);
    boolean success = new StructureGenerator<>(structure).world(world).generationInfo(saplingGenInfo).transform(transform).seed(random.nextLong()).maturity(StructureSpawnContext.GenerateMaturity.SUGGEST).memorize(RCConfig.memorizeSaplings).allowOverlaps(true).randomPosition(BlockSurfacePos.from(spawnPos), (context, blockCollection) -> spawnPos.getY()).generate() != null;
    if (!success)
        before.forEach((pos1, state) -> world.setBlockState(pos1, state, 4));
}
Also used : BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) java.util(java.util) Blocks(net.minecraft.init.Blocks) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) World(net.minecraft.world.World) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) StructureSpawnContext(ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext) StructureRegistry(ivorius.reccomplex.world.gen.feature.structure.StructureRegistry) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) BlockPos(net.minecraft.util.math.BlockPos) Multimap(com.google.common.collect.Multimap) WeightedSelector(ivorius.ivtoolkit.random.WeightedSelector) RCConfig(ivorius.reccomplex.RCConfig) Collectors(java.util.stream.Collectors) Environment(ivorius.reccomplex.world.gen.feature.structure.Environment) IBlockState(net.minecraft.block.state.IBlockState) IvFunctions(ivorius.ivtoolkit.util.IvFunctions) Lists(com.google.common.collect.Lists) Pair(org.apache.commons.lang3.tuple.Pair) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) WorldServer(net.minecraft.world.WorldServer) StructureBoundingBox(net.minecraft.world.gen.structure.StructureBoundingBox) Nullable(javax.annotation.Nullable) SaplingGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.SaplingGeneration) IBlockState(net.minecraft.block.state.IBlockState) StructureGenerator(ivorius.reccomplex.world.gen.feature.StructureGenerator) AxisAlignedTransform2D(ivorius.ivtoolkit.math.AxisAlignedTransform2D) BlockPos(net.minecraft.util.math.BlockPos)

Example 10 with Structure

use of ivorius.reccomplex.world.gen.feature.structure.Structure in project RecurrentComplex by Ivorforce.

the class WorldGenStructures method generateRandomStructureInChunk.

public static boolean generateRandomStructureInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen) {
    MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = StructureRegistry.INSTANCE.naturalStructureSelectors().get(biomeGen, world.provider);
    float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
    for (int i = 0; i < STRUCTURE_TRIES; i++) {
        Pair<Structure<?>, NaturalGeneration> pair = structureSelector.selectOne(random, world.provider, world.getBiome(chunkPos.getBlock(0, 0, 0)), null, distanceToSpawn);
        if (pair != null) {
            if (planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()))
                return true;
        }
    }
    return false;
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration)

Aggregations

Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)12 BlockPos (net.minecraft.util.math.BlockPos)6 RCConfig (ivorius.reccomplex.RCConfig)5 StructureRegistry (ivorius.reccomplex.world.gen.feature.structure.StructureRegistry)5 Nullable (javax.annotation.Nullable)5 WorldServer (net.minecraft.world.WorldServer)5 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)4 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)3 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)3 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)3 StructureSpawnContext (ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)2 Lists (com.google.common.collect.Lists)2 Multimap (com.google.common.collect.Multimap)2 WeightedSelector (ivorius.ivtoolkit.random.WeightedSelector)2 IvFunctions (ivorius.ivtoolkit.util.IvFunctions)2 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)2 ServerTranslations (ivorius.reccomplex.utils.ServerTranslations)2