Search in sources :

Example 31 with ChunkPrimer

use of net.minecraft.world.chunk.ChunkPrimer in project SpongeCommon by SpongePowered.

the class MixinChunkGeneratorOverworld method populate.

@Override
public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeVolume biomes) {
    int x = GenericMath.floor(buffer.getBlockMin().getX() / 16f);
    int z = GenericMath.floor(buffer.getBlockMin().getZ() / 16f);
    this.rand.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
    this.biomesForGeneration = getBiomesFromGenerator(x, z);
    ChunkPrimer chunkprimer = new ChunkBufferPrimer(buffer);
    this.setBlocksInChunk(x, z, chunkprimer);
    setBedrock(buffer);
}
Also used : ChunkBufferPrimer(org.spongepowered.common.util.gen.ChunkBufferPrimer) ChunkPrimer(net.minecraft.world.chunk.ChunkPrimer)

Example 32 with ChunkPrimer

use of net.minecraft.world.chunk.ChunkPrimer in project SpongeCommon by SpongePowered.

the class SpongeChunkGenerator method generateChunk.

@Override
public Chunk generateChunk(int chunkX, int chunkZ) {
    this.rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L);
    this.cachedBiomes.reuse(new Vector3i(chunkX * 16, 0, chunkZ * 16));
    this.biomeGenerator.generateBiomes(this.cachedBiomes);
    ImmutableBiomeVolume biomeBuffer = this.cachedBiomes.getImmutableBiomeCopy();
    // Generate base terrain
    ChunkPrimer chunkprimer = new ChunkPrimer();
    MutableBlockVolume blockBuffer = new ChunkPrimerBuffer(chunkprimer, chunkX, chunkZ);
    this.baseGenerator.populate((org.spongepowered.api.world.World) this.world, blockBuffer, biomeBuffer);
    if (!(this.baseGenerator instanceof SpongeGenerationPopulator)) {
        replaceBiomeBlocks(this.world, this.rand, chunkX, chunkZ, chunkprimer, biomeBuffer);
    }
    // Apply the generator populators to complete the blockBuffer
    for (GenerationPopulator populator : this.genpop) {
        populator.populate((org.spongepowered.api.world.World) this.world, blockBuffer, biomeBuffer);
    }
    // Get unique biomes to determine what generator populators to run
    List<BiomeType> uniqueBiomes = Lists.newArrayList();
    BiomeType biome;
    for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
            biome = this.cachedBiomes.getBiome(chunkX * 16 + x, 0, chunkZ * 16 + z);
            if (!uniqueBiomes.contains(biome)) {
                uniqueBiomes.add(biome);
            }
        }
    }
    // run our generator populators
    for (BiomeType type : uniqueBiomes) {
        BiomeGenerationSettings settings = getBiomeSettings(type);
        for (GenerationPopulator populator : settings.getGenerationPopulators()) {
            populator.populate((org.spongepowered.api.world.World) this.world, blockBuffer, biomeBuffer);
        }
    }
    // Assemble chunk
    Chunk chunk;
    if (this.baseGenerator instanceof SpongeGenerationPopulator && ((SpongeGenerationPopulator) this.baseGenerator).getCachedChunk() != null) {
        chunk = ((SpongeGenerationPopulator) this.baseGenerator).getCachedChunk();
        ((IMixinChunk) chunk).fill(chunkprimer);
    } else {
        chunk = new Chunk(this.world, chunkprimer, chunkX, chunkZ);
        this.cachedBiomes.fill(chunk.getBiomeArray());
    }
    chunk.generateSkylightMap();
    return chunk;
}
Also used : ImmutableBiomeVolume(org.spongepowered.api.world.extent.ImmutableBiomeVolume) MutableBlockVolume(org.spongepowered.api.world.extent.MutableBlockVolume) IMixinChunk(org.spongepowered.common.interfaces.IMixinChunk) ChunkPrimerBuffer(org.spongepowered.common.util.gen.ChunkPrimerBuffer) IMixinChunk(org.spongepowered.common.interfaces.IMixinChunk) Chunk(net.minecraft.world.chunk.Chunk) ChunkPrimer(net.minecraft.world.chunk.ChunkPrimer) BiomeType(org.spongepowered.api.world.biome.BiomeType) ChunkGeneratorOverworld(net.minecraft.world.gen.ChunkGeneratorOverworld) IChunkProviderOverworld(org.spongepowered.common.interfaces.world.gen.IChunkProviderOverworld) GenerationPopulator(org.spongepowered.api.world.gen.GenerationPopulator) IGenerationPopulator(org.spongepowered.common.interfaces.world.gen.IGenerationPopulator) Vector3i(com.flowpowered.math.vector.Vector3i) BiomeGenerationSettings(org.spongepowered.api.world.biome.BiomeGenerationSettings) SpongeBiomeGenerationSettings(org.spongepowered.common.world.biome.SpongeBiomeGenerationSettings)

Example 33 with ChunkPrimer

use of net.minecraft.world.chunk.ChunkPrimer in project MorePlanets by SteveKunG.

the class ChunkGeneratorNibiru method generateChunk.

