package com.irtimaled.bbor.client;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.events.*;
import com.irtimaled.bbor.client.gui.LoadSavesScreen;
import com.irtimaled.bbor.client.gui.SettingsScreen;
import com.irtimaled.bbor.common.CommonProxy;
import com.irtimaled.bbor.common.EventBus;
import com.irtimaled.bbor.common.VillageColorCache;
-import com.irtimaled.bbor.config.ConfigManager;
public class ClientProxy extends CommonProxy {
static {
.onKeyPressHandler(LoadSavesScreen::show);
}
+ public ClientProxy() {
+ ConfigManager.loadConfig();
+ }
+
@Override
public void init() {
super.init();
package com.irtimaled.bbor.client;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.client.models.*;
import com.irtimaled.bbor.client.providers.*;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
import com.irtimaled.bbor.common.models.BoundingBoxVillage;
-import com.irtimaled.bbor.config.ConfigManager;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
package com.irtimaled.bbor.client.commands;
+import com.irtimaled.bbor.client.config.ConfigManager;
+import com.irtimaled.bbor.client.config.Setting;
import com.irtimaled.bbor.client.gui.SettingsScreen;
-import com.irtimaled.bbor.config.ConfigManager;
-import com.irtimaled.bbor.config.Setting;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
--- /dev/null
+package com.irtimaled.bbor.client.config;
+
+public abstract class AbstractSetting {
+ String comment;
+ String category;
+ String name;
+
+ private final char type;
+
+ AbstractSetting(char type) {
+ this.type = type;
+ }
+
+ public char getType() {
+ return type;
+ }
+
+ public String getName() { return name; }
+
+ abstract Object getValue();
+}
package com.irtimaled.bbor.client.config;
import com.irtimaled.bbor.common.BoundingBoxType;
-import com.irtimaled.bbor.config.ConfigManager;
-import com.irtimaled.bbor.config.Setting;
import java.util.HashMap;
import java.util.Map;
--- /dev/null
+package com.irtimaled.bbor.client.config;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ConfigManager {
+ private static final Set<Setting<?>> settings = new HashSet<>();
+ private static File configDir;
+
+ public static Setting<Boolean> fill;
+ public static Setting<Boolean> drawVillages;
+ public static Setting<Boolean> drawDesertTemples;
+ public static Setting<Boolean> drawJungleTemples;
+ public static Setting<Boolean> drawWitchHuts;
+ public static Setting<Boolean> drawStrongholds;
+ public static Setting<Boolean> drawMineShafts;
+ public static Setting<Boolean> drawNetherFortresses;
+ public static Setting<Boolean> drawOceanMonuments;
+ public static Setting<Boolean> alwaysVisible;
+ public static Setting<Boolean> drawIronGolemSpawnArea;
+ public static Setting<Boolean> drawVillageDoors;
+ public static Setting<Boolean> drawSlimeChunks;
+ public static Setting<Integer> slimeChunkMaxY;
+ public static Setting<Boolean> keepCacheBetweenSessions;
+ public static Setting<Boolean> drawWorldSpawn;
+ public static Setting<Integer> worldSpawnMaxY;
+ public static Setting<Boolean> drawLazySpawnChunks;
+ public static Setting<Boolean> drawEndCities;
+ public static Setting<Boolean> drawMansions;
+ public static Setting<Boolean> drawShipwrecks;
+ public static Setting<Boolean> drawOceanRuins;
+ public static Setting<Boolean> drawBuriedTreasure;
+ public static Setting<Boolean> drawIgloos;
+ public static Setting<Boolean> drawMobSpawners;
+ public static Setting<Boolean> renderMobSpawnerSpawnArea;
+ public static Setting<Boolean> renderMobSpawnerActivationLines;
+ public static Setting<Boolean> drawPillagerOutposts;
+ public static Setting<Boolean> outerBoxesOnly;
+ public static Setting<Integer> villageSphereDotSize;
+ public static Setting<Integer> villageSphereDensity;
+ public static Setting<Boolean> drawVillageSpheres;
+ public static Setting<Boolean> drawAFKSpheres;
+ public static Setting<Boolean> renderAFKSpawnableBlocks;
+ public static Setting<Integer> afkSpawnableBlocksRenderDistance;
+ public static Setting<Boolean> drawBeacons;
+ public static Setting<Boolean> drawBiomeBorders;
+ public static Setting<Boolean> renderOnlyCurrentBiome;
+ public static Setting<Integer> biomeBordersRenderDistance;
+ public static Setting<Integer> biomeBordersMaxY;
+ public static Setting<Boolean> drawNetherFossils;
+ public static Setting<Boolean> drawBastionRemnants;
+ public static Setting<Boolean> drawRuinedPortals;
+ public static Setting<Boolean> drawConduits;
+ public static Setting<Boolean> renderConduitMobHarmArea;
+
+ public static void loadConfig() {
+ configDir = new File(".", "config");
+ configDir.mkdirs();
+ Configuration config = loadConfiguration();
+
+ fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled.");
+ outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
+ alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
+ keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
+
+ drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
+
+ drawConduits = setup(config, "conduits", "drawConduits", true, "If set to true conduit bounding spheres will be drawn.");
+ renderConduitMobHarmArea = setup(config, "conduits", "renderConduitMobHarmArea", true, "If set to true a box to show the area where hostile mobs are harmed will be drawn");
+
+ drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
+ renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
+ biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
+ biomeBordersMaxY = setup(config, "biomeBorders", "biomeBordersMaxY", -1, "The maximum top of the biome borders. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
+
+ drawVillageSpheres = setup(config, "villages", "drawVillageSpheres", true, "If set to true village bounding spheres are drawn.");
+ drawIronGolemSpawnArea = setup(config, "villages", "drawIronGolemSpawnArea", true, "If set to true the iron golem spawn area of the village will be drawn. (default:true)");
+ drawVillageDoors = setup(config, "villages", "drawVillageDoors", false, "If set to true lines between the village centre and doors will be drawn. (default:false)");
+ villageSphereDotSize = setup(config, "villages", "villageSphereDotSize", 2, "The size of the dots used when rendering village as sphere.");
+ villageSphereDensity = setup(config, "villages", "villageSphereDensity", 3, "The density of the dots used when rendering village as sphere.");
+
+ drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
+ drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
+ drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
+ drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
+ drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn.");
+ drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn.");
+ drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn.");
+ drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn.");
+ drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn.");
+ drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn.");
+ drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn.");
+ drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn.");
+ drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn.");
+ drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn.");
+ drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn.");
+ drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn.");
+ drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn.");
+ drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn.");
+
+ drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn.");
+ slimeChunkMaxY = setup(config, "slimeChunks", "slimeChunkMaxY", -1, "The maximum top of the slime chunk bounding box. If set to -1 it will use the value when activated, if set to 0 it will always track the player's feet.");
+
+ drawWorldSpawn = setup(config, "worldSpawn", "drawWorldSpawn", true, "If set to true world spawn and spawn chunks bounding boxes are drawn.");
+ worldSpawnMaxY = setup(config, "worldSpawn", "worldSpawnMaxY", -1, "The maximum top of the world spawn bounding boxes. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
+ drawLazySpawnChunks = setup(config, "worldSpawn", "drawLazySpawnChunks", false, "If set to true the lazy spawn chunks bounding boxes will be drawn.");
+
+ drawMobSpawners = setup(config, "mobSpawners", "drawMobSpawners", true, "If set to true mob spawners will be drawn.");
+ renderMobSpawnerSpawnArea = setup(config, "mobSpawners", "renderMobSpawnerSpawnArea", true, "If set to true a box to show the maximum possible spawn area (10x10x4) for a spawner will be drawn");
+ renderMobSpawnerActivationLines = setup(config, "mobSpawners", "renderMobSpawnerActivationLines", true, "If set to true a red/orange/green line will be drawn to show if the spawner is active");
+
+ drawAFKSpheres = setup(config, "afkSpot", "drawAFKSpheres", true, "If set to true afk spot spheres will be drawn.");
+ renderAFKSpawnableBlocks = setup(config, "afkSpot", "renderAFKSpawnableBlocks", true, "If set to true boxes to show spawnable blocks within the AFK sphere will be drawn.");
+ afkSpawnableBlocksRenderDistance = setup(config, "afkSpot", "afkSpawnableBlocksRenderDistance", 3, "The distance from the player where spawnable blocks within the AFK sphere will be drawn.");
+
+ config.save();
+ }
+
+ private static Configuration loadConfiguration() {
+ Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
+ config.load();
+ return config;
+ }
+
+ public static void saveConfig() {
+ Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
+ for (Setting<?> setting : settings) {
+ config.put(setting);
+ }
+ config.save();
+ }
+
+ private static <T> Setting<T> setup(Configuration config, String category, String settingName, T defaultValue, String comment) {
+ Setting<T> setting = config.get(category, settingName, defaultValue);
+ setting.category = category;
+ setting.name = settingName;
+ setting.comment = comment + " (default: " + defaultValue.toString() + ")";
+ settings.add(setting);
+ return setting;
+ }
+
+ public static void Toggle(Setting<Boolean> setting) {
+ setting.set(!setting.get());
+ }
+
+ public static Set<Setting<?>> getSettings() {
+ return settings;
+ }
+}
--- /dev/null
+package com.irtimaled.bbor.client.config;
+
+import com.google.common.io.Files;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+class Configuration {
+ private static final String FALLBACK_CATEGORY = "features";
+ private final File file;
+
+ Configuration(File file) {
+ this.file = file;
+ }
+
+ void save() {
+ try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
+ writer.write("# Configuration file\n");
+ for (String category : settingsGroup.keySet()) {
+ writer.write("\n");
+ writer.write(String.format("%s {\n", category));
+ Map<String, Setting<?>> settings = settingsGroup.get(category);
+ boolean first = true;
+ for (String settingName : settings.keySet()) {
+ if (!first)
+ writer.write("\n");
+ first = false;
+ Setting setting = settings.get(settingName);
+ writer.write(String.format(" # %s\n", setting.comment));
+ writer.write(String.format(" %s:%s=%s\n", setting.getType(), settingName, setting.getValue()));
+ }
+ writer.write("}\n");
+ }
+ } catch (IOException ignored) {
+ }
+ }
+
+ private final Map<String, Map<String, Setting<?>>> settingsGroup = new HashMap<>();
+
+ void load() {
+ try {
+ List<String> lines = Files.readLines(file, StandardCharsets.UTF_8);
+ String category = null;
+ String lastCommentLine = null;
+ for (String line : lines) {
+ String trimmedLine = line.trim();
+ if (trimmedLine.isEmpty()) {
+ continue;
+ }
+ if (trimmedLine.startsWith("#")) {
+ lastCommentLine = trimmedLine.substring(1).trim();
+ continue;
+ }
+ if (trimmedLine.equals("}")) {
+ category = null;
+ continue;
+ }
+ if (category == null && trimmedLine.endsWith("{")) {
+ category = trimmedLine.substring(0, trimmedLine.length() - 1).trim();
+ settingsGroup.put(category, new HashMap<>());
+ continue;
+ }
+ if (category != null) {
+ String[] items = trimmedLine.split("[:=]");
+ char type = items[0].charAt(0);
+ String name = items[1];
+ String stringValue = items[2];
+ Setting setting = getTypedSetting(type, stringValue);
+ setting.comment = lastCommentLine;
+ settingsGroup.get(category).put(name, setting);
+ }
+ }
+ } catch (IOException ignored) {
+ }
+ }
+
+ private Setting<?> getTypedSetting(char type, String value) {
+ switch (type) {
+ case 'I':
+ return new Setting<>(type, Integer.parseInt(value));
+ case 'B':
+ return new Setting<>(type, value.equals("1") || value.toLowerCase().equals("true"));
+ }
+ return new Setting<>(type, value);
+ }
+
+ <T> Setting<T> get(String category, String settingName, T defaultValue) {
+ char type = getType(defaultValue);
+ if (!settingsGroup.containsKey(category)) {
+ settingsGroup.put(category, new HashMap<>());
+ }
+ Map<String, Setting<?>> settings = settingsGroup.get(category);
+ Setting<?> setting = settings.get(settingName);
+ if (setting == null && !category.equals(FALLBACK_CATEGORY))
+ setting = getFallbackSetting(settingName, settings);
+ if (setting != null && setting.getType() != type) {
+ setting = null;
+ }
+ if (setting == null) {
+ settings.put(settingName, setting = new Setting<>(type, defaultValue));
+ }
+ return (Setting<T>) setting;
+ }
+
+ private Setting<?> getFallbackSetting(String settingName, Map<String, Setting<?>> settings) {
+ Map<String, Setting<?>> fallbackSettings = settingsGroup.get(FALLBACK_CATEGORY);
+ if (fallbackSettings == null) return null;
+
+ Setting<?> setting = fallbackSettings.get(settingName);
+ if (setting != null) {
+ fallbackSettings.remove(settingName);
+ settings.put(settingName, setting);
+ }
+ return setting;
+ }
+
+ private <T> char getType(T defaultValue) {
+ String[] typeNames = defaultValue.getClass().getName().split("[.]");
+ return typeNames[typeNames.length - 1].charAt(0);
+ }
+
+ void put(Setting<?> setting) {
+ String category = setting.category;
+ if (!settingsGroup.containsKey(category)) {
+ settingsGroup.put(category, new HashMap<>());
+ }
+ Map<String, Setting<?>> settings = settingsGroup.get(category);
+ settings.put(setting.name, setting);
+ }
+}
--- /dev/null
+package com.irtimaled.bbor.client.config;
+
+public class Setting<T> extends AbstractSetting {
+ private T value;
+
+ Setting(char type, T value) {
+ super(type);
+ this.value = value;
+ }
+
+ public T get() {
+ return value;
+ }
+
+ public void set(T value) {
+ this.value = value;
+ }
+
+ @Override
+ Object getValue() {
+ return value;
+ }
+}
package com.irtimaled.bbor.client.gui;
-import com.irtimaled.bbor.config.ConfigManager;
-import com.irtimaled.bbor.config.Setting;
+import com.irtimaled.bbor.client.config.ConfigManager;
+import com.irtimaled.bbor.client.config.Setting;
public class BoolSettingButton extends BoolButton {
private final Setting<Boolean> setting;
package com.irtimaled.bbor.client.gui;
-import com.irtimaled.bbor.config.Setting;
+import com.irtimaled.bbor.client.config.Setting;
import net.minecraft.client.resources.I18n;
import java.util.HashMap;
package com.irtimaled.bbor.client.gui;
-import com.irtimaled.bbor.config.Setting;
+import com.irtimaled.bbor.client.config.Setting;
import net.minecraft.client.resources.I18n;
class MaxYSettingSlider extends IntSettingSlider {
package com.irtimaled.bbor.client.gui;
import com.irtimaled.bbor.client.ClientRenderer;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.common.BoundingBoxType;
-import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import com.irtimaled.bbor.client.Player;
import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.BiomeBorderHelper;
import com.irtimaled.bbor.client.models.BoundingBoxBiomeBorder;
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.config.ConfigManager;
import java.util.HashMap;
import java.util.Map;
import com.irtimaled.bbor.client.GetCache;
import com.irtimaled.bbor.client.Player;
import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.ClientInterop;
import com.irtimaled.bbor.common.BoundingBoxCache;
import com.irtimaled.bbor.common.MathHelper;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
-import com.irtimaled.bbor.config.ConfigManager;
import java.util.HashSet;
import java.util.Map;
package com.irtimaled.bbor.client.renderers;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.common.models.AbstractBoundingBox;
-import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
package com.irtimaled.bbor.client.renderers;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.BoundingBoxBiomeBorder;
import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.config.ConfigManager;
import java.awt.*;
package com.irtimaled.bbor.client.renderers;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.BoundingBoxConduit;
import com.irtimaled.bbor.common.models.Colors;
import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.config.ConfigManager;
import java.awt.*;
package com.irtimaled.bbor.client.renderers;
import com.irtimaled.bbor.client.Player;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.BoundingBoxMobSpawner;
import com.irtimaled.bbor.common.models.Colors;
import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.config.ConfigManager;
import java.awt.*;
package com.irtimaled.bbor.client.renderers;
import com.irtimaled.bbor.client.Player;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.BoundingBoxSlimeChunk;
-import com.irtimaled.bbor.config.ConfigManager;
import java.awt.*;
package com.irtimaled.bbor.client.renderers;
import com.irtimaled.bbor.client.Player;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.interop.SpawningSphereHelper;
import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
import com.irtimaled.bbor.common.MathHelper;
-import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.client.resources.I18n;
import java.awt.*;
package com.irtimaled.bbor.client.renderers;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.common.models.BoundingBoxVillage;
import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.config.ConfigManager;
import org.lwjgl.opengl.GL11;
import java.awt.*;
package com.irtimaled.bbor.client.renderers;
import com.irtimaled.bbor.client.Player;
+import com.irtimaled.bbor.client.config.ConfigManager;
import com.irtimaled.bbor.client.models.BoundingBoxWorldSpawn;
import com.irtimaled.bbor.common.models.Coords;
-import com.irtimaled.bbor.config.ConfigManager;
import java.awt.*;
import com.irtimaled.bbor.common.EventBus;
import com.irtimaled.bbor.common.events.*;
import com.irtimaled.bbor.common.models.ServerPlayer;
-import com.irtimaled.bbor.config.ConfigManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.NetworkManager;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.feature.structure.StructureStart;
-import java.io.File;
import java.util.Collection;
import java.util.Map;
public class CommonInterop {
- public static void init() {
- ConfigManager.loadConfig(new File("."));
- }
-
public static void chunkLoaded(Chunk chunk) {
int dimensionId = chunk.getWorld().getDimension().getType().getId();
Map<String, StructureStart> structures = chunk.getStructureStarts();
+++ /dev/null
-package com.irtimaled.bbor.config;
-
-public abstract class AbstractSetting {
- String comment;
- String category;
- String name;
-
- private final char type;
-
- AbstractSetting(char type) {
- this.type = type;
- }
-
- public char getType() {
- return type;
- }
-
- public String getName() { return name; }
-
- abstract Object getValue();
-}
+++ /dev/null
-package com.irtimaled.bbor.config;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-public class ConfigManager {
- private static final Set<Setting<?>> settings = new HashSet<>();
- public static File configDir;
-
- public static Setting<Boolean> fill;
- public static Setting<Boolean> drawVillages;
- public static Setting<Boolean> drawDesertTemples;
- public static Setting<Boolean> drawJungleTemples;
- public static Setting<Boolean> drawWitchHuts;
- public static Setting<Boolean> drawStrongholds;
- public static Setting<Boolean> drawMineShafts;
- public static Setting<Boolean> drawNetherFortresses;
- public static Setting<Boolean> drawOceanMonuments;
- public static Setting<Boolean> alwaysVisible;
- public static Setting<Boolean> drawIronGolemSpawnArea;
- public static Setting<Boolean> drawVillageDoors;
- public static Setting<Boolean> drawSlimeChunks;
- public static Setting<Integer> slimeChunkMaxY;
- public static Setting<Boolean> keepCacheBetweenSessions;
- public static Setting<Boolean> drawWorldSpawn;
- public static Setting<Integer> worldSpawnMaxY;
- public static Setting<Boolean> drawLazySpawnChunks;
- public static Setting<Boolean> drawEndCities;
- public static Setting<Boolean> drawMansions;
- public static Setting<Boolean> drawShipwrecks;
- public static Setting<Boolean> drawOceanRuins;
- public static Setting<Boolean> drawBuriedTreasure;
- public static Setting<Boolean> drawIgloos;
- public static Setting<Boolean> drawMobSpawners;
- public static Setting<Boolean> renderMobSpawnerSpawnArea;
- public static Setting<Boolean> renderMobSpawnerActivationLines;
- public static Setting<Boolean> drawPillagerOutposts;
- public static Setting<Boolean> outerBoxesOnly;
- public static Setting<Integer> villageSphereDotSize;
- public static Setting<Integer> villageSphereDensity;
- public static Setting<Boolean> drawVillageSpheres;
- public static Setting<Boolean> drawAFKSpheres;
- public static Setting<Boolean> renderAFKSpawnableBlocks;
- public static Setting<Integer> afkSpawnableBlocksRenderDistance;
- public static Setting<Boolean> drawBeacons;
- public static Setting<Boolean> drawBiomeBorders;
- public static Setting<Boolean> renderOnlyCurrentBiome;
- public static Setting<Integer> biomeBordersRenderDistance;
- public static Setting<Integer> biomeBordersMaxY;
- public static Setting<Boolean> drawNetherFossils;
- public static Setting<Boolean> drawBastionRemnants;
- public static Setting<Boolean> drawRuinedPortals;
- public static Setting<Boolean> drawConduits;
- public static Setting<Boolean> renderConduitMobHarmArea;
-
- public static void loadConfig(File mcConfigDir) {
- configDir = new File(mcConfigDir, "config");
- configDir.mkdirs();
- Configuration config = loadConfig();
-
- fill = setup(config, "general", "fill", true, "If set to true the bounding boxes are filled.");
- outerBoxesOnly = setup(config, "general", "outerBoxesOnly", false, "If set to true only the outer bounding boxes are rendered.");
- alwaysVisible = setup(config, "general", "alwaysVisible", false, "If set to true boxes will be visible even through other blocks.");
- keepCacheBetweenSessions = setup(config, "general", "keepCacheBetweenSessions", false, "If set to true bounding box caches will be kept between sessions.");
-
- drawBeacons = setup(config, "beacons", "drawBeacons", true, "If set to true beacon bounding boxes will be drawn.");
-
- drawConduits = setup(config, "conduits", "drawConduits", true, "If set to true conduit bounding spheres will be drawn.");
- renderConduitMobHarmArea = setup(config, "conduits", "renderConduitMobHarmArea", true, "If set to true a box to show the area where hostile mobs are harmed will be drawn");
-
- drawBiomeBorders = setup(config, "biomeBorders", "drawBiomeBorders", true, "If set to true biome borders will be drawn.");
- renderOnlyCurrentBiome = setup(config, "biomeBorders", "renderOnlyCurrentBiome", true, "If set to true only the biome border for the current biome will be drawn.");
- biomeBordersRenderDistance = setup(config, "biomeBorders", "biomeBordersRenderDistance", 3, "The distance from the player where biome borders will be drawn.");
- biomeBordersMaxY = setup(config, "biomeBorders", "biomeBordersMaxY", -1, "The maximum top of the biome borders. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
-
- drawVillageSpheres = setup(config, "villages", "drawVillageSpheres", true, "If set to true village bounding spheres are drawn.");
- drawIronGolemSpawnArea = setup(config, "villages", "drawIronGolemSpawnArea", true, "If set to true the iron golem spawn area of the village will be drawn. (default:true)");
- drawVillageDoors = setup(config, "villages", "drawVillageDoors", false, "If set to true lines between the village centre and doors will be drawn. (default:false)");
- villageSphereDotSize = setup(config, "villages", "villageSphereDotSize", 2, "The size of the dots used when rendering village as sphere.");
- villageSphereDensity = setup(config, "villages", "villageSphereDensity", 3, "The density of the dots used when rendering village as sphere.");
-
- drawVillages = setup(config, "structures", "drawVillages", false, "If set to true village bounding boxes will be drawn.");
- drawDesertTemples = setup(config, "structures", "drawDesertTemples", true, "If set to true desert temple bounding boxes are drawn.");
- drawJungleTemples = setup(config, "structures", "drawJungleTemples", true, "If set to true jungle temple bounding boxes are drawn.");
- drawWitchHuts = setup(config, "structures", "drawWitchHuts", true, "If set to true witch hut bounding boxes are drawn.");
- drawStrongholds = setup(config, "structures", "drawStrongholds", false, "If set to true stronghold bounding boxes are drawn.");
- drawMineShafts = setup(config, "structures", "drawMineShafts", false, "If set to true mineshaft bounding boxes are drawn.");
- drawNetherFortresses = setup(config, "structures", "drawNetherFortresses", true, "If set to true nether fortress bounding boxes are drawn.");
- drawOceanMonuments = setup(config, "structures", "drawOceanMonuments", true, "If set to true ocean monument bounding boxes are drawn.");
- drawEndCities = setup(config, "structures", "drawEndCities", true, "If set to true end city bounding boxes will be drawn.");
- drawMansions = setup(config, "structures", "drawMansions", true, "If set to true woodland mansions will be drawn.");
- drawIgloos = setup(config, "structures", "drawIgloos", true, "If set to true igloos will be drawn.");
- drawShipwrecks = setup(config, "structures", "drawShipwrecks", true, "If set to true shipwrecks will be drawn.");
- drawOceanRuins = setup(config, "structures", "drawOceanRuins", true, "If set to true ocean ruins will be drawn.");
- drawBuriedTreasure = setup(config, "structures", "drawBuriedTreasures", true, "If set to true buried treasure will be drawn.");
- drawPillagerOutposts = setup(config, "structures", "drawPillagerOutposts", true, "If set to true pillager outposts will be drawn.");
- drawNetherFossils = setup(config, "structures", "drawNetherFossils", true, "If set to true nether fossils will be drawn.");
- drawBastionRemnants = setup(config, "structures", "drawBastionRemnants", true, "If set to true bastion remnants will be drawn.");
- drawRuinedPortals = setup(config, "structures", "drawRuinedPortals", true, "If set to true ruined portals will be drawn.");
-
- drawSlimeChunks = setup(config, "slimeChunks", "drawSlimeChunks", true, "If set to true slime chunks bounding boxes are drawn.");
- slimeChunkMaxY = setup(config, "slimeChunks", "slimeChunkMaxY", -1, "The maximum top of the slime chunk bounding box. If set to -1 it will use the value when activated, if set to 0 it will always track the player's feet.");
-
- drawWorldSpawn = setup(config, "worldSpawn", "drawWorldSpawn", true, "If set to true world spawn and spawn chunks bounding boxes are drawn.");
- worldSpawnMaxY = setup(config, "worldSpawn", "worldSpawnMaxY", -1, "The maximum top of the world spawn bounding boxes. If set to -1 it will use the value when activated, if set to 0 it will always track the players feet.");
- drawLazySpawnChunks = setup(config, "worldSpawn", "drawLazySpawnChunks", false, "If set to true the lazy spawn chunks bounding boxes will be drawn.");
-
- drawMobSpawners = setup(config, "mobSpawners", "drawMobSpawners", true, "If set to true mob spawners will be drawn.");
- renderMobSpawnerSpawnArea = setup(config, "mobSpawners", "renderMobSpawnerSpawnArea", true, "If set to true a box to show the maximum possible spawn area (10x10x4) for a spawner will be drawn");
- renderMobSpawnerActivationLines = setup(config, "mobSpawners", "renderMobSpawnerActivationLines", true, "If set to true a red/orange/green line will be drawn to show if the spawner is active");
-
- drawAFKSpheres = setup(config, "afkSpot", "drawAFKSpheres", true, "If set to true afk spot spheres will be drawn.");
- renderAFKSpawnableBlocks = setup(config, "afkSpot", "renderAFKSpawnableBlocks", true, "If set to true boxes to show spawnable blocks within the AFK sphere will be drawn.");
- afkSpawnableBlocksRenderDistance = setup(config, "afkSpot", "afkSpawnableBlocksRenderDistance", 3, "The distance from the player where spawnable blocks within the AFK sphere will be drawn.");
-
- config.save();
- }
-
- private static Configuration loadConfig() {
- Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
- config.load();
- return config;
- }
-
- public static void saveConfig() {
- Configuration config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
- for (Setting<?> setting : settings) {
- config.put(setting);
- }
- config.save();
- }
-
- private static <T> Setting<T> setup(Configuration config, String category, String settingName, T defaultValue, String comment) {
- Setting<T> setting = config.get(category, settingName, defaultValue);
- setting.category = category;
- setting.name = settingName;
- setting.comment = comment + " (default: " + defaultValue.toString() + ")";
- settings.add(setting);
- return setting;
- }
-
- public static void Toggle(Setting<Boolean> setting) {
- setting.set(!setting.get());
- }
-
- public static Set<Setting<?>> getSettings() {
- return settings;
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.config;
-
-import com.google.common.io.Files;
-
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class Configuration {
- public static final String FALLBACK_CATEGORY = "features";
- private final File file;
-
- Configuration(File file) {
- this.file = file;
- }
-
- void save() {
- try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write("# Configuration file\n");
- for (String category : settingsGroup.keySet()) {
- writer.write("\n");
- writer.write(String.format("%s {\n", category));
- Map<String, Setting<?>> settings = settingsGroup.get(category);
- boolean first = true;
- for (String settingName : settings.keySet()) {
- if (!first)
- writer.write("\n");
- first = false;
- Setting setting = settings.get(settingName);
- writer.write(String.format(" # %s\n", setting.comment));
- writer.write(String.format(" %s:%s=%s\n", setting.getType(), settingName, setting.getValue()));
- }
- writer.write("}\n");
- }
- } catch (IOException ignored) {
- }
- }
-
- private final Map<String, Map<String, Setting<?>>> settingsGroup = new HashMap<>();
-
- void load() {
- try {
- List<String> lines = Files.readLines(file, StandardCharsets.UTF_8);
- String category = null;
- String lastCommentLine = null;
- for (String line : lines) {
- String trimmedLine = line.trim();
- if (trimmedLine.isEmpty()) {
- continue;
- }
- if (trimmedLine.startsWith("#")) {
- lastCommentLine = trimmedLine.substring(1).trim();
- continue;
- }
- if (trimmedLine.equals("}")) {
- category = null;
- continue;
- }
- if (category == null && trimmedLine.endsWith("{")) {
- category = trimmedLine.substring(0, trimmedLine.length() - 1).trim();
- settingsGroup.put(category, new HashMap<>());
- continue;
- }
- if (category != null) {
- String[] items = trimmedLine.split("[:=]");
- char type = items[0].charAt(0);
- String name = items[1];
- String stringValue = items[2];
- Setting setting = getTypedSetting(type, stringValue);
- setting.comment = lastCommentLine;
- settingsGroup.get(category).put(name, setting);
- }
- }
- } catch (IOException ignored) {
- }
- }
-
- private Setting<?> getTypedSetting(char type, String value) {
- switch (type) {
- case 'I':
- return new Setting<>(type, Integer.parseInt(value));
- case 'B':
- return new Setting<>(type, value.equals("1") || value.toLowerCase().equals("true"));
- }
- return new Setting<>(type, value);
- }
-
- <T> Setting<T> get(String category, String settingName, T defaultValue) {
- char type = getType(defaultValue);
- if (!settingsGroup.containsKey(category)) {
- settingsGroup.put(category, new HashMap<>());
- }
- Map<String, Setting<?>> settings = settingsGroup.get(category);
- Setting<?> setting = settings.get(settingName);
- if (setting == null && !category.equals(FALLBACK_CATEGORY))
- setting = getFallbackSetting(settingName, settings);
- if (setting != null && setting.getType() != type) {
- setting = null;
- }
- if (setting == null) {
- settings.put(settingName, setting = new Setting<>(type, defaultValue));
- }
- return (Setting<T>) setting;
- }
-
- private Setting<?> getFallbackSetting(String settingName, Map<String, Setting<?>> settings) {
- Map<String, Setting<?>> fallbackSettings = settingsGroup.get(FALLBACK_CATEGORY);
- if (fallbackSettings == null) return null;
-
- Setting<?> setting = fallbackSettings.get(settingName);
- if (setting != null) {
- fallbackSettings.remove(settingName);
- settings.put(settingName, setting);
- }
- return setting;
- }
-
- private <T> char getType(T defaultValue) {
- String[] typeNames = defaultValue.getClass().getName().split("[.]");
- return typeNames[typeNames.length - 1].charAt(0);
- }
-
- void put(Setting<?> setting) {
- String category = setting.category;
- if (!settingsGroup.containsKey(category)) {
- settingsGroup.put(category, new HashMap<>());
- }
- Map<String, Setting<?>> settings = settingsGroup.get(category);
- settings.put(setting.name, setting);
- }
-}
+++ /dev/null
-package com.irtimaled.bbor.config;
-
-public class Setting<T> extends AbstractSetting {
- private T value;
-
- Setting(char type, T value) {
- super(type);
- this.value = value;
- }
-
- public T get() {
- return value;
- }
-
- public void set(T value) {
- this.value = value;
- }
-
- @Override
- Object getValue() {
- return value;
- }
-}
import com.irtimaled.bbor.client.ClientProxy;
import com.irtimaled.bbor.client.interop.ModPackFinder;
-import com.irtimaled.bbor.common.interop.CommonInterop;
import net.minecraft.client.Minecraft;
import net.minecraft.client.main.GameConfiguration;
import net.minecraft.client.resources.ResourcePackInfoClient;
@Inject(method = "<init>", at = @At("RETURN"))
private void constructor(GameConfiguration configuration, CallbackInfo ci) {
- CommonInterop.init();
clientProxy = new ClientProxy();
this.resourcePackRepository.addPackFinder(new ModPackFinder());
}
package com.irtimaled.bbor.mixin.server.dedicated;
import com.irtimaled.bbor.common.CommonProxy;
-import com.irtimaled.bbor.common.interop.CommonInterop;
import net.minecraft.server.dedicated.DedicatedServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
public class MixinDedicatedServer {
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServer;loadAllWorlds(Ljava/lang/String;Ljava/lang/String;JLnet/minecraft/world/WorldType;Lcom/google/gson/JsonElement;)V"))
private void init(CallbackInfoReturnable<Boolean> cir) {
- CommonInterop.init();
new CommonProxy().init();
}
}