use of cavern.config.manager.CaveVein 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.config.manager.CaveVein in project Cavern2 by kegare.
the class CavernConfig method generateVeinsConfig.
public static void generateVeinsConfig(CaveVeinManager manager, Collection<CaveVein> veins) {
String category = "veins";
Property prop;
String comment;
String blockDefault = Blocks.STONE.getRegistryName().toString();
int index = 0;
for (CaveVein vein : veins) {
String entry = Integer.toString(index);
List<String> propOrder = Lists.newArrayList();
prop = manager.config.get(entry, "block", blockDefault);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getBlockMeta().getBlockName());
prop = manager.config.get(entry, "blockMeta", Integer.toString(0));
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getBlockMeta().getMetaString());
prop = manager.config.get(entry, "targetBlock", blockDefault);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getTarget().getBlockName());
prop = manager.config.get(entry, "targetBlockMeta", Integer.toString(0));
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getTarget().getMetaString());
prop = manager.config.get(entry, "weight", 1);
prop.setMinValue(0).setMaxValue(100);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + "]";
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getWeight());
prop = manager.config.get(entry, "chance", 1.0D);
prop.setMinValue(0.0D).setMaxValue(1.0D);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: " + prop.getDefault() + "]";
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getChance());
prop = manager.config.get(entry, "size", 1);
prop.setMinValue(0).setMaxValue(100);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + "]";
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getSize());
prop = manager.config.get(entry, "minHeight", 0);
prop.setMinValue(0).setMaxValue(255);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: " + prop.getDefault() + "]";
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getMinHeight());
prop = manager.config.get(entry, "maxHeight", 255);
prop.setMinValue(0).setMaxValue(255);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
comment += " [range: " + prop.getMinValue() + " ~ " + prop.getMaxValue() + ", default: " + prop.getDefault() + "]";
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getMaxHeight());
prop = manager.config.get(entry, "biomes", new String[0]);
prop.setMaxListLength(256);
prop.setLanguageKey(Config.LANG_KEY + category + "." + prop.getName());
comment = Cavern.proxy.translate(prop.getLanguageKey() + ".tooltip");
prop.setComment(comment);
propOrder.add(prop.getName());
prop.set(vein.getBiomes());
manager.config.setCategoryPropertyOrder(entry, propOrder);
manager.addCaveVein(vein);
++index;
}
}
use of cavern.config.manager.CaveVein 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.config.manager.CaveVein in project Cavern2 by kegare.
the class GuiVeinsEditor method keyTyped.
@Override
protected void keyTyped(char c, int code) throws IOException {
if (editMode) {
for (GuiTextField textField : editFieldList) {
if (code == Keyboard.KEY_ESCAPE) {
textField.setFocused(false);
} else if (textField.isFocused()) {
if (textField != blockField && textField != blockMetaField && textField != targetField && textField != targetMetaField && textField != biomesField) {
if (!CharUtils.isAsciiControl(c) && !CharUtils.isAsciiNumeric(c)) {
continue;
}
}
textField.textboxKeyTyped(c, code);
}
}
} else {
if (filterTextField.isFocused()) {
if (code == Keyboard.KEY_ESCAPE) {
filterTextField.setFocused(false);
}
String prev = filterTextField.getText();
filterTextField.textboxKeyTyped(c, code);
String text = filterTextField.getText();
boolean changed = text != prev;
if (Strings.isNullOrEmpty(text) && changed) {
veinList.setFilter(null);
} else if (instantFilter.isChecked() && changed || code == Keyboard.KEY_RETURN) {
veinList.setFilter(text);
}
} else {
if (code == Keyboard.KEY_ESCAPE) {
actionPerformed(doneButton);
} else if (code == Keyboard.KEY_BACK) {
veinList.selected.clear();
} else if (code == Keyboard.KEY_TAB) {
if (++veinList.nameType > 2) {
veinList.nameType = 0;
}
} else if (code == Keyboard.KEY_UP) {
if (isCtrlKeyDown()) {
Collections.sort(veinList.selected, veinList);
for (CaveVein vein : veinList.selected) {
veinList.contents.swapTo(veinList.contents.indexOf(vein), -1);
veinList.veins.swapTo(veinList.veins.indexOf(vein), -1);
}
veinList.scrollToTop();
veinList.scrollToSelected();
} else {
veinList.scrollUp();
}
} else if (code == Keyboard.KEY_DOWN) {
if (isCtrlKeyDown()) {
Collections.sort(veinList.selected, veinList);
Collections.reverse(veinList.selected);
for (CaveVein vein : veinList.selected) {
veinList.contents.swapTo(veinList.contents.indexOf(vein), 1);
veinList.veins.swapTo(veinList.veins.indexOf(vein), 1);
}
veinList.scrollToTop();
veinList.scrollToSelected();
} else {
veinList.scrollDown();
}
} else if (code == Keyboard.KEY_HOME) {
veinList.scrollToTop();
} else if (code == Keyboard.KEY_END) {
veinList.scrollToEnd();
} else if (code == Keyboard.KEY_SPACE) {
veinList.scrollToSelected();
} else if (code == Keyboard.KEY_PRIOR) {
veinList.scrollToPrev();
} else if (code == Keyboard.KEY_NEXT) {
veinList.scrollToNext();
} else if (code == Keyboard.KEY_F || code == mc.gameSettings.keyBindChat.getKeyCode()) {
filterTextField.setFocused(true);
} else if (isCtrlKeyDown() && code == Keyboard.KEY_A) {
veinList.contents.forEach(entry -> veinList.selected.add(entry));
} else if (code == Keyboard.KEY_DELETE && !veinList.selected.isEmpty()) {
actionPerformed(removeButton);
} else if (code == Keyboard.KEY_C && isCtrlKeyDown()) {
Collections.sort(veinList.selected, veinList);
veinList.copied.clear();
for (CaveVein entry : veinList.selected) {
veinList.copied.add(new CaveVein(entry));
}
} else if (code == Keyboard.KEY_X && isCtrlKeyDown()) {
keyTyped(Character.MIN_VALUE, Keyboard.KEY_C);
actionPerformed(removeButton);
} else if (code == Keyboard.KEY_V && isCtrlKeyDown() && !veinList.copied.isEmpty()) {
int index1 = -1;
int index2 = -1;
int i = 0;
for (CaveVein vein : veinList.copied) {
CaveVein entry = new CaveVein(vein);
if (veinList.veins.add(entry) && veinList.contents.add(entry) && !veinList.selected.isEmpty()) {
if (index1 < 0) {
index1 = veinList.contents.indexOf(veinList.selected.get(veinList.selected.size() - 1)) + 1;
}
Collections.swap(veinList.contents, index1 + i, veinList.contents.indexOf(entry));
if (index2 < 0) {
index2 = veinList.veins.indexOf(veinList.selected.get(veinList.selected.size() - 1)) + 1;
}
Collections.swap(veinList.veins, index2 + i, veinList.veins.indexOf(entry));
++i;
}
}
veinList.scrollToTop();
veinList.scrollToSelected();
}
}
}
}
use of cavern.config.manager.CaveVein in project Cavern2 by kegare.
the class CavernConfig method addVeinsFromConfig.
public static boolean addVeinsFromConfig(CaveVeinManager manager) {
boolean flag = false;
for (String name : manager.config.getCategoryNames()) {
if (NumberUtils.isCreatable(name)) {
try {
ConfigCategory category = manager.config.getCategory(name);
String block = category.get("block").getString();
String blockMeta = category.get("blockMeta").getString();
String targetBlock = category.get("targetBlock").getString();
String targetBlockMeta = category.get("targetBlockMeta").getString();
int weight = category.get("weight").getInt();
double chance = category.get("chance").getDouble();
int size = category.get("size").getInt();
int minHeight = category.get("minHeight").getInt();
int maxHeight = category.get("maxHeight").getInt();
String[] biomes = category.get("biomes").getStringList();
CaveVein vein = new CaveVein();
vein.setBlockMeta(new BlockMeta(block, blockMeta));
vein.setTarget(new BlockMeta(targetBlock, targetBlockMeta));
vein.setWeight(weight);
vein.setChance(chance);
vein.setSize(size);
vein.setMinHeight(minHeight);
vein.setMaxHeight(maxHeight);
vein.setBiomes(biomes);
manager.addCaveVein(vein);
} catch (Exception e) {
}
} else {
flag = true;
}
}
return flag;
}
Aggregations