@Override
public Chunk generateChunk(int chunkX, int chunkZ) {
    this.rand.setSeed(chunkX * 341873128712L + chunkZ * 132897987541L);
    ChunkPrimer chunkprimer = new ChunkPrimer();
    this.setBlocksInChunk(chunkX, chunkZ, chunkprimer);
    this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomesForGeneration(this.biomesForGeneration, chunkX * 16, chunkZ * 16, 16, 16);
    this.replaceBlocksForBiome(chunkX, chunkZ, chunkprimer, this.biomesForGeneration);
    this.caveGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.ravineGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.mineshaftGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.strongholdGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.pyramidGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.jungleTempleGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.oceanMonumentGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.villageGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    this.dungeonGenerator.generate(this.worldObj, chunkX, chunkZ, chunkprimer);
    Chunk chunk = new Chunk(this.worldObj, chunkprimer, chunkX, chunkZ);
    byte[] abyte = chunk.getBiomeArray();
    for (int i = 0; i < abyte.length; ++i) {
        abyte[i] = (byte) Biome.getIdForBiome(this.biomesForGeneration[i]);
    }
    chunk.generateSkylightMap();
    return chunk;
}
Also used : Chunk(net.minecraft.world.chunk.Chunk) ChunkPrimer(net.minecraft.world.chunk.ChunkPrimer)

Example 34 with ChunkPrimer

use of net.minecraft.world.chunk.ChunkPrimer in project Galacticraft by micdoodle8.

the class ChunkProviderVenus method provideChunk.

@Override
public Chunk provideChunk(int x, int z) {
    this.rand.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
    ChunkPrimer chunkprimer = new ChunkPrimer();
    this.setBlocksInChunk(x, z, chunkprimer);
    this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);
    this.lavaCaveGenerator.generate(this, this.worldObj, x, z, chunkprimer);
    this.replaceBlocksForBiome(x, z, chunkprimer, this.biomesForGeneration);
    this.caveGenerator.generate(this, this.worldObj, x, z, chunkprimer);
    this.dungeonGenerator.generate(this, this.worldObj, x, z, chunkprimer);
    Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z);
    byte[] abyte = chunk.getBiomeArray();
    for (int i = 0; i < abyte.length; ++i) {
        abyte[i] = (byte) this.biomesForGeneration[i].biomeID;
    }
    chunk.generateSkylightMap();
    return chunk;
}
Also used : Chunk(net.minecraft.world.chunk.Chunk) ChunkPrimer(net.minecraft.world.chunk.ChunkPrimer)

Example 35 with ChunkPrimer

use of net.minecraft.world.chunk.ChunkPrimer in project Galacticraft by micdoodle8.

the class ChunkProviderAsteroids method provideChunk.

@Override
public Chunk provideChunk(int par1, int par2) {
    ChunkPrimer primer = new ChunkPrimer();
    // long time1 = System.nanoTime();
    this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L);
    // final Block[] ids = new Block[65536];
    // final byte[] meta = new byte[65536];
    this.generateTerrain(par1, par2, primer, false);
    if (this.worldObj.provider instanceof WorldProviderAsteroids && ((WorldProviderAsteroids) this.worldObj.provider).checkHasAsteroids()) {
        this.dungeonGenerator.generate(this, this.worldObj, par1, par2, primer);
    }
    // long time2 = System.nanoTime();
    final Chunk var4 = new Chunk(this.worldObj, primer, par1, par2);
    final byte[] var5 = var4.getBiomeArray();
    for (int var6 = 0; var6 < var5.length; ++var6) {
        var5[var6] = (byte) BiomeGenBaseAsteroids.asteroid.biomeID;
    }
    // long time3 = System.nanoTime();
    this.generateSkylightMap(var4, par1, par2);
    // }
    return var4;
}
Also used : Chunk(net.minecraft.world.chunk.Chunk) WorldProviderAsteroids(micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids) ChunkPrimer(net.minecraft.world.chunk.ChunkPrimer)

Aggregations

ChunkPrimer (net.minecraft.world.chunk.ChunkPrimer)49 Chunk (net.minecraft.world.chunk.Chunk)38 IBlockState (net.minecraft.block.state.IBlockState)8 BlockPos (net.minecraft.util.math.BlockPos)3 Biome (net.minecraft.world.biome.Biome)3 ChunkBufferPrimer (org.spongepowered.common.util.gen.ChunkBufferPrimer)3 Nonnull (javax.annotation.Nonnull)2 ChunkPos (net.minecraft.util.math.ChunkPos)2 BOPOverworldBiome (biomesoplenty.common.biome.overworld.BOPOverworldBiome)1 Vector3i (com.flowpowered.math.vector.Vector3i)1 MapGenStructureHook (ivorius.reccomplex.world.gen.feature.structure.MapGenStructureHook)1 Random (java.util.Random)1 Nullable (javax.annotation.Nullable)1 Pair (kotlin.Pair)1 WorldProviderAsteroids (micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids)1 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)1 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)1 World (net.minecraft.world.World)1 BiomeProvider (net.minecraft.world.biome.BiomeProvider)1 ChunkGeneratorOverworld (net.minecraft.world.gen.ChunkGeneratorOverworld)1