mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Add configuration to set a start-point of the map, defaults to world-spawn
This commit is contained in:
parent
3e2fa6dd59
commit
a56b610afb
@ -24,7 +24,7 @@ renderThreadCount: -2
|
||||
|
||||
# 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/
|
||||
# This allows me to track the basic usage of BlueMap and helps me stay motivated to further develop this tool! Please leave it on :)
|
||||
# An example report looks like this: {"implementation":"CLI","version":"%version%"}
|
||||
# An example report looks like this: {"implementation":"bukkit","version":"%version%"}
|
||||
metrics: true
|
||||
|
||||
# The folder where bluemap saves data-files it needs during runtime or to save e.g. the render-progress to resume it later.
|
||||
@ -74,6 +74,10 @@ maps: [
|
||||
|
||||
# The path to the save-folder of the world to render
|
||||
world: "world"
|
||||
|
||||
# The position on the world where the map will be centered if you open it.
|
||||
# This defaults to the world-spawn if you don't set it.
|
||||
#startPos: [500, -820]
|
||||
|
||||
# If this is false, BlueMap tries to omit all blocks that are not visible from above-ground.
|
||||
# More specific: Block-Faces that have a sunlight/skylight value of 0 are removed.
|
||||
|
@ -136,15 +136,14 @@ public void renderMaps() throws IOException {
|
||||
webSettings.setAllEnabled(false);
|
||||
for (MapType map : maps.values()) {
|
||||
webSettings.setEnabled(true, map.getId());
|
||||
webSettings.setName(map.getName(), map.getId());
|
||||
webSettings.setFrom(map.getTileRenderer(), map.getId());
|
||||
webSettings.setFrom(map.getWorld(), map.getId());
|
||||
}
|
||||
int ordinal = 0;
|
||||
for (MapConfig map : config.getMapConfigs()) {
|
||||
if (!maps.containsKey(map.getId())) continue; //don't add not loaded maps
|
||||
webSettings.setOrdinal(ordinal++, map.getId());
|
||||
webSettings.setHiresViewDistance(map.getHiresViewDistance(), map.getId());
|
||||
webSettings.setLowresViewDistance(map.getLowresViewDistance(), map.getId());
|
||||
webSettings.setFrom(map, map.getId());
|
||||
}
|
||||
webSettings.save();
|
||||
|
||||
|
@ -24,7 +24,7 @@ renderThreadCount: 0
|
||||
|
||||
# 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/
|
||||
# This allows me to track the basic usage of BlueMap and helps me stay motivated to further develop this tool! Please leave it on :)
|
||||
# An example report looks like this: {"implementation":"CLI","version":"%version%"}
|
||||
# An example report looks like this: {"implementation":"cli","version":"%version%"}
|
||||
metrics: true
|
||||
|
||||
# The folder where bluemap saves data-files it needs during runtime
|
||||
@ -73,6 +73,10 @@ maps: [
|
||||
|
||||
# The path to the save-folder of the world to render
|
||||
world: "world"
|
||||
|
||||
# The position on the world where the map will be centered if you open it.
|
||||
# This defaults to the world-spawn if you don't set it.
|
||||
#startPos: [500, -820]
|
||||
|
||||
# If this is false, BlueMap tries to omit all blocks that are not visible from above-ground.
|
||||
# More specific: Block-Faces that have a sunlight/skylight value of 0 are removed.
|
||||
|
@ -232,15 +232,14 @@ public synchronized void load() throws IOException, ParseResourceException {
|
||||
webSettings.setAllEnabled(false);
|
||||
for (MapType map : maps.values()) {
|
||||
webSettings.setEnabled(true, map.getId());
|
||||
webSettings.setName(map.getName(), map.getId());
|
||||
webSettings.setFrom(map.getTileRenderer(), map.getId());
|
||||
webSettings.setFrom(map.getWorld(), map.getId());
|
||||
}
|
||||
int ordinal = 0;
|
||||
for (MapConfig map : config.getMapConfigs()) {
|
||||
if (!maps.containsKey(map.getId())) continue; //don't add not loaded maps
|
||||
webSettings.setOrdinal(ordinal++, map.getId());
|
||||
webSettings.setHiresViewDistance(map.getHiresViewDistance(), map.getId());
|
||||
webSettings.setLowresViewDistance(map.getLowresViewDistance(), map.getId());
|
||||
webSettings.setFrom(map, map.getId());
|
||||
}
|
||||
webSettings.save();
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
@ -194,6 +195,8 @@ public class MapConfig implements RenderSettings {
|
||||
private String name;
|
||||
private String world;
|
||||
|
||||
private Vector2i startPos;
|
||||
|
||||
private boolean renderCaves;
|
||||
private float ambientOcclusion;
|
||||
private float lighting;
|
||||
@ -219,6 +222,8 @@ private MapConfig(ConfigurationNode node) throws IOException {
|
||||
this.world = node.getNode("world").getString("");
|
||||
if (world.isEmpty()) throw new IOException("Invalid configuration: Node maps[?].world is not defined");
|
||||
|
||||
if (!node.getNode("startPos").isVirtual()) this.startPos = ConfigUtils.readVector2i(node.getNode("startPos"));
|
||||
|
||||
this.renderCaves = node.getNode("renderCaves").getBoolean(false);
|
||||
this.ambientOcclusion = node.getNode("ambientOcclusion").getFloat(0.25f);
|
||||
this.lighting = node.getNode("lighting").getFloat(0.8f);
|
||||
@ -259,6 +264,10 @@ public String getName() {
|
||||
public String getWorldPath() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public Vector2i getStartPos() {
|
||||
return startPos;
|
||||
}
|
||||
|
||||
public boolean isRenderCaves() {
|
||||
return renderCaves;
|
||||
|
@ -31,7 +31,9 @@
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
|
||||
import de.bluecolored.bluemap.core.config.MainConfig.MapConfig;
|
||||
import de.bluecolored.bluemap.core.render.TileRenderer;
|
||||
import de.bluecolored.bluemap.core.world.World;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.gson.GsonConfigurationLoader;
|
||||
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||
@ -128,13 +130,23 @@ public void setFrom(TileRenderer tileRenderer, String mapId) {
|
||||
set(pointSize.getX() / 2, mapId, "lowres", "translate", "x");
|
||||
set(pointSize.getY() / 2, mapId, "lowres", "translate", "z");
|
||||
}
|
||||
|
||||
public void setHiresViewDistance(float hiresViewDistance, String mapId) {
|
||||
set(hiresViewDistance, mapId, "hires", "viewDistance");
|
||||
|
||||
public void setFrom(World world, String mapId) {
|
||||
set(world.getSpawnPoint().getX(), mapId, "startPos", "x");
|
||||
set(world.getSpawnPoint().getZ(), mapId, "startPos", "z");
|
||||
}
|
||||
|
||||
public void setLowresViewDistance(float lowresViewDistance, String mapId) {
|
||||
set(lowresViewDistance, mapId, "lowres", "viewDistance");
|
||||
public void setFrom(MapConfig mapConfig, String mapId) {
|
||||
Vector2i startPos = mapConfig.getStartPos();
|
||||
if (startPos != null) {
|
||||
set(startPos.getX(), mapId, "startPos", "x");
|
||||
set(startPos.getY(), mapId, "startPos", "z");
|
||||
}
|
||||
|
||||
set(mapConfig.getLowresViewDistance(), mapId, "lowres", "viewDistance");
|
||||
set(mapConfig.getHiresViewDistance(), mapId, "hires", "viewDistance");
|
||||
|
||||
setName(mapConfig.getName(), mapId);
|
||||
}
|
||||
|
||||
public void setOrdinal(int ordinal, String mapId) {
|
||||
|
@ -81,29 +81,11 @@ export default class BlueMap {
|
||||
this.controls = new Controls(this.camera, this.element, this.hiresScene);
|
||||
|
||||
this.loadSettings().then(async () => {
|
||||
this.controls.setTileSize(this.settings[this.map]['hires']['tileSize']);
|
||||
|
||||
this.lowresTileManager = new TileManager(
|
||||
this,
|
||||
this.settings[this.map]['lowres']['viewDistance'],
|
||||
this.loadLowresTile,
|
||||
this.lowresScene,
|
||||
this.settings[this.map]['lowres']['tileSize'],
|
||||
{x: 0, z: 0}
|
||||
);
|
||||
|
||||
this.hiresTileManager = new TileManager(
|
||||
this,
|
||||
this.settings[this.map]['hires']['viewDistance'],
|
||||
this.loadHiresTile,
|
||||
this.hiresScene,
|
||||
this.settings[this.map]['hires']['tileSize'],
|
||||
{x: 0, z: 0}
|
||||
);
|
||||
|
||||
await this.loadHiresMaterial();
|
||||
await this.loadLowresMaterial();
|
||||
|
||||
this.changeMap(this.map);
|
||||
|
||||
this.initModules();
|
||||
this.start();
|
||||
}).catch(error => this.onLoadError(error.toString()));
|
||||
@ -119,12 +101,20 @@ export default class BlueMap {
|
||||
}
|
||||
|
||||
changeMap(map) {
|
||||
this.hiresTileManager.close();
|
||||
this.lowresTileManager.close();
|
||||
if (this.hiresTileManager !== undefined) this.hiresTileManager.close();
|
||||
if (this.lowresTileManager !== undefined) this.lowresTileManager.close();
|
||||
|
||||
this.map = map;
|
||||
|
||||
let startPos = {
|
||||
x: this.settings[this.map]["startPos"]["x"],
|
||||
z: this.settings[this.map]["startPos"]["z"]
|
||||
};
|
||||
|
||||
this.controls.setTileSize(this.settings[this.map]['hires']['tileSize']);
|
||||
this.controls.resetPosition();
|
||||
this.controls.targetPosition.set(startPos.x, this.controls.targetPosition.y, startPos.z);
|
||||
this.controls.position.copy(this.controls.targetPosition);
|
||||
|
||||
this.lowresTileManager = new TileManager(
|
||||
this,
|
||||
@ -132,7 +122,7 @@ export default class BlueMap {
|
||||
this.loadLowresTile,
|
||||
this.lowresScene,
|
||||
this.settings[this.map]['lowres']['tileSize'],
|
||||
{x: 0, z: 0}
|
||||
startPos
|
||||
);
|
||||
|
||||
this.hiresTileManager = new TileManager(
|
||||
@ -141,7 +131,7 @@ export default class BlueMap {
|
||||
this.loadHiresTile,
|
||||
this.hiresScene,
|
||||
this.settings[this.map]['hires']['tileSize'],
|
||||
{x: 0, z: 0}
|
||||
startPos
|
||||
);
|
||||
|
||||
this.lowresTileManager.update();
|
||||
|
@ -37,7 +37,8 @@ export default class TileManager {
|
||||
this.scene = scene;
|
||||
this.tileSize = new Vector2(tileSize.x, tileSize.z);
|
||||
|
||||
this.tile = new Vector2(position.x, position.z);
|
||||
this.tile = new Vector2(0, 0);
|
||||
this.tile.set(position.x, position.z).divide(this.tileSize).floor();
|
||||
this.lastTile = this.tile.clone();
|
||||
|
||||
this.closed = false;
|
||||
|
@ -69,6 +69,10 @@ maps: [
|
||||
|
||||
# The path to the save-folder of the world to render
|
||||
world: "world"
|
||||
|
||||
# The position on the world where the map will be centered if you open it.
|
||||
# This defaults to the world-spawn if you don't set it.
|
||||
#startPos: [500, -820]
|
||||
|
||||
# If this is false, BlueMap tries to omit all blocks that are not visible from above-ground.
|
||||
# More specific: Block-Faces that have a sunlight/skylight value of 0 are removed.
|
||||
|
Loading…
Reference in New Issue
Block a user