use of cavern.config.manager.CaveBiome in project Cavern2 by kegare.
the class ChunkGeneratorCavern method replaceBiomeBlocks.
public void replaceBiomeBlocks(int chunkX, int chunkZ, ChunkPrimer primer) {
if (!ForgeEventFactory.onReplaceBiomeBlocks(this, chunkX, chunkZ, primer, world)) {
return;
}
int worldHeight = world.provider.getActualHeight();
int blockHeight = worldHeight - 1;
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
Biome biome = biomesForGeneration[x * 16 + z];
CaveBiome caveBiome = CavernConfig.biomeManager.getCaveBiome(biome);
IBlockState top = caveBiome == null ? STONE : caveBiome.getTopBlock().getBlockState();
IBlockState filter = caveBiome == null ? top : caveBiome.getTerrainBlock().getBlockState();
primer.setBlockState(x, 0, z, BEDROCK);
primer.setBlockState(x, blockHeight, z, BEDROCK);
for (int y = 1; y <= blockHeight - 1; ++y) {
if (primer.getBlockState(x, y, z).getMaterial().isSolid() && primer.getBlockState(x, y + 1, z).getBlock() == Blocks.AIR) {
primer.setBlockState(x, y, z, top);
} else if (primer.getBlockState(x, y, z).getBlock() == Blocks.STONE) {
primer.setBlockState(x, y, z, filter);
}
}
if (blockHeight < 255) {
for (int y = blockHeight + 1; y < 256; ++y) {
primer.setBlockState(x, y, z, AIR);
}
}
}
}
}
use of cavern.config.manager.CaveBiome in project Cavern2 by kegare.
the class ChunkGeneratorHugeCavern method replaceBiomeBlocks.
public void replaceBiomeBlocks(int chunkX, int chunkZ, ChunkPrimer primer) {
if (!ForgeEventFactory.onReplaceBiomeBlocks(this, chunkX, chunkZ, primer, world)) {
return;
}
int worldHeight = world.provider.getActualHeight();
int blockHeight = worldHeight - 1;
for (int x = 0; x < 16; ++x) {
for (int z = 0; z < 16; ++z) {
Biome biome = biomesForGeneration[x * 16 + z];
CaveBiome caveBiome = HugeCavernConfig.biomeManager.getCaveBiome(biome);
IBlockState top = caveBiome == null ? STONE : caveBiome.getTopBlock().getBlockState();
IBlockState filter = caveBiome == null ? top : caveBiome.getTerrainBlock().getBlockState();
primer.setBlockState(x, 0, z, BEDROCK);
primer.setBlockState(x, blockHeight, z, BEDROCK);
for (int y = 1; y <= blockHeight - 1; ++y) {
if (primer.getBlockState(x, y, z).getMaterial().isSolid() && primer.getBlockState(x, y + 1, z).getBlock() == Blocks.AIR) {
primer.setBlockState(x, y, z, top);
} else if (primer.getBlockState(x, y, z).getBlock() == Blocks.STONE) {
primer.setBlockState(x, y, z, filter);
}
}
if (blockHeight < 255) {
for (int y = blockHeight + 1; y < 256; ++y) {
primer.setBlockState(x, y, z, AIR);
}
}
}
}
}
use of cavern.config.manager.CaveBiome 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.config.manager.CaveBiome in project Cavern2 by kegare.
the class GuiBiomesEditor method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float ticks) {
biomeList.drawScreen(mouseX, mouseY, ticks);
drawCenteredString(fontRenderer, I18n.format(Config.LANG_KEY + "biomes"), width / 2, 15, 0xFFFFFF);
super.drawScreen(mouseX, mouseY, ticks);
if (editMode) {
GuiTextField textField;
for (int i = 0; i < editFieldList.size(); ++i) {
textField = editFieldList.get(i);
textField.drawTextBox();
drawString(fontRenderer, editLabelList.get(i), textField.x - maxLabelWidth - 10, textField.y + 3, 0xBBBBBB);
}
if (weightHoverChecker.checkHover(mouseX, mouseY)) {
List<String> hover = Lists.newArrayList();
String key = Config.LANG_KEY + "biomes.weight";
hover.add(TextFormatting.GRAY + I18n.format(key));
hover.addAll(fontRenderer.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));
drawHoveringText(hover, mouseX, mouseY);
} else if (terrainBlockHoverChecker.checkHover(mouseX, mouseY)) {
List<String> hover = Lists.newArrayList();
String key = Config.LANG_KEY + "biomes.terrainBlock";
hover.add(TextFormatting.GRAY + I18n.format(key));
hover.addAll(fontRenderer.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));
drawHoveringText(hover, mouseX, mouseY);
} else if (topBlockHoverChecker.checkHover(mouseX, mouseY)) {
List<String> hover = Lists.newArrayList();
String key = Config.LANG_KEY + "biomes.topBlock";
hover.add(TextFormatting.GRAY + I18n.format(key));
hover.addAll(fontRenderer.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));
drawHoveringText(hover, mouseX, mouseY);
}
} else {
filterTextField.drawTextBox();
}
if (detailHoverChecker.checkHover(mouseX, mouseY)) {
drawHoveringText(fontRenderer.listFormattedStringToWidth(I18n.format(Config.LANG_KEY + "detail.hover"), 300), mouseX, mouseY);
} else if (instantHoverChecker.checkHover(mouseX, mouseY)) {
drawHoveringText(fontRenderer.listFormattedStringToWidth(I18n.format(Config.LANG_KEY + "instant.hover"), 300), mouseX, mouseY);
} else if (biomeList.isMouseYWithinSlotBounds(mouseY) && isCtrlKeyDown()) {
CaveBiome caveBiome = biomeList.contents.get(biomeList.getSlotIndexFromScreenCoords(mouseX, mouseY), null);
if (caveBiome != null) {
List<String> info = Lists.newArrayList();
String prefix = TextFormatting.GRAY.toString();
info.add(prefix + I18n.format(Config.LANG_KEY + "biomes.weight") + ": " + caveBiome.getWeight());
info.add(prefix + I18n.format(Config.LANG_KEY + "biomes.terrainBlock") + ": " + caveBiome.getTerrainBlock().getName());
info.add(prefix + I18n.format(Config.LANG_KEY + "biomes.topBlock") + ": " + caveBiome.getTopBlock().getName());
drawHoveringText(info, mouseX, mouseY);
}
}
if (biomeList.selected.size() > 1 && mouseX <= 100 && mouseY <= 20) {
drawString(fontRenderer, I18n.format(Config.LANG_KEY + "select.entry.selected", biomeList.selected.size()), 5, 5, 0xEFEFEF);
}
}
use of cavern.config.manager.CaveBiome 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);
}
Aggregations