- track transient threadpools and shutdown/dispose accordingly

- fix the worldtype option buttons on dimension settings
This commit is contained in:
dags- 2020-06-27 11:04:01 +01:00
parent 54b7ad7e85
commit a79b6ff213
6 changed files with 22 additions and 27 deletions

2
Engine

@ -1 +1 @@
Subproject commit b0a2908a05efa2390580cd147f4313a77bffc270 Subproject commit e151e3ccf02d305378c269e3086863069fdf4a12

View File

@ -35,7 +35,7 @@ repositories {
dependencies { dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
lib(project(":FeatureManager")) { transitive false } lib(project(":FeatureManager")) { transitive false }
lib project(":Engine") lib(project(":Engine"))
} }
minecraft { minecraft {
@ -97,21 +97,6 @@ task collectLibs(type: Copy) {
duplicatesStrategy = "EXCLUDE" 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 { processResources {
filesMatching("**/mods.toml") { filesMatching("**/mods.toml") {
// replaces the version string in the mods.toml // replaces the version string in the mods.toml
@ -133,7 +118,6 @@ publishing {
// publish the mod jar & api jar // publish the mod jar & api jar
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
artifact jar artifact jar
artifact apiJar
} }
} }

View File

@ -95,13 +95,13 @@ public class WorldPage extends BasePage {
private CompoundNBT getDimSettings() { private CompoundNBT getDimSettings() {
CompoundNBT dimSettings = instance.settingsData.getCompound("dimensions"); CompoundNBT dimSettings = instance.settingsData.getCompound("dimensions");
CompoundNBT generators = dimSettings.getCompound("dimensions");
CompoundNBT generators = dimSettings.getCompound("dimensions").getCompound("value");
for (String name : generators.keySet()) { for (String name : generators.keySet()) {
CompoundNBT setting = generators.getCompound(name); if (name.startsWith("#")) {
setting.put("#options", getWorldTypes()); CompoundNBT metadata = generators.getCompound(name);
metadata.put("options", getWorldTypes());
}
} }
return dimSettings; return dimSettings;
} }

View File

@ -29,6 +29,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.concurrent.cache.CacheEntry; 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.concurrent.thread.ThreadPools;
import com.terraforged.core.settings.Settings; import com.terraforged.core.settings.Settings;
import com.terraforged.core.tile.Size; import com.terraforged.core.tile.Size;
@ -62,6 +63,7 @@ public class Preview extends Button {
private final int offsetX; private final int offsetX;
private final int offsetZ; private final int offsetZ;
private final ThreadPool threadPool = ThreadPools.createDefault();
private final Random random = new Random(System.currentTimeMillis()); private final Random random = new Random(System.currentTimeMillis());
private final PreviewSettings previewSettings = new PreviewSettings(); private final PreviewSettings previewSettings = new PreviewSettings();
private final DynamicTexture texture = new DynamicTexture(new NativeImage(WIDTH, HEIGHT, true)); private final DynamicTexture texture = new DynamicTexture(new NativeImage(WIDTH, HEIGHT, true));
@ -92,6 +94,7 @@ public class Preview extends Button {
public void close() { public void close() {
texture.close(); texture.close();
threadPool.shutdown();
} }
@Override @Override
@ -204,7 +207,7 @@ public class Preview extends Button {
context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center); context.factory.getHeightmap().getContinent().getNearestCenter(offsetX, offsetZ, center);
TileGenerator renderer = TileGenerator.builder() TileGenerator renderer = TileGenerator.builder()
.pool(ThreadPools.getPool()) .pool(threadPool)
.size(FACTOR, 0) .size(FACTOR, 0)
.factory(context.factory) .factory(context.factory)
.batch(6) .batch(6)

View File

@ -19,8 +19,7 @@ public class Preview extends Widget {
private static final float ZOOM_SCALE = 200F; private static final float ZOOM_SCALE = 200F;
private final ThreadPool threadPool = ThreadPools.getPool(); private final ThreadPool threadPool = ThreadPools.createDefault();
private final TerraSettings settings; private final TerraSettings settings;
private int seed; private int seed;
@ -49,6 +48,10 @@ public class Preview extends Widget {
world.update(offsetX, offsetZ, zoom, true); world.update(offsetX, offsetZ, zoom, true);
} }
public void close() {
threadPool.shutdown();
}
@Override @Override
public void render(int mx, int my, float ticks) { public void render(int mx, int my, float ticks) {
try { try {

View File

@ -24,6 +24,11 @@ public class PreviewPage extends UpdatablePage {
return preview.getSeed(); return preview.getSeed();
} }
@Override
public void close() {
preview.close();
}
@Override @Override
public void apply(Consumer<TerraSettings> consumer) { public void apply(Consumer<TerraSettings> consumer) {
consumer.accept(genSettings); consumer.accept(genSettings);