Search in sources :

Example 11 with CaveVein

use of cavern.config.manager.CaveVein in project Cavern2 by kegare.

the class HugeCavernConfig method syncVeinsConfig.

public static void syncVeinsConfig() {
    if (veinManager.config == null) {
        veinManager.config = Config.loadConfig("hugecavern", "veins");
    } else {
        veinManager.getCaveVeins().clear();
    }
    if (veinManager.config.getCategoryNames().isEmpty()) {
        List<CaveVein> veins = Lists.newArrayList();
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.GRANITE.getMetadata()), 15, 25, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.GRANITE.getMetadata()), 28, 25, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.DIORITE.getMetadata()), 15, 25, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.DIORITE.getMetadata()), 28, 25, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.ANDESITE.getMetadata()), 18, 25, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.ANDESITE.getMetadata()), 30, 25, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 30, 17, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 55, 17, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 35, 10, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 60, 10, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.GOLD_ORE, 0), 5, 5, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.GOLD_ORE, 0), 10, 5, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.REDSTONE_ORE, 0), 8, 6, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.REDSTONE_ORE, 0), 20, 6, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.LAPIS_ORE, 0), 10, 5, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.LAPIS_ORE, 0), 22, 5, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.DIAMOND_ORE, 0), 2, 5, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.DIAMOND_ORE, 0), 4, 5, 50, 255));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.AQUAMARINE_ORE.getMetadata()), 10, 8, 1, 50, Type.COLD, Type.WATER, Type.WET));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.AQUAMARINE_ORE.getMetadata()), 12, 8, 50, 255, Type.COLD, Type.WATER, Type.WET));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.MAGNITE_ORE.getMetadata()), 30, 10, 1, 50));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.MAGNITE_ORE.getMetadata()), 50, 10, 50, 255));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.RANDOMITE_ORE.getMetadata()), 15, 4, 1, 50));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.RANDOMITE_ORE.getMetadata()), 24, 4, 50, 255));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.HEXCITE_ORE.getMetadata()), 2, 5, 1, 50));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.HEXCITE_ORE.getMetadata()), 4, 5, 50, 255));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.FISSURED_STONE.getMetadata()), 40, 2, 1, 50));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.FISSURED_STONE.getMetadata()), 80, 2, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.DIRT, 0), 16, 25, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.DIRT, 0), 20, 25, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.GRAVEL, 0), 8, 20, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.GRAVEL, 0), 10, 20, 50, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 8, 20, 1, 50, Type.SANDY));
        veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 10, 20, 50, 255, Type.SANDY));
        CavernConfig.generateVeinsConfig(veinManager, veins);
    } else {
        if (CavernConfig.addVeinsFromConfig(veinManager)) {
            try {
                FileUtils.forceDelete(new File(veinManager.config.toString()));
                veinManager.getCaveVeins().clear();
                veinManager.config = null;
                syncVeinsConfig();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    Config.saveConfig(veinManager.config);
}
Also used : BlockMeta(cavern.util.BlockMeta) File(java.io.File) CaveVein(cavern.config.manager.CaveVein)

Example 12 with CaveVein

use of cavern.config.manager.CaveVein in project Cavern2 by kegare.

the class VeinGenerator method generate.

public void generate(World world, Random rand, Biome[] biomes, ChunkPrimer primer) {
    int worldHeight = world.getActualHeight();
    for (CaveVein vein : veins) {
        if (vein == null || vein.getWeight() <= 0 || vein.getSize() <= 0) {
            continue;
        }
        for (int veinCount = 0; veinCount < vein.getWeight(); ++veinCount) {
            if (vein.getChance() < 1.0D && rand.nextDouble() < vein.getChance()) {
                continue;
            }
            int yChance = rand.nextInt(3) + 3;
            int originX = rand.nextInt(16);
            int originY = MathHelper.getInt(rand, vein.getMinHeight(), vein.getMaxHeight());
            int originZ = rand.nextInt(16);
            int x = originX;
            int y = originY;
            int z = originZ;
            Axis prev = null;
            for (int oreCount = 0; oreCount < vein.getSize(); ++oreCount) {
                int checkCount = 0;
                while (oreCount > 0) {
                    Axis next;
                    int checkX = x;
                    int checkY = y;
                    int checkZ = z;
                    if (prev == null) {
                        next = rand.nextInt(yChance) == 0 ? Axis.Y : rand.nextBoolean() ? Axis.X : Axis.Z;
                    } else
                        switch(prev) {
                            case X:
                                next = rand.nextInt(yChance - 1) == 0 ? Axis.Y : Axis.Z;
                                break;
                            case Y:
                                next = rand.nextBoolean() ? Axis.X : Axis.Z;
                                break;
                            case Z:
                                next = rand.nextInt(yChance - 1) == 0 ? Axis.Y : Axis.X;
                                break;
                            default:
                                next = rand.nextInt(yChance) == 0 ? Axis.Y : rand.nextBoolean() ? Axis.X : Axis.Z;
                        }
                    switch(next) {
                        case X:
                            if (x <= 0) {
                                checkX = 1;
                            } else if (x >= 15) {
                                checkX = 14;
                            } else {
                                checkX = x + (rand.nextBoolean() ? 1 : -1);
                            }
                            break;
                        case Y:
                            if (y <= 0) {
                                checkY = 1;
                            } else if (y >= worldHeight - 1) {
                                checkY = worldHeight - 2;
                            } else {
                                checkY = y + (rand.nextBoolean() ? 1 : -1);
                            }
                            break;
                        case Z:
                            if (z <= 0) {
                                checkZ = 1;
                            } else if (z >= 15) {
                                checkZ = 14;
                            } else {
                                checkZ = z + (rand.nextBoolean() ? 1 : -1);
                            }
                            break;
                    }
                    IBlockState state = primer.getBlockState(checkX, checkY, checkZ);
                    if (state.getBlock() == vein.getTarget().getBlock() && state.getBlock().getMetaFromState(state) == vein.getTarget().getMeta()) {
                        x = checkX;
                        y = checkY;
                        z = checkZ;
                        break;
                    }
                    if (++checkCount > 10) {
                        break;
                    }
                }
                IBlockState state = primer.getBlockState(x, y, z);
                if (state.getBlock() == vein.getTarget().getBlock() && state.getBlock().getMetaFromState(state) == vein.getTarget().getMeta()) {
                    String[] targetBiomes = vein.getBiomes();
                    if (targetBiomes != null && targetBiomes.length > 0) {
                        Biome biome = biomes[x * 16 + z];
                        if (biome == null || Config.containsBiome(targetBiomes, biome)) {
                            continue;
                        }
                    }
                    primer.setBlockState(x, y, z, vein.getBlockMeta().getBlockState());
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Biome(net.minecraft.world.biome.Biome) Axis(net.minecraft.util.EnumFacing.Axis) CaveVein(cavern.config.manager.CaveVein)

Aggregations

CaveVein (cavern.config.manager.CaveVein)12 BlockMeta (cavern.util.BlockMeta)8 File (java.io.File)7 List (java.util.List)3 GuiTextField (net.minecraft.client.gui.GuiTextField)3 Biome (net.minecraft.world.biome.Biome)3 CaveConfigGui (cavern.client.config.CaveConfigGui)2 CavernConfig (cavern.config.CavernConfig)2 Config (cavern.config.Config)2 CaveVeinManager (cavern.config.manager.CaveVeinManager)2 ArrayListExtended (cavern.util.ArrayListExtended)2 CaveFilters (cavern.util.CaveFilters)2 CaveUtils (cavern.util.CaveUtils)2 Joiner (com.google.common.base.Joiner)2 Splitter (com.google.common.base.Splitter)2 Strings (com.google.common.base.Strings)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 Sets (com.google.common.collect.Sets)2 IOException (java.io.IOException)2