fix terra gen biomes + river layers

This commit is contained in:
Sen 2025-07-30 17:18:52 +02:00
parent cef99a063a
commit 02c007f0c0
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
7 changed files with 70 additions and 108 deletions

View file

@ -635,7 +635,7 @@ public abstract class UniverseRegistry extends DimensionRegistry {
.addSpawn(EntityFox.class, 3, 2, 5)); .addSpawn(EntityFox.class, 3, 2, 5));
registerPlanet("transylvania", "Vampirplanet Transsylvanien", new Planet(8374921, 33850466L, 49760L, 20.0f, 10.0f, 255.5f, Blocks.rock.getState(), Blocks.water.getState(), 63), registerPlanet("transylvania", "Vampirplanet Transsylvanien", new Planet(8374921, 33850466L, 49760L, 20.0f, 10.0f, 255.5f, Blocks.rock.getState(), Blocks.water.getState(), 63),
new GeneratorData().setGenerator(new GeneratorPerlin(true)) new GeneratorData().setGenerator(new GeneratorPerlin(true))
.setReplacer(new ReplacerTerranian(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState())) .setReplacer(new ReplacerAltSimple(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState()))
.setBiomeGen(new BiomeGenerator(new Biome(8.0f, 80.0f), true, 5, 3, 3, 30)) .setBiomeGen(new BiomeGenerator(new Biome(8.0f, 80.0f), true, 5, 3, 3, 30))
.setPopulator(new PopulatorForest(0)).addCaveGen(new MapGenCaves(Blocks.lava.getState()), new MapGenRavine(Blocks.lava.getState())) .setPopulator(new PopulatorForest(0)).addCaveGen(new MapGenCaves(Blocks.lava.getState()), new MapGenRavine(Blocks.lava.getState()))
.addFeature(new FeatureDungeons(10)).enableSnow() .addFeature(new FeatureDungeons(10)).enableSnow()

View file

@ -67,14 +67,13 @@ public class BiomeGenerator {
} }
public BiomeGenerator(Biome def, boolean fixed, int biomeSize, int riverSize, int snowRarity, int seaRarity, Biome[] add, int addRarity, Biome[] hot, Biome[] medium, Biome[] cold, Biome[] frost) { public BiomeGenerator(Biome def, boolean fixed, int biomeSize, int riverSize, int snowRarity, int seaRarity, Biome[] add, int addRarity, Biome[] hot, Biome[] medium, Biome[] cold, Biome[] frost) {
this.biomes = new Biome[6 + hot.length + medium.length + cold.length + frost.length + add.length]; this.biomes = new Biome[5 + hot.length + medium.length + cold.length + frost.length + add.length];
this.biomes[GenLayer.NONE] = def.copy(); this.defBiome = this.biomes[GenLayerRiverMix.NONE] = def;
this.biomes[GenLayer.RIVER] = new Biome(0.0f, 50.0f, Scaling.SEA_SHALLOW); this.biomes[GenLayerRiverMix.RIVER] = new Biome(0.0f, 50.0f, Scaling.SEA_SHALLOW);
this.biomes[GenLayer.SEA] = new Biome(0.0f, 50.0f, Scaling.SEA_MEDIUM); this.biomes[GenLayerRiverMix.SEA] = new Biome(0.0f, 50.0f, Scaling.SEA_MEDIUM);
this.biomes[GenLayer.ICE_RIVER] = new Biome(-20.0f, 50.0f, Scaling.SEA_SHALLOW); this.biomes[GenLayerRiverMix.ICE_RIVER] = new Biome(-20.0f, 50.0f, Scaling.SEA_SHALLOW);
this.biomes[GenLayer.ICE_SEA] = new Biome(-20.0f, 50.0f, Scaling.SEA_MEDIUM); this.biomes[GenLayerRiverMix.ICE_SEA] = new Biome(-20.0f, 50.0f, Scaling.SEA_MEDIUM);
this.defBiome = this.biomes[GenLayer.DEFAULT] = def; int n = 5;
int n = 6;
for(Biome biome : frost) { for(Biome biome : frost) {
this.biomes[n++] = biome; this.biomes[n++] = biome;
} }

View file

@ -1,22 +1,11 @@
package server.worldgen.layer; package server.worldgen.layer;
public abstract class GenLayer { public abstract class GenLayer {
public static final int NONE = 0;
public static final int RIVER = 1;
public static final int SEA = 2;
public static final int ICE_RIVER = 3;
public static final int ICE_SEA = 4;
public static final int DEFAULT = 5;
private long worldGenSeed; private long worldGenSeed;
private long chunkSeed; private long chunkSeed;
private long baseSeed; private long baseSeed;
protected GenLayer parent; protected GenLayer parent;
protected static boolean isSea(int id) {
return id == SEA || id == ICE_SEA;
}
public GenLayer(long base) { public GenLayer(long base) {
this.baseSeed = base; this.baseSeed = base;
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L; this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;

View file

@ -58,7 +58,7 @@ public class GenLayerAddSea extends GenLayer
this.initChunkSeed((long)(areaX + j1), (long)(areaY + i1)); this.initChunkSeed((long)(areaX + j1), (long)(areaY + i1));
if (k2 == 0 && this.nextInt(this.rarity) == 0) if (k2 == 0 && this.nextInt(this.rarity) == 0)
{ {
aint1[j1 + i1 * areaWidth] = l2 > 1 ? ICE_SEA : SEA; aint1[j1 + i1 * areaWidth] = l2 > 1 ? 1001 : 1000;
} }
else else
{ {

View file

@ -39,7 +39,7 @@ public class GenLayerBiome extends GenLayer
{ {
data[j + i * width] = this.fixed; data[j + i * width] = this.fixed;
} }
else if (id == 0 || isSea(id)) else if (id == 0 || id == 1000 || id == 1001)
{ {
data[j + i * width] = id; data[j + i * width] = id;
} }

View file

@ -2,16 +2,12 @@ package server.worldgen.layer;
public class GenLayerRiver extends GenLayer public class GenLayerRiver extends GenLayer
{ {
public GenLayerRiver(long p_i2128_1_, GenLayer p_i2128_3_) public GenLayerRiver(long seed, GenLayer parent)
{ {
super(p_i2128_1_); super(seed);
super.parent = p_i2128_3_; super.parent = parent;
} }
/**
* Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
* amounts, or biomeList[] indices based on the particular GenLayer subclass.
*/
public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight)
{ {
int i = areaX - 1; int i = areaX - 1;
@ -25,28 +21,23 @@ public class GenLayerRiver extends GenLayer
{ {
for (int j1 = 0; j1 < areaWidth; ++j1) for (int j1 = 0; j1 < areaWidth; ++j1)
{ {
int k1 = this.func_151630_c(aint[j1 + 0 + (i1 + 1) * k]); int k1 = aint[j1 + 0 + (i1 + 1) * k];
int l1 = this.func_151630_c(aint[j1 + 2 + (i1 + 1) * k]); int l1 = aint[j1 + 2 + (i1 + 1) * k];
int i2 = this.func_151630_c(aint[j1 + 1 + (i1 + 0) * k]); int i2 = aint[j1 + 1 + (i1 + 0) * k];
int j2 = this.func_151630_c(aint[j1 + 1 + (i1 + 2) * k]); int j2 = aint[j1 + 1 + (i1 + 2) * k];
int k2 = this.func_151630_c(aint[j1 + 1 + (i1 + 1) * k]); int k2 = aint[j1 + 1 + (i1 + 1) * k];
if (k2 == k1 && k2 == i2 && k2 == l1 && k2 == j2) if (k2 == k1 && k2 == i2 && k2 == l1 && k2 == j2)
{ {
aint1[j1 + i1 * areaWidth] = -1; aint1[j1 + i1 * areaWidth] = 0;
} }
else else
{ {
aint1[j1 + i1 * areaWidth] = RIVER; aint1[j1 + i1 * areaWidth] = 1;
} }
} }
} }
return aint1; return aint1;
} }
private int func_151630_c(int p_151630_1_)
{
return p_151630_1_ >= 2 ? 2 + (p_151630_1_ & 1) : p_151630_1_;
}
} }

View file

@ -5,76 +5,59 @@ import java.util.Set;
import common.collect.Sets; import common.collect.Sets;
import server.worldgen.Biome; import server.worldgen.Biome;
public class GenLayerRiverMix extends GenLayer public class GenLayerRiverMix extends GenLayer {
{ public static final int NONE = 0;
private GenLayer biomePatternGeneratorChain; public static final int RIVER = 1;
private GenLayer riverPatternGeneratorChain; public static final int SEA = 2;
private final int def; public static final int ICE_RIVER = 3;
private final Set<Integer> freeze = Sets.newHashSet(); public static final int ICE_SEA = 4;
public GenLayerRiverMix(long p_i2129_1_, GenLayer p_i2129_3_, GenLayer p_i2129_4_, Biome def, Biome[] freeze) private GenLayer biomeGen;
{ private GenLayer riverGen;
super(p_i2129_1_); private final int def;
this.biomePatternGeneratorChain = p_i2129_3_; private final Set<Integer> freeze = Sets.newHashSet();
this.riverPatternGeneratorChain = p_i2129_4_;
this.def = def.id;
for(Biome biome : freeze) {
this.freeze.add(biome.id);
}
}
/** public GenLayerRiverMix(long seed, GenLayer biomes, GenLayer rivers, Biome def, Biome[] freeze) {
* Initialize layer's local worldGenSeed based on its own baseSeed and the world's global seed (passed in as an super(seed);
* argument). this.biomeGen = biomes;
*/ this.riverGen = rivers;
public void initWorldGenSeed(long seed) this.def = def.id;
{ for(Biome biome : freeze) {
this.biomePatternGeneratorChain.initWorldGenSeed(seed); this.freeze.add(biome.id);
this.riverPatternGeneratorChain.initWorldGenSeed(seed); }
super.initWorldGenSeed(seed); }
}
/** public void initWorldGenSeed(long seed) {
* Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall this.biomeGen.initWorldGenSeed(seed);
* amounts, or biomeList[] indices based on the particular GenLayer subclass. this.riverGen.initWorldGenSeed(seed);
*/ super.initWorldGenSeed(seed);
public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) }
{
int[] biome = this.biomePatternGeneratorChain.getInts(areaX, areaY, areaWidth, areaHeight);
int[] river = this.riverPatternGeneratorChain.getInts(areaX, areaY, areaWidth, areaHeight);
int[] out = IntCache.getIntCache(areaWidth * areaHeight);
for (int i = 0; i < areaWidth * areaHeight; ++i) public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) {
{ int[] biome = this.biomeGen.getInts(areaX, areaY, areaWidth, areaHeight);
if(biome[i] == NONE) int[] river = this.riverGen.getInts(areaX, areaY, areaWidth, areaHeight);
{ int[] out = IntCache.getIntCache(areaWidth * areaHeight);
out[i] = this.def;
}
else if(biome[i] == SEA || biome[i] == ICE_SEA)
{
out[i] = biome[i];
}
else if (river[i] == RIVER)
{
if (this.freeze.contains(biome[i]))
{
out[i] = ICE_RIVER;
}
else // if (biome[i] != Biome.mushroomPlains.id && biome[i] != Biome.mushroomPlainsEdge.id)
{
out[i] = RIVER;
}
// else
// {
// out[i] = Biome.mushroomPlainsEdge.id;
// }
}
else
{
out[i] = biome[i];
}
}
return out; for(int i = 0; i < areaWidth * areaHeight; ++i) {
} if(biome[i] == 0) {
out[i] = this.def;
}
else if(biome[i] == 1000 || biome[i] == 1001) {
out[i] = biome[i] == 1000 ? SEA : ICE_SEA;
}
else if(river[i] == 1) {
if(this.freeze.contains(biome[i])) {
out[i] = ICE_RIVER;
}
else {
out[i] = RIVER;
}
}
else {
out[i] = biome[i];
}
}
return out;
}
} }