biome rework test

This commit is contained in:
Sen 2025-07-22 23:59:00 +02:00
parent 0f128c1b1b
commit b524eeeaa3
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
28 changed files with 454 additions and 1108 deletions

View file

@ -108,7 +108,6 @@ import server.vars.SVar;
import server.vars.SVars;
import server.world.Region;
import server.world.WorldServer;
import server.worldgen.biome.GenBiome;
public final class Server implements IThreadListener, Executor {
private final Thread thread = Thread.currentThread();

View file

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import common.biome.Biome;
import common.block.Block;
import common.block.artificial.BlockFence;
import common.block.artificial.BlockFenceGate;
@ -888,7 +887,7 @@ public class Player extends User implements Executor, IPlayer
{
int x = (chunk.xPos << 4) | (n >> 4);
int z = (chunk.zPos << 4) | (n & 15);
int temp = Float.floatToIntBits(gen == null ? 0.0f : gen.getBiomeAt(new BlockPos(x, 0, z), Biome.NONE).temperature);
int temp = Float.floatToIntBits(gen == null ? 0.0f : gen.getBiomeAt(new BlockPos(x, 0, z)).temperature);
int off = Float.floatToIntBits(world.getTempNoise(x, z));
dataset.data[j++] = (byte)(temp & 255);
dataset.data[j++] = (byte)(temp >> 8 & 255);

View file

@ -1,9 +1,7 @@
package server.world;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import common.biome.Biome;
import common.block.Block;
import common.entity.Entity;
import common.init.BlockRegistry;

View file

@ -16,7 +16,6 @@ import common.util.ChunkPos;
import common.util.ExtMath;
import common.world.World;
import server.vars.SVars;
import server.worldgen.biome.GenBiome;
public abstract class Spawner {
private static final int MOB_COUNT_DIV = (int)Math.pow(17.0D, 2.0D);

View file

@ -105,17 +105,15 @@ import server.worldgen.MobConstants;
import server.worldgen.ReplacerAltSimple;
import server.worldgen.ReplacerAltBiome;
import server.worldgen.ReplacerAltSurface;
import server.worldgen.ReplacerBiome;
import server.worldgen.ReplacerMesa;
import server.worldgen.ReplacerTerranian;
import server.worldgen.ReplacerTopLayer;
import server.worldgen.biome.GenBiome;
import server.worldgen.caves.MapGenBigCaves;
import server.worldgen.caves.MapGenCaves;
import server.worldgen.caves.MapGenRavine;
import server.worldgen.foliage.WorldGenBigMushroom;
import server.worldgen.populator.Populator;
import server.worldgen.populator.PopulatorBasic;
import server.worldgen.populator.PopulatorMesa;
import server.worldgen.structure.MapGenBridge;
import server.worldgen.structure.MapGenMineshaft;
import server.worldgen.structure.MapGenScatteredFeature;
@ -270,7 +268,13 @@ public final class WorldServer extends AWorldServer {
private Populator createPopulator() {
switch(this.dimension.getPopulatorType()) {
case NONE:
return null;
case MESARIAN:
return new PopulatorMesa(true);
case TERRANIAN:
default:
return null;
}
}
@ -2340,13 +2344,21 @@ public final class WorldServer extends AWorldServer {
}
protected float getTemperature(BlockPos pos) {
float temperature = this.biomeGen == null ? 0.0f : this.biomeGen.getBiomeAt(pos, Biome.NONE).temperature;
float temperature = this.biomeGen == null ? 0.0f : this.biomeGen.getBiomeAt(pos).temperature;
return pos.getY() > 64 ? temperature - (this.getTempNoise(pos.getX(), pos.getZ()) + (float)pos.getY() - 64.0F) / 15.0f : temperature;
}
public float getTempNoise(int x, int z) {
return (float)(this.tempGen.generate((double)x * 1.0D / 8.0D, (double)z * 1.0D / 8.0D) * 4.0D);
}
public float getGenTemperature(int x, int z) {
return this.dimension.getTemperature() + (this.biomeGen == null ? 0.0f : this.biomeGen.getBiomeAt(x, z).temperature);
}
public float getGenHumidity(int x, int z) {
return this.biomeGen == null ? 50.0f : this.biomeGen.getBiomeAt(x, z).humidity;
}
// public boolean canBlockSeeSky(BlockPos pos) {
// if(pos.getY() >= this.getSeaLevel()) {

View file

@ -1,11 +1,9 @@
package server.worldgen;
import java.util.List;
import java.util.Set;
import common.biome.Biome;
import common.biome.Scaling;
import common.collect.Lists;
import common.log.Log;
import common.util.BlockPos;
import common.util.LongHashMap;
import server.worldgen.layer.GenLayer;
@ -15,15 +13,12 @@ import server.worldgen.layer.GenLayerAddSea;
import server.worldgen.layer.GenLayerAddSnow;
import server.worldgen.layer.GenLayerBase;
import server.worldgen.layer.GenLayerBiome;
import server.worldgen.layer.GenLayerBiomeEdge;
import server.worldgen.layer.GenLayerEdge;
import server.worldgen.layer.GenLayerFuzzyZoom;
import server.worldgen.layer.GenLayerHills;
import server.worldgen.layer.GenLayerRemoveEmpty;
import server.worldgen.layer.GenLayerRiver;
import server.worldgen.layer.GenLayerRiverInit;
import server.worldgen.layer.GenLayerRiverMix;
import server.worldgen.layer.GenLayerShore;
import server.worldgen.layer.GenLayerSmooth;
import server.worldgen.layer.GenLayerVoronoiZoom;
import server.worldgen.layer.GenLayerZoom;
@ -56,12 +51,38 @@ public class BiomeGenerator {
private final GenLayer biomeIndexLayer;
private final LongHashMap<CacheBlock> cacheMap = new LongHashMap();
private final List<CacheBlock> cache = Lists.<CacheBlock>newArrayList();
private final Biome[] biomes = new Biome[256];
private final Biome[] biomes;
private final Biome defBiome;
private long lastCleanupTime;
public BiomeGenerator(long seed, 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[5 + hot.length + medium.length + cold.length + frost.length + add.length];
this.defBiome = this.biomes[GenLayer.NONE] = def;
this.biomes[GenLayer.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[GenLayer.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);
int n = 5;
for(Biome biome : frost) {
this.biomes[n++] = biome;
}
for(Biome biome : cold) {
this.biomes[n++] = biome;
}
for(Biome biome : medium) {
this.biomes[n++] = biome;
}
for(Biome biome : hot) {
this.biomes[n++] = biome;
}
for(Biome biome : add) {
this.biomes[n++] = biome;
}
for(int z = 0; z < this.biomes.length; z++) {
this.biomes[z].id = z;
}
GenLayer layer0t1 = new GenLayerBase(1L);
layer0t1 = new GenLayerFuzzyZoom(2000L, layer0t1);
GenLayerAddAreas layer2 = new GenLayerAddAreas(1L, layer0t1);
@ -85,25 +106,19 @@ public class BiomeGenerator {
GenLayerRiverInit layer20 = new GenLayerRiverInit(100L, layer19);
GenLayerBiome layer21n = new GenLayerBiome(200L, layer18, hot, medium, cold, frost, def, fixed);
GenLayer layer22n = GenLayerZoom.magnify(1000L, layer21n, 2);
GenLayerBiomeEdge layer23n = new GenLayerBiomeEdge(this, 1000L, layer22n);
GenLayer layer21l = GenLayerZoom.magnify(1000L, layer20, 2);
GenLayer layer24n = new GenLayerHills(this, 1000L, layer23n, layer21l, def);
GenLayer layer21t22a = GenLayerZoom.magnify(1000L, layer20, 2);
layer21t22a = GenLayerZoom.magnify(1000L, layer21t22a, riverSize);
GenLayerRiver layer23a = new GenLayerRiver(1L, layer21t22a);
GenLayerSmooth layer24a = new GenLayerSmooth(1000L, layer23a);
// layer24n = new GenLayerRareBiome(1001L, layer24n, biomeRarity);
for(int k = 0; k < biomeSize; ++k) {
layer24n = new GenLayerZoom((long)(1000 + k), layer24n);
layer22n = new GenLayerZoom((long)(1000 + k), layer22n);
if(k == 0) {
layer24n = new GenLayerAddAreas(3L, layer24n);
}
if(k == 1 || biomeSize == 1) {
layer24n = new GenLayerShore(this, 1000L, layer24n);
layer22n = new GenLayerAddAreas(3L, layer22n);
}
}
GenLayerSmooth layer25n = new GenLayerSmooth(1000L, layer24n);
GenLayerRiverMix layerOut = new GenLayerRiverMix(100L, layer25n, layer24a, def);
GenLayerSmooth layer25n = new GenLayerSmooth(1000L, layer22n);
GenLayerRiverMix layerOut = new GenLayerRiverMix(100L, layer25n, layer24a, def, frost);
GenLayer layerIndex = // perlinGen ? new GenLayerRiverMix(100L, layer25n, layer24a) :
new GenLayerVoronoiZoom(10L, layerOut);
layerOut.initWorldGenSeed(seed);
@ -111,7 +126,6 @@ public class BiomeGenerator {
// return new GenLayer[] {layerOut, layerIndex};
this.genBiomes = layerOut;
this.biomeIndexLayer = layerIndex;
this.defBiome = def;
}
private CacheBlock getBiomeCacheBlock(int x, int z)
@ -156,16 +170,21 @@ public class BiomeGenerator {
}
}
public Biome getBiome(int id)
private Biome getBiome(int id)
{
return id >= 0 && id < this.biomes.length ? this.biomes[id] : null;
return id < 0 || id >= this.biomes.length || this.biomes[id] == null ? this.defBiome : this.biomes[id];
}
public Biome getBiomeAt(BlockPos pos, Biome def) {
public Biome getBiomeAt(BlockPos pos) {
int x = pos.getX();
int z = pos.getZ();
Biome biome = this.getBiomeCacheBlock(x, z).getBiomeGenAt(x, z);
return biome == null ? def : biome;
return biome == null ? this.defBiome : biome;
}
public Biome getBiomeAt(int x, int z) {
Biome biome = this.getBiomeCacheBlock(x, z).getBiomeGenAt(x, z);
return biome == null ? this.defBiome : biome;
}
private void getFactors(double[] listToReuse, int x, int z, int width, int length) {
@ -174,8 +193,7 @@ public class BiomeGenerator {
int[] aint = this.biomeIndexLayer.getInts(x, z, width, length);
for(int i = 0; i < width * length; ++i) {
Biome biome = this.getBiome(aint[i]);
listToReuse[i] = biome == null ? 0.0 : (double)biome.factor;
listToReuse[i] = (double)this.getBiome(aint[i]).factor;
}
}
@ -190,21 +208,20 @@ public class BiomeGenerator {
int[] aint = this.biomeIndexLayer.getInts(xPos, zPos, sizeX, sizeZ);
for(int i = 0; i < sizeX * sizeZ; ++i) {
Biome biome = this.getBiome(aint[i]);
factors[i] = biome == null ? 0.0 : (double)biome.factor;
factors[i] = (double)this.getBiome(aint[i]).factor;
}
}
}
public void getGenBiomes(float[] depths, float[] scales, int x, int z, int width, int height) {
public void genScaling(float[] depths, float[] scales, int x, int z, int width, int height) {
IntCache.resetIntCache();
int[] aint = this.genBiomes.getInts(x, z, width, height);
for(int i = 0; i < width * height; ++i) {
Biome biome = this.getBiome(aint[i]);
depths[i] = biome == null ? 0.0f : biome.depth;
scales[i] = biome == null ? 0.0f : biome.scale;
depths[i] = biome.depth;
scales[i] = biome.scale;
}
}
@ -219,30 +236,8 @@ public class BiomeGenerator {
int[] aint = this.biomeIndexLayer.getInts(x, z, width, length);
for(int i = 0; i < width * length; ++i) {
Biome biome = this.getBiome(aint[i]);
listToReuse[i] = biome == null ? this.defBiome : biome;
listToReuse[i] = this.getBiome(aint[i]);
}
}
}
public boolean areBiomesViable(int x, int z, int size, Set<Biome> allowed) {
IntCache.resetIntCache();
int i = x - size >> 2;
int j = z - size >> 2;
int k = x + size >> 2;
int l = z + size >> 2;
int i1 = k - i + 1;
int j1 = l - j + 1;
int[] aint = this.genBiomes.getInts(i, j, i1, j1);
for(int k1 = 0; k1 < i1 * j1; ++k1) {
Biome biome = this.getBiome(aint[k1]);
if(biome == null || !allowed.contains(biome.base)) {
return false;
}
}
return true;
}
}

View file

@ -8,7 +8,6 @@ import common.util.BlockPos;
import common.world.LightType;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.biome.GenBiome;
public class FeatureLakes
{

View file

@ -2,7 +2,6 @@ package server.worldgen;
import java.util.Arrays;
import common.biome.Biome;
import common.dimension.Dimension;
import common.rng.NoiseGen;
import common.rng.OctaveGen;
@ -10,7 +9,6 @@ import common.rng.Random;
import common.util.ExtMath;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.biome.GenBiome;
public class GeneratorPerlin implements ChunkGenerator
{
@ -119,7 +117,7 @@ public class GeneratorPerlin implements ChunkGenerator
{
int sea = world.getSeaLevel();
if(world.getBiomeGenerator() != null)
world.getBiomeGenerator().getGenBiomes(this.depths, this.scales, x * 4 - 2, z * 4 - 2, 10, 10);
world.getBiomeGenerator().genScaling(this.depths, this.scales, x * 4 - 2, z * 4 - 2, 10, 10);
this.genNoisemap(x * 4, 0, z * 4);
for (int xb = 0; xb < 4; ++xb)

View file

@ -7,7 +7,6 @@ import common.rng.OctaveGen;
import common.rng.Random;
import common.world.State;
import server.world.WorldServer;
import server.worldgen.biome.GenBiome;
public class ReplacerAltBiome implements BlockReplacer
{

View file

@ -15,11 +15,10 @@ public class ReplacerMesa extends ReplacerBiome
private final PerlinGen baseBryceGen;
private final PerlinGen highBryceGen;
private final PerlinGen clayColorGen;
private final PerlinGen soilGen;
private final PerlinGen peakGen;
private final State surface;
private boolean bryce;
private boolean soil;
public ReplacerMesa(Random rand, State filler, State liquid, int seaLevel, State surface) {
super(rand, filler, liquid, seaLevel);
this.layers = new State[64];
@ -27,6 +26,8 @@ public class ReplacerMesa extends ReplacerBiome
this.clayColorGen = new PerlinGen(rand, 1);
this.baseBryceGen = new PerlinGen(rand, 4);
this.highBryceGen = new PerlinGen(rand, 1);
this.soilGen = new PerlinGen(rand, 8);
this.peakGen = new PerlinGen(rand, 8);
this.setupLayers(rand);
this.surface = surface;
}
@ -39,9 +40,12 @@ public class ReplacerMesa extends ReplacerBiome
public void genTerrainBlocks(WorldServer world, Random rand, ChunkPrimer primer, int x, int z, double noise)
{
boolean soil = this.soilGen.generate((double)x * 0.5D, (double)z * 0.5D) > 0.1;
boolean peak = this.peakGen.generate((double)x * 0.5D, (double)z * 0.5D) > 0.1;
double d4 = 0.0D;
if (this.bryce)
if (peak)
{
int i = (x & -16) + (z & 15);
int j = (z & -16) + (x & 15);
@ -118,7 +122,7 @@ public class ReplacerMesa extends ReplacerBiome
primer.set(by, i1, bx, Blocks.orange_clay.getState());
}
}
else if (this.soil && i1 > 86 + rng * 2)
else if (soil && i1 > 86 + rng * 2)
{
if (hard)
{

View file

@ -4,25 +4,14 @@ import common.block.foliage.BlockLilyPad;
import common.init.Blocks;
import common.rng.PerlinGen;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
import server.world.WorldServer;
public class ReplacerTerranian extends ReplacerAltSimple {
private final PerlinGen grassNoiseGen;
private final State dry;
private boolean stone; // hills*
private boolean gravel; // hills_mod*
private boolean podzol; // mega_taiga*
private boolean savanna; // savanna_mod*
private boolean swamp; // swamp*
private boolean sand; // beach*, desert*
private boolean fullStone; // stonebeach*
private boolean snow; // ice_spikes
public ReplacerTerranian(Random rand, State surface, State top, State filler, State alt, State dry, State liquid, int seaLevel) {
super(rand, surface, top, filler, alt, liquid, seaLevel);
this.grassNoiseGen = new PerlinGen(rand, 1);
@ -35,44 +24,17 @@ public class ReplacerTerranian extends ReplacerAltSimple {
public void genTerrainBlocks(WorldServer world, Random rand, ChunkPrimer primer, int x, int z, double noise)
{
float absTemp = world.getTemperatureC(new BlockPos(x, 0, z));
float absTemp = world.getGenTemperature(x, z);
float humidity = world.getGenHumidity(x, z);
State topBlock = this.surface;
State fillerBlock = this.top;
if(this.sand) {
if(absTemp >= 50.0f) {
topBlock = this.dry;
fillerBlock = this.dry;
}
else if(this.fullStone) {
topBlock = this.filler;
fillerBlock = this.filler;
}
else if(this.snow) {
topBlock = Blocks.snow.getState();
}
if (this.gravel && (noise < -1.0D || noise > 2.0D))
{
topBlock = this.alt;
fillerBlock = this.alt;
}
else if (this.stone && noise > 1.0D)
{
topBlock = this.filler;
fillerBlock = this.filler;
}
if (this.podzol)
{
if (noise > 1.75D)
{
topBlock = Blocks.coarse_dirt.getState();
}
else if (noise > -0.95D)
{
topBlock = Blocks.podzol.getState();
}
}
if(this.savanna) {
else if(absTemp >= 38.0f && humidity < 50.0f) {
if (noise > 1.75D)
{
topBlock = this.filler;
@ -83,7 +45,34 @@ public class ReplacerTerranian extends ReplacerAltSimple {
topBlock = Blocks.coarse_dirt.getState();
}
}
if(this.swamp) {
else if(absTemp <= 10.0f && humidity <= 10.0f) {
topBlock = this.filler;
fillerBlock = this.filler;
}
else if(absTemp <= 10.0f && humidity < 60.0f) {
if (noise < -1.0D || noise > 2.0D)
{
topBlock = this.alt;
fillerBlock = this.alt;
}
else if (humidity < 40.0f && noise > 1.0D)
{
topBlock = this.filler;
fillerBlock = this.filler;
}
}
else if (absTemp >= 25.0f && humidity >= 70.0f)
{
if (noise > 1.75D)
{
topBlock = Blocks.coarse_dirt.getState();
}
else if (noise > -0.95D)
{
topBlock = Blocks.podzol.getState();
}
}
else if(absTemp < 22.0f && humidity >= 65.0f) {
topBlock = Blocks.swamp.getState();
int sea = world.getSeaLevel() - 1;
double d0 = grassNoiseGen.generate((double)x * 0.25D, (double)z * 0.25D);

View file

@ -1,7 +0,0 @@
package server.worldgen.biome;
import common.biome.Biome;
import common.log.Log;
public class GenBiome extends Biome {
}

View file

@ -1,29 +1,19 @@
package server.worldgen.layer;
import common.biome.Biome;
import server.worldgen.BiomeGenerator;
public abstract class GenLayer {
protected BiomeGenerator generator;
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;
private long worldGenSeed;
private long chunkSeed;
private long baseSeed;
protected GenLayer parent;
protected boolean canBeNearby(int id1, int id2) {
if(id1 == id2) {
return true;
}
else {
Biome biome1 = this.generator.getBiome(id1);
Biome biome2 = this.generator.getBiome(id2);
return biome1 != null && biome2 != null ? biome1.isEqualTo(biome2) : false;
}
}
protected static boolean isSea(int id) {
return id == Biome.SEA.id || id == Biome.ICE_SEA.id;
return id == SEA || id == ICE_SEA;
}
public GenLayer(long base) {

View file

@ -1,7 +1,5 @@
package server.worldgen.layer;
import common.biome.Biome;
public class GenLayerAddSea extends GenLayer
{
private final int rarity;
@ -60,7 +58,7 @@ public class GenLayerAddSea extends GenLayer
this.initChunkSeed((long)(areaX + j1), (long)(areaY + i1));
if (k2 == 0 && this.nextInt(this.rarity) == 0)
{
aint1[j1 + i1 * areaWidth] = l2 > 1 ? Biome.ICE_SEA.id : Biome.SEA.id;
aint1[j1 + i1 * areaWidth] = l2 > 1 ? ICE_SEA : SEA;
}
else
{

View file

@ -1,170 +0,0 @@
package server.worldgen.layer;
import common.biome.Biome;
import common.biome.Temperature;
import server.worldgen.BiomeGenerator;
import server.worldgen.biome.GenBiome;
public class GenLayerBiomeEdge extends GenLayer
{
public GenLayerBiomeEdge(BiomeGenerator gen, long p_i45475_1_, GenLayer p_i45475_3_)
{
super(p_i45475_1_);
this.parent = p_i45475_3_;
this.generator = gen;
}
/**
* 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)
{
int[] aint = this.parent.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2);
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
for (int i = 0; i < areaHeight; ++i)
{
for (int j = 0; j < areaWidth; ++j)
{
this.initChunkSeed((long)(j + areaX), (long)(i + areaY));
int k = aint[j + 1 + (i + 1) * (areaWidth + 2)];
if (!this.replaceBiomeEdgeIfNecessary(aint, aint1, j, i, areaWidth, k, Biome.HILLS.id, Biome.HILLS_EDGE.id) && /* !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, Biome.mesaPlateau_F.id, Biome.mesa.id) && !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, Biome.mesaPlateau.id, Biome.mesa.id) && */ !this.replaceBiomeEdge(aint, aint1, j, i, areaWidth, k, Biome.LARGE_TAIGA.id, Biome.TAIGA.id))
{
if (k == Biome.DESERT.id)
{
int l1 = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)];
int i2 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)];
int j2 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)];
int k2 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)];
if (l1 != Biome.ICE.id && i2 != Biome.ICE.id && j2 != Biome.ICE.id && k2 != Biome.ICE.id)
{
aint1[j + i * areaWidth] = k;
}
else
{
aint1[j + i * areaWidth] = Biome.LARGE_HILLS.id;
}
}
else if (k == Biome.SWAMP.id)
{
int l = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)];
int i1 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)];
int j1 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)];
int k1 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)];
if (l != Biome.DESERT.id && i1 != Biome.DESERT.id && j1 != Biome.DESERT.id && k1 != Biome.DESERT.id && l != Biome.ICE_TAIGA.id && i1 != Biome.ICE_TAIGA.id && j1 != Biome.ICE_TAIGA.id && k1 != Biome.ICE_TAIGA.id && l != Biome.ICE.id && i1 != Biome.ICE.id && j1 != Biome.ICE.id && k1 != Biome.ICE.id)
{
if (l != Biome.TROPIC.id && k1 != Biome.TROPIC.id && i1 != Biome.TROPIC.id && j1 != Biome.TROPIC.id)
{
aint1[j + i * areaWidth] = k;
}
else
{
aint1[j + i * areaWidth] = Biome.TROPIC_EDGE.id;
}
}
else
{
aint1[j + i * areaWidth] = Biome.PLAIN.id;
}
}
else
{
aint1[j + i * areaWidth] = k;
}
}
}
}
return aint1;
}
/**
* Creates a border around a biome if necessary, e.g. A transition from hot to cold climates would otherwise occur.
*/
private boolean replaceBiomeEdgeIfNecessary(int[] p_151636_1_, int[] p_151636_2_, int p_151636_3_, int p_151636_4_, int p_151636_5_, int p_151636_6_, int p_151636_7_, int p_151636_8_)
{
if (!canBeNearby(p_151636_6_, p_151636_7_))
{
return false;
}
else
{
int i = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 - 1) * (p_151636_5_ + 2)];
int j = p_151636_1_[p_151636_3_ + 1 + 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)];
int k = p_151636_1_[p_151636_3_ + 1 - 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)];
int l = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 + 1) * (p_151636_5_ + 2)];
if (this.canBiomesBeNeighbors(i, p_151636_7_) && this.canBiomesBeNeighbors(j, p_151636_7_) && this.canBiomesBeNeighbors(k, p_151636_7_) && this.canBiomesBeNeighbors(l, p_151636_7_))
{
p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_6_;
}
else
{
p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_8_;
}
return true;
}
}
/**
* Creates a border around a biome.
*/
private boolean replaceBiomeEdge(int[] p_151635_1_, int[] p_151635_2_, int p_151635_3_, int p_151635_4_, int p_151635_5_, int p_151635_6_, int p_151635_7_, int p_151635_8_)
{
if (p_151635_6_ != p_151635_7_)
{
return false;
}
else
{
int i = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 - 1) * (p_151635_5_ + 2)];
int j = p_151635_1_[p_151635_3_ + 1 + 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)];
int k = p_151635_1_[p_151635_3_ + 1 - 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)];
int l = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 + 1) * (p_151635_5_ + 2)];
if (canBeNearby(i, p_151635_7_) && canBeNearby(j, p_151635_7_) && canBeNearby(k, p_151635_7_) && canBeNearby(l, p_151635_7_))
{
p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_6_;
}
else
{
p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_8_;
}
return true;
}
}
/**
* Returns if two biomes can logically be neighbors. If one is hot and the other cold, for example, it returns
* false.
*/
private boolean canBiomesBeNeighbors(int p_151634_1_, int p_151634_2_)
{
if (canBeNearby(p_151634_1_, p_151634_2_))
{
return true;
}
else
{
Biome biomegenbase = this.generator.getBiome(p_151634_1_);
Biome biomegenbase1 = this.generator.getBiome(p_151634_2_);
if (biomegenbase != null && biomegenbase1 != null)
{
Temperature biomegenbase$tempcategory = biomegenbase.category;
Temperature biomegenbase$tempcategory1 = biomegenbase1.category;
return biomegenbase$tempcategory == biomegenbase$tempcategory1 || biomegenbase$tempcategory == Temperature.MEDIUM || biomegenbase$tempcategory1 == Temperature.MEDIUM;
}
else
{
return false;
}
}
}
}

