- 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

@ -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
}
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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 {

View File

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