Skip to content

Commit

Permalink
Make local rendering work again.
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaik committed Nov 22, 2020
1 parent 781984f commit fbd5e5e
Showing 1 changed file with 41 additions and 35 deletions.
76 changes: 41 additions & 35 deletions src/main/java/de/lemaik/chunkymap/dynmap/ChunkyMapTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,45 +87,51 @@ public boolean render(MapChunkCache mapChunkCache, String s) {
map.cameraAdapter.apply(scene.camera(), tx, ty, map.getMapZoomOutLevels(),
world.getExtraZoomOutLevels());

if (renderer instanceof RemoteRenderer && ((RemoteRenderer) renderer)
.shouldInitializeLocally()) {
scene.loadChunks(SilentTaskTracker.INSTANCE, chunkyWorld,
perspective.getRequiredChunks(this).stream()
if (renderer instanceof RemoteRenderer) {
if (((RemoteRenderer) renderer).shouldInitializeLocally()) {
scene.loadChunks(SilentTaskTracker.INSTANCE, chunkyWorld,
perspective.getRequiredChunks(this).stream()
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
.collect(Collectors.toSet()));
scene.getActors().removeIf(actor -> actor instanceof PlayerEntity);
try {
scene.saveScene(context, new TaskTracker(ProgressListener.NONE));
} catch (IOException e) {
throw new RuntimeException("Could not save scene", e);
}
} else {
try {
Field chunks = Scene.class.getDeclaredField("chunks");
chunks.setAccessible(true);
Collection<ChunkPosition> chunksList = (Collection<ChunkPosition>) chunks.get(scene);
chunksList.clear();
chunksList.addAll(perspective.getRequiredChunks(this).stream()
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
.collect(Collectors.toSet()));
scene.getActors().removeIf(actor -> actor instanceof PlayerEntity);
try {
scene.saveScene(context, new TaskTracker(ProgressListener.NONE));
} catch (IOException e) {
throw new RuntimeException("Could not save scene", e);
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not set chunks", e);
}
try {
Field worldPath = Scene.class.getDeclaredField("worldPath");
worldPath.setAccessible(true);
worldPath.set(scene, bukkitWorld.getWorldFolder().getAbsolutePath());
Field worldDimension = Scene.class.getDeclaredField("worldDimension");
worldDimension.setAccessible(true);
worldDimension.setInt(scene, bukkitWorld.getEnvironment().getId());
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not set world", e);
}
try {
scene.saveDescription(context.getSceneDescriptionOutputStream(scene.name));
} catch (IOException e) {
throw new RuntimeException("Could not save scene", e);
}
}
} else {
try {
Field chunks = Scene.class.getDeclaredField("chunks");
chunks.setAccessible(true);
Collection<ChunkPosition> chunksList = (Collection<ChunkPosition>) chunks.get(scene);
chunksList.clear();
chunksList.addAll(perspective.getRequiredChunks(this).stream()
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
.collect(Collectors.toSet()));
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not set chunks", e);
}
try {
Field worldPath = Scene.class.getDeclaredField("worldPath");
worldPath.setAccessible(true);
worldPath.set(scene, bukkitWorld.getWorldFolder().getAbsolutePath());
Field worldDimension = Scene.class.getDeclaredField("worldDimension");
worldDimension.setAccessible(true);
worldDimension.setInt(scene, bukkitWorld.getEnvironment().getId());
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not set world", e);
}
try {
scene.saveDescription(context.getSceneDescriptionOutputStream(scene.name));
} catch (IOException e) {
throw new RuntimeException("Could not save scene", e);
}
scene.loadChunks(SilentTaskTracker.INSTANCE, chunkyWorld,
perspective.getRequiredChunks(this).stream()
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
.collect(Collectors.toSet()));
}
}).thenApply((image) -> {
MapStorage var52 = world.getMapStorage();
Expand Down

0 comments on commit fbd5e5e

Please sign in to comment.