Search in sources :

Example 1 with WorldGenDungeons

use of net.minecraft.world.gen.feature.WorldGenDungeons in project RFToolsDimensions by McJty.

the class GenericChunkGenerator method populate.

@Override
public void populate(int chunkX, int chunkZ) {
    BlockFalling.fallInstantly = true;
    int x = chunkX * 16;
    int z = chunkZ * 16;
    World w = this.worldObj;
    Biome Biome = w.getBiomeForCoordsBody(new BlockPos(x + 16, 0, z + 16));
    this.rand.setSeed(w.getSeed());
    long i1 = this.rand.nextLong() / 2L * 2L + 1L;
    long j1 = this.rand.nextLong() / 2L * 2L + 1L;
    this.rand.setSeed(chunkX * i1 + chunkZ * j1 ^ w.getSeed());
    boolean flag = false;
    if (dimensionInformation.getTerrainType() == TerrainType.TERRAIN_INVERTIGO) {
        if (upsidedownWorld == null) {
            World ww = worldObj;
            upsidedownWorld = new UpsidedownWorld((WorldServer) worldObj) {

                @Override
                protected IChunkProvider createChunkProvider() {
                    IChunkLoader ichunkloader = ww.getSaveHandler().getChunkLoader(ww.provider);
                    return new ChunkProviderServer((WorldServer) ww, ichunkloader, ww.provider.createChunkGenerator());
                }

                @Override
                public ChunkProviderServer getChunkProvider() {
                    return (ChunkProviderServer) ww.getChunkProvider();
                }
            };
            net.minecraftforge.common.DimensionManager.setWorld(ww.provider.getDimension(), (WorldServer) ww, ww.getMinecraftServer());
        }
        upsidedownWorld.worldObj = (WorldServer) worldObj;
        w = upsidedownWorld;
    }
    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(this, w, rand, chunkX, chunkZ, flag));
    ChunkPos cp = new ChunkPos(chunkX, chunkZ);
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_MINESHAFT)) {
        this.mineshaftGenerator.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_VILLAGE)) {
        flag = this.villageGenerator.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_STRONGHOLD)) {
        this.strongholdGenerator.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_FORTRESS)) {
        this.genNetherBridge.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_SCATTERED)) {
        this.scatteredFeatureGenerator.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_SWAMPHUT)) {
        this.genSwampHut.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_DESERTTEMPLE)) {
        this.genDesertTemple.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_JUNGLETEMPLE)) {
        this.genJungleTemple.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_IGLOO)) {
        this.genIgloo.generateStructure(w, this.rand, cp);
    }
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_OCEAN_MONUMENT)) {
        this.oceanMonumentGenerator.generateStructure(w, this.rand, cp);
    }
    int k1;
    int l1;
    int i2;
    if (dimensionInformation.getTerrainType() != TerrainType.TERRAIN_INVERTIGO) {
        if (dimensionInformation.hasFeatureType(FeatureType.FEATURE_LAKES)) {
            if (dimensionInformation.getFluidsForLakes().length == 0) {
                // No specific liquid dimlets specified: we generate default lakes (water and lava were appropriate).
                if (Biome != Biomes.DESERT && Biome != Biomes.DESERT_HILLS && !flag && this.rand.nextInt(4) == 0 && TerrainGen.populate(this, w, rand, chunkX, chunkZ, flag, PopulateChunkEvent.Populate.EventType.LAKE)) {
                    k1 = x + this.rand.nextInt(16) + 8;
                    l1 = this.rand.nextInt(256);
                    i2 = z + this.rand.nextInt(16) + 8;
                    (new WorldGenLakes(Blocks.WATER)).generate(w, this.rand, new BlockPos(k1, l1, i2));
                }
                if (TerrainGen.populate(this, w, rand, chunkX, chunkZ, flag, PopulateChunkEvent.Populate.EventType.LAVA) && !flag && this.rand.nextInt(8) == 0) {
                    k1 = x + this.rand.nextInt(16) + 8;
                    l1 = this.rand.nextInt(this.rand.nextInt(248) + 8);
                    i2 = z + this.rand.nextInt(16) + 8;
                    if (l1 < 63 || this.rand.nextInt(10) == 0) {
                        (new WorldGenLakes(Blocks.LAVA)).generate(w, this.rand, new BlockPos(k1, l1, i2));
                    }
                }
            } else {
                // Generate lakes for the specified biomes.
                for (Block liquid : dimensionInformation.getFluidsForLakes()) {
                    if (!flag && this.rand.nextInt(4) == 0 && TerrainGen.populate(this, w, rand, chunkX, chunkZ, flag, PopulateChunkEvent.Populate.EventType.LAKE)) {
                        k1 = x + this.rand.nextInt(16) + 8;
                        l1 = this.rand.nextInt(256);
                        i2 = z + this.rand.nextInt(16) + 8;
                        (new WorldGenLakes(liquid)).generate(w, this.rand, new BlockPos(k1, l1, i2));
                    }
                }
            }
        }
    }
    boolean doGen = false;
    if (dimensionInformation.hasStructureType(StructureType.STRUCTURE_DUNGEON)) {
        doGen = TerrainGen.populate(this, w, rand, chunkX, chunkZ, flag, PopulateChunkEvent.Populate.EventType.DUNGEON);
        for (k1 = 0; doGen && k1 < 8; ++k1) {
            l1 = x + this.rand.nextInt(16) + 8;
            i2 = this.rand.nextInt(256);
            int j2 = z + this.rand.nextInt(16) + 8;
            (new WorldGenDungeons()).generate(w, this.rand, new BlockPos(l1, i2, j2));
        }
    }
    BlockPos pos = new BlockPos(x, 0, z);
    Biome.decorate(w, this.rand, pos);
    // OresAPlenty
    if (dimensionInformation.hasFeatureType(FeatureType.FEATURE_ORESAPLENTY)) {
        generateOre(w, this.rand, coalGen, OreGenEvent.GenerateMinable.EventType.COAL, pos, OresAPlentyConfiguration.coal);
        generateOre(w, this.rand, ironGen, OreGenEvent.GenerateMinable.EventType.IRON, pos, OresAPlentyConfiguration.iron);
        generateOre(w, this.rand, goldGen, OreGenEvent.GenerateMinable.EventType.GOLD, pos, OresAPlentyConfiguration.gold);
        generateOre(w, this.rand, lapisGen, OreGenEvent.GenerateMinable.EventType.LAPIS, pos, OresAPlentyConfiguration.lapis);
        generateOre(w, this.rand, diamondGen, OreGenEvent.GenerateMinable.EventType.DIAMOND, pos, OresAPlentyConfiguration.diamond);
        generateOre(w, this.rand, redstoneGen, OreGenEvent.GenerateMinable.EventType.REDSTONE, pos, OresAPlentyConfiguration.redstone);
        generateOre(w, this.rand, emeraldGen, OreGenEvent.GenerateMinable.EventType.EMERALD, pos, OresAPlentyConfiguration.emerald);
    }
    if (TerrainGen.populate(this, w, rand, chunkX, chunkZ, flag, PopulateChunkEvent.Populate.EventType.ANIMALS)) {
        WorldEntitySpawner.performWorldGenSpawning(w, Biome, x + 8, z + 8, 16, 16, this.rand);
    }
    x += 8;
    z += 8;
    doGen = TerrainGen.populate(this, w, rand, chunkX, chunkZ, flag, PopulateChunkEvent.Populate.EventType.ICE);
    for (k1 = 0; doGen && k1 < 16; ++k1) {
        for (l1 = 0; l1 < 16; ++l1) {
            i2 = w.getPrecipitationHeight(new BlockPos(x + k1, 0, z + l1)).getY();
            if (w.canBlockFreeze(new BlockPos(k1 + x, i2 - 1, l1 + z), false)) {
                w.setBlockState(new BlockPos(k1 + x, i2 - 1, l1 + z), Blocks.ICE.getDefaultState(), 2);
            }
            if (w.canSnowAt(new BlockPos(k1 + x, i2, l1 + z), true)) {
                w.setBlockState(new BlockPos(k1 + x, i2, l1 + z), Blocks.SNOW_LAYER.getDefaultState(), 2);
            }
        }
    }
    MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(this, w, rand, chunkX, chunkZ, flag));
    BlockFalling.fallInstantly = false;
}
Also used : IChunkLoader(net.minecraft.world.chunk.storage.IChunkLoader) WorldServer(net.minecraft.world.WorldServer) PopulateChunkEvent(net.minecraftforge.event.terraingen.PopulateChunkEvent) World(net.minecraft.world.World) WorldGenLakes(net.minecraft.world.gen.feature.WorldGenLakes) Biome(net.minecraft.world.biome.Biome) IChunkProvider(net.minecraft.world.chunk.IChunkProvider) BlockPos(net.minecraft.util.math.BlockPos) ChunkPos(net.minecraft.util.math.ChunkPos) WorldGenDungeons(net.minecraft.world.gen.feature.WorldGenDungeons)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 World (net.minecraft.world.World)1 WorldServer (net.minecraft.world.WorldServer)1 Biome (net.minecraft.world.biome.Biome)1 IChunkProvider (net.minecraft.world.chunk.IChunkProvider)1 IChunkLoader (net.minecraft.world.chunk.storage.IChunkLoader)1 WorldGenDungeons (net.minecraft.world.gen.feature.WorldGenDungeons)1 WorldGenLakes (net.minecraft.world.gen.feature.WorldGenLakes)1 PopulateChunkEvent (net.minecraftforge.event.terraingen.PopulateChunkEvent)1