From a79b6ff213123ca978b7d142ac93e9e5441086cc Mon Sep 17 00:00:00 2001 From: dags- Date: Sat, 27 Jun 2020 11:04:01 +0100 Subject: [PATCH] - track transient threadpools and shutdown/dispose accordingly - fix the worldtype option buttons on dimension settings --- Engine | 2 +- build.gradle | 20 ++----------------- .../mod/client/gui/page/WorldPage.java | 10 +++++----- .../mod/client/gui/preview/Preview.java | 5 ++++- .../mod/client/gui/preview2/Preview.java | 7 +++++-- .../mod/client/gui/preview2/PreviewPage.java | 5 +++++ 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Engine b/Engine index b0a2908..e151e3c 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit b0a2908a05efa2390580cd147f4313a77bffc270 +Subproject commit e151e3ccf02d305378c269e3086863069fdf4a12 diff --git a/build.gradle b/build.gradle index c44434d..6d829e9 100644 --- a/build.gradle +++ b/build.gradle @@ -34,8 +34,8 @@ repositories { dependencies { minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" - lib (project(":FeatureManager")) { transitive false } - lib project(":Engine") + lib(project(":FeatureManager")) { transitive false } + lib(project(":Engine")) } minecraft { @@ -97,21 +97,6 @@ task collectLibs(type: Copy) { duplicatesStrategy = "EXCLUDE" } -task apiJar(type: Jar) { - dependsOn("reobfJar") - - // copy contents of the main mod jar but only select packages - from { zipTree(tasks.jar.archivePath) } - include "com/terraforged/fm/**" - include "com/terraforged/api/**" - include "com/terraforged/core/**" - include "com/terraforged/n2d/**" - include "com/terraforged/world/**" - - // self explanatory - classifier "api" -} - processResources { filesMatching("**/mods.toml") { // replaces the version string in the mods.toml @@ -133,7 +118,6 @@ publishing { // publish the mod jar & api jar mavenJava(MavenPublication) { artifact jar - artifact apiJar } } diff --git a/src/main/java/com/terraforged/mod/client/gui/page/WorldPage.java b/src/main/java/com/terraforged/mod/client/gui/page/WorldPage.java index f996101..07de647 100644 --- a/src/main/java/com/terraforged/mod/client/gui/page/WorldPage.java +++ b/src/main/java/com/terraforged/mod/client/gui/page/WorldPage.java @@ -95,13 +95,13 @@ public class WorldPage extends BasePage { private CompoundNBT getDimSettings() { CompoundNBT dimSettings = instance.settingsData.getCompound("dimensions"); - - CompoundNBT generators = dimSettings.getCompound("dimensions").getCompound("value"); + CompoundNBT generators = dimSettings.getCompound("dimensions"); for (String name : generators.keySet()) { - CompoundNBT setting = generators.getCompound(name); - setting.put("#options", getWorldTypes()); + if (name.startsWith("#")) { + CompoundNBT metadata = generators.getCompound(name); + metadata.put("options", getWorldTypes()); + } } - return dimSettings; } diff --git a/src/main/java/com/terraforged/mod/client/gui/preview/Preview.java b/src/main/java/com/terraforged/mod/client/gui/preview/Preview.java index 2af7133..a622ff2 100644 --- a/src/main/java/com/terraforged/mod/client/gui/preview/Preview.java +++ b/src/main/java/com/terraforged/mod/client/gui/preview/Preview.java @@ -29,6 +29,7 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.terraforged.core.cell.Cell; import com.terraforged.core.concurrent.cache.CacheEntry; +import com.terraforged.core.concurrent.thread.ThreadPool; import com.terraforged.core.concurrent.thread.ThreadPools; import com.terraforged.core.settings.Settings; import com.terraforged.core.tile.Size; @@ -62,6 +63,7 @@ public class Preview extends Button { private final int offsetX; private final int offsetZ; + private final ThreadPool threadPool = ThreadPools.createDefault(); private final Random random = new Random(System.currentTimeMillis()); private final PreviewSettings previewSettings = new PreviewSettings(); private final DynamicTexture texture = new DynamicTexture(new NativeImage(WIDTH, HEIGHT, true)); @@ -92,6 +94,7 @@ public class Preview extends Button { public void close() { texture.close(); + threadPool.shutdown(); } @Override @@ -204,7 +207,7 @@ public class Preview extends Button { context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center); TileGenerator renderer = TileGenerator.builder() - .pool(ThreadPools.getPool()) + .pool(threadPool) .size(FACTOR, 0) .factory(context.factory) .batch(6) diff --git a/src/main/java/com/terraforged/mod/client/gui/preview2/Preview.java b/src/main/java/com/terraforged/mod/client/gui/preview2/Preview.java index 22d10d5..c58e64e 100644 --- a/src/main/java/com/terraforged/mod/client/gui/preview2/Preview.java +++ b/src/main/java/com/terraforged/mod/client/gui/preview2/Preview.java @@ -19,8 +19,7 @@ public class Preview extends Widget { private static final float ZOOM_SCALE = 200F; - private final ThreadPool threadPool = ThreadPools.getPool(); - + private final ThreadPool threadPool = ThreadPools.createDefault(); private final TerraSettings settings; private int seed; @@ -49,6 +48,10 @@ public class Preview extends Widget { world.update(offsetX, offsetZ, zoom, true); } + public void close() { + threadPool.shutdown(); + } + @Override public void render(int mx, int my, float ticks) { try { diff --git a/src/main/java/com/terraforged/mod/client/gui/preview2/PreviewPage.java b/src/main/java/com/terraforged/mod/client/gui/preview2/PreviewPage.java index 106e756..7bb8fe5 100644 --- a/src/main/java/com/terraforged/mod/client/gui/preview2/PreviewPage.java +++ b/src/main/java/com/terraforged/mod/client/gui/preview2/PreviewPage.java @@ -24,6 +24,11 @@ public class PreviewPage extends UpdatablePage { return preview.getSeed(); } + @Override + public void close() { + preview.close(); + } + @Override public void apply(Consumer consumer) { consumer.accept(genSettings);