Search in sources :

Example 11 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class CavernConfig method syncVeinsConfig.

public static void syncVeinsConfig() {
    if (veinManager.config == null) {
        veinManager.config = Config.loadConfig("cavern", "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()), 28, 25, 1, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.DIORITE.getMetadata()), 28, 25, 1, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.ANDESITE.getMetadata()), 30, 25, 1, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 35, 17, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 30, 10, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.GOLD_ORE, 0), 5, 7, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.REDSTONE_ORE, 0), 12, 7, 1, 40));
        veins.add(new CaveVein(new BlockMeta(Blocks.LAPIS_ORE, 0), 4, 5, 1, 50));
        veins.add(new CaveVein(new BlockMeta(Blocks.DIAMOND_ORE, 0), 2, 6, 1, 20));
        veins.add(new CaveVein(new BlockMeta(Blocks.EMERALD_ORE, 0), 8, 5, 50, 127, Type.MOUNTAIN, Type.HILLS));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.AQUAMARINE_ORE.getMetadata()), 12, 8, 20, 127, Type.COLD, Type.WATER, Type.WET));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.MAGNITE_ORE.getMetadata()), 30, 10, 1, 127));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.RANDOMITE_ORE.getMetadata()), 24, 4, 1, 127));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.HEXCITE_ORE.getMetadata()), 4, 5, 1, 30));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.FISSURED_STONE.getMetadata()), 60, 2, 1, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.DIRT, 0), 20, 25, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.GRAVEL, 0), 10, 20, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 10, 20, 1, 127, Type.SANDY));
        if (Config.highProfiles) {
            veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 35, 18, 128, 255));
            veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 30, 10, 128, 255));
            veins.add(new CaveVein(new BlockMeta(Blocks.GOLD_ORE, 0), 5, 7, 128, 255));
            veins.add(new CaveVein(new BlockMeta(Blocks.LAPIS_ORE, 0), 4, 6, 128, 255));
            veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.AQUAMARINE_ORE.getMetadata()), 12, 8, 128, 255, Type.COLD, Type.WATER, Type.WET));
            veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.MAGNITE_ORE.getMetadata()), 30, 10, 128, 255));
            veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.RANDOMITE_ORE.getMetadata()), 28, 2, 128, 255));
            veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.HEXCITE_ORE.getMetadata()), 4, 5, 200, 255));
            veins.add(new CaveVein(new BlockMeta(Blocks.DIRT, 0), 20, 25, 128, 255));
            veins.add(new CaveVein(new BlockMeta(Blocks.GRAVEL, 0), 10, 20, 128, 255));
            veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 10, 20, 128, 255, Type.SANDY));
        }
        generateVeinsConfig(veinManager, veins);
    } else {
        if (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 BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class CavernConfig method addBiomesFromConfig.

public static void addBiomesFromConfig(CaveBiomeManager manager) {
    for (String name : manager.config.getCategoryNames()) {
        Biome biome = Config.getBiomeFromString(name);
        if (biome == null) {
            continue;
        }
        ConfigCategory category = manager.config.getCategory(name);
        int weight = category.get("weight").getInt();
        String terrainBlock = category.get("terrainBlock").getString();
        String terrainBlockMeta = category.get("terrainBlockMeta").getString();
        String topBlock = category.get("topBlock").getString();
        String topBlockMeta = category.get("topBlockMeta").getString();
        CaveBiome caveBiome = new CaveBiome(biome, weight);
        caveBiome.setTerrainBlock(new BlockMeta(terrainBlock, terrainBlockMeta));
        caveBiome.setTopBlock(new BlockMeta(topBlock, topBlockMeta));
        manager.addCaveBiome(caveBiome);
    }
}
Also used : CaveBiome(cavern.config.manager.CaveBiome) Biome(net.minecraft.world.biome.Biome) CaveBiome(cavern.config.manager.CaveBiome) ConfigCategory(net.minecraftforge.common.config.ConfigCategory) BlockMeta(cavern.util.BlockMeta)

Example 13 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class CaveniaConfig method syncBiomesConfig.

public static void syncBiomesConfig() {
    if (biomeManager.config == null) {
        biomeManager.config = Config.loadConfig("cavenia", "biomes");
    } else {
        biomeManager.getCaveBiomes().clear();
    }
    if (biomeManager.config.getCategoryNames().isEmpty()) {
        List<CaveBiome> biomes = Lists.newArrayList();
        biomes.add(new CaveBiome(Biomes.OCEAN, 15, null, new BlockMeta(Blocks.GRAVEL.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.PLAINS, 100, null, new BlockMeta(Blocks.GRASS.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.DESERT, 70, null, new BlockMeta(Blocks.SAND.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.DESERT_HILLS, 10, null, new BlockMeta(Blocks.SANDSTONE.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.FOREST, 80, null, new BlockMeta(Blocks.GRAVEL.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.FOREST_HILLS, 10, null, new BlockMeta(Blocks.GRAVEL.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.TAIGA, 80));
        biomes.add(new CaveBiome(Biomes.TAIGA_HILLS, 10));
        biomes.add(new CaveBiome(Biomes.JUNGLE, 80, null, new BlockMeta(Blocks.GRAVEL.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.JUNGLE_HILLS, 10, null, new BlockMeta(Blocks.GRAVEL.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.SWAMPLAND, 60, null, new BlockMeta(Blocks.GRASS.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.EXTREME_HILLS, 50));
        biomes.add(new CaveBiome(Biomes.SAVANNA, 50, null, new BlockMeta(Blocks.GRASS.getDefaultState())));
        biomes.add(new CaveBiome(Biomes.MESA, 50, null, new BlockMeta(Blocks.RED_SANDSTONE.getDefaultState())));
        CavernConfig.generateBiomesConfig(biomeManager, biomes);
    } else {
        CavernConfig.addBiomesFromConfig(biomeManager);
    }
    Config.saveConfig(biomeManager.config);
}
Also used : CaveBiome(cavern.config.manager.CaveBiome) BlockMeta(cavern.util.BlockMeta)

Example 14 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class CaveniaConfig method syncVeinsConfig.

public static void syncVeinsConfig() {
    if (veinManager.config == null) {
        veinManager.config = Config.loadConfig("cavenia", "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()), 28, 25, 1, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.DIORITE.getMetadata()), 28, 25, 1, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.ANDESITE.getMetadata()), 30, 25, 1, 255));
        veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 50, 17, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 40, 10, 1, 127));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.AQUAMARINE_ORE.getMetadata()), 12, 8, 20, 127, Type.COLD, Type.WATER, Type.WET));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.MAGNITE_ORE.getMetadata()), 30, 10, 1, 127));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.RANDOMITE_ORE.getMetadata()), 24, 4, 1, 127));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.HEXCITE_ORE.getMetadata()), 4, 5, 1, 30));
        veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.FISSURED_STONE.getMetadata()), 150, 2, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.DIRT, 0), 20, 25, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.GRAVEL, 0), 10, 20, 1, 127));
        veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 10, 20, 1, 127, 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 15 with BlockMeta

