Search in sources :

Example 11 with NukkitRandom

use of cn.nukkit.math.NukkitRandom in project Nukkit by Nukkit.

the class PopulatorCaves method populate.

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = new Random();
    this.random.setSeed(level.getSeed());
    long worldLong1 = this.random.nextLong();
    long worldLong2 = this.random.nextLong();
    int size = this.checkAreaSize;
    for (int x = chunkX - size; x <= chunkX + size; x++) for (int z = chunkZ - size; z <= chunkZ + size; z++) {
        long randomX = x * worldLong1;
        long randomZ = z * worldLong2;
        this.random.setSeed(randomX ^ randomZ ^ level.getSeed());
        generateChunk(x, z, level.getChunk(chunkX, chunkZ));
    }
}
Also used : NukkitRandom(cn.nukkit.math.NukkitRandom) Random(java.util.Random)

Example 12 with NukkitRandom

use of cn.nukkit.math.NukkitRandom in project Nukkit by Nukkit.

the class PopulatorRavines method populate.

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = new Random();
    this.random.setSeed(level.getSeed());
    worldLong1 = this.random.nextLong();
    worldLong2 = this.random.nextLong();
    int i = this.checkAreaSize;
    for (int x = chunkX - i; x <= chunkX + i; x++) for (int z = chunkZ - i; z <= chunkZ + i; z++) {
        long l3 = x * worldLong1;
        long l4 = z * worldLong2;
        this.random.setSeed(l3 ^ l4 ^ level.getSeed());
        generateChunk(chunkX, chunkZ, level.getChunk(chunkX, chunkZ));
    }
}
Also used : NukkitRandom(cn.nukkit.math.NukkitRandom) Random(java.util.Random)

Example 13 with NukkitRandom

use of cn.nukkit.math.NukkitRandom in project Nukkit by Nukkit.

the class Normal method init.

@Override
public void init(ChunkManager level, NukkitRandom random) {
    this.level = level;
    this.nukkitRandom = random;
    this.random = new Random();
    this.nukkitRandom.setSeed(this.level.getSeed());
    this.localSeed1 = this.random.nextLong();
    this.localSeed2 = this.random.nextLong();
    this.noiseSeaFloor = new Simplex(this.nukkitRandom, 1F, 1F / 8F, 1F / 64F);
    this.noiseLand = new Simplex(this.nukkitRandom, 2F, 1F / 8F, 1F / 512F);
    this.noiseMountains = new Simplex(this.nukkitRandom, 4F, 1F, 1F / 500F);
    this.noiseBaseGround = new Simplex(this.nukkitRandom, 4F, 1F / 4F, 1F / 64F);
    this.noiseRiver = new Simplex(this.nukkitRandom, 2F, 1F, 1F / 512F);
    this.nukkitRandom.setSeed(this.level.getSeed());
    this.selector = new BiomeSelector(this.nukkitRandom, Biome.getBiome(Biome.FOREST));
    this.heightOffset = random.nextRange(-5, 3);
    this.selector.addBiome(Biome.getBiome(OCEAN));
    this.selector.addBiome(Biome.getBiome(PLAINS));
    this.selector.addBiome(Biome.getBiome(DESERT));
    this.selector.addBiome(Biome.getBiome(FOREST));
    this.selector.addBiome(Biome.getBiome(TAIGA));
    this.selector.addBiome(Biome.getBiome(RIVER));
    this.selector.addBiome(Biome.getBiome(ICE_PLAINS));
    this.selector.addBiome(Biome.getBiome(BIRCH_FOREST));
    this.selector.addBiome(Biome.getBiome(JUNGLE));
    this.selector.addBiome(Biome.getBiome(SAVANNA));
    this.selector.addBiome(Biome.getBiome(ROOFED_FOREST));
    this.selector.addBiome(Biome.getBiome(ROOFED_FOREST_M));
    this.selector.addBiome(Biome.getBiome(MUSHROOM_ISLAND));
    this.selector.addBiome(Biome.getBiome(SWAMP));
    this.selector.recalculate();
    PopulatorCaves caves = new PopulatorCaves();
    this.populators.add(caves);
    PopulatorRavines ravines = new PopulatorRavines();
    this.populators.add(ravines);
    // PopulatorDungeon dungeons = new PopulatorDungeon();
    // this.populators.add(dungeons);
    PopulatorGroundCover cover = new PopulatorGroundCover();
    this.generationPopulators.add(cover);
    PopulatorOre ores = new PopulatorOre();
    ores.setOreTypes(new OreType[] { new OreType(new BlockOreCoal(), 20, 17, 0, 128), new OreType(new BlockOreIron(), 20, 9, 0, 64), new OreType(new BlockOreRedstone(), 8, 8, 0, 16), new OreType(new BlockOreLapis(), 1, 7, 0, 16), new OreType(new BlockOreGold(), 2, 9, 0, 32), new OreType(new BlockOreDiamond(), 1, 8, 0, 16), new OreType(new BlockDirt(), 10, 33, 0, 128), new OreType(new BlockGravel(), 8, 33, 0, 128), new OreType(new BlockStone(BlockStone.GRANITE), 10, 33, 0, 80), new OreType(new BlockStone(BlockStone.DIORITE), 10, 33, 0, 80), new OreType(new BlockStone(BlockStone.ANDESITE), 10, 33, 0, 80) });
    this.populators.add(ores);
}
Also used : Simplex(cn.nukkit.level.generator.noise.Simplex) BiomeSelector(cn.nukkit.level.generator.biome.BiomeSelector) OreType(cn.nukkit.level.generator.object.ore.OreType) NukkitRandom(cn.nukkit.math.NukkitRandom)

Aggregations

NukkitRandom (cn.nukkit.math.NukkitRandom)13 BlockSpreadEvent (cn.nukkit.event.block.BlockSpreadEvent)2 Simplex (cn.nukkit.level.generator.noise.Simplex)2 BigMushroom (cn.nukkit.level.generator.object.mushroom.BigMushroom)2 OreType (cn.nukkit.level.generator.object.ore.OreType)2 Vector3 (cn.nukkit.math.Vector3)2 Random (java.util.Random)2 Entity (cn.nukkit.entity.Entity)1 EntityPrimedTNT (cn.nukkit.entity.item.EntityPrimedTNT)1 ItemBlock (cn.nukkit.item.ItemBlock)1 SimpleChunkManager (cn.nukkit.level.SimpleChunkManager)1 Generator (cn.nukkit.level.generator.Generator)1 BiomeSelector (cn.nukkit.level.generator.biome.BiomeSelector)1 BasicGenerator (cn.nukkit.level.generator.object.BasicGenerator)1 BoneMealParticle (cn.nukkit.level.particle.BoneMealParticle)1 EnchantParticle (cn.nukkit.level.particle.EnchantParticle)1 Particle (cn.nukkit.level.particle.Particle)1 SpellParticle (cn.nukkit.level.particle.SpellParticle)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 DoubleTag (cn.nukkit.nbt.tag.DoubleTag)1