diff --git a/Engine b/Engine index 5b2c44a..b0a2908 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 5b2c44a6c2fd3a440e6600060780ba9193b8f389 +Subproject commit b0a2908a05efa2390580cd147f4313a77bffc270 diff --git a/build.gradle b/build.gradle index 6707f4c..c44434d 100644 --- a/build.gradle +++ b/build.gradle @@ -97,10 +97,7 @@ task collectLibs(type: Copy) { duplicatesStrategy = "EXCLUDE" } -// runs during publication task apiJar(type: Jar) { - // make sure jar is reobf'd before creating the api jar - // dependents must use fg.deobf("dependency") for their environment dependsOn("reobfJar") // copy contents of the main mod jar but only select packages @@ -127,8 +124,8 @@ classes { dependsOn(collectLibs) } -build { - dependsOn("reobfJar") +jar { + finalizedBy("reobfJar") } publishing { diff --git a/src/main/java/com/terraforged/mod/TerraForgedMod.java b/src/main/java/com/terraforged/mod/TerraForgedMod.java index 1413f1d..2fbda6f 100644 --- a/src/main/java/com/terraforged/mod/TerraForgedMod.java +++ b/src/main/java/com/terraforged/mod/TerraForgedMod.java @@ -26,8 +26,8 @@ package com.terraforged.mod; import com.terraforged.api.material.WGTags; +import com.terraforged.fm.template.TemplateManager; import com.terraforged.mod.chunk.settings.SettingsHelper; -import com.terraforged.mod.server.command.TerraCommand; import com.terraforged.mod.config.ConfigManager; import com.terraforged.mod.data.DataGen; import com.terraforged.mod.feature.context.ContextSelectorFeature; @@ -35,7 +35,7 @@ import com.terraforged.mod.feature.decorator.poisson.PoissonAtSurface; import com.terraforged.mod.feature.feature.BushFeature; import com.terraforged.mod.feature.feature.DiskFeature; import com.terraforged.mod.feature.feature.FreezeLayer; -import com.terraforged.fm.template.TemplateManager; +import com.terraforged.mod.server.command.TerraCommand; import com.terraforged.mod.util.DataPackFinder; import com.terraforged.mod.util.Environment; import net.minecraft.world.biome.Biomes; diff --git a/src/main/java/com/terraforged/mod/chunk/settings/SettingsHelper.java b/src/main/java/com/terraforged/mod/chunk/settings/SettingsHelper.java index 299e92b..cb5477d 100644 --- a/src/main/java/com/terraforged/mod/chunk/settings/SettingsHelper.java +++ b/src/main/java/com/terraforged/mod/chunk/settings/SettingsHelper.java @@ -54,26 +54,32 @@ public class SettingsHelper { return options; } - public static TerraSettings getSettings(WorldInfo info) { + public static TerraSettings readDefaults() { TerraSettings settings = new TerraSettings(); - if (info.getGeneratorOptions().isEmpty()) { - if (DEFAULTS_FILE.exists()) { - try (Reader reader = new BufferedReader(new FileReader(DEFAULTS_FILE))) { - Log.info("Loading generator settings from json"); - JsonElement json = new JsonParser().parse(reader); - CompoundNBT root = NBTHelper.fromJson(json); - NBTHelper.deserialize(root, settings); - } catch (Throwable t) { - t.printStackTrace(); - } + if (DEFAULTS_FILE.exists()) { + try (Reader reader = new BufferedReader(new FileReader(DEFAULTS_FILE))) { + Log.info("Loading generator settings from json"); + JsonElement json = new JsonParser().parse(reader); + CompoundNBT root = NBTHelper.fromJson(json); + NBTHelper.deserialize(root, settings); + } catch (Throwable t) { + t.printStackTrace(); } - } else { - Log.info("Loading generator settings from level.dat"); - NBTHelper.deserialize(info.getGeneratorOptions(), settings); } return settings; } + public static TerraSettings getSettings(WorldInfo info) { + if (info.getGeneratorOptions().isEmpty()) { + return readDefaults(); + } else { + Log.info("Loading generator settings from level.dat"); + TerraSettings settings = new TerraSettings(); + NBTHelper.deserialize(info.getGeneratorOptions(), settings); + return settings; + } + } + public static void init() { if (!DEFAULTS_FILE.exists()) { exportDefaults(new TerraSettings()); diff --git a/src/main/java/com/terraforged/mod/chunk/settings/preset/PresetManager.java b/src/main/java/com/terraforged/mod/chunk/settings/preset/PresetManager.java index 482127f..6ab2d3a 100644 --- a/src/main/java/com/terraforged/mod/chunk/settings/preset/PresetManager.java +++ b/src/main/java/com/terraforged/mod/chunk/settings/preset/PresetManager.java @@ -116,7 +116,7 @@ public class PresetManager implements Iterable { } File[] files = PRESETS_DIR.listFiles(); - if (files == null || files.length == 0) { + if (files == null) { return new PresetManager(new ArrayList<>()); } diff --git a/src/main/java/com/terraforged/mod/client/gui/Instance.java b/src/main/java/com/terraforged/mod/client/gui/Instance.java index 5744a51..f6ced3f 100644 --- a/src/main/java/com/terraforged/mod/client/gui/Instance.java +++ b/src/main/java/com/terraforged/mod/client/gui/Instance.java @@ -17,4 +17,10 @@ public class Instance { this.settings = settings; this.settingsData = NBTHelper.serialize(settings); } + + public TerraSettings createCopy() { + TerraSettings settings = new TerraSettings(); + NBTHelper.deserialize(settingsData, settings); + return settings; + } } diff --git a/src/main/java/com/terraforged/mod/client/gui/page/PresetsPage.java b/src/main/java/com/terraforged/mod/client/gui/page/PresetsPage.java index f39a249..7bb68bb 100644 --- a/src/main/java/com/terraforged/mod/client/gui/page/PresetsPage.java +++ b/src/main/java/com/terraforged/mod/client/gui/page/PresetsPage.java @@ -77,8 +77,8 @@ public class PresetsPage extends BasePage { @Override public void onClick(double x, double y) { super.onClick(x, y); - // create new preset with default settings - Preset preset = new Preset(nameInput.getValue(), new TerraSettings()); + // create new preset with current settings + Preset preset = new Preset(nameInput.getValue(), instance.createCopy()); // register with the manager & reset the text field manager.add(preset); @@ -121,8 +121,7 @@ public class PresetsPage extends BasePage { super.onClick(x, y); getSelected().ifPresent(preset -> { // create a copy of the settings - TerraSettings settings = new TerraSettings(); - NBTHelper.deserialize(instance.settingsData, settings); + TerraSettings settings = instance.createCopy(); // replace the current preset with the updated version manager.add(new Preset(preset.getName(), settings)); @@ -234,6 +233,7 @@ public class PresetsPage extends BasePage { private void rebuildPresetList() { Column left = getColumn(0); + left.scrollPane.setSelected(null); left.scrollPane.setRenderSelection(true); left.scrollPane.children().clear();