import java.io.File;
public class BoundingBoxOutlineReloaded {
- public static ClientProxy proxy;
+ private static ClientProxy proxy;
public static void init() {
+ ConfigManager.loadConfig(new File(Minecraft.getMinecraft().mcDataDir, "config"));
proxy = new ClientProxy();
- proxy.init(new ConfigManager(new File(Minecraft.getMinecraft().mcDataDir, "config")));
+ proxy.init();
}
public static void chunkLoaded(Chunk chunk) {
}
@Override
- public void init(ConfigManager configManager) {
- super.init(configManager);
+ public void init() {
+ super.init();
String category = "Bounding Box Outline Reloaded";
activeHotKey = new KeyBinding("Toggle On/Off", Keyboard.KEY_B, category);
outerBoxOnlyHotKey = new KeyBinding("Toggle Display Outer Box Only", Keyboard.KEY_O, category);
private void loadLocalStructures(String host, int port) {
Logger.info("Looking for local structures (host:port=%s:%d)", host, port);
String path = String.format("BBOutlineReloaded%s%s%s%d", File.separator, host, File.separator, port);
- File localStructuresFolder = new File(configManager.configDir, path);
+ File localStructuresFolder = new File(ConfigManager.configDir, path);
Logger.info("Looking for local structures (folder=%s)", localStructuresFolder.getAbsolutePath());
if (!localStructuresFolder.exists()) {
path = String.format("BBOutlineReloaded%s%s", File.separator, host);
- localStructuresFolder = new File(configManager.configDir, path);
+ localStructuresFolder = new File(ConfigManager.configDir, path);
Logger.info("Looking for local structures (folder=%s)", localStructuresFolder.getAbsolutePath());
}
if (!localStructuresFolder.exists()) {
path = String.format("BBOutlineReloaded%s%s,%d", File.separator, host, port);
- localStructuresFolder = new File(configManager.configDir, path);
+ localStructuresFolder = new File(ConfigManager.configDir, path);
Logger.info("Looking for local structures (folder=%s)", localStructuresFolder.getAbsolutePath());
}
if (!localStructuresFolder.exists()) {
private void loadOverworldStructures(File localStructuresFolder) {
BoundingBoxCache cache = new BoundingBoxCache();
- if (configManager.drawDesertTemples.getBoolean()) {
+ if (ConfigManager.drawDesertTemples.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "Temple.dat", StructureType.DesertTemple.getColor(), "TeDP");
}
- if (configManager.drawJungleTemples.getBoolean()) {
+ if (ConfigManager.drawJungleTemples.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "Temple.dat", StructureType.JungleTemple.getColor(), "TeJP");
}
- if (configManager.drawWitchHuts.getBoolean()) {
+ if (ConfigManager.drawWitchHuts.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "Temple.dat", StructureType.WitchHut.getColor(), "TeSH");
}
- if (configManager.drawOceanMonuments.getBoolean()) {
+ if (ConfigManager.drawOceanMonuments.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "Monument.dat", StructureType.OceanMonument.getColor(), "*");
}
- if (configManager.drawStrongholds.getBoolean()) {
+ if (ConfigManager.drawStrongholds.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "Stronghold.dat", StructureType.Stronghold.getColor(), "*");
}
- if (configManager.drawMansions.getBoolean()) {
+ if (ConfigManager.drawMansions.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "Mansion.dat", StructureType.Mansion.getColor(), "*");
}
- if (configManager.drawMineShafts.getBoolean()) {
+ if (ConfigManager.drawMineShafts.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "Mineshaft.dat", StructureType.MineShaft.getColor(), "*");
}
- if (configManager.drawVillages.getBoolean()) {
+ if (ConfigManager.drawVillages.getBoolean()) {
loadVillageNbtFile(localStructuresFolder, cache, "Villages.dat");
}
private void loadNetherStructures(File localStructuresFolder) {
BoundingBoxCache cache = new BoundingBoxCache();
- if (configManager.drawNetherFortresses.getBoolean())
+ if (ConfigManager.drawNetherFortresses.getBoolean())
loadStructureNbtFile(localStructuresFolder, cache, "Fortress.dat", StructureType.NetherFortress.getColor(), "*");
- if (configManager.drawVillages.getBoolean()) {
+ if (ConfigManager.drawVillages.getBoolean()) {
loadVillageNbtFile(localStructuresFolder, cache, "villages_nether.dat");
}
boundingBoxCacheMap.put(DimensionType.NETHER, cache);
private void loadEndStructures(File localStructuresFolder) {
BoundingBoxCache cache = new BoundingBoxCache();
- if (configManager.drawVillages.getBoolean()) {
+ if (ConfigManager.drawVillages.getBoolean()) {
loadVillageNbtFile(localStructuresFolder, cache, "Villages_end.dat");
}
- if (configManager.drawEndCities.getBoolean()) {
+ if (ConfigManager.drawEndCities.getBoolean()) {
loadStructureNbtFile(localStructuresFolder, cache, "EndCity.dat", StructureType.EndCity.getColor(), "*");
}
boundingBoxCacheMap.put(DimensionType.THE_END, cache);
public void playerDisconnectedFromServer() {
active = false;
- if (configManager.keepCacheBetweenSessions.getBoolean()) return;
+ if (ConfigManager.keepCacheBetweenSessions.getBoolean()) return;
worldData = null;
worldSpawnBoundingBox = null;
spawnChunksBoundingBox = null;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_CULL_FACE);
- if (configManager.alwaysVisible.getBoolean()) {
+ if (ConfigManager.alwaysVisible.getBoolean()) {
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
}
if (bb instanceof BoundingBoxVillage) {
BoundingBoxVillage villageBB = (BoundingBoxVillage) bb;
- if (configManager.renderVillageAsSphere.getBoolean()) {
+ if (ConfigManager.renderVillageAsSphere.getBoolean()) {
renderBoundingBoxVillageAsSphere(villageBB);
} else {
renderBoundingBox(villageBB);
}
- if (configManager.drawIronGolemSpawnArea.getBoolean() &&
+ if (ConfigManager.drawIronGolemSpawnArea.getBoolean() &&
villageBB.getSpawnsIronGolems()) {
renderIronGolemSpawnArea(villageBB);
}
- if (configManager.drawVillageDoors.getBoolean())
+ if (ConfigManager.drawVillageDoors.getBoolean())
renderVillageDoors(villageBB);
} else if (bb instanceof BoundingBoxSlimeChunk) {
renderSlimeChunk((BoundingBoxSlimeChunk) bb);
private void renderWorldSpawn(BoundingBoxWorldSpawn bb) {
AxisAlignedBB aaBB = bb.toAxisAlignedBB(false);
Color color = bb.getColor();
- double y = getMaxY(configManager.worldSpawnMaxY.getInt()) + 0.001F;
+ double y = getMaxY(ConfigManager.worldSpawnMaxY.getInt()) + 0.001F;
renderRectangle(aaBB, y, y, color, false);
}
Color color = bb.getColor();
renderCuboid(aaBB, color, fill());
- double maxY = getMaxY(configManager.slimeChunkMaxY.getInt());
+ double maxY = getMaxY(ConfigManager.slimeChunkMaxY.getInt());
if (maxY > 39) {
renderRectangle(aaBB, 39, maxY, color, fill());
}
}
private boolean fill() {
- return configManager.fill.getBoolean();
+ return ConfigManager.fill.getBoolean();
}
private void renderIronGolemSpawnArea(BoundingBoxVillage villageBB) {
}
Set<BoundingBox> boundingBoxes = new HashSet<>();
- if (configManager.drawWorldSpawn.getBoolean()) {
+ if (ConfigManager.drawWorldSpawn.getBoolean()) {
boundingBoxes.add(getWorldSpawnBoundingBox(worldData.getSpawnX(), worldData.getSpawnZ()));
boundingBoxes.add(getSpawnChunksBoundingBox(worldData.getSpawnX(), worldData.getSpawnZ()));
}
- if (configManager.drawLazySpawnChunks.getBoolean()) {
+ if (ConfigManager.drawLazySpawnChunks.getBoolean()) {
boundingBoxes.add(getLazySpawnChunksBoundingBox(worldData.getSpawnX(), worldData.getSpawnZ()));
}
- if (configManager.drawSlimeChunks.getBoolean()) {
+ if (ConfigManager.drawSlimeChunks.getBoolean()) {
boundingBoxes.addAll(this.getSlimeChunks());
}
return boundingBoxes;
public class CommonProxy {
public Map<DimensionType, BoundingBoxCache> boundingBoxCacheMap = new ConcurrentHashMap<>();
- public ConfigManager configManager;
protected WorldData worldData;
private IEventHandler eventHandler = null;
- public void init(ConfigManager configManager) {
- this.configManager = configManager;
+ public void init() {
}
public void worldLoaded(World world) {
setWorldData(new WorldData(world.getSeed(), world.getWorldInfo().getSpawnX(), world.getWorldInfo().getSpawnZ()));
DimensionType dimensionType = world.provider.getDimensionType();
Logger.info("create world dimension: %s, %s (chunkprovider: %s) (seed: %d)", dimensionType, world.getClass().toString(), chunkGenerator.getClass().toString(), worldData.getSeed());
- boundingBoxCacheMap.put(dimensionType, new DimensionProcessor(eventHandler, configManager, world, dimensionType, chunkGenerator));
+ boundingBoxCacheMap.put(dimensionType, new DimensionProcessor(eventHandler, world, dimensionType, chunkGenerator));
}
}
import java.util.List;
public class DimensionProcessor extends BoundingBoxCache {
- private ConfigManager configManager;
private World world;
private IEventHandler eventHandler;
- public DimensionProcessor(IEventHandler eventHandler, ConfigManager configManager, World world, DimensionType dimensionType, IChunkGenerator chunkGenerator) {
+ public DimensionProcessor(IEventHandler eventHandler, World world, DimensionType dimensionType, IChunkGenerator chunkGenerator) {
this.eventHandler = eventHandler;
- this.configManager = configManager;
this.world = world;
this.dimensionType = dimensionType;
this.chunkGenerator = chunkGenerator;
private Map<StructureType, Collection<StructureStart>> getStructures() {
Map<StructureType, Collection<StructureStart>> structureMap = new HashMap<>();
if (chunkGenerator instanceof ChunkGeneratorOverworld) {
- if (configManager.drawDesertTemples.getBoolean()) {
+ if (ConfigManager.drawDesertTemples.getBoolean()) {
structureMap.put(StructureType.DesertTemple, getStructuresWithComponent(getStructures(chunkGenerator, MapGenScatteredFeature.class), ComponentScatteredFeaturePieces.DesertPyramid.class));
}
- if (configManager.drawJungleTemples.getBoolean()) {
+ if (ConfigManager.drawJungleTemples.getBoolean()) {
structureMap.put(StructureType.JungleTemple, getStructuresWithComponent(getStructures(chunkGenerator, MapGenScatteredFeature.class), ComponentScatteredFeaturePieces.JunglePyramid.class));
}
- if (configManager.drawWitchHuts.getBoolean()) {
+ if (ConfigManager.drawWitchHuts.getBoolean()) {
structureMap.put(StructureType.WitchHut, getStructuresWithComponent(getStructures(chunkGenerator, MapGenScatteredFeature.class), ComponentScatteredFeaturePieces.SwampHut.class));
}
- if (configManager.drawOceanMonuments.getBoolean()) {
+ if (ConfigManager.drawOceanMonuments.getBoolean()) {
structureMap.put(StructureType.OceanMonument, getStructures(chunkGenerator, StructureOceanMonument.class));
}
- if (configManager.drawStrongholds.getBoolean()) {
+ if (ConfigManager.drawStrongholds.getBoolean()) {
structureMap.put(StructureType.Stronghold, getStructures(chunkGenerator, MapGenStronghold.class));
}
- if (configManager.drawMansions.getBoolean()) {
+ if (ConfigManager.drawMansions.getBoolean()) {
structureMap.put(StructureType.Mansion, getStructures(chunkGenerator, WoodlandMansion.class));
}
- if (configManager.drawMineShafts.getBoolean()) {
+ if (ConfigManager.drawMineShafts.getBoolean()) {
structureMap.put(StructureType.MineShaft, getStructures(chunkGenerator, MapGenMineshaft.class));
}
} else if (chunkGenerator instanceof ChunkGeneratorHell) {
- if (configManager.drawNetherFortresses.getBoolean()) {
+ if (ConfigManager.drawNetherFortresses.getBoolean()) {
structureMap.put(StructureType.NetherFortress, getStructures(chunkGenerator, MapGenNetherBridge.class));
}
} else if (chunkGenerator instanceof ChunkGeneratorEnd) {
- if (configManager.drawEndCities.getBoolean()) {
+ if (ConfigManager.drawEndCities.getBoolean()) {
structureMap.put(StructureType.EndCity, getStructures(chunkGenerator, MapGenEndCity.class));
}
}
}
}
- if (configManager.drawVillages.getBoolean() &&
+ if (ConfigManager.drawVillages.getBoolean() &&
world.getVillageCollection() != null) {
Map<Integer, BoundingBoxVillage> villageBoundingBoxes = new HashMap<>();
List<Village> villages = world.getVillageCollection().getVillageList();
import java.io.File;
public class ConfigManager {
- public final File configDir;
+ public static File configDir;
- public Setting fill;
- public Setting drawVillages;
- public Setting drawDesertTemples;
- public Setting drawJungleTemples;
- public Setting drawWitchHuts;
- public Setting drawStrongholds;
- public Setting drawMineShafts;
- public Setting drawNetherFortresses;
- public Setting drawOceanMonuments;
- public Setting alwaysVisible;
- public Setting renderVillageAsSphere;
- public Setting drawIronGolemSpawnArea;
- public Setting drawVillageDoors;
- public Setting drawSlimeChunks;
- public Setting slimeChunkMaxY;
- public Setting keepCacheBetweenSessions;
- public Setting drawWorldSpawn;
- public Setting worldSpawnMaxY;
- public Setting drawLazySpawnChunks;
- public Setting drawEndCities;
- public Setting drawMansions;
+ public static Setting fill;
+ public static Setting drawVillages;
+ public static Setting drawDesertTemples;
+ public static Setting drawJungleTemples;
+ public static Setting drawWitchHuts;
+ public static Setting drawStrongholds;
+ public static Setting drawMineShafts;
+ public static Setting drawNetherFortresses;
+ public static Setting drawOceanMonuments;
+ public static Setting alwaysVisible;
+ public static Setting renderVillageAsSphere;
+ public static Setting drawIronGolemSpawnArea;
+ public static Setting drawVillageDoors;
+ public static Setting drawSlimeChunks;
+ public static Setting slimeChunkMaxY;
+ public static Setting keepCacheBetweenSessions;
+ public static Setting drawWorldSpawn;
+ public static Setting worldSpawnMaxY;
+ public static Setting drawLazySpawnChunks;
+ public static Setting drawEndCities;
+ public static Setting drawMansions;
- private Configuration config;
+ private static Configuration config;
- public ConfigManager(File configDir) {
- this.configDir = configDir;
+ public static void loadConfig(File mcConfigDir) {
+ configDir = mcConfigDir;
config = new Configuration(new File(configDir, "BBOutlineReloaded.cfg"));
config.load();
config.save();
}
- private Setting SetupBooleanProperty(Configuration config, String category, String settingName, Boolean defaultValue, String comment) {
+ private static Setting SetupBooleanProperty(Configuration config, String category, String settingName, Boolean defaultValue, String comment) {
Setting property = config.get(category, settingName, defaultValue);
property.comment = comment;
property.set(property.getBoolean(defaultValue));
return property;
}
- private Setting SetupIntegerProperty(Configuration config, String category, String settingName, int defaultValue, String comment) {
+ private static Setting SetupIntegerProperty(Configuration config, String category, String settingName, int defaultValue, String comment) {
Setting property = config.get(category, settingName, defaultValue);
property.comment = comment;
property.set(property.getInt(defaultValue));
protected SimpleNetworkWrapper network;
private CommonProxy commonProxy;
- public void init(ConfigManager configManager) {
+ public void init() {
CommonProxy proxy = getProxy();
proxy.setEventHandler(this);
- proxy.init(configManager);
+ proxy.init();
network = NetworkRegistry.INSTANCE.newSimpleChannel("bbor");
network.registerMessage(AddBoundingBoxMessageHandler.class, AddBoundingBoxMessage.class, 0, Side.CLIENT);
network.registerMessage(RemoveBoundingBoxMessageHandler.class, RemoveBoundingBoxMessage.class, 1, Side.CLIENT);
public static final String VERSION = "1.0.0-beta18";
public static final String MCVERSION = "1.12";
- private ConfigManager configManager;
-
public SimpleNetworkWrapper network;
@Mod.Instance()
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt) {
- configManager = new ConfigManager(evt.getModConfigurationDirectory());
+ ConfigManager.loadConfig(evt.getModConfigurationDirectory());
}
@Mod.EventHandler
public void load(FMLInitializationEvent evt) {
MinecraftForge.EVENT_BUS.register(proxy);
- proxy.init(configManager);
+ proxy.init();
}
}