Search in sources :

Example 1 with GenInfo

use of mcjty.rftoolsdim.dimensions.world.terrain.lost.GenInfo in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method generateLootSpawners.

private void generateLootSpawners(Random random, int chunkX, int chunkZ, World world) {
    BuildingInfo info = new BuildingInfo(chunkX, chunkZ, world.getSeed());
    int buildingtop = 0;
    boolean building = info.hasBuilding;
    if (building) {
        buildingtop = 69 + info.floors * 6;
    }
    int height = 63 - info.floorsBelowGround * 6;
    while (height < buildingtop) {
        int f = LostCitiesTerrainGenerator.getFloor(height);
        if (f == 0) {
            BlockPos floorpos = new BlockPos(chunkX * 16, height, chunkZ * 16);
            int floortype = info.floorTypes[LostCitiesTerrainGenerator.getLevel(height) + info.floorsBelowGround];
            GenInfo getInfo = LostCitiesTerrainGenerator.getGenInfos().get(Pair.of(info.getGenInfoIndex(), floortype));
            for (BlockPos p : getInfo.getChest()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createLootChest(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getRandomFeatures()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createRandomFeature(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getModularStorages()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createModularStorage(random, world, pos);
                }
            }
            for (BlockPos p : getInfo.getRandomRFToolsMachines()) {
                BlockPos pos = floorpos.add(p);
                if (!world.isAirBlock(pos)) {
                    createRFToolsMachine(random, world, pos);
                }
            }
            for (Map.Entry<BlockPos, Integer> entry : getInfo.getSpawnerType().entrySet()) {
                BlockPos pos = floorpos.add(entry.getKey());
                if (!world.isAirBlock(pos)) {
                    world.setBlockState(pos, Blocks.MOB_SPAWNER.getDefaultState(), 18);
                    TileEntity tileentity = world.getTileEntity(pos);
                    if (tileentity instanceof TileEntityMobSpawner) {
                        TileEntityMobSpawner spawner = (TileEntityMobSpawner) tileentity;
                        switch(entry.getValue()) {
                            case 1:
                                MobSpawnerBaseLogic mobspawnerbaselogic3 = spawner.getSpawnerBaseLogic();
                                mobspawnerbaselogic3.setEntityId(new ResourceLocation("minecraft:zombie"));
                                spawner.markDirty();
                                break;
                            case 2:
                                MobSpawnerBaseLogic mobspawnerbaselogic2 = spawner.getSpawnerBaseLogic();
                                mobspawnerbaselogic2.setEntityId(new ResourceLocation("minecraft:skeleton"));
                                spawner.markDirty();
                                break;
                            case 3:
                                MobSpawnerBaseLogic mobspawnerbaselogic1 = spawner.getSpawnerBaseLogic();
                                mobspawnerbaselogic1.setEntityId(new ResourceLocation("minecraft:spider"));
                                spawner.markDirty();
                                break;
                            case 4:
                                MobSpawnerBaseLogic mobspawnerbaselogic = spawner.getSpawnerBaseLogic();
                                mobspawnerbaselogic.setEntityId(new ResourceLocation("minecraft:blaze"));
                                spawner.markDirty();
                                break;
                        }
                    }
                }
            }
        }
        height++;
    }
}
Also used : ModularStorageTileEntity(mcjty.rftools.blocks.storage.ModularStorageTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) MobSpawnerBaseLogic(net.minecraft.tileentity.MobSpawnerBaseLogic) BuildingInfo(mcjty.rftoolsdim.dimensions.world.terrain.lost.BuildingInfo) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) GenInfo(mcjty.rftoolsdim.dimensions.world.terrain.lost.GenInfo) TileEntityMobSpawner(net.minecraft.tileentity.TileEntityMobSpawner) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 ModularStorageTileEntity (mcjty.rftools.blocks.storage.ModularStorageTileEntity)1 BuildingInfo (mcjty.rftoolsdim.dimensions.world.terrain.lost.BuildingInfo)1 GenInfo (mcjty.rftoolsdim.dimensions.world.terrain.lost.GenInfo)1 MobSpawnerBaseLogic (net.minecraft.tileentity.MobSpawnerBaseLogic)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityMobSpawner (net.minecraft.tileentity.TileEntityMobSpawner)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockPos (net.minecraft.util.math.BlockPos)1