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);
}
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);
}
}
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);
}
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);
}
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));
}
}
}
Aggregations