Add v7 Floatlands support
parent
d4e05b9749
commit
9bcbfed694
|
@ -146,7 +146,7 @@ public class LayerBuilder {
|
|||
new AlphaInitializer( declarations.get(LayerIds.ALPHA), settings.fragmentFading),
|
||||
new BiomeDataLoader( declarations.get(LayerIds.BIOME_DATA), world.getBiomeDataOracle()),
|
||||
new EndIslandsLoader( declarations.get(LayerIds.END_ISLANDS), world.getEndIslandOracle()),
|
||||
new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeProfileSelection), new TheEndColorProvider())),
|
||||
new ImageLoader( declarations.get(LayerIds.BACKGROUND), Resolution.QUARTER, new BackgroundColorProvider(new BiomeColorProvider(biomeSelection, settings.biomeProfileSelection), new TheEndColorProvider())),
|
||||
new ImageLoader( declarations.get(LayerIds.MINETEST_RIVER), Resolution.QUARTER, new MinetestRiverColorProvider(Resolution.QUARTER)),
|
||||
new ImageLoader( declarations.get(LayerIds.MINETEST_OCEAN), Resolution.QUARTER, new MinetestOceanColorProvider()),
|
||||
new ImageLoader( declarations.get(LayerIds.MINETEST_MOUNTAIN), Resolution.QUARTER, new MinetestMountainColorProvider(Resolution.QUARTER)),
|
||||
|
|
|
@ -22,6 +22,7 @@ import amidst.fragment.FragmentGraphItem;
|
|||
import amidst.fragment.drawer.FragmentDrawer;
|
||||
import amidst.gui.main.viewer.widget.Widget;
|
||||
import amidst.mojangapi.world.Dimension;
|
||||
import amidst.mojangapi.world.WorldType;
|
||||
import amidst.settings.Setting;
|
||||
|
||||
@NotThreadSafe
|
||||
|
@ -42,11 +43,13 @@ public class Drawer {
|
|||
.getImage("/amidst/gui/main/dropshadow/inner_left.png");
|
||||
private static final BufferedImage DROP_SHADOW_RIGHT = ResourceLoader
|
||||
.getImage("/amidst/gui/main/dropshadow/inner_right.png");
|
||||
private static final BufferedImage VOID_TEXTURE = ResourceLoader.getImage("/amidst/gui/main/void.png");
|
||||
private static final BufferedImage VOID_TEXTURE = ResourceLoader.getImage("/amidst/gui/main/void.png");
|
||||
private static final BufferedImage VOID2_TEXTURE = ResourceLoader.getImage("/amidst/gui/main/void2.png"); // void2 is clouds, or atmospheric
|
||||
|
||||
private final AffineTransform originalLayerMatrix = new AffineTransform();
|
||||
private final AffineTransform layerMatrix = new AffineTransform();
|
||||
|
||||
private final WorldType worldType;
|
||||
private final FragmentGraph graph;
|
||||
private final FragmentGraphToScreenTranslator translator;
|
||||
private final Zoom zoom;
|
||||
|
@ -55,7 +58,7 @@ public class Drawer {
|
|||
private final Iterable<FragmentDrawer> drawers;
|
||||
private final Setting<Dimension> dimensionSetting;
|
||||
private final Graphics2DAccelerationCounter accelerationCounter;
|
||||
private final TexturePaint voidTexturePaint;
|
||||
private final TexturePaint voidTexturePaint, void2TexturePaint;
|
||||
|
||||
private Graphics2D g2d;
|
||||
private int viewerWidth;
|
||||
|
@ -68,6 +71,7 @@ public class Drawer {
|
|||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public Drawer(
|
||||
WorldType worldType,
|
||||
FragmentGraph graph,
|
||||
FragmentGraphToScreenTranslator translator,
|
||||
Zoom zoom,
|
||||
|
@ -76,6 +80,7 @@ public class Drawer {
|
|||
Iterable<FragmentDrawer> drawers,
|
||||
Setting<Dimension> dimensionSetting,
|
||||
Graphics2DAccelerationCounter accelerationCounter) {
|
||||
this.worldType = worldType;
|
||||
this.graph = graph;
|
||||
this.translator = translator;
|
||||
this.zoom = zoom;
|
||||
|
@ -87,6 +92,10 @@ public class Drawer {
|
|||
this.voidTexturePaint = new TexturePaint(
|
||||
VOID_TEXTURE,
|
||||
new Rectangle(0, 0, VOID_TEXTURE.getWidth(), VOID_TEXTURE.getHeight()));
|
||||
this.void2TexturePaint = new TexturePaint(
|
||||
VOID2_TEXTURE,
|
||||
new Rectangle(0, 0, VOID2_TEXTURE.getWidth(), VOID2_TEXTURE.getHeight()));
|
||||
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
|
@ -157,6 +166,8 @@ public class Drawer {
|
|||
private void clear() {
|
||||
if (dimensionSetting.get().equals(Dimension.END)) {
|
||||
g2d.setPaint(voidTexturePaint);
|
||||
} else if (worldType == WorldType.V7_FLOATLANDS) { // consider making "isAboveVoid" a field of WorldType if it ever applies to more than one worldtype
|
||||
g2d.setPaint(void2TexturePaint);
|
||||
} else {
|
||||
g2d.setColor(Color.black);
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ public class PerViewerFacadeInjector {
|
|||
settings,
|
||||
progressMessageHolder::getProgressMessage);
|
||||
this.drawer = new Drawer(
|
||||
world.getWorldType(),
|
||||
graph,
|
||||
translator,
|
||||
zoom,
|
||||
|
|
|
@ -13,6 +13,7 @@ import amidst.gameengineabstraction.CoordinateSystem;
|
|||
import amidst.gui.main.viewer.FragmentGraphToScreenTranslator;
|
||||
import amidst.logging.AmidstLogger;
|
||||
import amidst.logging.AmidstMessageBox;
|
||||
import amidst.minetest.world.mapgen.MinetestBiome;
|
||||
import amidst.mojangapi.world.Dimension;
|
||||
import amidst.mojangapi.world.biome.Biome;
|
||||
import amidst.mojangapi.world.biome.UnknownBiomeIndexException;
|
||||
|
@ -84,6 +85,11 @@ public class CursorInformationWidget extends TextWidget {
|
|||
try {
|
||||
return biomeAuthority.getBiomeByIndex(biome).getName();
|
||||
} catch (UnknownBiomeIndexException e) {
|
||||
if (biome == MinetestBiome.VOID.getIndex()) {
|
||||
// Special case
|
||||
return MinetestBiome.VOID.getName();
|
||||
}
|
||||
|
||||
// This can happen legitimately now, as changing the biomeprofile in minetest (not minecraft)
|
||||
// causes the biome data to be recalculated with the new biomes, which might now be fewer than
|
||||
// the index of the soon-to-be-updated biome your mouse is currently hovering over.
|
||||
|
|
|
@ -55,6 +55,7 @@ public class DefaultVersionFeatures implements VersionFeaturesFactory {
|
|||
this.worldTypes = new WorldTypes(
|
||||
new WorldType[]{
|
||||
WorldType.V7,
|
||||
WorldType.V7_FLOATLANDS,
|
||||
WorldType.V6,
|
||||
WorldType.V5,
|
||||
WorldType.CARPATHIAN,
|
||||
|
@ -87,6 +88,14 @@ public class DefaultVersionFeatures implements VersionFeaturesFactory {
|
|||
LayerIds.MINETEST_MOUNTAIN
|
||||
).construct()
|
||||
);
|
||||
enabledLayers.put(WorldType.V7_FLOATLANDS,
|
||||
VersionFeature.<Integer> listBuilder()
|
||||
.init(commonLayers)
|
||||
.initExtend(
|
||||
LayerIds.MINETEST_OCEAN,
|
||||
LayerIds.MINETEST_MOUNTAIN
|
||||
).construct()
|
||||
);
|
||||
enabledLayers.put(WorldType.V6,
|
||||
VersionFeature.<Integer> listBuilder()
|
||||
.init(commonLayers)
|
||||
|
@ -119,7 +128,11 @@ public class DefaultVersionFeatures implements VersionFeaturesFactory {
|
|||
.init(
|
||||
new AbstractMap.SimpleEntry<WorldType, TriFunction<Long, MapgenParams, BiomeProfileSelection, IBiomeDataOracle>>(
|
||||
WorldType.V7,
|
||||
(seed, mapgenParams, biomeProfile) -> new amidst.minetest.world.oracle.BiomeDataOracleV7(mapgenParams, biomeProfile, seed)
|
||||
(seed, mapgenParams, biomeProfile) -> new amidst.minetest.world.oracle.BiomeDataOracleV7(false, mapgenParams, biomeProfile, seed)
|
||||
),
|
||||
new AbstractMap.SimpleEntry<WorldType, TriFunction<Long, MapgenParams, BiomeProfileSelection, IBiomeDataOracle>>(
|
||||
WorldType.V7_FLOATLANDS,
|
||||
(seed, mapgenParams, biomeProfile) -> new amidst.minetest.world.oracle.BiomeDataOracleV7(true, mapgenParams, biomeProfile, seed)
|
||||
),
|
||||
new AbstractMap.SimpleEntry<WorldType, TriFunction<Long, MapgenParams, BiomeProfileSelection, IBiomeDataOracle>>(
|
||||
WorldType.V6,
|
||||
|
|
|
@ -12,6 +12,9 @@ public class DefaultBiomes {
|
|||
public static final String BIOMEPROFILENAME_V6 = "V6 biomes";
|
||||
public static final String BIOMEPROFILENAME_DEFAULT = "Minetest default";
|
||||
|
||||
public static final short FLOATLAND_SHADOW_LIMIT = 1024;
|
||||
public static final short FLOATLAND_LEVEL = 1280;
|
||||
|
||||
/**
|
||||
* The first item in the list will be considered the definitive biome list
|
||||
*/
|
||||
|
@ -23,39 +26,43 @@ public class DefaultBiomes {
|
|||
BIOMEPROFILENAME_DEFAULT,
|
||||
setIndexes(
|
||||
new MinetestBiome[] {
|
||||
new MinetestBiome("Icesheet", BiomeColor.from(213, 221, 240), (short) -8, Short.MAX_VALUE, 0, 73),
|
||||
new MinetestBiome("Icesheet ocean", BiomeColor.from(216, 216, 183), (short)-112, (short)-9, 0, 73),
|
||||
new MinetestBiome("Tundra", BiomeColor.from(205, 205, 216), (short) 2, Short.MAX_VALUE, 0, 40),
|
||||
new MinetestBiome("Tundra beach", BiomeColor.from(131, 131, 131), (short) -3, (short)1, 0, 40),
|
||||
new MinetestBiome("Tundra ocean", BiomeColor.from(214, 213, 179), (short)-112, (short)-4, 0, 40),
|
||||
new MinetestBiome("Taiga", BiomeColor.from(174, 191, 190), (short) 2, Short.MAX_VALUE, 25, 70),
|
||||
new MinetestBiome("Taiga ocean", BiomeColor.from(208, 210, 177), (short)-112, (short)1, 25, 70),
|
||||
new MinetestBiome("Snowy grassland", BiomeColor.from(187, 201, 187), (short) 5, Short.MAX_VALUE, 20, 35),
|
||||
new MinetestBiome("Snowy grassland ocean", BiomeColor.from(210, 212, 177), (short)-112, (short)4, 20, 35),
|
||||
new MinetestBiome("Grassland", BiomeColor.from( 76, 129, 36), (short) 6, Short.MAX_VALUE, 50, 35),
|
||||
new MinetestBiome("Grassland dunes", BiomeColor.from(174, 175, 81), (short) 4, (short)5, 50, 35),
|
||||
new MinetestBiome("Grassland ocean", BiomeColor.from(198, 204, 156), (short)-112, (short)3, 50, 35),
|
||||
new MinetestBiome("Coniferous forest", BiomeColor.from( 25, 61, 33), (short) 6, Short.MAX_VALUE, 45, 70),
|
||||
new MinetestBiome("Coniferous forest dunes", BiomeColor.from(162, 180, 114), (short) 4, (short)5, 45, 70),
|
||||
new MinetestBiome("Coniferous forest ocean", BiomeColor.from(191, 195, 156), (short)-112, (short)3, 45, 70),
|
||||
new MinetestBiome("Deciduous forest", BiomeColor.from( 12, 94, 11), (short) 1, Short.MAX_VALUE, 60, 68),
|
||||
new MinetestBiome("Deciduous forest shore", BiomeColor.from( 95, 64, 39), (short) -1, (short)0, 60, 68),
|
||||
new MinetestBiome("Deciduous forest ocean", BiomeColor.from(190, 199, 153), (short)-112, (short)-2, 60, 68),
|
||||
new MinetestBiome("Desert", BiomeColor.from(206, 199, 152), (short) 5, Short.MAX_VALUE, 92, 16),
|
||||
new MinetestBiome("Desert ocean", BiomeColor.from(215, 213, 171), (short)-112, (short)4, 92, 16),
|
||||
new MinetestBiome("Sandstone desert", BiomeColor.from(194, 168, 127), (short) 5, Short.MAX_VALUE, 60, 0),
|
||||
new MinetestBiome("Sandstone desert ocean", BiomeColor.from(212, 206, 165), (short)-112, (short)4, 60, 0),
|
||||
new MinetestBiome("Cold desert", BiomeColor.from(193, 191, 179), (short) 5, Short.MAX_VALUE, 40, 0),
|
||||
new MinetestBiome("Cold desert ocean", BiomeColor.from(211, 210, 175), (short)-112, (short)4, 40, 0),
|
||||
new MinetestBiome("Savanna", BiomeColor.from(139, 142, 64), (short) 1, Short.MAX_VALUE, 89, 42),
|
||||
new MinetestBiome("Savanna shore", BiomeColor.from(113, 95, 49), (short) -1, (short)0, 89, 42),
|
||||
new MinetestBiome("Savanna ocean", BiomeColor.from(201, 200, 152), (short)-112, (short)-2, 89, 42),
|
||||
new MinetestBiome("Rainforest", BiomeColor.from( 0, 60, 0), (short) 1, Short.MAX_VALUE, 86, 65),
|
||||
new MinetestBiome("Rainforest swamp", BiomeColor.from( 0, 40, 0), (short) -1, (short)0, 86, 65),
|
||||
new MinetestBiome("Rainforest ocean", BiomeColor.from(188, 195, 151), (short)-112, (short)-2, 86, 65),
|
||||
new MinetestBiome("Icesheet", BiomeColor.from(213, 221, 240), (short) -8, FLOATLAND_SHADOW_LIMIT, 0, 73),
|
||||
new MinetestBiome("Icesheet ocean", BiomeColor.from(216, 216, 183), (short)-112, (short)-9, 0, 73),
|
||||
new MinetestBiome("Tundra", BiomeColor.from(205, 205, 216), (short) 2, FLOATLAND_SHADOW_LIMIT, 0, 40),
|
||||
new MinetestBiome("Tundra beach", BiomeColor.from(131, 131, 131), (short) -3, (short)1, 0, 40),
|
||||
new MinetestBiome("Tundra ocean", BiomeColor.from(214, 213, 179), (short)-112, (short)-4, 0, 40),
|
||||
new MinetestBiome("Taiga", BiomeColor.from(174, 191, 190), (short) 2, FLOATLAND_SHADOW_LIMIT, 25, 70),
|
||||
new MinetestBiome("Taiga ocean", BiomeColor.from(208, 210, 177), (short)-112, (short)1, 25, 70),
|
||||
new MinetestBiome("Snowy grassland", BiomeColor.from(187, 201, 187), (short) 5, FLOATLAND_SHADOW_LIMIT, 20, 35),
|
||||
new MinetestBiome("Snowy grassland ocean", BiomeColor.from(210, 212, 177), (short)-112, (short)4, 20, 35),
|
||||
new MinetestBiome("Grassland", BiomeColor.from( 76, 129, 36), (short) 6, FLOATLAND_SHADOW_LIMIT, 50, 35),
|
||||
new MinetestBiome("Grassland dunes", BiomeColor.from(174, 175, 81), (short) 4, (short)5, 50, 35),
|
||||
new MinetestBiome("Grassland ocean", BiomeColor.from(198, 204, 156), (short)-112, (short)3, 50, 35),
|
||||
new MinetestBiome("Coniferous forest", BiomeColor.from( 25, 61, 33), (short) 6, FLOATLAND_SHADOW_LIMIT, 45, 70),
|
||||
new MinetestBiome("Coniferous forest dunes", BiomeColor.from(162, 180, 114), (short) 4, (short)5, 45, 70),
|
||||
new MinetestBiome("Coniferous forest ocean", BiomeColor.from(191, 195, 156), (short)-112, (short)3, 45, 70),
|
||||
new MinetestBiome("Deciduous forest", BiomeColor.from( 12, 94, 11), (short) 1, FLOATLAND_SHADOW_LIMIT, 60, 68),
|
||||
new MinetestBiome("Deciduous forest shore", BiomeColor.from( 95, 64, 39), (short) -1, (short)0, 60, 68),
|
||||
new MinetestBiome("Deciduous forest ocean", BiomeColor.from(190, 199, 153), (short)-112, (short)-2, 60, 68),
|
||||
new MinetestBiome("Desert", BiomeColor.from(206, 199, 152), (short) 5, FLOATLAND_SHADOW_LIMIT, 92, 16),
|
||||
new MinetestBiome("Desert ocean", BiomeColor.from(215, 213, 171), (short)-112, (short)4, 92, 16),
|
||||
new MinetestBiome("Sandstone desert", BiomeColor.from(194, 168, 127), (short) 5, FLOATLAND_SHADOW_LIMIT, 60, 0),
|
||||
new MinetestBiome("Sandstone desert ocean", BiomeColor.from(212, 206, 165), (short)-112, (short)4, 60, 0),
|
||||
new MinetestBiome("Cold desert", BiomeColor.from(193, 191, 179), (short) 5, FLOATLAND_SHADOW_LIMIT, 40, 0),
|
||||
new MinetestBiome("Cold desert ocean", BiomeColor.from(211, 210, 175), (short)-112, (short)4, 40, 0),
|
||||
new MinetestBiome("Savanna", BiomeColor.from(139, 142, 64), (short) 1, FLOATLAND_SHADOW_LIMIT, 89, 42),
|
||||
new MinetestBiome("Savanna shore", BiomeColor.from(113, 95, 49), (short) -1, (short)0, 89, 42),
|
||||
new MinetestBiome("Savanna ocean", BiomeColor.from(201, 200, 152), (short)-112, (short)-2, 89, 42),
|
||||
new MinetestBiome("Rainforest", BiomeColor.from( 0, 60, 0), (short) 1, FLOATLAND_SHADOW_LIMIT, 86, 65),
|
||||
new MinetestBiome("Rainforest swamp", BiomeColor.from( 0, 40, 0), (short) -1, (short)0, 86, 65),
|
||||
new MinetestBiome("Rainforest ocean", BiomeColor.from(188, 195, 151), (short)-112, (short)-2, 86, 65),
|
||||
|
||||
// Underground (normally Amidst don't care, but here it's needed because ocean floor can drop lower than -112)
|
||||
new MinetestBiome("Underground", BiomeColor.from( 20, 20, 20), Short.MIN_VALUE, (short)-113, 50, 50)
|
||||
new MinetestBiome("Underground", BiomeColor.from( 20, 20, 20), Short.MIN_VALUE, (short)-113, 50, 50),
|
||||
|
||||
// Floatlands
|
||||
new MinetestBiome("Floatland grassland", BiomeColor.from( 76, 129, 36), (short)(FLOATLAND_LEVEL + 4), Short.MAX_VALUE, 50, 50),
|
||||
new MinetestBiome("Floatland grassland ocean", BiomeColor.from(198, 204, 156), FLOATLAND_SHADOW_LIMIT, (short)(FLOATLAND_LEVEL + 3), 50, 50)
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
|
@ -6,7 +6,10 @@ import amidst.mojangapi.world.biome.BiomeColor;
|
|||
|
||||
public class MinetestBiome extends BiomeBase {
|
||||
|
||||
public static MinetestBiome NONE = new MinetestBiome("None", -1, BiomeColor.from(0, 0, 0), (short)0, (short)0, 0, 0);
|
||||
// The index for out-of-bounds biomes must be (Short.MIN_VALUE + x) rather than -x, as values
|
||||
// like -1 would be destroyed by applying a bitplane mask.
|
||||
public static MinetestBiome NONE = new MinetestBiome("None", Short.MIN_VALUE + 1, BiomeColor.from(0, 0, 0), (short)0, (short)0, 0, 0);
|
||||
public static MinetestBiome VOID = new MinetestBiome("Void", Short.MIN_VALUE + 2, BiomeColor.transparent(), (short)0, (short)0, 0, 0);
|
||||
|
||||
protected MinetestBiome(String name, BiomeColor defaultColor, short y_min, short y_max, float heat_point, float humidity_point) {
|
||||
this(name, -1, defaultColor, y_min, y_max, heat_point, humidity_point);
|
||||
|
|
|
@ -3,6 +3,7 @@ package amidst.minetest.world.oracle;
|
|||
import amidst.documentation.Immutable;
|
||||
import amidst.logging.AmidstLogger;
|
||||
import amidst.logging.AmidstMessageBox;
|
||||
import amidst.minetest.world.mapgen.Constants;
|
||||
import amidst.minetest.world.mapgen.InvalidNoiseParamsException;
|
||||
import amidst.minetest.world.mapgen.MapgenParams;
|
||||
import amidst.minetest.world.mapgen.MapgenV7Params;
|
||||
|
@ -14,6 +15,8 @@ import amidst.settings.biomeprofile.BiomeProfileSelection;
|
|||
|
||||
@Immutable
|
||||
public class BiomeDataOracleV7 extends MinetestBiomeDataOracle {
|
||||
|
||||
private boolean isFloatlands;
|
||||
private final MapgenV7Params v7params;
|
||||
|
||||
private Noise noise_terrain_base;
|
||||
|
@ -25,7 +28,7 @@ public class BiomeDataOracleV7 extends MinetestBiomeDataOracle {
|
|||
private Noise noise_floatland_base;
|
||||
private Noise noise_float_base_height;
|
||||
private Noise noise_mountain;
|
||||
private Noise noise_ridge;
|
||||
//private Noise noise_ridge;
|
||||
//private Noise noise_filler_depth; // commented out because it shouldn't been needed for the surface
|
||||
|
||||
|
||||
|
@ -46,9 +49,10 @@ public class BiomeDataOracleV7 extends MinetestBiomeDataOracle {
|
|||
* @param seed
|
||||
* @throws InvalidNoiseParamsException
|
||||
*/
|
||||
public BiomeDataOracleV7(MapgenParams mapgenV7Params, BiomeProfileSelection biomeProfileSelection, long seed) {
|
||||
public BiomeDataOracleV7(boolean is_floatlands, MapgenParams mapgenV7Params, BiomeProfileSelection biomeProfileSelection, long seed) {
|
||||
|
||||
super(mapgenV7Params, biomeProfileSelection, seed);
|
||||
this.isFloatlands = is_floatlands;
|
||||
|
||||
if (params instanceof MapgenV7Params) {
|
||||
v7params = (MapgenV7Params)params;
|
||||
|
@ -56,37 +60,34 @@ public class BiomeDataOracleV7 extends MinetestBiomeDataOracle {
|
|||
AmidstLogger.error("Error: BiomeDataOracleV7 cannot cast params to v7params. Using defaults instead.");
|
||||
this.params = v7params = new MapgenV7Params();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This is to avoid a divide-by-zero.
|
||||
// Parameter will be saved to map_meta.txt in limited form.
|
||||
v7params.float_mount_height = Math.max(v7params.float_mount_height, 1.0f);
|
||||
float_mount_height = v7params.float_mount_height;
|
||||
|
||||
|
||||
// 2D noise
|
||||
// TODO: Set these to the fragment size, rather than minetest's chunklength, and use the faster noise funcs (set scale appropriately)
|
||||
try {
|
||||
noise_terrain_base = new Noise(v7params.np_terrain_base, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_terrain_alt = new Noise(v7params.np_terrain_alt, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_terrain_persist = new Noise(v7params.np_terrain_persist, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_height_select = new Noise(v7params.np_height_select, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
//noise_filler_depth = new Noise(v7params.np_filler_depth, this.seed, v7params.chunk_length_x, v7params.chunk_length_z);
|
||||
|
||||
if (isFloatlands) {
|
||||
noise_floatland_base = new Noise(v7params.np_floatland_base, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_float_base_height = new Noise(v7params.np_float_base_height, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
} else {
|
||||
noise_terrain_base = new Noise(v7params.np_terrain_base, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_terrain_alt = new Noise(v7params.np_terrain_alt, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_terrain_persist = new Noise(v7params.np_terrain_persist, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_height_select = new Noise(v7params.np_height_select, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
//noise_filler_depth = new Noise(v7params.np_filler_depth, this.seed, v7params.chunk_length_x, v7params.chunk_length_z);
|
||||
}
|
||||
|
||||
// Mountains layer might be displayed even if mountains are off, so initialize these regardless
|
||||
noise_mount_height = new Noise(v7params.np_mount_height, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_mountain = new Noise(v7params.np_mountain, this.seed, params.chunk_length_x, params.chunk_length_y + 2, params.chunk_length_z);
|
||||
|
||||
if ((v7params.spflags & MapgenV7Params.FLAG_V7_FLOATLANDS) > 0) {
|
||||
noise_floatland_base = new Noise(v7params.np_floatland_base, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
noise_float_base_height = new Noise(v7params.np_float_base_height, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
}
|
||||
|
||||
if ((v7params.spflags & MapgenV7Params.FLAG_V7_RIDGES) > 0) {
|
||||
noise_ridge_uwater = new Noise(v7params.np_ridge_uwater, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
|
||||
// 3D noise, 1-up 1-down overgeneration
|
||||
noise_ridge = new Noise(v7params.np_ridge, this.seed, params.chunk_length_x, params.chunk_length_y + 2, params.chunk_length_z);
|
||||
}
|
||||
|
||||
// River layer might be displayed even if ridges are off, so initialize these regardless
|
||||
noise_ridge_uwater = new Noise(v7params.np_ridge_uwater, this.seed, params.chunk_length_x, params.chunk_length_z);
|
||||
// 3D noise, 1-up 1-down overgeneration
|
||||
//noise_ridge = new Noise(v7params.np_ridge, this.seed, params.chunk_length_x, params.chunk_length_y + 2, params.chunk_length_z);
|
||||
|
||||
} catch (InvalidNoiseParamsException ex) {
|
||||
AmidstLogger.error("Invalid v7params from Minetest game. " + ex);
|
||||
|
@ -128,9 +129,15 @@ public class BiomeDataOracleV7 extends MinetestBiomeDataOracle {
|
|||
|
||||
return (height_base * hselect) + (height_alt * (1.0f - hselect));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short populateArray(CoordinatesInWorld corner, short[][] result, boolean useQuarterResolution) {
|
||||
return isFloatlands ?
|
||||
populateArray_floatlands(corner, result, useQuarterResolution) :
|
||||
populateArray_groundlevel(corner, result, useQuarterResolution);
|
||||
}
|
||||
|
||||
public short populateArray_groundlevel(CoordinatesInWorld corner, short[][] result, boolean useQuarterResolution) {
|
||||
|
||||
// The v7 mapgen terrain has been officially stable since 0.4.16 when it was made the default
|
||||
// mapgen, however the optional floatlands (disabled by default) are not stable yet, maybe they
|
||||
|
@ -242,22 +249,116 @@ public class BiomeDataOracleV7 extends MinetestBiomeDataOracle {
|
|||
}
|
||||
return MASK_BITPLANES;
|
||||
}
|
||||
|
||||
public boolean isFloatlandMountain(int x, int height_above_floatland_level, int z) {
|
||||
float density_gradient = (float) -Math.pow(height_above_floatland_level / float_mount_height, float_mount_exponent);
|
||||
float floatn = Noise.NoisePerlin3D(noise_mountain.np, x, height_above_floatland_level + floatland_level, z, seed) + float_mount_density;
|
||||
return floatn + density_gradient >= 0.0f;
|
||||
}
|
||||
|
||||
public short populateArray_floatlands(CoordinatesInWorld corner, short[][] result, boolean useQuarterResolution) {
|
||||
|
||||
// The v7 mapgen terrain has been officially stable since 0.4.16 when it was made the default
|
||||
// mapgen, however the optional floatlands (disabled by default) are not stable yet, maybe they
|
||||
// will be for 0.5.0.
|
||||
// See https://forum.minetest.net/viewtopic.php?f=18&t=19132
|
||||
|
||||
int width = result.length;
|
||||
if (width > 0) {
|
||||
Resolution resolution = Resolution.from(useQuarterResolution);
|
||||
int height = result[0].length;
|
||||
int left = (int) corner.getX();
|
||||
int top = (int) corner.getY();
|
||||
int shift = resolution.getShift();
|
||||
int step = resolution.getStep();
|
||||
int world_z;
|
||||
int world_x;
|
||||
short biomeValue;
|
||||
MinetestBiome[] biomes = getBiomeArray();
|
||||
|
||||
try {
|
||||
for (int z = 0; z < height; z++) {
|
||||
|
||||
world_z = top + (z << shift);
|
||||
world_x = left;
|
||||
|
||||
// Use -world_z because Minetest uses left-handed coordinates, while Minecraft
|
||||
// and Amidst use right-handed coordinates.
|
||||
world_z = -world_z;
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
|
||||
biomeValue = 0;
|
||||
|
||||
short surface_y = Constants.MAX_MAP_GENERATION_LIMIT;
|
||||
|
||||
/*
|
||||
public static void copyToResult(short[][] result, int width, int height, int[] biomeData) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
result[x][y] = (short) biomeData[getBiomeDataIndex(x, y, width)];
|
||||
// Calculate floatland plains
|
||||
float n_base = Noise.NoisePerlin2D(noise_floatland_base.np, world_x, world_z, seed);
|
||||
if (n_base > 0.0f) {
|
||||
float n_base_height = Math.max(1.0f, Noise.NoisePerlin2D(noise_float_base_height.np, world_x, world_z, seed));
|
||||
float amp = n_base * n_base_height;
|
||||
float ridge = n_base_height / 3.0f;
|
||||
|
||||
if (amp > ridge * 2.0f) {
|
||||
// Lake bed
|
||||
surface_y = (short)(floatland_level - (amp - ridge * 2.0f) / 2.0f);
|
||||
biomeValue |= BITPLANE_OCEAN;
|
||||
} else {
|
||||
// Hills and ridges
|
||||
float diff = Math.abs(amp - ridge) / ridge;
|
||||
// Smooth ridges using the 'smoothstep function'
|
||||
float smooth_diff = diff * diff * (3.0f - 2.0f * diff);
|
||||
surface_y = (short)(floatland_level + ridge - smooth_diff * ridge);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate floatland mountains
|
||||
if (isFloatlandMountain(world_x, 0, world_z)) {
|
||||
// Mountains are here
|
||||
if (surface_y == Constants.MAX_MAP_GENERATION_LIMIT) {
|
||||
// there aren't any floatlands plains here to have already set surface_y, so set
|
||||
// it to what we know of these mountains.
|
||||
surface_y = floatland_level; // we know there is ground here
|
||||
}
|
||||
|
||||
// Remove ocean since mountains are at least at floatland_level.
|
||||
// This makes the oceans more correct, but the biome here might be wrong since
|
||||
// we haven't worked out the real height.
|
||||
if ((biomeValue & BITPLANE_OCEAN) > 0) biomeValue -= BITPLANE_OCEAN;
|
||||
|
||||
// check if mountains are lower than 4, so that default biome beaches are right
|
||||
// TODO: Perhaps do a logarithmic search for the height like we do in v5 oracle
|
||||
if (isFloatlandMountain(world_x, 4, world_z)) {
|
||||
// Ground is at least 4 high.
|
||||
// Mountains are here, but since we only have a 1-bit plane to represent them, lets
|
||||
// only draw ones that are quite high
|
||||
if (isFloatlandMountain(world_x, cMimimumMountainHeight, world_z)) {
|
||||
surface_y = (short) Math.max(surface_y, cMimimumMountainHeight + floatland_level); // we know the ground here is at least 4 high
|
||||
biomeValue |= BITPLANE_MOUNTAIN;
|
||||
} else {
|
||||
surface_y = (short) Math.max(surface_y, 4 + floatland_level); // we know the ground here is at least 4 high
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (surface_y < Constants.MAX_MAP_GENERATION_LIMIT) {
|
||||
// add the biome index
|
||||
// (mask the bitplanes in case the biome returned is -1 (NONE)
|
||||
biomeValue |= calcBiomeAtPoint(biomes, world_x, surface_y, world_z).getIndex() & MASK_BITPLANES;
|
||||
} else {
|
||||
// It's a long fall
|
||||
biomeValue = (short) MinetestBiome.VOID.getIndex();
|
||||
}
|
||||
|
||||
result[x][z] = biomeValue;
|
||||
world_x += step;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
AmidstLogger.error(e);
|
||||
AmidstMessageBox.displayError("Error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int[] getBiomeData(int x, int y, int width, int height, boolean useQuarterResolution)
|
||||
throws UnsupportedOperationException {
|
||||
|
||||
// return minecraftInterface.getBiomeData(x, y, width, height, useQuarterResolution);
|
||||
throw new UnsupportedOperationException("getBiomeData (minetest)");
|
||||
}*/
|
||||
|
||||
return MASK_BITPLANES;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,19 +8,20 @@ import amidst.mojangapi.minecraftinterface.local.SymbolicNames;
|
|||
@Immutable
|
||||
public enum WorldType {
|
||||
// @formatter:off
|
||||
DEFAULT ("Default", "default", SymbolicNames.FIELD_WORLD_TYPE_DEFAULT),
|
||||
FLAT ("Flat", "flat", SymbolicNames.FIELD_WORLD_TYPE_FLAT),
|
||||
LARGE_BIOMES ("Large Biomes", "large-biomes", SymbolicNames.FIELD_WORLD_TYPE_LARGE_BIOMES),
|
||||
AMPLIFIED ("Amplified", "amplified", SymbolicNames.FIELD_WORLD_TYPE_AMPLIFIED),
|
||||
CUSTOMIZED ("Customized", "customized", SymbolicNames.FIELD_WORLD_TYPE_CUSTOMIZED),
|
||||
DEFAULT ("Default", "default", SymbolicNames.FIELD_WORLD_TYPE_DEFAULT),
|
||||
FLAT ("Flat", "flat", SymbolicNames.FIELD_WORLD_TYPE_FLAT),
|
||||
LARGE_BIOMES ("Large Biomes", "large-biomes", SymbolicNames.FIELD_WORLD_TYPE_LARGE_BIOMES),
|
||||
AMPLIFIED ("Amplified", "amplified", SymbolicNames.FIELD_WORLD_TYPE_AMPLIFIED),
|
||||
CUSTOMIZED ("Customized", "customized", SymbolicNames.FIELD_WORLD_TYPE_CUSTOMIZED),
|
||||
|
||||
// Minetest world types
|
||||
V5 ("v5", "v5", null),
|
||||
V6 ("v6", "v6", null),
|
||||
V7 ("v7", "v7", null),
|
||||
V5 ("v5", "v5", null),
|
||||
V6 ("v6", "v6", null),
|
||||
V7 ("v7", "v7", null),
|
||||
V7_FLOATLANDS ("v7 Floatlands", "v7floatlands", null),
|
||||
// FLAT - can reuse the minecraft FLAT
|
||||
FRACTAL ("Fractal", "fractal", null),
|
||||
CARPATHIAN ("Carpathian", "carpathian", null);
|
||||
FRACTAL ("Fractal", "fractal", null),
|
||||
CARPATHIAN ("Carpathian", "carpathian", null);
|
||||
// @formatter:on
|
||||
|
||||
public static final String PROMPT_EACH_TIME = "Prompt each time";
|
||||
|
|
|
@ -22,9 +22,14 @@ public class BiomeColor {
|
|||
public static BiomeColor error() {
|
||||
return ERROR_BIOME_COLOR;
|
||||
}
|
||||
|
||||
public static BiomeColor transparent() {
|
||||
return TRANSPARENT_BIOME_COLOR;
|
||||
}
|
||||
|
||||
private static final BiomeColor UNKNOWN_BIOME_COLOR = new BiomeColor(0, 0, 0);
|
||||
private static final BiomeColor ERROR_BIOME_COLOR = new BiomeColor(255, 0, 255);
|
||||
private static final BiomeColor UNKNOWN_BIOME_COLOR = new BiomeColor(0, 0, 0);
|
||||
private static final BiomeColor ERROR_BIOME_COLOR = new BiomeColor(255, 0, 255);
|
||||
private static final BiomeColor TRANSPARENT_BIOME_COLOR = new BiomeColor(0, 0, 0, 0);
|
||||
|
||||
private static final int DESELECT_NUMBER = 30;
|
||||
private static final int LIGHTEN_BRIGHTNESS = 40;
|
||||
|
@ -36,26 +41,31 @@ public class BiomeColor {
|
|||
private final int deselectRGB;
|
||||
private final Color color;
|
||||
|
||||
|
||||
private BiomeColor(int r, int g, int b) {
|
||||
this(r, g, b, 255);
|
||||
}
|
||||
|
||||
private BiomeColor(int r, int g, int b, int alpha) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.rgb = createRGB(r, g, b);
|
||||
this.deselectRGB = createDeselectRGB(r, g, b);
|
||||
this.color = new Color(r, g, b);
|
||||
this.rgb = createRGB(r, g, b, alpha);
|
||||
this.deselectRGB = createDeselectRGB(r, g, b, alpha);
|
||||
this.color = new Color(r, g, b, alpha);
|
||||
}
|
||||
|
||||
private int createRGB(int r, int g, int b) {
|
||||
int result = 0xFF000000;
|
||||
private int createRGB(int r, int g, int b, int alpha) {
|
||||
int result = 0xFF000000 & (alpha << 24);
|
||||
result |= 0xFF0000 & (r << 16);
|
||||
result |= 0xFF00 & (g << 8);
|
||||
result |= 0xFF & b;
|
||||
return result;
|
||||
}
|
||||
|
||||
private int createDeselectRGB(int r, int g, int b) {
|
||||
private int createDeselectRGB(int r, int g, int b, int alpha) {
|
||||
int sum = r + g + b;
|
||||
return createRGB(deselect(r, sum), deselect(g, sum), deselect(b, sum));
|
||||
return createRGB(deselect(r, sum), deselect(g, sum), deselect(b, sum), alpha);
|
||||
}
|
||||
|
||||
private int deselect(int x, int average) {
|
||||
|
|
|
@ -38,7 +38,11 @@ public class BiomeProfileSelection {
|
|||
private BiomeColor getBiomeColor(int index) throws UnknownBiomeIndexException {
|
||||
BiomeColor[] biomeColors = this.biomeColors;
|
||||
if (index < 0 || index >= biomeColors.length || biomeColors[index] == null) {
|
||||
throw new UnknownBiomeIndexException("unsupported biome index detected: " + index);
|
||||
if (index == MinetestBiome.VOID.getIndex()) {
|
||||
return BiomeColor.transparent();
|
||||
} else {
|
||||
throw new UnknownBiomeIndexException("unsupported biome index detected: " + index);
|
||||
}
|
||||
} else {
|
||||
return biomeColors[index];
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Loading…
Reference in New Issue