Search in sources :

Example 1 with NaturalGeneration

use of ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration in project RecurrentComplex by Ivorforce.

the class WorldGenStructures method planStructuresInChunk.

public static void planStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen, @Nullable Predicate<Structure> structurePredicate) {
    MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = StructureRegistry.INSTANCE.naturalStructureSelectors().get(biomeGen, world.provider);
    float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
    // TODO Use STRUCTURE_TRIES
    List<Pair<Structure<?>, NaturalGeneration>> generated = structureSelector.generatedStructures(random, world.getBiome(chunkPos.getBlock(0, 0, 0)), world.provider, distanceToSpawn);
    generated.stream().filter(pair -> structurePredicate == null || structurePredicate.test(pair.getLeft())).forEach(pair -> planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()));
}
Also used : BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) NaturalStructureSelector(ivorius.reccomplex.world.gen.feature.selector.NaturalStructureSelector) StaticGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.StaticGeneration) Structures(ivorius.reccomplex.world.gen.feature.structure.Structures) Predicate(java.util.function.Predicate) 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) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) Random(java.util.Random) RCConfig(ivorius.reccomplex.RCConfig) Collectors(java.util.stream.Collectors) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) MathHelper(net.minecraft.util.math.MathHelper) MixingStructureSelector(ivorius.reccomplex.world.gen.feature.selector.MixingStructureSelector) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) WorldServer(net.minecraft.world.WorldServer) IvVecMathHelper(ivorius.ivtoolkit.math.IvVecMathHelper) Biome(net.minecraft.world.biome.Biome) Nullable(javax.annotation.Nullable) ChunkPos(net.minecraft.util.math.ChunkPos) NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration) Pair(org.apache.commons.lang3.tuple.Pair)

Example 2 with NaturalGeneration

use of ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration in project RecurrentComplex by Ivorforce.

the class GenericStructure method createDefaultStructure.

public static GenericStructure createDefaultStructure() {
    GenericStructure genericStructureInfo = new GenericStructure();
    genericStructureInfo.rotatable = true;
    genericStructureInfo.mirrorable = true;
    genericStructureInfo.blocking = true;
    genericStructureInfo.transformer.getData().setPreset("structure");
    genericStructureInfo.generationTypes.add(new NaturalGeneration());
    return genericStructureInfo;
}
Also used : NaturalGeneration(ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration)

Example 3 with NaturalGeneration

use of ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration 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

NaturalGeneration (ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration)3 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)2 ChunkPos (net.minecraft.util.math.ChunkPos)2 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 IvVecMathHelper (ivorius.ivtoolkit.math.IvVecMathHelper)1 RCConfig (ivorius.reccomplex.RCConfig)1 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)1 MixingStructureSelector (ivorius.reccomplex.world.gen.feature.selector.MixingStructureSelector)1 NaturalStructureSelector (ivorius.reccomplex.world.gen.feature.selector.NaturalStructureSelector)1 StructureRegistry (ivorius.reccomplex.world.gen.feature.structure.StructureRegistry)1 Structures (ivorius.reccomplex.world.gen.feature.structure.Structures)1 StructureSpawnContext (ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext)1 StaticGeneration (ivorius.reccomplex.world.gen.feature.structure.generic.generation.StaticGeneration)1 List (java.util.List)1 Random (java.util.Random)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 BlockPos (net.minecraft.util.math.BlockPos)1 MathHelper (net.minecraft.util.math.MathHelper)1