use of cavern.util.BlockMeta in project Cavern2 by kegare.

the class CaveEventHooks method onBlockBreak.

@SubscribeEvent
public void onBlockBreak(BreakEvent event) {
    EntityPlayer entityPlayer = event.getPlayer();
    if (entityPlayer == null || entityPlayer instanceof FakePlayer || !(entityPlayer instanceof EntityPlayerMP)) {
        return;
    }
    EntityPlayerMP player = (EntityPlayerMP) entityPlayer;
    if (!CavernAPI.dimension.isInCaveDimensions(player)) {
        return;
    }
    World world = event.getWorld();
    IBlockState state = event.getState();
    ItemStack stack = player.getHeldItemMainhand();
    if (GeneralConfig.isMiningPointItem(stack)) {
        int point = MinerStats.getPointAmount(state);
        if (point != 0) {
            IMinerStats stats = MinerStats.get(player);
            IMiningData data = MiningData.get(player);
            if (player.inventory.hasItemStack(ItemCave.EnumType.MINER_ORB.getItemStack())) {
                if (RANDOM.nextDouble() < 0.15D) {
                    point += Math.max(point / 2, 1);
                }
            }
            stats.addPoint(point);
            stats.addMiningRecord(new BlockMeta(state));
            data.notifyMining(state, point);
            int combo = data.getMiningCombo();
            if (combo > 0 && combo % 10 == 0) {
                world.playSound(null, player.posX, player.posY + 0.25D, player.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.1F, 0.5F * ((RANDOM.nextFloat() - RANDOM.nextFloat()) * 0.7F + 1.8F));
                player.addExperience(combo / 10);
            }
            if (combo >= 50) {
                PlayerHelper.grantAdvancement(player, "good_mine");
            }
            CaveNetworkRegistry.sendTo(new MiningMessage(state, point), player);
        }
    }
    if (CavernAPI.dimension.isInFrostMountains(player)) {
        if (player.capabilities.isCreativeMode) {
            return;
        }
        if (state.getBlock() != Blocks.PACKED_ICE || EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0) {
            return;
        }
        BlockPos pos = event.getPos();
        Biome biome = world.getBiome(pos);
        if (!biome.isSnowyBiome()) {
            return;
        }
        if (RANDOM.nextDouble() < 0.05D) {
            Block.spawnAsEntity(world, pos, new ItemStack(Blocks.ICE));
        } else if (RANDOM.nextDouble() < 0.005D) {
            Block.spawnAsEntity(world, pos, RandomiteHelper.getDropItem());
        } else if (stack.getItem() instanceof IIceEquipment && RANDOM.nextDouble() < 0.03D || RANDOM.nextDouble() < 0.01D) {
            Block.spawnAsEntity(world, pos, new ItemStack(Blocks.PACKED_ICE));
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IIceEquipment(cavern.api.IIceEquipment) World(net.minecraft.world.World) FakePlayer(net.minecraftforge.common.util.FakePlayer) IMinerStats(cavern.api.IMinerStats) IMiningData(cavern.api.IMiningData) Biome(net.minecraft.world.biome.Biome) EntityPlayer(net.minecraft.entity.player.EntityPlayer) MiningMessage(cavern.network.client.MiningMessage) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) BlockMeta(cavern.util.BlockMeta) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

BlockMeta (cavern.util.BlockMeta)21 CaveVein (cavern.config.manager.CaveVein)7 File (java.io.File)7 CaveBiome (cavern.config.manager.CaveBiome)5 Biome (net.minecraft.world.biome.Biome)4 Block (net.minecraft.block.Block)3 IBlockState (net.minecraft.block.state.IBlockState)3 ItemStack (net.minecraft.item.ItemStack)3 Strings (com.google.common.base.Strings)2 Sets (com.google.common.collect.Sets)2 IOException (java.io.IOException)2 List (java.util.List)2 Set (java.util.Set)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 ConfigCategory (net.minecraftforge.common.config.ConfigCategory)2 IIceEquipment (cavern.api.IIceEquipment)1 IMinerStats (cavern.api.IMinerStats)1 IMiningData (cavern.api.IMiningData)1 CaveConfigGui (cavern.client.config.CaveConfigGui)1