Skip to content

Commit 9c6525f

Browse files
committed
Add MineClone 2 biomes
1 parent a3a59f6 commit 9c6525f

File tree

3 files changed

+209
-1
lines changed

3 files changed

+209
-1
lines changed

src/main/java/amidst/minetest/world/mapgen/DefaultBiomes.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ public static Map<String, MinetestBiome[]> getDefaultBiomeSets() {
215215
}
216216
)
217217
);
218-
218+
219+
biomeLists.put("MineClone 2", setIndexes(MineCloneBiomes.getBiomeList()));
219220
}
220221
return biomeLists;
221222
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
package amidst.minetest.world.mapgen;
2+
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.LinkedHashMap;
6+
import java.util.Map;
7+
import java.util.stream.Collectors;
8+
9+
import amidst.logging.AmidstLogger;
10+
import amidst.mojangapi.world.biome.BiomeColor;
11+
12+
/**
13+
* Generates a list of all the biomes that MineClone 2 uses
14+
*/
15+
public class MineCloneBiomes {
16+
17+
private static final short OVERWORLD_MIN = -62;
18+
private static final short OVERWORLD_MAX = 31000;
19+
private static final short OCEAN_MIN = -15;
20+
private static final short DEEP_OCEAN_MIN = -31;
21+
private static final short DEEP_OCEAN_MAX = OCEAN_MIN - 1;
22+
23+
private static final BiomeColor BEACH_BLEND_COLOR = BiomeColor.from(232, 224, 171); // sand
24+
private static final BiomeColor OCEAN_BLEND_COLOR = BiomeColor.from(214, 207, 158); // sand floor
25+
private static final BiomeColor DEEP_OCEAN_BLEND_COLOR = BiomeColor.from(190, 190, 190); // gravel floor
26+
27+
private static Map<String, BiomeColor> baseBiomes = null;
28+
29+
private enum ColorModifier {
30+
None,
31+
Beach,
32+
Ocean,
33+
DeepOcean
34+
}
35+
36+
private static BiomeColor getColor(String baseBiomeName, ColorModifier modifier) {
37+
38+
BiomeColor baseColor = baseBiomes.get(baseBiomeName);
39+
if (baseColor == null) {
40+
AmidstLogger.error("Base MineClone biome not found: " + baseBiomeName);
41+
return BiomeColor.error();
42+
}
43+
44+
switch(modifier) {
45+
case Beach: return baseColor.blend(0.83f, BEACH_BLEND_COLOR);
46+
case Ocean: return baseColor.blend(0.83f, OCEAN_BLEND_COLOR);
47+
case DeepOcean: return baseColor.blend(0.83f, DEEP_OCEAN_BLEND_COLOR);
48+
default: return baseColor;
49+
}
50+
}
51+
52+
public static MinetestBiome[] getBiomeList() {
53+
54+
if (baseBiomes == null) {
55+
baseBiomes = new LinkedHashMap<String, BiomeColor>();
56+
baseBiomes.put("IcePlains", BiomeColor.from(255, 255, 255));
57+
baseBiomes.put("IcePlainsSpikes", BiomeColor.from(140, 180, 180));
58+
baseBiomes.put("ColdTaiga", BiomeColor.from( 49, 85, 74));
59+
baseBiomes.put("ExtremeHills", BiomeColor.from( 96, 96, 96));
60+
baseBiomes.put("ExtremeHillsM", BiomeColor.from( 76, 76, 76));
61+
baseBiomes.put("ExtremeHills+", BiomeColor.from(114, 120, 154));
62+
baseBiomes.put("Taiga", BiomeColor.from( 11, 102, 89));
63+
baseBiomes.put("MegaTaiga", BiomeColor.from( 49, 85, 74));
64+
baseBiomes.put("MegaSpruceTaiga", BiomeColor.from( 89, 102, 81));
65+
baseBiomes.put("StoneBeach", BiomeColor.from(162, 162, 132));
66+
baseBiomes.put("Plains", BiomeColor.from(141, 179, 96));
67+
baseBiomes.put("SunflowerPlains", BiomeColor.from(141, 179, 96));
68+
baseBiomes.put("Forest", BiomeColor.from( 5, 102, 33));
69+
baseBiomes.put("FlowerForest", BiomeColor.from( 32, 175, 180));
70+
baseBiomes.put("BirchForest", BiomeColor.from( 48, 116, 68));
71+
baseBiomes.put("BirchForestM", BiomeColor.from( 38, 106, 58));
72+
baseBiomes.put("RoofedForest", BiomeColor.from( 64, 81, 26));
73+
baseBiomes.put("Swampland", BiomeColor.from( 7, 249, 178));
74+
baseBiomes.put("Jungle", BiomeColor.from( 83, 123, 9));
75+
baseBiomes.put("JungleM", BiomeColor.from( 73, 113, 6));
76+
baseBiomes.put("JungleEdge", BiomeColor.from( 98, 139, 23));
77+
baseBiomes.put("JungleEdgeM", BiomeColor.from( 88, 129, 18));
78+
baseBiomes.put("MushroomIsland", BiomeColor.from(255, 0, 255));
79+
baseBiomes.put("Desert", BiomeColor.from(250, 148, 24));
80+
baseBiomes.put("Savanna", BiomeColor.from(189, 178, 95));
81+
baseBiomes.put("SavannaM", BiomeColor.from(167, 157, 100));
82+
baseBiomes.put("Mesa", BiomeColor.from(217, 69, 21));
83+
baseBiomes.put("MesaPlateauF", BiomeColor.from(176, 151, 101));
84+
}
85+
86+
ArrayList<MinetestBiome> biomes = new ArrayList<MinetestBiome>(
87+
Arrays.asList(
88+
new MinetestBiome("IcePlainsSpikes", getColor("IcePlainsSpikes", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, -5, 24),
89+
new MinetestBiome("IcePlainsSpikes ocean", getColor("IcePlainsSpikes", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, -5, 24),
90+
new MinetestBiome("ColdTaiga", getColor("ColdTaiga", ColorModifier.None), (short) 3, (short) OVERWORLD_MAX, 8, 58),
91+
new MinetestBiome("ColdTaiga beach", getColor("ColdTaiga", ColorModifier.Beach), (short) 1, (short) 2, 8, 58),
92+
new MinetestBiome("ColdTaiga beach water", getColor("ColdTaiga", ColorModifier.Ocean), (short) -3, (short) 0, 8, 58),
93+
new MinetestBiome("ColdTaiga ocean", getColor("ColdTaiga", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -4, 8, 58),
94+
new MinetestBiome("MegaTaiga", getColor("MegaTaiga", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 10, 76),
95+
new MinetestBiome("MegaTaiga ocean", getColor("MegaTaiga", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 10, 76),
96+
new MinetestBiome("MegaSpruceTaiga", getColor("MegaSpruceTaiga", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 8, 100),
97+
new MinetestBiome("MegaSpruceTaiga ocean", getColor("MegaSpruceTaiga", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 8, 100),
98+
new MinetestBiome("ExtremeHills", getColor("ExtremeHills", ColorModifier.None), (short) 4, (short) OVERWORLD_MAX, 45, 10),
99+
new MinetestBiome("ExtremeHills beach", getColor("ExtremeHills", ColorModifier.Beach), (short) -3, (short) 3, 45, 10),
100+
new MinetestBiome("ExtremeHills ocean", getColor("ExtremeHills", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -4, 45, 10),
101+
new MinetestBiome("ExtremeHillsM", getColor("ExtremeHillsM", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 25, 0),
102+
new MinetestBiome("ExtremeHillsM ocean", getColor("ExtremeHillsM", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 25, 0),
103+
new MinetestBiome("ExtremeHills+", getColor("ExtremeHills+", ColorModifier.None), (short) 1, (short) 44, 25, 24),
104+
new MinetestBiome("ExtremeHills+ snowtop", BiomeColor.from(230, 230, 255), (short) 45, (short) OVERWORLD_MAX, 25, 24),
105+
new MinetestBiome("ExtremeHills+ ocean", getColor("ExtremeHills+", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 25, 24),
106+
new MinetestBiome("StoneBeach", getColor("StoneBeach", ColorModifier.None), (short) -6, (short) OVERWORLD_MAX, 8, 0),
107+
new MinetestBiome("StoneBeach ocean", getColor("StoneBeach", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -7, 8, 0),
108+
new MinetestBiome("IcePlains", getColor("IcePlains", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 8, 24),
109+
new MinetestBiome("IcePlains ocean", getColor("IcePlains", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 8, 24),
110+
new MinetestBiome("Plains", getColor("Plains", ColorModifier.None), (short) 3, (short) OVERWORLD_MAX, 58, 39),
111+
new MinetestBiome("Plains beach", getColor("Plains", ColorModifier.Beach), (short) 0, (short) 2, 58, 39),
112+
new MinetestBiome("Plains ocean", getColor("Plains", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -1, 58, 39),
113+
new MinetestBiome("SunflowerPlains", getColor("SunflowerPlains", ColorModifier.None), (short) 4, (short) OVERWORLD_MAX, 45, 28),
114+
new MinetestBiome("SunflowerPlains ocean", getColor("SunflowerPlains", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 45, 28),
115+
new MinetestBiome("Taiga", getColor("Taiga", ColorModifier.None), (short) 4, (short) OVERWORLD_MAX, 22, 58),
116+
new MinetestBiome("Taiga beach", getColor("Taiga", ColorModifier.Beach), (short) 1, (short) 3, 22, 58),
117+
new MinetestBiome("Taiga ocean", getColor("Taiga", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 22, 58),
118+
new MinetestBiome("Forest", getColor("Forest", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 45, 61),
119+
new MinetestBiome("Forest beach", getColor("Forest", ColorModifier.Beach), (short) -1, (short) 0, 45, 61),
120+
new MinetestBiome("Forest ocean", getColor("Forest", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -2, 45, 61),
121+
new MinetestBiome("FlowerForest", getColor("FlowerForest", ColorModifier.None), (short) 3, (short) OVERWORLD_MAX, 32, 44),
122+
new MinetestBiome("FlowerForest beach", getColor("FlowerForest", ColorModifier.Beach), (short) -2, (short) 2, 32, 44),
123+
new MinetestBiome("FlowerForest ocean", getColor("FlowerForest", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -3, 32, 44),
124+
new MinetestBiome("BirchForest", getColor("BirchForest", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 31, 78),
125+
new MinetestBiome("BirchForest ocean", getColor("BirchForest", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 31, 78),
126+
new MinetestBiome("BirchForestM", getColor("BirchForestM", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 27, 77),
127+
new MinetestBiome("BirchForestM ocean", getColor("BirchForestM", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 27, 77),
128+
new MinetestBiome("Desert", getColor("Desert", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 94, 26),
129+
new MinetestBiome("Desert ocean", getColor("Desert", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 94, 26),
130+
new MinetestBiome("RoofedForest", getColor("RoofedForest", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 27, 94),
131+
new MinetestBiome("RoofedForest ocean", getColor("RoofedForest", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 27, 94),
132+
new MinetestBiome("Mesa", getColor("Mesa", ColorModifier.None), (short) 11, (short) OVERWORLD_MAX, 100, 0),
133+
new MinetestBiome("Mesa sandlevel", getColor("Mesa", ColorModifier.Beach), (short) -3, (short) 10, 100, 0),
134+
new MinetestBiome("Mesa ocean", getColor("Mesa", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -4, 100, 0),
135+
new MinetestBiome("MesaPlateauF", getColor("MesaPlateauF", ColorModifier.None), (short) 11, (short) 29, 60, 0),
136+
new MinetestBiome("MesaPlateauF grasstop", BiomeColor.from(202, 140, 101), (short) 30, (short) OVERWORLD_MAX, 60, 0),
137+
new MinetestBiome("MesaPlateauF sandlevel", getColor("MesaPlateauF", ColorModifier.Beach), (short) -3, (short) 10, 60, 0),
138+
new MinetestBiome("MesaPlateauF ocean", getColor("MesaPlateauF", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -4, 60, 0),
139+
new MinetestBiome("Savanna", getColor("Savanna", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 79, 36),
140+
new MinetestBiome("Savanna beach", getColor("Savanna", ColorModifier.Beach), (short) -1, (short) 0, 79, 36),
141+
new MinetestBiome("Savanna ocean", getColor("Savanna", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -2, 79, 36),
142+
new MinetestBiome("SavannaM", getColor("SavannaM", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 100, 48),
143+
new MinetestBiome("SavannaM ocean", getColor("SavannaM", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 100, 48),
144+
new MinetestBiome("Jungle", getColor("Jungle", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 81, 88),
145+
new MinetestBiome("Jungle shore", getColor("Jungle", ColorModifier.Beach), (short) -1, (short) 0, 81, 88),
146+
new MinetestBiome("Jungle ocean", getColor("Jungle", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -2, 81, 88),
147+
new MinetestBiome("JungleM", getColor("JungleM", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 81, 92),
148+
new MinetestBiome("JungleM shore", getColor("JungleM", ColorModifier.Beach), (short) -1, (short) 0, 81, 92),
149+
new MinetestBiome("JungleM ocean", getColor("JungleM", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -2, 81, 92),
150+
new MinetestBiome("JungleEdge", getColor("JungleEdge", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 76, 88),
151+
new MinetestBiome("JungleEdge ocean", getColor("JungleEdge", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 76, 88),
152+
new MinetestBiome("JungleEdgeM", getColor("JungleEdgeM", ColorModifier.None), (short) 1, (short) OVERWORLD_MAX, 79, 90),
153+
new MinetestBiome("JungleEdgeM ocean", getColor("JungleEdgeM", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 79, 90),
154+
new MinetestBiome("Swampland", getColor("Swampland", ColorModifier.None), (short) 1, (short) 23, 50, 90),
155+
new MinetestBiome("Swampland shore", getColor("Swampland", ColorModifier.Beach), (short) -4, (short) 0, 50, 90),
156+
new MinetestBiome("Swampland ocean", getColor("Swampland", ColorModifier.Ocean), (short) OCEAN_MIN, (short) -5, 50, 90),
157+
new MinetestBiome("MushroomIsland", getColor("MushroomIsland", ColorModifier.None), (short) 4, (short) 20, 50, 106),
158+
new MinetestBiome("MushroomIsland shore", getColor("MushroomIsland", ColorModifier.Beach), (short) 1, (short) 3, 50, 106),
159+
new MinetestBiome("MushroomIsland ocean", getColor("MushroomIsland", ColorModifier.Ocean), (short) OCEAN_MIN, (short) 0, 50, 106)
160+
)
161+
);
162+
163+
Map<String, MinetestBiome> biomesByName = biomes.stream().collect(
164+
Collectors.toMap(biome -> biome.getName(), biome -> biome));
165+
166+
167+
for (Map.Entry<String, BiomeColor> entry : baseBiomes.entrySet()) {
168+
169+
String biomeName = entry.getKey();
170+
MinetestBiome baseBiome = biomesByName.get(biomeName);
171+
172+
// Add deep ocean biomes (gravel floor)
173+
MinetestBiome deepOceanBiome = new MinetestBiome(
174+
biomeName + " deep ocean",
175+
getColor(biomeName, ColorModifier.DeepOcean),
176+
DEEP_OCEAN_MIN,
177+
DEEP_OCEAN_MAX,
178+
baseBiome.heat_point,
179+
baseBiome.humidity_point
180+
);
181+
biomes.add(deepOceanBiome);
182+
183+
// Add underground biomes (needed for when ocean depth is lower than normal biome floors)
184+
MinetestBiome undergroundBiome = new MinetestBiome(
185+
biomeName + " underground",
186+
BiomeColor.from(20, 20, 20),
187+
OVERWORLD_MIN,
188+
(short)(DEEP_OCEAN_MIN - 1),
189+
baseBiome.heat_point,
190+
baseBiome.humidity_point
191+
);
192+
biomes.add(undergroundBiome);
193+
}
194+
195+
return biomes.toArray(new MinetestBiome[biomes.size()]);
196+
}
197+
}

src/main/java/amidst/mojangapi/world/biome/BiomeColor.java

+10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ public BiomeColor createLightenedBiomeColor() {
9494
return BiomeColor.from(lighten(r), lighten(g), lighten(b));
9595
}
9696

97+
public BiomeColor blend(float secondColorWeight, BiomeColor secondColor) {
98+
secondColorWeight = Math.max(0, Math.min(1, secondColorWeight));
99+
float firstColorWeight = 1.0f - secondColorWeight;
100+
return BiomeColor.from(
101+
Math.round(r * firstColorWeight + secondColor.r * secondColorWeight),
102+
Math.round(g * firstColorWeight + secondColor.g * secondColorWeight),
103+
Math.round(b * firstColorWeight + secondColor.b * secondColorWeight)
104+
);
105+
}
106+
97107
private int lighten(int x) {
98108
return Math.min(x + LIGHTEN_BRIGHTNESS, 0xFF);
99109
}

0 commit comments

Comments
 (0)