use of cavern.util.BlockMeta in project Cavern2 by kegare.
the class GuiVeinsEditor method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
switch(button.id) {
case 0:
if (editMode) {
for (CaveVein vein : veinList.selected) {
if (!Strings.isNullOrEmpty(blockField.getText())) {
Block block = Block.getBlockFromName(blockField.getText());
if (block != null && block != Blocks.AIR) {
int meta = BlockMeta.getMetaFromString(block, blockMetaField.getText());
if (meta < 0) {
meta = 0;
}
vein.setBlockMeta(new BlockMeta(block, meta));
}
}
if (!Strings.isNullOrEmpty(targetField.getText())) {
Block block = Block.getBlockFromName(targetField.getText());
if (block != null && block != Blocks.AIR) {
int meta = BlockMeta.getMetaFromString(block, targetMetaField.getText());
if (meta < 0) {
meta = 0;
}
vein.setTarget(new BlockMeta(block, meta));
}
}
if (!Strings.isNullOrEmpty(weightField.getText())) {
vein.setWeight(NumberUtils.toInt(weightField.getText(), vein.getWeight()));
}
if (!Strings.isNullOrEmpty(chanceField.getText())) {
vein.setChance(NumberUtils.toDouble(chanceField.getText(), vein.getChance()));
}
if (!Strings.isNullOrEmpty(sizeField.getText())) {
vein.setSize(NumberUtils.toInt(sizeField.getText(), vein.getSize()));
}
if (!Strings.isNullOrEmpty(minHeightField.getText())) {
vein.setMinHeight(NumberUtils.toInt(minHeightField.getText(), vein.getMinHeight()));
}
if (!Strings.isNullOrEmpty(maxHeightField.getText())) {
vein.setMaxHeight(NumberUtils.toInt(maxHeightField.getText(), vein.getMaxHeight()));
}
if (!Strings.isNullOrEmpty(biomesField.getText())) {
String text = biomesField.getText();
Set<String> biomes = Sets.newTreeSet();
if (text.contains(",")) {
for (String str : Splitter.on(',').trimResults().omitEmptyStrings().split(text)) {
if (Strings.isNullOrEmpty(str)) {
biomes.add(str);
}
}
} else {
biomes.add(text);
}
if (!biomes.isEmpty()) {
vein.setBiomes(biomes.toArray(new String[biomes.size()]));
}
}
}
actionPerformed(cancelButton);
veinList.scrollToTop();
veinList.scrollToSelected();
} else {
manager.getCaveVeins().clear();
try {
FileUtils.forceDelete(new File(manager.config.toString()));
manager.config.load();
} catch (Exception e) {
e.printStackTrace();
}
CavernConfig.generateVeinsConfig(manager, veinList.veins);
Config.saveConfig(manager.config);
actionPerformed(cancelButton);
veinList.selected.clear();
veinList.scrollToTop();
}
break;
case 1:
if (editMode) {
actionPerformed(cancelButton);
} else if (!veinList.selected.isEmpty()) {
editMode = true;
initGui();
veinList.scrollToTop();
veinList.scrollToSelected();
if (veinList.selected.size() > 1) {
blockField.setText("");
blockMetaField.setText("");
targetField.setText("");
targetMetaField.setText("");
weightField.setText("");
chanceField.setText("");
sizeField.setText("");
minHeightField.setText("");
maxHeightField.setText("");
biomesField.setText("");
} else
for (CaveVein vein : veinList.selected) {
if (vein != null) {
blockField.setText(vein.getBlockMeta().getBlockName());
blockMetaField.setText(vein.getBlockMeta().getMetaString());
targetField.setText(vein.getTarget().getBlockName());
targetMetaField.setText(vein.getTarget().getMetaString());
weightField.setText(Integer.toString(vein.getWeight()));
chanceField.setText(Double.toString(vein.getChance()));
sizeField.setText(Integer.toString(vein.getSize()));
minHeightField.setText(Integer.toString(vein.getMinHeight()));
maxHeightField.setText(Integer.toString(vein.getMaxHeight()));
String[] biomes = vein.getBiomes();
if (biomes == null || biomes.length <= 0) {
biomesField.setText("");
} else {
biomesField.setText(Joiner.on(", ").join(biomes));
}
}
}
}
break;
case 2:
if (editMode) {
editMode = false;
initGui();
} else {
mc.displayGuiScreen(parent);
}
break;
case 3:
mc.displayGuiScreen(new GuiSelectBlock(this, selected -> {
if (editMode) {
return;
}
veinList.selected.clear();
for (BlockMeta blockMeta : selected) {
CaveVein vein = new CaveVein(blockMeta, 1, 1, 1, 255);
veinList.veins.addIfAbsent(vein);
veinList.contents.addIfAbsent(vein);
veinList.selected.add(vein);
}
veinList.scrollToTop();
veinList.scrollToSelected();
}));
break;
case 4:
for (CaveVein vein : veinList.selected) {
veinList.veins.remove(vein);
veinList.contents.remove(vein);
}
veinList.selected.clear();
break;
case 5:
veinList.veins.forEach(entry -> veinList.selected.add(entry));
actionPerformed(removeButton);
break;
case 6:
CaveConfigGui.detailInfo = detailInfo.isChecked();
break;
case 7:
CaveConfigGui.instantFilter = instantFilter.isChecked();
break;
default:
veinList.actionPerformed(button);
}
}
}
use of cavern.util.BlockMeta in project Cavern2 by kegare.
the class GuiBiomesEditor method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
switch(button.id) {
case 0:
if (editMode) {
for (CaveBiome caveBiome : biomeList.selected) {
if (!Strings.isNullOrEmpty(weightField.getText())) {
caveBiome.setWeight(NumberUtils.toInt(weightField.getText(), caveBiome.getWeight()));
}
if (!Strings.isNullOrEmpty(terrainBlockField.getText())) {
Block block = Block.getBlockFromName(terrainBlockField.getText());
if (block != null && block != Blocks.AIR) {
int meta = BlockMeta.getMetaFromString(block, terrainBlockMetaField.getText());
if (meta < 0) {
meta = 0;
}
caveBiome.setTerrainBlock(new BlockMeta(block, meta));
}
}
if (!Strings.isNullOrEmpty(topBlockField.getText())) {
Block block = Block.getBlockFromName(topBlockField.getText());
if (block != null && block != Blocks.AIR) {
int meta = BlockMeta.getMetaFromString(block, topBlockMetaField.getText());
if (meta < 0) {
meta = 0;
}
caveBiome.setTopBlock(new BlockMeta(block, meta));
}
}
}
actionPerformed(cancelButton);
biomeList.scrollToTop();
biomeList.scrollToSelected();
} else {
manager.getCaveBiomes().clear();
try {
FileUtils.forceDelete(new File(manager.config.toString()));
manager.config.load();
} catch (Exception e) {
e.printStackTrace();
}
Collections.sort(biomeList.biomes);
CavernConfig.generateBiomesConfig(manager, biomeList.biomes);
Config.saveConfig(manager.config);
actionPerformed(cancelButton);
biomeList.selected.clear();
biomeList.scrollToTop();
}
break;
case 1:
if (editMode) {
actionPerformed(cancelButton);
} else if (!biomeList.selected.isEmpty()) {
editMode = true;
initGui();
biomeList.scrollToTop();
biomeList.scrollToSelected();
if (biomeList.selected.size() > 1) {
weightField.setText("");
terrainBlockField.setText("");
terrainBlockMetaField.setText("");
topBlockField.setText("");
topBlockMetaField.setText("");
} else
for (CaveBiome biome : biomeList.selected) {
if (biome != null) {
weightField.setText(Integer.toString(biome.getWeight()));
terrainBlockField.setText(biome.getTerrainBlock().getBlockName());
terrainBlockMetaField.setText(biome.getTerrainBlock().getMetaString());
topBlockField.setText(biome.getTopBlock().getBlockName());
topBlockMetaField.setText(biome.getTopBlock().getMetaString());
}
}
}
break;
case 2:
if (editMode) {
editMode = false;
initGui();
} else {
mc.displayGuiScreen(parent);
}
break;
case 3:
Set<Biome> invisibleBiomes = biomeList.biomes.stream().map(CaveBiome::getBiome).collect(Collectors.toSet());
mc.displayGuiScreen(new GuiSelectBiome(this, new ISelectorCallback<Biome>() {
@Override
public boolean isValidEntry(Biome entry) {
return entry != null && !invisibleBiomes.contains(entry);
}
@Override
public void onSelected(List<Biome> selected) {
if (editMode) {
return;
}
biomeList.selected.clear();
for (Biome biome : selected) {
CaveBiome caveBiome = new CaveBiome(biome, 10);
biomeList.biomes.addIfAbsent(caveBiome);
biomeList.contents.addIfAbsent(caveBiome);
biomeList.selected.add(caveBiome);
}
biomeList.scrollToTop();
biomeList.scrollToSelected();
}
}));
break;
case 4:
for (CaveBiome biome : biomeList.selected) {
biomeList.biomes.remove(biome);
biomeList.contents.remove(biome);
}
biomeList.selected.clear();
break;
case 5:
biomeList.biomes.forEach(entry -> biomeList.selected.add(entry));
actionPerformed(removeButton);
break;
case 6:
CaveConfigGui.detailInfo = detailInfo.isChecked();
break;
case 7:
CaveConfigGui.instantFilter = instantFilter.isChecked();
break;
default:
biomeList.actionPerformed(button);
}
}
}
use of cavern.util.BlockMeta in project Cavern2 by kegare.
the class AquaCavernConfig method syncBiomesConfig.
public static void syncBiomesConfig() {
if (biomeManager.config == null) {
biomeManager.config = Config.loadConfig("aquacavern", "biomes");
} else {
biomeManager.getCaveBiomes().clear();
}
if (biomeManager.config.getCategoryNames().isEmpty()) {
List<CaveBiome> biomes = Lists.newArrayList();
biomes.add(new CaveBiome(Biomes.OCEAN, 100));
biomes.add(new CaveBiome(Biomes.PLAINS, 50));
biomes.add(new CaveBiome(Biomes.DESERT, 10));
biomes.add(new CaveBiome(Biomes.DESERT_HILLS, 5));
biomes.add(new CaveBiome(Biomes.FOREST, 50));
biomes.add(new CaveBiome(Biomes.FOREST_HILLS, 10));
biomes.add(new CaveBiome(Biomes.TAIGA, 70));
biomes.add(new CaveBiome(Biomes.TAIGA_HILLS, 10));
biomes.add(new CaveBiome(Biomes.JUNGLE, 50));
biomes.add(new CaveBiome(Biomes.JUNGLE_HILLS, 10));
biomes.add(new CaveBiome(Biomes.SWAMPLAND, 30));
biomes.add(new CaveBiome(Biomes.EXTREME_HILLS, 20));
biomes.add(new CaveBiome(Biomes.ICE_PLAINS, 80));
biomes.add(new CaveBiome(Biomes.ICE_MOUNTAINS, 10));
biomes.add(new CaveBiome(Biomes.SAVANNA, 50));
biomes.add(new CaveBiome(Biomes.MESA, 30, 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 AquaCavernConfig method syncVeinsConfig.
public static void syncVeinsConfig() {
if (veinManager.config == null) {
veinManager.config = Config.loadConfig("aquacavern", "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()), 30, 25, 1, 255));
veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.DIORITE.getMetadata()), 32, 25, 1, 255));
veins.add(new CaveVein(new BlockMeta(Blocks.STONE, BlockStone.EnumType.ANDESITE.getMetadata()), 32, 25, 1, 255));
veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 40, 17, 1, 127));
veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 40, 10, 1, 127));
veins.add(new CaveVein(new BlockMeta(Blocks.GOLD_ORE, 0), 8, 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), 8, 5, 1, 50));
veins.add(new CaveVein(new BlockMeta(Blocks.DIAMOND_ORE, 0), 3, 6, 1, 20));
veins.add(new CaveVein(new BlockMeta(Blocks.EMERALD_ORE, 0), 8, 5, 50, 127));
veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.AQUAMARINE_ORE.getMetadata()), 30, 8, 20, 127));
veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.MAGNITE_ORE.getMetadata()), 35, 10, 1, 127));
veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.RANDOMITE_ORE.getMetadata()), 28, 6, 1, 127));
veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.HEXCITE_ORE.getMetadata()), 6, 5, 1, 30));
veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.FISSURED_STONE.getMetadata()), 70, 3, 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.CLAY, 0), 30, 20, 1, 127));
veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 15, 20, 1, 127));
if (Config.highProfiles) {
veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 35, 20, 128, 255));
veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 30, 12, 128, 255));
veins.add(new CaveVein(new BlockMeta(Blocks.GOLD_ORE, 0), 5, 8, 128, 255));
veins.add(new CaveVein(new BlockMeta(Blocks.LAPIS_ORE, 0), 4, 7, 128, 255));
veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.AQUAMARINE_ORE.getMetadata()), 12, 12, 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, 4, 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.CLAY, 0), 30, 20, 128, 255));
veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 10, 20, 128, 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);
}
use of cavern.util.BlockMeta in project Cavern2 by kegare.
the class CavelandConfig method syncVeinsConfig.
public static void syncVeinsConfig() {
if (veinManager.config == null) {
veinManager.config = Config.loadConfig("caveland", "veins");
} else {
veinManager.getCaveVeins().clear();
}
if (veinManager.config.getCategoryNames().isEmpty()) {
List<CaveVein> veins = Lists.newArrayList();
veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 30, 17, 1, 127));
veins.add(new CaveVein(new BlockMeta(Blocks.COAL_ORE, 0), 20, 15, 1, 10));
veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 30, 10, 1, 127));
veins.add(new CaveVein(new BlockMeta(Blocks.IRON_ORE, 0), 20, 8, 1, 10));
veins.add(new CaveVein(new BlockMeta(Blocks.GRAVEL, 0), 30, 20, 1, 127));
veins.add(new CaveVein(new BlockMeta(Blocks.GRAVEL, 0), 10, 10, 1, 10));
veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 20, 20, 1, 127));
veins.add(new CaveVein(new BlockMeta(Blocks.SAND, BlockSand.EnumType.SAND.getMetadata()), 7, 10, 1, 10));
veins.add(new CaveVein(new BlockMeta(CaveBlocks.CAVE_BLOCK, BlockCave.EnumType.FISSURED_STONE.getMetadata()), 30, 2, 1, 10));
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);
}
Aggregations