163 lines
6.1 KiB
Java
Executable file
163 lines
6.1 KiB
Java
Executable file
package game.worldgen.layer;
|
|
|
|
import game.biome.Biome;
|
|
import game.biome.BiomeJungle;
|
|
|
|
public class GenLayerShore extends GenLayer
|
|
{
|
|
public GenLayerShore(long base, GenLayer parent)
|
|
{
|
|
super(base);
|
|
this.parent = parent;
|
|
}
|
|
|
|
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 = Biome.getBiome(id);
|
|
|
|
// if (id == Biome.mushroomPlains.id)
|
|
// {
|
|
// int j2 = pre[j + 1 + (i + 1 - 1) * (width + 2)];
|
|
// int i3 = pre[j + 1 + 1 + (i + 1) * (width + 2)];
|
|
// int l3 = pre[j + 1 - 1 + (i + 1) * (width + 2)];
|
|
// int k4 = pre[j + 1 + (i + 1 + 1) * (width + 2)];
|
|
//
|
|
// if (j2 != Biome.swampland.id && i3 != Biome.swampland.id && l3 != Biome.swampland.id && k4 != Biome.swampland.id)
|
|
// {
|
|
// data[j + i * width] = id;
|
|
// }
|
|
// else
|
|
// {
|
|
// data[j + i * width] = Biome.mushroomPlainsEdge.id;
|
|
// }
|
|
// }
|
|
// else
|
|
if (biome != null && biome.getBiomeClass() == BiomeJungle.class)
|
|
{
|
|
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.canNBJungle(i2) && this.canNBJungle(l2) && this.canNBJungle(k3) && this.canNBJungle(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.jungleEdge.id;
|
|
}
|
|
}
|
|
else if (id != Biome.extremeHills.id && id != Biome.extremeHillsPlus.id && id != Biome.extremeHillsEdge.id)
|
|
{
|
|
if (biome != null && biome.allowColdBeach)
|
|
{
|
|
this.putBeach(pre, data, j, i, width, id, Biome.coldBeach.id);
|
|
}
|
|
else // if (id != Biome.mesa.id && id != Biome.mesaPlateau_F.id)
|
|
// {
|
|
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
|
|
// {
|
|
// int l = pre[j + 1 + (i + 1 - 1) * (width + 2)];
|
|
// int i1 = pre[j + 1 + 1 + (i + 1) * (width + 2)];
|
|
// int j1 = pre[j + 1 - 1 + (i + 1) * (width + 2)];
|
|
// int k1 = pre[j + 1 + (i + 1 + 1) * (width + 2)];
|
|
//
|
|
// if (!isSea(l) && !isSea(i1) && !isSea(j1) && !isSea(k1))
|
|
// {
|
|
// if (this.canNBMesa(l) && this.canNBMesa(i1) && this.canNBMesa(j1) && this.canNBMesa(k1))
|
|
// {
|
|
// data[j + i * width] = id;
|
|
// }
|
|
// else
|
|
// {
|
|
// data[j + i * width] = Biome.desert.id;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// data[j + i * width] = id;
|
|
// }
|
|
// }
|
|
}
|
|
else
|
|
{
|
|
this.putBeach(pre, data, j, i, width, id, Biome.stoneBeach.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 canNBJungle(int id)
|
|
{
|
|
return Biome.getBiome(id) != null && Biome.getBiome(id).getBiomeClass() == BiomeJungle.class ? true : id == Biome.jungleEdge.id || id == Biome.jungle.id || id == Biome.jungleHills.id || id == Biome.forest.id || id == Biome.taiga.id || isSea(id);
|
|
}
|
|
|
|
// private boolean canNBMesa(int id)
|
|
// {
|
|
// return Biome.getBiome(id) instanceof BiomeMesa;
|
|
// }
|
|
}
|