mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-23 00:31:23 +01:00
Merge branch 'mc/1.13'
This commit is contained in:
commit
7856501001
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
@ -7,6 +7,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "BlueMapAPI"]
|
||||
path = BlueMapAPI
|
||||
url = https://github.com/BlueMap-Minecraft/BlueMapAPI
|
1
BlueMapAPI
Submodule
1
BlueMapAPI
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 1d7495dffd6d7c72e22a99888a277eb17de55d31
|
@ -111,9 +111,17 @@ public void renderMaps() throws IOException {
|
||||
Logger.global.logInfo("Preparing renderer for map '" + mapConfig.getId() + "' ...");
|
||||
World world = MCAWorld.load(worldFolder.toPath(), UUID.randomUUID(), configManager.getBlockIdConfig(), configManager.getBlockPropertiesConfig(), configManager.getBiomeConfig());
|
||||
|
||||
//slice world to render edges if configured
|
||||
if (mapConfig.isRenderEdges() && !(mapConfig.getMin().equals(RenderSettings.DEFAULT_MIN) && mapConfig.getMax().equals(RenderSettings.DEFAULT_MAX))) {
|
||||
world = new SlicedWorld(world, mapConfig.getMin(), mapConfig.getMax());
|
||||
//slice world if configured
|
||||
if (!mapConfig.getMin().equals(RenderSettings.DEFAULT_MIN) || !mapConfig.getMax().equals(RenderSettings.DEFAULT_MAX)) {
|
||||
if (mapConfig.isRenderEdges()) {
|
||||
world = new SlicedWorld(world, mapConfig.getMin(), mapConfig.getMax());
|
||||
} else {
|
||||
world = new SlicedWorld(
|
||||
world,
|
||||
mapConfig.getMin().min(mapConfig.getMin().sub(2, 2, 2)), // protect from int-overflow
|
||||
mapConfig.getMax().max(mapConfig.getMax().add(2, 2, 2)) // protect from int-overflow
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
HiresModelManager hiresModelManager = new HiresModelManager(
|
||||
|
@ -1,3 +1,4 @@
|
||||
dependencies {
|
||||
compile project(':BlueMapCore')
|
||||
compile project(':BlueMapAPI')
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
public class RenderManager {
|
||||
|
||||
private boolean running;
|
||||
private volatile boolean running;
|
||||
|
||||
private Thread[] renderThreads;
|
||||
private ArrayDeque<RenderTicket> renderTickets;
|
||||
@ -38,14 +38,13 @@ public RenderManager(int threadCount) {
|
||||
|
||||
public synchronized void start() {
|
||||
stop(); //ensure everything is stopped first
|
||||
running = true;
|
||||
|
||||
for (int i = 0; i < renderThreads.length; i++) {
|
||||
renderThreads[i] = new Thread(this::renderThread);
|
||||
renderThreads[i].setPriority(Thread.MIN_PRIORITY);
|
||||
renderThreads[i].start();
|
||||
}
|
||||
|
||||
running = true;
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
@ -118,7 +117,7 @@ public boolean removeRenderTask(RenderTask renderTask) {
|
||||
private void renderThread() {
|
||||
RenderTicket ticket = null;
|
||||
|
||||
while (!Thread.interrupted()) {
|
||||
while (!Thread.interrupted() && running) {
|
||||
synchronized (renderTickets) {
|
||||
ticket = renderTickets.poll();
|
||||
if (ticket != null) renderTicketMap.remove(ticket);
|
||||
@ -159,6 +158,10 @@ public int getQueueSize() {
|
||||
return renderTickets.size();
|
||||
}
|
||||
|
||||
public int getRenderThreadCount() {
|
||||
return renderThreads.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the deque with the render tasks in order as array
|
||||
*/
|
||||
|
@ -11,23 +11,23 @@ public class RenderTicket {
|
||||
private final Vector2i tile;
|
||||
|
||||
private int renderAttempts;
|
||||
private boolean finished;
|
||||
private boolean successfullyRendered;
|
||||
|
||||
public RenderTicket(MapType map, Vector2i tile) {
|
||||
this.map = map;
|
||||
this.tile = tile;
|
||||
|
||||
this.renderAttempts = 0;
|
||||
this.finished = false;
|
||||
this.successfullyRendered = false;
|
||||
}
|
||||
|
||||
public synchronized void render() throws IOException {
|
||||
renderAttempts++;
|
||||
|
||||
if (!finished) {
|
||||
if (!successfullyRendered) {
|
||||
map.renderTile(tile);
|
||||
|
||||
finished = true;
|
||||
successfullyRendered = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,10 +43,6 @@ public int getRenderAttempts() {
|
||||
return renderAttempts;
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return finished;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(map.getId(), tile);
|
||||
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapWorld;
|
||||
import de.bluecolored.bluemap.api.renderer.Renderer;
|
||||
import de.bluecolored.bluemap.common.MapType;
|
||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.world.World;
|
||||
|
||||
public class BlueMapAPIImpl extends BlueMapAPI {
|
||||
|
||||
public Plugin blueMap;
|
||||
public RendererImpl renderer;
|
||||
|
||||
public Map<UUID, BlueMapWorldImpl> worlds;
|
||||
public Map<String, BlueMapMapImpl> maps;
|
||||
|
||||
public BlueMapAPIImpl(Plugin blueMap) {
|
||||
this.blueMap = blueMap;
|
||||
|
||||
this.renderer = new RendererImpl(this, blueMap.getRenderManager());
|
||||
|
||||
worlds = new HashMap<>();
|
||||
for (World world : blueMap.getWorlds()) {
|
||||
BlueMapWorldImpl w = new BlueMapWorldImpl(this, world);
|
||||
worlds.put(w.getUuid(), w);
|
||||
}
|
||||
|
||||
maps = new HashMap<>();
|
||||
for (MapType map : blueMap.getMapTypes()) {
|
||||
BlueMapMapImpl m = new BlueMapMapImpl(this, map);
|
||||
maps.put(m.getId(), m);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Renderer getRenderer() {
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BlueMapMap> getMaps() {
|
||||
return Collections.unmodifiableCollection(maps.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BlueMapWorld> getWorlds() {
|
||||
return Collections.unmodifiableCollection(worlds.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlueMapVersion() {
|
||||
return BlueMap.VERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BlueMapWorld> getWorld(UUID uuid) {
|
||||
return Optional.ofNullable(worlds.get(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<BlueMapMap> getMap(String id) {
|
||||
return Optional.ofNullable(maps.get(id));
|
||||
}
|
||||
|
||||
public BlueMapWorldImpl getWorldForUuid(UUID uuid) {
|
||||
BlueMapWorldImpl world = worlds.get(uuid);
|
||||
|
||||
if (world == null) throw new IllegalArgumentException("There is no world loaded with this UUID: " + uuid.toString());
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
public BlueMapMapImpl getMapForId(String mapId) {
|
||||
BlueMapMapImpl map = maps.get(mapId);
|
||||
|
||||
if (map == null) throw new IllegalArgumentException("There is no map loaded with this id: " + mapId);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
BlueMapAPI.registerInstance(this);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
BlueMapAPI.unregisterInstance(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.api;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.common.MapType;
|
||||
|
||||
public class BlueMapMapImpl implements BlueMapMap {
|
||||
|
||||
private BlueMapAPIImpl api;
|
||||
private MapType delegate;
|
||||
|
||||
protected BlueMapMapImpl(BlueMapAPIImpl api, MapType delegate) {
|
||||
this.api = api;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return delegate.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlueMapWorldImpl getWorld() {
|
||||
return api.getWorldForUuid(delegate.getWorld().getUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getTileSize() {
|
||||
return delegate.getTileRenderer().getHiresModelManager().getTileSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getTileOffset() {
|
||||
return delegate.getTileRenderer().getHiresModelManager().getGridOrigin();
|
||||
}
|
||||
|
||||
public MapType getMapType() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.api;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapWorld;
|
||||
import de.bluecolored.bluemap.core.world.World;
|
||||
|
||||
public class BlueMapWorldImpl implements BlueMapWorld {
|
||||
|
||||
private BlueMapAPIImpl api;
|
||||
private World delegate;
|
||||
|
||||
private Collection<BlueMapMap> maps;
|
||||
|
||||
protected BlueMapWorldImpl(BlueMapAPIImpl api, World delegate) {
|
||||
this.api = api;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getSaveFolder() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUuid() {
|
||||
return delegate.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BlueMapMap> getMaps() {
|
||||
if (maps == null) {
|
||||
maps = Collections.unmodifiableCollection(
|
||||
api.getMaps().stream()
|
||||
.filter(map -> map.getWorld().equals(this))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return maps;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.api;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
|
||||
import de.bluecolored.bluemap.api.renderer.BlueMapMap;
|
||||
import de.bluecolored.bluemap.api.renderer.Renderer;
|
||||
import de.bluecolored.bluemap.common.RenderManager;
|
||||
|
||||
public class RendererImpl implements Renderer {
|
||||
|
||||
private BlueMapAPIImpl api;
|
||||
private RenderManager renderManager;
|
||||
|
||||
protected RendererImpl(BlueMapAPIImpl api, RenderManager renderManager) {
|
||||
this.api = api;
|
||||
this.renderManager = renderManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(UUID world, Vector3i blockPosition) {
|
||||
render(api.getWorldForUuid(world), blockPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(String mapId, Vector3i blockPosition) {
|
||||
render(api.getMapForId(mapId), blockPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(String mapId, Vector2i tile) {
|
||||
render(api.getMapForId(mapId), tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(BlueMapMap map, Vector2i tile) {
|
||||
BlueMapMapImpl cmap;
|
||||
if (map instanceof BlueMapMapImpl) {
|
||||
cmap = (BlueMapMapImpl) map;
|
||||
} else {
|
||||
cmap = api.getMapForId(map.getId());
|
||||
}
|
||||
|
||||
renderManager.createTicket(cmap.getMapType(), tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int renderQueueSize() {
|
||||
return renderManager.getQueueSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int renderThreadCount() {
|
||||
return renderManager.getRenderThreadCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return renderManager.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (!isRunning()) renderManager.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
renderManager.stop();
|
||||
}
|
||||
|
||||
}
|
@ -324,43 +324,19 @@ private Text createPrioritizeTaskText(RenderTask task) {
|
||||
}
|
||||
|
||||
private void createWorldRenderTask(CommandSource source, World world, Vector2i center, long blockRadius) {
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Collecting chunks to render..."));
|
||||
|
||||
String taskName = "world-render";
|
||||
|
||||
Predicate<Vector2i> filter;
|
||||
if (center == null || blockRadius < 0) {
|
||||
filter = c -> true;
|
||||
} else {
|
||||
filter = c -> c.mul(16).distanceSquared(center) <= blockRadius * blockRadius;
|
||||
taskName = "radius-render";
|
||||
}
|
||||
|
||||
Collection<Vector2i> chunks = world.getChunkList(filter);
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, chunks.size() + " chunks found!"));
|
||||
|
||||
for (MapType map : bluemap.getMapTypes()) {
|
||||
if (!map.getWorld().getUUID().equals(world.getUUID())) continue;
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Collecting tiles for map '" + map.getId() + "'"));
|
||||
|
||||
HiresModelManager hmm = map.getTileRenderer().getHiresModelManager();
|
||||
Collection<Vector2i> tiles = hmm.getTilesForChunks(chunks);
|
||||
|
||||
RenderTask task = new RenderTask(taskName, map);
|
||||
task.addTiles(tiles);
|
||||
task.optimizeQueue();
|
||||
bluemap.getRenderManager().addRenderTask(task);
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, tiles.size() + " tiles found! Task created."));
|
||||
createMapRenderTask(source, map, center, blockRadius);
|
||||
}
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, "All render tasks created! Use /bluemap to view the progress!"));
|
||||
}
|
||||
|
||||
private void createMapRenderTask(CommandSource source, MapType map, Vector2i center, long blockRadius) {
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Collecting chunks to render..."));
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Creating render-task for map: " + map.getId()));
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Collecting chunks..."));
|
||||
|
||||
String taskName = "world-render";
|
||||
|
||||
@ -375,7 +351,7 @@ private void createMapRenderTask(CommandSource source, MapType map, Vector2i cen
|
||||
Collection<Vector2i> chunks = map.getWorld().getChunkList(filter);
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, chunks.size() + " chunks found!"));
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Collecting tiles for map '" + map.getId() + "'"));
|
||||
source.sendMessage(Text.of(TextColor.GOLD, "Collecting tiles..."));
|
||||
|
||||
HiresModelManager hmm = map.getTileRenderer().getHiresModelManager();
|
||||
Collection<Vector2i> tiles = hmm.getTilesForChunks(chunks);
|
||||
@ -386,7 +362,6 @@ private void createMapRenderTask(CommandSource source, MapType map, Vector2i cen
|
||||
bluemap.getRenderManager().addRenderTask(task);
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, tiles.size() + " tiles found! Task created."));
|
||||
source.sendMessage(Text.of(TextColor.GREEN, "All render tasks created! Use /bluemap to view the progress!"));
|
||||
}
|
||||
|
||||
private boolean checkLoaded(CommandSource source) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
import de.bluecolored.bluemap.common.MapType;
|
||||
import de.bluecolored.bluemap.common.RenderManager;
|
||||
import de.bluecolored.bluemap.common.api.BlueMapAPIImpl;
|
||||
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerInterface;
|
||||
import de.bluecolored.bluemap.core.config.ConfigManager;
|
||||
import de.bluecolored.bluemap.core.config.MainConfig;
|
||||
@ -50,6 +51,8 @@ public class Plugin {
|
||||
|
||||
private static Plugin instance;
|
||||
|
||||
private BlueMapAPIImpl api;
|
||||
|
||||
private String implementationType;
|
||||
|
||||
private ServerInterface serverInterface;
|
||||
@ -172,9 +175,17 @@ public synchronized void load() throws IOException, ParseResourceException {
|
||||
}
|
||||
}
|
||||
|
||||
//slice world to render edges if configured
|
||||
if (mapConfig.isRenderEdges() && !(mapConfig.getMin().equals(RenderSettings.DEFAULT_MIN) && mapConfig.getMax().equals(RenderSettings.DEFAULT_MAX))) {
|
||||
world = new SlicedWorld(world, mapConfig.getMin(), mapConfig.getMax());
|
||||
//slice world if configured
|
||||
if (!mapConfig.getMin().equals(RenderSettings.DEFAULT_MIN) || !mapConfig.getMax().equals(RenderSettings.DEFAULT_MAX)) {
|
||||
if (mapConfig.isRenderEdges()) {
|
||||
world = new SlicedWorld(world, mapConfig.getMin(), mapConfig.getMax());
|
||||
} else {
|
||||
world = new SlicedWorld(
|
||||
world,
|
||||
mapConfig.getMin().min(mapConfig.getMin().sub(2, 2, 2)), // protect from int-overflow
|
||||
mapConfig.getMax().max(mapConfig.getMax().add(2, 2, 2)) // protect from int-overflow
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
HiresModelManager hiresModelManager = new HiresModelManager(
|
||||
@ -280,10 +291,17 @@ public synchronized void load() throws IOException, ParseResourceException {
|
||||
metricsThread.start();
|
||||
|
||||
loaded = true;
|
||||
|
||||
//enable api
|
||||
this.api = new BlueMapAPIImpl(this);
|
||||
this.api.register();
|
||||
}
|
||||
|
||||
public synchronized void unload() {
|
||||
|
||||
//disable api
|
||||
if (api != null) api.unregister();
|
||||
|
||||
//unregister listeners
|
||||
serverInterface.unregisterAllListeners();
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.util.AABB;
|
||||
|
||||
/**
|
||||
@ -47,6 +48,8 @@ public SlicedWorld(World world, Vector3i min, Vector3i max) {
|
||||
this.world = world;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
|
||||
Logger.global.logInfo("Sliced: " + min + max);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -116,23 +119,29 @@ public boolean isChunkGenerated(Vector2i chunkPos) throws IOException {
|
||||
|
||||
@Override
|
||||
public boolean isAreaGenerated(AABB area) throws IOException {
|
||||
if (!isInside(blockPosToChunkPos(area.getMin())) && !isInside(blockPosToChunkPos(area.getMax()))) return false;
|
||||
|
||||
return world.isAreaGenerated(area);
|
||||
return isAreaGenerated(area.getMin(), area.getMax());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAreaGenerated(Vector3i blockMin, Vector3i blockMax) throws IOException {
|
||||
if (!isInside(blockPosToChunkPos(blockMin)) && !isInside(blockPosToChunkPos(blockMax))) return false;
|
||||
|
||||
return world.isAreaGenerated(blockMin, blockMax);
|
||||
return isAreaGenerated(blockPosToChunkPos(blockMin), blockPosToChunkPos(blockMax));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAreaGenerated(Vector2i chunkMin, Vector2i chunkMax) throws IOException {
|
||||
if (!isInside(chunkMin) && !isInside(chunkMax)) return false;
|
||||
if (!isInside(chunkMin) &&
|
||||
!isInside(chunkMax) &&
|
||||
!isInside(new Vector2i(chunkMin.getX(), chunkMax.getY())) &&
|
||||
!isInside(new Vector2i(chunkMax.getX(), chunkMin.getY()))
|
||||
) return false;
|
||||
|
||||
return world.isAreaGenerated(chunkMin, chunkMax);
|
||||
for (int x = chunkMin.getX(); x <= chunkMax.getX(); x++) {
|
||||
for (int z = chunkMin.getY(); z <= chunkMax.getY(); z++) {
|
||||
if (!world.isChunkGenerated(new Vector2i(x, z))) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -170,10 +179,11 @@ private boolean isInside(Vector2i chunkPos) {
|
||||
|
||||
private boolean isInside(int chunkX, int chunkZ) {
|
||||
return
|
||||
chunkX * 16 >= min.getX() &&
|
||||
chunkX * 16 + 15 <= max.getX() &&
|
||||
chunkZ * 16 >= min.getZ() &&
|
||||
chunkZ * 16 + 15 <= max.getZ();
|
||||
chunkX * 16 <= max.getX() &&
|
||||
chunkX * 16 + 15 >= min.getX() &&
|
||||
chunkZ * 16 <= max.getZ() &&
|
||||
chunkZ * 16 + 15 >= min.getZ();
|
||||
|
||||
}
|
||||
|
||||
private Block createAirBlock(Vector3i pos) {
|
||||
|
@ -19,7 +19,7 @@ BlueMap can be used on the command-line, or as a plugin for your Sponge/Spigot/P
|
||||
If you have a question, help others using BlueMap or get the latest news and info you are welcome to join us [on Discord](https://discord.gg/zmkyJa3)!
|
||||
|
||||
### Clone
|
||||
If you have git installed, simply use the command `git clone https://github.com/BlueMap-Minecraft/BlueMap.git` to clone BlueMap.
|
||||
If you have git installed, simply use the command `git clone --recursive https://github.com/BlueMap-Minecraft/BlueMap.git` to clone BlueMap.
|
||||
|
||||
### Build
|
||||
In order to build BlueMap you simply need to run the `./gradlew clean build` command in BlueMap's root directory.
|
||||
|
@ -5,10 +5,12 @@ include ':BlueMapCommon'
|
||||
include ':BlueMapSponge'
|
||||
include ':BlueMapBukkit'
|
||||
include ':BlueMapForge'
|
||||
include ':BlueMapAPI'
|
||||
|
||||
project(':BlueMapCore').projectDir = "$rootDir/BlueMapCore" as File
|
||||
project(':BlueMapCLI').projectDir = "$rootDir/BlueMapCLI" as File
|
||||
project(':BlueMapCommon').projectDir = "$rootDir/BlueMapCommon" as File
|
||||
project(':BlueMapSponge').projectDir = "$rootDir/BlueMapSponge" as File
|
||||
project(':BlueMapBukkit').projectDir = "$rootDir/BlueMapBukkit" as File
|
||||
project(':BlueMapForge').projectDir = "$rootDir/BlueMapForge" as File
|
||||
project(':BlueMapForge').projectDir = "$rootDir/BlueMapForge" as File
|
||||
project(':BlueMapAPI').projectDir = "$rootDir/BlueMapAPI" as File
|
||||
|
Loading…
Reference in New Issue
Block a user