Skip to content

Commit 1af2a8c

Browse files
committed
Reorganize config, add render-bounds and make some optimizations
1 parent dfbbf7d commit 1af2a8c

File tree

25 files changed

+626
-311
lines changed

25 files changed

+626
-311
lines changed

BlueMapCLI/src/main/java/de/bluecolored/bluemap/cli/BlueMapCLI.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import de.bluecolored.bluemap.core.logger.Logger;
5959
import de.bluecolored.bluemap.core.mca.MCAWorld;
6060
import de.bluecolored.bluemap.core.metrics.Metrics;
61+
import de.bluecolored.bluemap.core.render.RenderSettings;
6162
import de.bluecolored.bluemap.core.render.TileRenderer;
6263
import de.bluecolored.bluemap.core.render.hires.HiresModelManager;
6364
import de.bluecolored.bluemap.core.render.lowres.LowresModelManager;
@@ -66,6 +67,7 @@
6667
import de.bluecolored.bluemap.core.web.BlueMapWebServer;
6768
import de.bluecolored.bluemap.core.web.WebFilesManager;
6869
import de.bluecolored.bluemap.core.web.WebSettings;
70+
import de.bluecolored.bluemap.core.world.SlicedWorld;
6971
import de.bluecolored.bluemap.core.world.World;
7072

