Ability to view mapgen params
parent
03fbf3fa46
commit
d0c69077ea
|
@ -24,6 +24,7 @@ import amidst.gui.crash.CrashWindow;
|
|||
import amidst.gui.main.menu.MovePlayerPopupMenu;
|
||||
import amidst.gui.main.viewer.ViewerFacade;
|
||||
import amidst.gui.seedsearcher.SeedSearcherWindow;
|
||||
import amidst.gui.text.TextWindow;
|
||||
import amidst.logging.AmidstLogger;
|
||||
import amidst.minetest.world.mapgen.DefaultBiomes;
|
||||
import amidst.mojangapi.world.WorldSeed;
|
||||
|
@ -306,6 +307,25 @@ public class Actions {
|
|||
application.displayLicenseWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is more useful for Minetest than Minecraft, as Minetest has extensive
|
||||
* modabble MapgenParams, which are exposed as the GeneratorOptions
|
||||
*/
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public void displayGeneratorOptions() {
|
||||
//
|
||||
String generatorOptions = null;
|
||||
ViewerFacade viewerFacade = viewerFacadeSupplier.get();
|
||||
if (viewerFacade != null) {
|
||||
generatorOptions = viewerFacade.getGeneratorOptions();
|
||||
}
|
||||
if (generatorOptions != null && generatorOptions.length() > 0) {
|
||||
TextWindow.showMonospace("World mapgen options", generatorOptions);
|
||||
} else {
|
||||
dialogs.displayInfo("World MapGen options", "There are currently no mapgen options in use");
|
||||
}
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public void about() {
|
||||
dialogs.displayInfo(
|
||||
|
|
|
@ -128,6 +128,8 @@ public class AmidstMenuBuilder {
|
|||
if (biomeAuthority.getBiomeProfileDirectory().isValid()) {
|
||||
result.add(create_Settings_BiomeProfile());
|
||||
}
|
||||
Menus.item(result, actions::displayGeneratorOptions, "View MapGen params", KeyEvent.VK_V);
|
||||
|
||||
result.addSeparator();
|
||||
// @formatter:off
|
||||
Menus.checkbox(result, settings.smoothScrolling, "Smooth Scrolling");
|
||||
|
@ -147,7 +149,7 @@ public class AmidstMenuBuilder {
|
|||
// @formatter:on
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private JMenu create_Settings_BiomeProfile() {
|
||||
JMenu result = new JMenu("Biome profile");
|
||||
// @formatter:off
|
||||
|
|
|
@ -148,6 +148,11 @@ public class ViewerFacade {
|
|||
return world.getWorldType();
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public String getGeneratorOptions() {
|
||||
return world.getGeneratorOptions();
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public WorldIcon getSpawnWorldIcon() {
|
||||
return world.getSpawnWorldIcon();
|
||||
|
|
|
@ -6,7 +6,8 @@ import amidst.mojangapi.world.WorldType;
|
|||
|
||||
public class MapgenFlatParams extends MapgenParams {
|
||||
|
||||
public static final int FLAG_V5_CAVERNS = 0x01;
|
||||
public static final int FLAG_FLAT_LAKES = 0x01;
|
||||
public static final int FLAG_FLAT_HILLS = 0x02;
|
||||
|
||||
public int spflags = 0;
|
||||
public short ground_level = 8;
|
||||
|
@ -23,6 +24,19 @@ public class MapgenFlatParams extends MapgenParams {
|
|||
|
||||
NoiseParams np_terrain = new NoiseParams(0, 1, new Vector3f(600, 600, 600), 7244, (short)5, 0.6f, 2.0f);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String prefix = "mgflat_";
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("mg_flags = ");
|
||||
appendFlags(result, spflags, new String[] {"lakes", "hills"});
|
||||
result.append("\r\n");
|
||||
result.append(String.format("ground_level = %s\r\n", formatFloat(ground_level)));
|
||||
result.append(super.toString());
|
||||
result.append(np_terrain.toString(prefix + "np_terrain"));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldType getWorldType() {
|
||||
return WorldType.FLAT;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package amidst.minetest.world.mapgen;
|
||||
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import amidst.mojangapi.world.WorldType;
|
||||
|
@ -21,4 +24,52 @@ public abstract class MapgenParams {
|
|||
public NoiseParams np_humidity_blend = new NoiseParams( 0, 1.5f, new Vector3f( 8, 8, 8), 90003, (short)2, 1.0f, 2.0f);
|
||||
|
||||
abstract WorldType getWorldType();
|
||||
|
||||
public String toString() {
|
||||
String prefix = "mg_biome_";
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(String.format("water_level = %d\r\n", water_level));
|
||||
result.append(np_heat.toString( prefix + "np_heat"));
|
||||
result.append(np_humidity.toString( prefix + "np_humidity"));
|
||||
result.append(np_heat_blend.toString( prefix + "np_heat_blend"));
|
||||
result.append(np_humidity_blend.toString(prefix + "np_humidity_blend"));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static void appendFlags(StringBuilder stringBuilder, int flagBits, String[] flags) {
|
||||
|
||||
if (flagBits == 0) {
|
||||
stringBuilder.append("none");
|
||||
} else {
|
||||
boolean commaRequired = false;
|
||||
int flagMask = 1;
|
||||
for(String flagname : flags) {
|
||||
if ((flagBits & flagMask) > 0) {
|
||||
if (commaRequired) stringBuilder.append(", ");
|
||||
stringBuilder.append(flagname);
|
||||
commaRequired = true;
|
||||
}
|
||||
flagMask <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String decimalSeparator;
|
||||
private static String formatFloatRegEx = null;
|
||||
|
||||
/**
|
||||
* Formats a float value into the way it would be naturally written, e.g. 2.0f -> "2"
|
||||
*
|
||||
* Used for [subclasses].toString(), but perhaps should be moved to a string library?
|
||||
*/
|
||||
public static String formatFloat(float value) {
|
||||
String result = String.format("%f", value);
|
||||
|
||||
if (formatFloatRegEx == null) {
|
||||
decimalSeparator = new DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT)).getDecimalSeparator() + "";
|
||||
formatFloatRegEx = "\\Q" + decimalSeparator + "\\E?0*$";
|
||||
}
|
||||
return result.contains(decimalSeparator) ? result.replaceAll(formatFloatRegEx, "") : result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,20 @@ public class MapgenV5Params extends MapgenParams {
|
|||
public NoiseParams np_height = new NoiseParams(0, 10, new Vector3f(250, 250, 250), 84174, (short)4, 0.5f, 2.0f);
|
||||
public NoiseParams np_ground = new NoiseParams(0, 40, new Vector3f( 80, 80, 80), 983240, (short)4, 0.55f, 2.0f, Noise.FLAG_EASED);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String prefix = "mgv5_";
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("mg_flags = ");
|
||||
appendFlags(result, spflags, new String[] {"caverns"});
|
||||
result.append("\r\n");
|
||||
result.append(super.toString());
|
||||
result.append(np_factor.toString(prefix + "np_factor"));
|
||||
result.append(np_height.toString(prefix + "np_height"));
|
||||
result.append(np_ground.toString(prefix + "np_ground"));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldType getWorldType() {
|
||||
return WorldType.V5;
|
||||
|
|
|
@ -33,6 +33,27 @@ public class MapgenV6Params extends MapgenParams {
|
|||
public NoiseParams np_trees = new NoiseParams(0, 1.0f, new Vector3f(125, 125, 125), 2, (short)4, 0.66f, 2.0f);
|
||||
public NoiseParams np_apple_trees = new NoiseParams(0, 1.0f, new Vector3f(100, 100, 100), 342902, (short)3, 0.45f, 2.0f);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String prefix = "mgv6_";
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("mg_flags = ");
|
||||
appendFlags(result, spflags, new String[] {"jungles", "biomeblend", "mudflow", "snowbiomes", "flat", "trees"});
|
||||
result.append("\r\n");
|
||||
result.append(String.format("freq_desert = %s\r\n", formatFloat(freq_desert)));
|
||||
result.append(String.format("freq_beach = %s\r\n", formatFloat(freq_beach)));
|
||||
result.append(super.toString());
|
||||
result.append(np_terrain_base.toString( prefix + "np_terrain_base"));
|
||||
result.append(np_terrain_higher.toString(prefix + "np_terrain_higher"));
|
||||
result.append(np_steepness.toString( prefix + "np_steepness"));
|
||||
result.append(np_height_select.toString( prefix + "np_height_select"));
|
||||
result.append(np_mud.toString( prefix + "np_mud"));
|
||||
result.append(np_beach.toString( prefix + "np_beach"));
|
||||
result.append(np_biome.toString( prefix + "np_biome"));
|
||||
result.append(np_humidity.toString( prefix + "np_humidity"));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldType getWorldType() {
|
||||
return WorldType.V6;
|
||||
|
|
|
@ -68,6 +68,25 @@ public class MapgenV7Params extends MapgenParams {
|
|||
NoiseParams np_cave1 = new NoiseParams(0, 12, new Vector3f(61, 61, 61), 52534, (short)3, 0.5f, 2.0f);
|
||||
NoiseParams np_cave2 = new NoiseParams(0, 12, new Vector3f(67, 67, 67), 10325, (short)3, 0.5f, 2.0f);
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String prefix = "mgv7_";
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("mg_flags = ");
|
||||
appendFlags(result, spflags, new String[] {"mountains", "ridges", "floatlands", "caverns", "biomerepeat"});
|
||||
result.append("\r\n");
|
||||
result.append(super.toString());
|
||||
result.append(np_terrain_base.toString( prefix + "np_terrain_base"));
|
||||
result.append(np_terrain_alt.toString( prefix + "np_terrain_alt"));
|
||||
result.append(np_terrain_persist.toString(prefix + "np_terrain_persist"));
|
||||
result.append(np_height_select.toString( prefix + "np_height_select"));
|
||||
result.append(np_mount_height.toString( prefix + "np_mount_height"));
|
||||
result.append(np_mountain.toString( prefix + "np_terrain_persist"));
|
||||
result.append(np_ridge_uwater.toString( prefix + "np_ridge_uwater"));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldType getWorldType() {
|
||||
return WorldType.V7;
|
||||
|
|
|
@ -22,6 +22,25 @@ public class NoiseParams {
|
|||
this(offset_, scale_, spread_, seed_, octaves_, persist_, lacunarity_, Noise.FLAG_DEFAULTS);
|
||||
}
|
||||
|
||||
public String toString(String name) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(name);
|
||||
result.append(" = {\r\n");
|
||||
result.append(" flags = ");
|
||||
MapgenParams.appendFlags(result, flags, new String[] {"defaults", "eased", "absvalue", "pointbuffer", "simplex"});
|
||||
result.append("\r\n");
|
||||
result.append(String.format(" lacunarity = %s\r\n", MapgenParams.formatFloat(lacunarity)));
|
||||
result.append(String.format(" offset = %s\r\n", MapgenParams.formatFloat(offset)));
|
||||
result.append(String.format(" scale = %s\r\n", MapgenParams.formatFloat(scale)));
|
||||
result.append(String.format(" spread = (%s, %s, %s)\r\n", MapgenParams.formatFloat(spread.x), MapgenParams.formatFloat(spread.y), MapgenParams.formatFloat(spread.z)));
|
||||
result.append(String.format(" seed = %s\r\n", MapgenParams.formatFloat(seed)));
|
||||
result.append(String.format(" octaves = %s\r\n", MapgenParams.formatFloat(octaves)));
|
||||
result.append(String.format(" persistence = %s\r\n", MapgenParams.formatFloat(persist)));
|
||||
result.append("}\r\n");
|
||||
return result.toString();
|
||||
|
||||
}
|
||||
|
||||
public NoiseParams(float offset_, float scale_, Vector3f spread_, int seed_,
|
||||
short octaves_, float persist_, float lacunarity_,
|
||||
int flags_)
|
||||
|
|
|
@ -24,7 +24,7 @@ public class BiomeDataOracleFlat extends MinetestBiomeDataOracle {
|
|||
flatParams = (MapgenFlatParams)params;
|
||||
} else {
|
||||
AmidstLogger.error("Error: BiomeDataOracleFlat cannot cast params to flatParams. Using defaults instead.");
|
||||
flatParams = new MapgenFlatParams();
|
||||
this.params = flatParams = new MapgenFlatParams();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BiomeDataOracleV5 extends MinetestBiomeDataOracle {
|
|||
v5params = (MapgenV5Params)params;
|
||||
} else {
|
||||
AmidstLogger.error("Error: BiomeDataOracleV5 cannot cast params to v5params. Using defaults instead.");
|
||||
v5params = new MapgenV5Params();
|
||||
this.params = v5params = new MapgenV5Params();
|
||||
}
|
||||
|
||||
noise_factor = new Noise(v5params.np_factor, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
|
|
|
@ -61,7 +61,7 @@ public class BiomeDataOracleV6 extends MinetestBiomeDataOracle {
|
|||
v6params = (MapgenV6Params)params;
|
||||
} else {
|
||||
AmidstLogger.error("Error: BiomeDataOracleV6 cannot cast params to v6params. Using defaults instead.");
|
||||
v6params = new MapgenV6Params();
|
||||
this.params = v6params = new MapgenV6Params();
|
||||
}
|
||||
|
||||
noise_terrain_base = new Noise(v6params.np_terrain_base, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class BiomeDataOracleV7 extends MinetestBiomeDataOracle {
|
|||
v7params = (MapgenV7Params)params;
|
||||
} else {
|
||||
AmidstLogger.error("Error: BiomeDataOracleV7 cannot cast params to v7params. Using defaults instead.");
|
||||
v7params = new MapgenV7Params();
|
||||
this.params = v7params = new MapgenV7Params();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import amidst.settings.biomeprofile.BiomeProfileUpdateListener;
|
|||
|
||||
public abstract class MinetestBiomeDataOracle implements IBiomeDataOracle, BiomeProfileUpdateListener {
|
||||
protected final int seed;
|
||||
protected final MapgenParams params;
|
||||
protected MapgenParams params;
|
||||
/**
|
||||
* Updated by onBiomeProfileUpdate event, can be null.
|
||||
*/
|
||||
|
@ -44,6 +44,10 @@ public abstract class MinetestBiomeDataOracle implements IBiomeDataOracle, Biome
|
|||
}
|
||||
}
|
||||
|
||||
public MapgenParams getMapgenParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
protected MinetestBiome[] getBiomeArray() {
|
||||
|
||||
MinetestBiome[] result;
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.util.function.Consumer;
|
|||
import amidst.documentation.ThreadSafe;
|
||||
import amidst.fragment.IBiomeDataOracle;
|
||||
import amidst.gameengineabstraction.world.versionfeatures.IVersionFeatures;
|
||||
import amidst.minetest.world.mapgen.MapgenParams;
|
||||
import amidst.minetest.world.oracle.MinetestBiomeDataOracle;
|
||||
import amidst.mojangapi.minecraftinterface.RecognisedVersion;
|
||||
import amidst.mojangapi.world.icon.WorldIcon;
|
||||
import amidst.mojangapi.world.icon.producer.CachedWorldIconProducer;
|
||||
|
@ -58,7 +60,6 @@ public class World {
|
|||
this.onDisposeWorld = onDisposeWorld;
|
||||
this.worldSeed = worldSeed;
|
||||
this.worldType = worldType;
|
||||
this.generatorOptions = "";
|
||||
this.movablePlayerList = movablePlayerList;
|
||||
this.recognisedVersion = recognisedVersion;
|
||||
this.versionFeatures = versionFeatures;
|
||||
|
@ -75,6 +76,15 @@ public class World {
|
|||
this.woodlandMansionProducer = null;
|
||||
this.netherFortressProducer = null;
|
||||
this.endCityProducer = null;
|
||||
|
||||
String mapgenParamsString = "";
|
||||
if (biomeDataOracle instanceof MinetestBiomeDataOracle) {
|
||||
MapgenParams params = ((MinetestBiomeDataOracle)biomeDataOracle).getMapgenParams();
|
||||
if (params != null) mapgenParamsString = params.toString();
|
||||
}
|
||||
// Repurposing the generatorOptions string from being a prescriptive
|
||||
// parameter with Minecraft, into a descriptive parameter for Minetest worlds.
|
||||
this.generatorOptions = mapgenParamsString;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue