Skip to content

Commit fbd5e5e

Browse files
committed
Make local rendering work again.
1 parent 781984f commit fbd5e5e

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

src/main/java/de/lemaik/chunkymap/dynmap/ChunkyMapTile.java

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87,45 +87,51 @@ public boolean render(MapChunkCache mapChunkCache, String s) {
8787
map.cameraAdapter.apply(scene.camera(), tx, ty, map.getMapZoomOutLevels(),
8888
world.getExtraZoomOutLevels());
8989

90-
if (renderer instanceof RemoteRenderer && ((RemoteRenderer) renderer)
91-
.shouldInitializeLocally()) {
92-
scene.loadChunks(SilentTaskTracker.INSTANCE, chunkyWorld,
93-
perspective.getRequiredChunks(this).stream()
90+
if (renderer instanceof RemoteRenderer) {
91+
if (((RemoteRenderer) renderer).shouldInitializeLocally()) {
92+
scene.loadChunks(SilentTaskTracker.INSTANCE, chunkyWorld,
93+
perspective.getRequiredChunks(this).stream()
94+
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
95+
.collect(Collectors.toSet()));
96+
scene.getActors().removeIf(actor -> actor instanceof PlayerEntity);
97+
try {
98+
scene.saveScene(context, new TaskTracker(ProgressListener.NONE));
99+
} catch (IOException e) {
100+
throw new RuntimeException("Could not save scene", e);
101+
}
102+
} else {
103+
try {
104+
Field chunks = Scene.class.getDeclaredField("chunks");
105+
chunks.setAccessible(true);
106+
Collection<ChunkPosition> chunksList = (Collection<ChunkPosition>) chunks.get(scene);
107+
chunksList.clear();
108+
chunksList.addAll(perspective.getRequiredChunks(this).stream()
94109
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
95110
.collect(Collectors.toSet()));
96-
scene.getActors().removeIf(actor -> actor instanceof PlayerEntity);
97-
try {
98-
scene.saveScene(context, new TaskTracker(ProgressListener.NONE));
99-
} catch (IOException e) {
100-
throw new RuntimeException("Could not save scene", e);
111+
} catch (ReflectiveOperationException e) {
112+
throw new RuntimeException("Could not set chunks", e);
113+
}
114+
try {
115+
Field worldPath = Scene.class.getDeclaredField("worldPath");
116+
worldPath.setAccessible(true);
117+
worldPath.set(scene, bukkitWorld.getWorldFolder().getAbsolutePath());
118+
Field worldDimension = Scene.class.getDeclaredField("worldDimension");
119+
worldDimension.setAccessible(true);
120+
worldDimension.setInt(scene, bukkitWorld.getEnvironment().getId());
121+
} catch (ReflectiveOperationException e) {
122+
throw new RuntimeException("Could not set world", e);
123+
}
124+
try {
125+
scene.saveDescription(context.getSceneDescriptionOutputStream(scene.name));
126+
} catch (IOException e) {
127+
throw new RuntimeException("Could not save scene", e);
128+
}
101129
}
102130
} else {
103-
try {
104-
Field chunks = Scene.class.getDeclaredField("chunks");
105-
chunks.setAccessible(true);
106-
Collection<ChunkPosition> chunksList = (Collection<ChunkPosition>) chunks.get(scene);
107-
chunksList.clear();
108-
chunksList.addAll(perspective.getRequiredChunks(this).stream()
109-
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
110-
.collect(Collectors.toSet()));
111-
} catch (ReflectiveOperationException e) {
112-
throw new RuntimeException("Could not set chunks", e);
113-
}
114-
try {
115-
Field worldPath = Scene.class.getDeclaredField("worldPath");
116-
worldPath.setAccessible(true);
117-
worldPath.set(scene, bukkitWorld.getWorldFolder().getAbsolutePath());
118-
Field worldDimension = Scene.class.getDeclaredField("worldDimension");
119-
worldDimension.setAccessible(true);
120-
worldDimension.setInt(scene, bukkitWorld.getEnvironment().getId());
121-
} catch (ReflectiveOperationException e) {
122-
throw new RuntimeException("Could not set world", e);
123-
}
124-
try {
125-
scene.saveDescription(context.getSceneDescriptionOutputStream(scene.name));
126-
} catch (IOException e) {
127-
throw new RuntimeException("Could not save scene", e);
128-
}
131+
scene.loadChunks(SilentTaskTracker.INSTANCE, chunkyWorld,
132+
perspective.getRequiredChunks(this).stream()
133+
.flatMap(c -> getChunksAround(c.x, c.z, map.getChunkPadding()).stream())
134+
.collect(Collectors.toSet()));
129135
}
130136
}).thenApply((image) -> {
131137
MapStorage var52 = world.getMapStorage();

0 commit comments

Comments
 (0)