7173
public class BlueMapCLI {
@@ -93,13 +95,18 @@ public void renderMaps() throws IOException {
9395
Map<String, MapType> maps = new HashMap<>();
9496

9597
for (MapConfig mapConfig : config.getMapConfigs()) {
96-
File mapPath = new File(mapConfig.getWorldPath());
97-
if (!mapPath.exists() || !mapPath.isDirectory()) {
98-
throw new IOException("Save folder '" + mapPath + "' does not exist or is not a directory!");
98+
File worldFolder = new File(mapConfig.getWorldPath());
99+
if (!worldFolder.exists() || !worldFolder.isDirectory()) {
100+
throw new IOException("Save folder '" + worldFolder + "' does not exist or is not a directory!");
99101
}
100102

101103
Logger.global.logInfo("Preparing renderer for map '" + mapConfig.getId() + "' ...");
102-
World world = MCAWorld.load(mapPath.toPath(), UUID.randomUUID(), configManager.getBlockIdConfig(), configManager.getBlockPropertiesConfig(), configManager.getBiomeConfig());
104+
World world = MCAWorld.load(worldFolder.toPath(), UUID.randomUUID(), configManager.getBlockIdConfig(), configManager.getBlockPropertiesConfig(), configManager.getBiomeConfig());
105+
106+
//slice world to render edges if configured
107+
if (mapConfig.isRenderEdges() && !(mapConfig.getMin().equals(RenderSettings.DEFAULT_MIN) && mapConfig.getMax().equals(RenderSettings.DEFAULT_MAX))) {
108+
world = new SlicedWorld(world, mapConfig.getMin(), mapConfig.getMax());
109+
}
103110

104111
HiresModelManager hiresModelManager = new HiresModelManager(
105112
config.getWebDataPath().resolve("hires").resolve(mapConfig.getId()),
@@ -123,12 +130,16 @@ public void renderMaps() throws IOException {
123130

124131
Logger.global.logInfo("Writing settings.json ...");
125132
WebSettings webSettings = new WebSettings(config.getWebDataPath().resolve("settings.json").toFile());
133+
webSettings.setAllEnabled(false);
126134
for (MapType map : maps.values()) {
135+
webSettings.setEnabled(true, map.getId());
127136
webSettings.setName(map.getName(), map.getId());
128137
webSettings.setFrom(map.getTileRenderer(), map.getId());
129138
}
139+
int ordinal = 0;
130140
for (MapConfig map : config.getMapConfigs()) {
131141
if (!maps.containsKey(map.getId())) continue; //don't add not loaded maps
142+
webSettings.setOrdinal(ordinal++, map.getId());
132143
webSettings.setHiresViewDistance(map.getHiresViewDistance(), map.getId());
133144
webSettings.setLowresViewDistance(map.getLowresViewDistance(), map.getId());
134145
}
@@ -233,7 +244,7 @@ private boolean loadResources() throws IOException, ParseResourceException {
233244
return true;
234245
}
235246

236-
private boolean handleMissingResources(File resourceFile) {
247+
private boolean handleMissingResources(File resourceFile) throws IOException {
237248
if (configManager.getMainConfig().isDownloadAccepted()) {
238249
try {
239250
Logger.global.logInfo("Downloading " + ResourcePack.MINECRAFT_CLIENT_URL + " to " + resourceFile.getCanonicalPath() + " ...");
@@ -246,7 +257,7 @@ private boolean handleMissingResources(File resourceFile) {
246257
} else {
247258
Logger.global.logWarning("BlueMap is missing important resources!");
248259
Logger.global.logWarning("You need to accept the download of the required files in order of BlueMap to work!");
249-
Logger.global.logWarning("Please check " + configManager.getMainConfigFile() + " and try again!");
260+
Logger.global.logWarning("Please check " + configManager.getMainConfigFile().getCanonicalPath() + " and try again!");
250261
return false;
251262
}
252263
}
@@ -278,7 +289,7 @@ public static void main(String[] args) throws IOException, ParseResourceExceptio
278289
config.loadMainConfig();
279290

280291
if (configCreated) {
281-
Logger.global.logInfo("No config file found! Created default configs here: " + configFolder);
292+
Logger.global.logInfo("No config file found! Created default configs here: " + config.getMainConfigFile().getCanonicalPath());
282293
return;
283294
}
284295

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
accept-download: false
22
metrics: true
3+
renderThreadCount: 0
34
data: "."
4-
web {
5+
webroot: "web"
6+
webserver {
57
enabled: false
6-
webroot: "web"
78
port: 8100
89
maxConnectionCount: 100
910
}
10-
renderThreadCount: 0

BlueMapCLI/src/main/resources/bluemap-cli.conf

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@
55
## http://bluecolored.de/ ##
66
## ##
77

8-
# !! Don't change this !!
9-
# This is used to detect version-changes in the configuration
10-
# and update configuration correctly.
11-
version: "%version%"
12-
138
# By changing the setting (accept-download) below to TRUE you are indicating that you have accepted mojang's EULA (https://account.mojang.com/documents/minecraft_eula),
149
# you confirm that you own a license to Minecraft (Java Edition)
1510
# and you agree that BlueMap will download and use this file for you: %minecraft-client-url%
1611
# (Alternatively you can download the file yourself and store it here: <data>/minecraft-client-%minecraft-client-version%.jar)
17-
# This file contains resources that belong to mojang and you must not redistribute it or do anything else that is not compilant with mojang's EULA.
12+
# This file contains resources that belong to mojang and you must not redistribute it or do anything else that is not compliant with mojang's EULA.
1813
# BlueMap uses resources in this file to generate the 3D-Models used for the map and texture them. (BlueMap will not work without those resources.)
1914
# %datetime-iso%
2015
accept-download: false
2116

17+
# This changes the amount of threads that BlueMap will use to render the maps.
18+
# A higher value can improve render-speed but could impact performance on the host machine.
19+
# This should be always below or equal to the number of available processor-cores.
20+
# Zero or a negative value means the amount of of available processor-cores subtracted by the value.
21+
# (So a value of -2 with 6 cores results in 4 render-processes)
22+
# Default is 0
23+
renderThreadCount: 0
24+
2225
# If this is true, BlueMap might send really basic metrics reports containg only the implementation-type and the version that is being used to https://metrics.bluecolored.de/bluemap/
2326
# This allows me to track the basic usage of BlueMap and helps me stay motivated to further develop this tool! Please leave it on :)
2427
# An example report looks like this: {"implementation":"CLI","version":"%version%"}
@@ -27,40 +30,33 @@ metrics: true
2730
# The folder where bluemap saves data-files it needs during runtime
2831
data: "."
2932

30-
web {
33+
# The webroot of the website that displays the map.
34+
webroot: "web"
35+
36+
# Unncomment this to override the path where bluemap stores the data-files.
37+
# Default is "<webroot>/data"
38+
#webdata: "path/to/data/folder"
39+
40+
webserver {
3141
# With this setting you can enable the integrated web-server.
42+
# Default is disabled
3243
enabled: false
3344

34-
# The webroot of the website that displays the map.
35-
webroot: "web"
36-
3745
# The IP-Adress that the webserver binds to.
3846
# If this setting is commented out, bluemap tries to find the default ip-adress of your system.
3947
# If you only want to access it locally use "localhost".
4048
#ip: "localhost"
4149
#ip: "127.0.0.1"
42-
50+
4351
# The port that the webserver listenes to.
4452
# Default is 8100
4553
port: 8100
46-
54+
4755
# Max number of simultaneous connections that the webserver allows
4856
# Default is 100
4957
maxConnectionCount: 100
50-
51-
# Unncomment this to override the path where bluemap stores the data-files.
52-
# Default is "<webroot>/data"
53-
#web-data: "path/to/data/folder"
5458
}
5559

56-
# This changes the amount of threads that BlueMap will use to render the maps.
57-
# A higher value can improve render-speed but could impact performance on the host machine.
58-
# This should be always below or equal to the number of available processor-cores.
59-
# Zero or a negative value means the amount of of available processor-cores subtracted by the value.
60-
# (So a value of -2 with 6 cores results in 4 render-processes)
61-
# Default is 0
62-
renderThreadCount: 0
63-
6460
# This is an array with multiple configured maps.
6561
# You can define multiple maps, for different worlds with different render-settings here
6662
maps: [
@@ -96,15 +92,21 @@ maps: [
9692
# Default is 0.8
9793
lighting: 0.8
9894

99-
# Using this, BlueMap pretends that every Block above the defined value is AIR.
100-
# Default is disabled
101-
#sliceY: 90
102-
103-
# With the below values you can just not render blocks at certain heights.
104-
# This can be used to ignore the nethers ceiling.
105-
# Default is no min or max y value
95+
# With the below values you can limit the map-render.
96+
# This can be used to ignore the nethers ceiling or render only a certain part of a world.
97+
# Default is no min or max value (= infinite bounds)
98+
#minX: -4000
99+
#maxX: 4000
100+
#minZ: -4000
101+
#maxZ: 4000
106102
#minY: 50
107103
#maxY: 126
104+
105+
# Using this, BlueMap pretends that every Block out of the defined render-bounds is AIR,
106+
# this means you can see the blocks where the world is cut (instead of having a see-through/xray view).
107+
# This has only an effect if you set some render-bounds above.
108+
# Default is enabled
109+
renderEdges: true
108110

109111
# HIRES is the high-resolution render of the map. Where you see every block.
110112
hires {
@@ -118,7 +120,7 @@ maps: [
118120
viewDistance: 4.5
119121
}
120122

121-
# LOWRES is the low-resolution render of the map. THats the model that you see if you zoom far out to get an overview.
123+
# LOWRES is the low-resolution render of the map. Thats the model that you see if you zoom far out to get an overview.
122124
lowres {
123125
# Defines resolution of the lowres model. E.g. If the hires.tileSize is 32, a value of 4 means that every 8*8 blocks will be summarized by one point on the lowres map.
124126
# Calculation: 32 / 4 = 8
@@ -137,13 +139,13 @@ maps: [
137139
}
138140

139141
# Here another example for the End-Map
140-
# Things we dont want to change from default we can just omit
142+
# Things we don't want to change from default we can just omit
141143
{
142144
id: "end"
143145
name: "End"
144146
world: "world/DIM1"
145147

146-
# In the end is no light, so we need to enable this or we don't see anything.
148+
# In the end is no sky-light, so we need to enable this or we won't see anything.
147149
renderCaves: true
148150

149151
# Same here, we don't want a dark map. But not completely disabled, so we see the effect of e.g torches.
@@ -159,12 +161,10 @@ maps: [
159161
renderCaves: true
160162
lighting: 0.6
161163

162-
# We slice the whole world at y:90 so evrery block above 90 will be air.
163-
# This way we dont render the nethers ceiling.
164-
sliceY: 90
165-
166-
# Instead of slicing we also could do this, that would look like an x-ray view through the ceiling.
167-
#maxY: 126
164+
# We slice the whole world at y:90 so every block above 90 will be air.
165+
# This way we don't render the nethers ceiling.
166+
maxY: 90
167+
renderEdges: true
168168
}
169169

170170
]

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/config/BiomeConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public BiomeConfig(ConfigurationNode node, ConfigurationLoader<? extends Configu
5151
for (Entry<Object, ? extends ConfigurationNode> e : node.getChildrenMap().entrySet()){
5252
String id = e.getKey().toString();
5353
Biome biome = Biome.create(id, e.getValue());
54-
biomes.put(biome.getOrdinal(), biome);
54+
biomes.put(biome.getNumeralId(), biome);
5555
}
5656

5757
}

0 commit comments

Comments
 (0)