View file

@ -1,202 +0,0 @@
package server.worldgen.layer;
import common.biome.Biome;
import common.log.Log;
import server.worldgen.BiomeGenerator;
public class GenLayerHills extends GenLayer
{
private GenLayer field_151628_d;
private final int def;
public GenLayerHills(BiomeGenerator gen, long p_i45479_1_, GenLayer p_i45479_3_, GenLayer p_i45479_4_, Biome def)
{
super(p_i45479_1_);
this.parent = p_i45479_3_;
this.field_151628_d = p_i45479_4_;
this.def = def.id;
this.generator = gen;
}
/**
* 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)
{
int[] aint = this.parent.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2);
int[] aint1 = this.field_151628_d.getInts(areaX - 1, areaY - 1, areaWidth + 2, areaHeight + 2);
int[] aint2 = IntCache.getIntCache(areaWidth * areaHeight);
for (int i = 0; i < areaHeight; ++i)
{
for (int j = 0; j < areaWidth; ++j)
{
this.initChunkSeed((long)(j + areaX), (long)(i + areaY));
int k = aint[j + 1 + (i + 1) * (areaWidth + 2)];
int l = aint1[j + 1 + (i + 1) * (areaWidth + 2)];
boolean flag = (l - 2) % 29 == 0;
if (k > 255)
{
Log.TICK.warn("Altes Biom (" + k + ")!");
}
if (k != 0 && l >= 2 && (l - 2) % 29 == 1 && k < 128)
{
Biome gb = this.generator.getBiome(k);
if (gb != null && gb.mutated != null)
{
aint2[j + i * areaWidth] = gb.mutated.id;
}
else
{
aint2[j + i * areaWidth] = k;
}
}
else if (this.nextInt(3) != 0 && !flag)
{
aint2[j + i * areaWidth] = k;
}
else
{
int i1 = k;
if (k == Biome.DESERT.id)
{
i1 = Biome.DESERT_HILLS.id;
}
else if (k == Biome.FOREST.id)
{
i1 = Biome.FOREST_HILLS.id;
}
else if (k == Biome.BIRCH_FOREST.id)
{
i1 = Biome.BIRCH_HILLS.id;
}
else if (k == Biome.DARK_FOREST.id)
{
i1 = Biome.PLAIN.id;
}
else if (k == Biome.TAIGA.id)
{
i1 = Biome.TAIGA_HILLS.id;
}
else if (k == Biome.LARGE_TAIGA.id)
{
i1 = Biome.LARGE_TAIGA_HILLS.id;
}
else if (k == Biome.ICE_TAIGA.id)
{
i1 = Biome.ICE_TAIGA_HILLS.id;
}
else if (k == Biome.PLAIN.id)
{
if (this.nextInt(3) == 0)
{
i1 = Biome.FOREST_HILLS.id;
}
else
{
i1 = Biome.FOREST.id;
}
}
else if (k == Biome.ICE.id)
{
i1 = Biome.ICE_HILLS.id;
}
else if (k == Biome.TROPIC.id)
{
i1 = Biome.TROPIC_HILLS.id;
}
else if (k == Biome.NONE.id)
{
i1 = this.def;
}
else if (k == Biome.HILLS.id)
{
i1 = Biome.LARGE_HILLS.id;
}
else if (k == Biome.SAVANNA.id)
{
i1 = Biome.SAVANNA_PLATEAU.id;
}
// else if (canBeNearby(k, Biome.mesaPlateau_F.id))
// {
// i1 = Biome.mesa.id;
// }
else if (k == Biome.SEA.id && this.nextInt(3) == 0)
{
int j1 = this.nextInt(2);
if (j1 == 0)
{
i1 = Biome.PLAIN.id;
}
else
{
i1 = Biome.FOREST.id;
}
}
if (flag && i1 != k)
{
Biome gb = this.generator.getBiome(i1);
if (gb != null && gb.mutated != null)
{
i1 = gb.mutated.id;
}
else
{
i1 = k;
}
}
if (i1 == k)
{
aint2[j + i * areaWidth] = k;
}
else
{
int k2 = aint[j + 1 + (i + 1 - 1) * (areaWidth + 2)];
int k1 = aint[j + 1 + 1 + (i + 1) * (areaWidth + 2)];
int l1 = aint[j + 1 - 1 + (i + 1) * (areaWidth + 2)];
int i2 = aint[j + 1 + (i + 1 + 1) * (areaWidth + 2)];
int j2 = 0;
if (canBeNearby(k2, k))
{
++j2;
}
if (canBeNearby(k1, k))
{
++j2;
}
if (canBeNearby(l1, k))
{
++j2;
}
if (canBeNearby(i2, k))
{
++j2;
}
if (j2 >= 3)
{
aint2[j + i * areaWidth] = i1;
}
else
{
aint2[j + i * areaWidth] = k;
}
}
}
}
}
return aint2;
}
}

View file

@ -1,7 +1,5 @@
package server.worldgen.layer;
import common.biome.Biome;
public class GenLayerRiver extends GenLayer
{
public GenLayerRiver(long p_i2128_1_, GenLayer p_i2128_3_)
@ -39,7 +37,7 @@ public class GenLayerRiver extends GenLayer
}
else
{
aint1[j1 + i1 * areaWidth] = Biome.RIVER.id;
aint1[j1 + i1 * areaWidth] = RIVER;
}
}
}

View file

@ -1,19 +1,26 @@
package server.worldgen.layer;
import java.util.Set;
import common.biome.Biome;
import common.collect.Sets;
public class GenLayerRiverMix extends GenLayer
{
private GenLayer biomePatternGeneratorChain;
private GenLayer riverPatternGeneratorChain;
private final int def;
private final Set<Integer> freeze = Sets.newHashSet();
public GenLayerRiverMix(long p_i2129_1_, GenLayer p_i2129_3_, GenLayer p_i2129_4_, Biome def)
public GenLayerRiverMix(long p_i2129_1_, GenLayer p_i2129_3_, GenLayer p_i2129_4_, Biome def, Biome[] freeze)
{
super(p_i2129_1_);
this.biomePatternGeneratorChain = p_i2129_3_;
this.riverPatternGeneratorChain = p_i2129_4_;
this.def = def.id;
for(Biome biome : freeze) {
this.freeze.add(biome.id);
}
}
/**
@ -39,23 +46,23 @@ public class GenLayerRiverMix extends GenLayer
for (int i = 0; i < areaWidth * areaHeight; ++i)
{
if(biome[i] == Biome.NONE.id)
if(biome[i] == NONE)
{
out[i] = this.def;
}
else if(biome[i] == Biome.SEA.id || biome[i] == Biome.ICE_SEA.id)
else if(biome[i] == SEA || biome[i] == ICE_SEA)
{
out[i] = biome[i];
}
else if (river[i] == Biome.RIVER.id)
else if (river[i] == RIVER)
{
if (biome[i] == Biome.ICE.id)
if (this.freeze.contains(biome[i]))
{
out[i] = Biome.ICE_RIVER.id;
out[i] = ICE_RIVER;
}
else // if (biome[i] != Biome.mushroomPlains.id && biome[i] != Biome.mushroomPlainsEdge.id)
{
out[i] = Biome.RIVER.id;
out[i] = RIVER;
}
// else
// {

View file

@ -1,118 +0,0 @@
package server.worldgen.layer;
import common.biome.Biome;
import server.worldgen.BiomeGenerator;
import server.worldgen.biome.GenBiome;
public class GenLayerShore extends GenLayer
{
public GenLayerShore(BiomeGenerator gen, long base, GenLayer parent)
{
super(base);
this.parent = parent;
this.generator = gen;
}
public int[] getInts(int x, int z, int width, int height)
{
int[] pre = this.parent.getInts(x - 1, z - 1, width + 2, height + 2);
int[] data = IntCache.getIntCache(width * height);
for (int i = 0; i < height; ++i)
{
for (int j = 0; j < width; ++j)
{
this.initChunkSeed((long)(j + x), (long)(i + z));
int id = pre[j + 1 + (i + 1) * (width + 2)];
Biome biome = this.generator.getBiome(id);
if (biome != null && biome.tropical)
{
int i2 = pre[j + 1 + (i + 1 - 1) * (width + 2)];
int l2 = pre[j + 1 + 1 + (i + 1) * (width + 2)];
int k3 = pre[j + 1 - 1 + (i + 1) * (width + 2)];
int j4 = pre[j + 1 + (i + 1 + 1) * (width + 2)];
if (this.canPlaceTropical(i2) && this.canPlaceTropical(l2) && this.canPlaceTropical(k3) && this.canPlaceTropical(j4))
{
if (!isSea(i2) && !isSea(l2) && !isSea(k3) && !isSea(j4))
{
data[j + i * width] = id;
}
else
{
data[j + i * width] = Biome.BEACH.id;
}
}
else
{
data[j + i * width] = Biome.TROPIC_EDGE.id;
}
}
else if (id != Biome.HILLS.id && id != Biome.LARGE_HILLS.id && id != Biome.HILLS_EDGE.id)
{
if (biome != null && biome.allowColdBeach)
{
this.putBeach(pre, data, j, i, width, id, Biome.ICE_BEACH.id);
}
else if (biome != null && !biome.disallowBeach)
{
int l1 = pre[j + 1 + (i + 1 - 1) * (width + 2)];
int k2 = pre[j + 1 + 1 + (i + 1) * (width + 2)];
int j3 = pre[j + 1 - 1 + (i + 1) * (width + 2)];
int i4 = pre[j + 1 + (i + 1 + 1) * (width + 2)];
if (!isSea(l1) && !isSea(k2) && !isSea(j3) && !isSea(i4))
{
data[j + i * width] = id;
}
else
{
data[j + i * width] = Biome.BEACH.id;
}
}
else
{
data[j + i * width] = id;
}
}
else
{
this.putBeach(pre, data, j, i, width, id, Biome.STONE_BEACH.id);
}
}
}
return data;
}
private void putBeach(int[] pre, int[] data, int x, int z, int width, int biome, int beach)
{
if (isSea(biome))
{
data[x + z * width] = biome;
}
else
{
int i = pre[x + 1 + (z + 1 - 1) * (width + 2)];
int j = pre[x + 1 + 1 + (z + 1) * (width + 2)];
int k = pre[x + 1 - 1 + (z + 1) * (width + 2)];
int l = pre[x + 1 + (z + 1 + 1) * (width + 2)];
if (!isSea(i) && !isSea(j) && !isSea(k) && !isSea(l))
{
data[x + z * width] = biome;
}
else
{
data[x + z * width] = beach;
}
}
}
private boolean canPlaceTropical(int id)
{
Biome biome = this.generator.getBiome(id);
return (biome != null && biome.tropical) || id == Biome.TROPIC_EDGE.id || id == Biome.TROPIC.id || id == Biome.TROPIC_HILLS.id || id == Biome.FOREST.id || id == Biome.TAIGA.id || isSea(id);
}
}

View file

@ -10,7 +10,6 @@ import server.world.WorldServer;
public class MapGenScatteredFeature extends MapGenStructure
{
private static final List<Biome> biomelist = Arrays.<Biome>asList(Biome.DESERT, Biome.DESERT_HILLS, Biome.TROPIC, Biome.TROPIC_HILLS, Biome.SWAMP);
private static final int MAX_DISTANCE = 32;
private static final int MIN_DISTANCE = 8;
@ -42,22 +41,9 @@ public class MapGenScatteredFeature extends MapGenStructure
k = k + random.zrange(MapGenScatteredFeature.MAX_DISTANCE - MapGenScatteredFeature.MIN_DISTANCE);
l = l + random.zrange(MapGenScatteredFeature.MAX_DISTANCE - MapGenScatteredFeature.MIN_DISTANCE);
if (i == k && j == l && this.worldObj.getBiomeGenerator() != null)
if (i == k && j == l)
{
Biome biomegenbase = this.worldObj.getBiomeGenerator().getBiomeAt(new BlockPos(i * 16 + 8, 0, j * 16 + 8), null);
if (biomegenbase == null)
{
return false;
}
for (Biome biomegenbase1 : biomelist)
{
if (biomegenbase == biomegenbase1)
{
return true;
}
}
return true;
}
return false;
@ -92,20 +78,16 @@ public class MapGenScatteredFeature extends MapGenStructure
public Start(WorldServer worldIn, Random p_i2060_2_, int p_i2060_3_, int p_i2060_4_)
{
super(p_i2060_3_, p_i2060_4_);
Biome biomegenbase = worldIn.getBiomeGenerator().getBiomeAt(new BlockPos(p_i2060_3_ * 16 + 8, 0, p_i2060_4_ * 16 + 8), null);
float temp = worldIn.getGenTemperature(p_i2060_3_ * 16 + 8, p_i2060_4_ * 16 + 8);
if (biomegenbase != Biome.TROPIC && biomegenbase != Biome.TROPIC_HILLS)
if(temp >= 40.0f) {
StructureScattered.DesertPyramid componentscatteredfeaturepieces$desertpyramid = new StructureScattered.DesertPyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
this.components.add(componentscatteredfeaturepieces$desertpyramid);
}
else if (temp < 30.0f)
{
if (biomegenbase == Biome.SWAMP)
{
StructureScattered.SwampHut componentscatteredfeaturepieces$swamphut = new StructureScattered.SwampHut(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
this.components.add(componentscatteredfeaturepieces$swamphut);
}
else if (biomegenbase == Biome.DESERT || biomegenbase == Biome.DESERT_HILLS)
{
StructureScattered.DesertPyramid componentscatteredfeaturepieces$desertpyramid = new StructureScattered.DesertPyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
this.components.add(componentscatteredfeaturepieces$desertpyramid);
}
StructureScattered.SwampHut componentscatteredfeaturepieces$swamphut = new StructureScattered.SwampHut(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
this.components.add(componentscatteredfeaturepieces$swamphut);
}
else
{

View file

@ -11,8 +11,6 @@ import server.world.WorldServer;
public class MapGenVillage extends MapGenStructure
{
public static final Set<Biome> villageSpawnBiomes = Sets.<Biome>newHashSet(Biome.PLAIN, Biome.DESERT, Biome.SAVANNA);
/** World terrain type, 0 for normal, 1 for flat map */
private int terrainType;
private int distance;
@ -69,14 +67,9 @@ public class MapGenVillage extends MapGenStructure
k = k + random.zrange(this.distance - this.field_82666_h);
l = l + random.zrange(this.distance - this.field_82666_h);
if (i == k && j == l && this.worldObj.getBiomeGenerator() != null)
if (i == k && j == l)
{
boolean flag = this.worldObj.getBiomeGenerator().areBiomesViable(i * 16 + 8, j * 16 + 8, 0, villageSpawnBiomes);
if (flag)
{
return true;
}
return true;
}
return false;
@ -99,7 +92,7 @@ public class MapGenVillage extends MapGenStructure
{
super(x, z);
List<StructureVillage.PieceWeight> list = StructureVillage.getStructureVillageWeightedPieceList(rand, size);
StructureVillage.Start structurevillagepieces$start = new StructureVillage.Start(worldIn.getBiomeGenerator(), 0, rand, (x << 4) + 2, (z << 4) + 2, list, size);
StructureVillage.Start structurevillagepieces$start = new StructureVillage.Start(worldIn, 0, rand, (x << 4) + 2, (z << 4) + 2, list, size);
this.components.add(structurevillagepieces$start);
structurevillagepieces$start.buildComponent(structurevillagepieces$start, this.components, rand);
List<StructureComponent> list1 = structurevillagepieces$start.field_74930_j;

View file

@ -216,12 +216,9 @@ public class StructureVillage
int l = structurecomponent.boundingBox.maxZ - structurecomponent.boundingBox.minZ;
int i1 = k > l ? k : l;
if (start.getBiomeGenerator().areBiomesViable(i, j, i1 / 2 + 4, MapGenVillage.villageSpawnBiomes))
{
p_176066_1_.add(structurecomponent);
start.field_74932_i.add(structurecomponent);
return structurecomponent;
}
p_176066_1_.add(structurecomponent);
start.field_74932_i.add(structurecomponent);
return structurecomponent;
}
return null;
@ -251,12 +248,9 @@ public class StructureVillage
int l = structurecomponent.boundingBox.maxZ - structurecomponent.boundingBox.minZ;
int i1 = k > l ? k : l;
if (start.getBiomeGenerator().areBiomesViable(i, j, i1 / 2 + 4, MapGenVillage.villageSpawnBiomes))
{
p_176069_1_.add(structurecomponent);
start.field_74930_j.add(structurecomponent);
return structurecomponent;
}
p_176069_1_.add(structurecomponent);
start.field_74930_j.add(structurecomponent);
return structurecomponent;
}
return null;
@ -1411,7 +1405,6 @@ public class StructureVillage
public static class Start extends StructureVillage.Well
{
public BiomeGenerator biomeGen;
public boolean inDesert;
public int terrainType;
public StructureVillage.PieceWeight structVillagePieceWeight;
@ -1423,21 +1416,14 @@ public class StructureVillage
{
}
public Start(BiomeGenerator genIn, int p_i2104_2_, Random rand, int p_i2104_4_, int p_i2104_5_, List<StructureVillage.PieceWeight> p_i2104_6_, int p_i2104_7_)
public Start(WorldServer genIn, int p_i2104_2_, Random rand, int p_i2104_4_, int p_i2104_5_, List<StructureVillage.PieceWeight> p_i2104_6_, int p_i2104_7_)
{
super((StructureVillage.Start)null, 0, rand, p_i2104_4_, p_i2104_5_);
this.biomeGen = genIn;
this.structureVillageWeightedPieceList = p_i2104_6_;
this.terrainType = p_i2104_7_;
Biome biomegenbase = genIn.getBiomeAt(new BlockPos(p_i2104_4_, 0, p_i2104_5_), null);
this.inDesert = biomegenbase == Biome.DESERT || biomegenbase == Biome.DESERT_HILLS;
this.inDesert = genIn.getGenTemperature(p_i2104_4_, p_i2104_5_) >= 40.0f;
this.func_175846_a(this.inDesert);
}
public BiomeGenerator getBiomeGenerator()
{
return this.biomeGen;
}
}
public static class Torch extends StructureVillage.Village