Search in sources :

Example 6 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class MapGenStrongholdRTG method canSpawnStructureAtCoords.

protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
    if (!this.ranBiomeCheck) {
        this.generatePositions();
        this.ranBiomeCheck = true;
    }
    for (ChunkPos chunkpos : this.structureCoords) {
        if (chunkX == chunkpos.chunkXPos && chunkZ == chunkpos.chunkZPos) {
            return true;
        }
    }
    return false;
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos)

Example 7 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class MapGenStrongholdRTG method generatePositions.

private void generatePositions() {
    this.initializeStructureData(this.world);
    int i = 0;
    for (StructureStart structurestart : this.structureMap.values()) {
        if (i < this.structureCoords.length) {
            this.structureCoords[i++] = new ChunkPos(structurestart.getChunkPosX(), structurestart.getChunkPosZ());
        }
    }
    Random random = new Random();
    random.setSeed(this.world.getSeed());
    double d1 = random.nextDouble() * Math.PI * 2.0D;
    int j = 0;
    int k = 0;
    int l = this.structureMap.size();
    if (l < this.structureCoords.length) {
        for (int i1 = 0; i1 < this.structureCoords.length; ++i1) {
            double d0 = 4.0D * this.distance + this.distance * (double) j * 6.0D + (random.nextDouble() - 0.5D) * this.distance * 2.5D;
            int j1 = (int) Math.round(Math.cos(d1) * d0);
            int k1 = (int) Math.round(Math.sin(d1) * d0);
            BlockPos blockpos = this.world.getBiomeProvider().findBiomePosition((j1 << 4) + 8, (k1 << 4) + 8, 112, this.allowedBiomes, random);
            if (blockpos != null) {
                j1 = blockpos.getX() >> 4;
                k1 = blockpos.getZ() >> 4;
            }
            if (i1 >= l) {
                this.structureCoords[i1] = new ChunkPos(j1, k1);
            }
            d1 += (Math.PI * 2D) / (double) this.spread;
            ++k;
            if (k == this.spread) {
                ++j;
                k = 0;
                this.spread += 2 * this.spread / (j + 1);
                this.spread = Math.min(this.spread, this.structureCoords.length - i1);
                d1 += random.nextDouble() * Math.PI * 2.0D;
            }
        }
    }
}
Also used : Random(java.util.Random) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) StructureStart(net.minecraft.world.gen.structure.StructureStart)

Example 8 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class LandscapeGenerator method landscape.

/*
     * All of the 'cx' and 'cz' parameters have been flipped when passing them.
     * Prior to flipping, the terrain was being XZ-chunk-flipped. - WhichOnesPink
     */
synchronized ChunkLandscape landscape(IBiomeProviderRTG cmr, int cx, int cz) {
    ChunkPos chunkPos = new ChunkPos(cx, cz);
    ChunkLandscape preExisting = this.storage.get(chunkPos);
    if (preExisting != null)
        return preExisting;
    ChunkLandscape result = new ChunkLandscape();
    getNewerNoise(cmr, cx, cz, result);
    int[] biomeIndices = cmr.getBiomesGens(cx, cz, 16, 16);
    analyzer.newRepair(biomeIndices, result.biome, this.biomeData, this.sampleSize, result.noise, result.river);
    //-cmr.getRiverStrength(cx * 16 + 7, cy * 16 + 7));
    storage.put(chunkPos, result);
    return result;
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos)

Example 9 with ChunkPos

use of net.minecraft.util.math.ChunkPos in project Realistic-Terrain-Generation by Team-RTG.

the class DecoSingleBiomeDecorations method generate.

@Override
public void generate(IRealisticBiome biome, RTGWorld rtgWorld, Random rand, int worldX, int worldZ, float strength, float river, boolean hasPlacedVillageBlocks) {
    if (this.allowed) {
        // skip if already decorated
        ChunkPos position = new ChunkPos(worldX, worldZ);
        if (rtgWorld.decoratedChunks.contains(position))
            return;
        rtgWorld.decoratedChunks.add(position);
        super.generate(biome, rtgWorld, rand, worldX, worldZ, strength, river, hasPlacedVillageBlocks);
    }
}
Also used : ChunkPos(net.minecraft.util.math.ChunkPos)

Example 10 with ChunkPos

use of net.minecraft.util.math.ChunkPos 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)

Aggregations

ChunkPos (net.minecraft.util.math.ChunkPos)33 BlockPos (net.minecraft.util.math.BlockPos)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 Random (java.util.Random)4 WorldServer (net.minecraft.world.WorldServer)4 Biome (net.minecraft.world.biome.Biome)4 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)3 StructureSpawnContext (ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext)2 NaturalGeneration (ivorius.reccomplex.world.gen.feature.structure.generic.generation.NaturalGeneration)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 World (net.minecraft.world.World)2 IChunkProvider (net.minecraft.world.chunk.IChunkProvider)2 BlockWorldScale (betterwithaddons.block.BlockWorldScale)1 BlockSurfaceArea (ivorius.ivtoolkit.blocks.BlockSurfaceArea)1 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 IvVecMathHelper (ivorius.ivtoolkit.math.IvVecMathHelper)1 RCConfig (ivorius.reccomplex.RCConfig)1