initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
95
java/src/game/worldgen/layer/GenLayer.java
Executable file
95
java/src/game/worldgen/layer/GenLayer.java
Executable file
|
@ -0,0 +1,95 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.biome.Biome;
|
||||
|
||||
public abstract class GenLayer {
|
||||
private long worldGenSeed;
|
||||
private long chunkSeed;
|
||||
private long baseSeed;
|
||||
protected GenLayer parent;
|
||||
|
||||
protected static boolean canBeNearby(int id1, int id2) {
|
||||
if(id1 == id2) {
|
||||
return true;
|
||||
}
|
||||
else { // if(id1 != Biome.mesaPlateau_F.id && id1 != Biome.mesaPlateau.id) {
|
||||
final Biome biome1 = Biome.getBiome(id1);
|
||||
final Biome biome2 = Biome.getBiome(id2);
|
||||
return biome1 != null && biome2 != null ? biome1.isEqualTo(biome2) : false;
|
||||
}
|
||||
// else {
|
||||
// return id2 == Biome.mesaPlateau_F.id || id2 == Biome.mesaPlateau.id;
|
||||
// }
|
||||
}
|
||||
|
||||
protected static boolean isSea(int id) {
|
||||
return id == Biome.sea.id || id == Biome.frozenSea.id;
|
||||
}
|
||||
|
||||
public GenLayer(long base) {
|
||||
this.baseSeed = base;
|
||||
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.baseSeed += base;
|
||||
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.baseSeed += base;
|
||||
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.baseSeed += base;
|
||||
}
|
||||
|
||||
public abstract int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight);
|
||||
|
||||
public void initWorldGenSeed(long seed) {
|
||||
this.worldGenSeed = seed;
|
||||
if(this.parent != null) {
|
||||
this.parent.initWorldGenSeed(seed);
|
||||
}
|
||||
this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.worldGenSeed += this.baseSeed;
|
||||
this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.worldGenSeed += this.baseSeed;
|
||||
this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.worldGenSeed += this.baseSeed;
|
||||
}
|
||||
|
||||
public void initChunkSeed(long x, long z) {
|
||||
this.chunkSeed = this.worldGenSeed;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += x;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += z;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += x;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += z;
|
||||
}
|
||||
|
||||
protected int nextInt(int range) {
|
||||
int i = (int)((this.chunkSeed >> 24) % (long)range);
|
||||
if(i < 0) {
|
||||
i += range;
|
||||
}
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += this.worldGenSeed;
|
||||
return i;
|
||||
}
|
||||
|
||||
protected int getRandom(int... ids) {
|
||||
return ids[this.nextInt(ids.length)];
|
||||
}
|
||||
|
||||
protected int getFrequent(int a, int b, int c, int d) {
|
||||
return
|
||||
b == c && c == d ? b :
|
||||
(a == b && a == c ? a :
|
||||
(a == b && a == d ? a :
|
||||
(a == c && a == d ? a :
|
||||
(a == b && c != d ? a :
|
||||
(a == c && b != d ? a :
|
||||
(a == d && b != c ? a :
|
||||
(b == c && a != d ? b :
|
||||
(b == d && a != c ? b :
|
||||
(c == d && a != b ? c :
|
||||
this.getRandom(a, b, c, d)
|
||||
)))))))));
|
||||
}
|
||||
}
|
103
java/src/game/worldgen/layer/GenLayerAddAreas.java
Executable file
103
java/src/game/worldgen/layer/GenLayerAddAreas.java
Executable file
|
@ -0,0 +1,103 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerAddAreas extends GenLayer
|
||||
{
|
||||
public GenLayerAddAreas(long p_i2119_1_, GenLayer p_i2119_3_)
|
||||
{
|
||||
super(p_i2119_1_);
|
||||
this.parent = p_i2119_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 i = areaX - 1;
|
||||
int j = areaY - 1;
|
||||
int k = areaWidth + 2;
|
||||
int l = areaHeight + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int i1 = 0; i1 < areaHeight; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < areaWidth; ++j1)
|
||||
{
|
||||
int k1 = aint[j1 + 0 + (i1 + 0) * k];
|
||||
int l1 = aint[j1 + 2 + (i1 + 0) * k];
|
||||
int i2 = aint[j1 + 0 + (i1 + 2) * k];
|
||||
int j2 = aint[j1 + 2 + (i1 + 2) * k];
|
||||
int k2 = aint[j1 + 1 + (i1 + 1) * k];
|
||||
this.initChunkSeed((long)(j1 + areaX), (long)(i1 + areaY));
|
||||
|
||||
if (k2 != 0 || k1 == 0 && l1 == 0 && i2 == 0 && j2 == 0)
|
||||
{
|
||||
if (k2 > 0 && (k1 == 0 || l1 == 0 || i2 == 0 || j2 == 0))
|
||||
{
|
||||
if (this.nextInt(5) == 0)
|
||||
{
|
||||
if (k2 == 4)
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = k2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = k2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int l2 = 1;
|
||||
int i3 = 1;
|
||||
|
||||
if (k1 != 0 && this.nextInt(l2++) == 0)
|
||||
{
|
||||
i3 = k1;
|
||||
}
|
||||
|
||||
if (l1 != 0 && this.nextInt(l2++) == 0)
|
||||
{
|
||||
i3 = l1;
|
||||
}
|
||||
|
||||
if (i2 != 0 && this.nextInt(l2++) == 0)
|
||||
{
|
||||
i3 = i2;
|
||||
}
|
||||
|
||||
if (j2 != 0 && this.nextInt(l2++) == 0)
|
||||
{
|
||||
i3 = j2;
|
||||
}
|
||||
|
||||
if (this.nextInt(3) == 0)
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = i3;
|
||||
}
|
||||
else if (i3 == 4)
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
}
|
54
java/src/game/worldgen/layer/GenLayerAddExtra.java
Executable file
54
java/src/game/worldgen/layer/GenLayerAddExtra.java
Executable file
|
@ -0,0 +1,54 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.biome.Biome;
|
||||
|
||||
public class GenLayerAddExtra extends GenLayer
|
||||
{
|
||||
private final int[] biomes;
|
||||
private final int rarity;
|
||||
|
||||
public GenLayerAddExtra(long base, GenLayer parent, Biome[] biomes, int rarity)
|
||||
{
|
||||
super(base);
|
||||
this.parent = parent;
|
||||
this.biomes = new int[biomes.length];
|
||||
for(int z = 0; z < biomes.length; z++) {
|
||||
this.biomes[z] = biomes[z].id;
|
||||
}
|
||||
this.rarity = rarity < 1 ? 1 : rarity;
|
||||
}
|
||||
|
||||
public int[] getInts(int x, int z, int width, int height)
|
||||
{
|
||||
int i = x - 1;
|
||||
int j = z - 1;
|
||||
int k = width + 2;
|
||||
int l = height + 2;
|
||||
int[] pre = this.parent.getInts(i, j, k, l);
|
||||
int[] data = IntCache.getIntCache(width * height);
|
||||
|
||||
for (int i1 = 0; i1 < height; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < width; ++j1)
|
||||
{
|
||||
int k1 = pre[j1 + 0 + (i1 + 0) * k];
|
||||
int l1 = pre[j1 + 2 + (i1 + 0) * k];
|
||||
int i2 = pre[j1 + 0 + (i1 + 2) * k];
|
||||
int j2 = pre[j1 + 2 + (i1 + 2) * k];
|
||||
int k2 = pre[j1 + 1 + (i1 + 1) * k];
|
||||
this.initChunkSeed((long)(j1 + x), (long)(i1 + z));
|
||||
|
||||
if (this.biomes.length > 0 && k2 == 0 && k1 < 2 && l1 < 2 && i2 < 2 && j2 < 2 && this.nextInt(this.rarity) == 0)
|
||||
{
|
||||
data[j1 + i1 * width] = this.biomes[this.nextInt(this.biomes.length)];
|
||||
}
|
||||
else
|
||||
{
|
||||
data[j1 + i1 * width] = k2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
74
java/src/game/worldgen/layer/GenLayerAddSea.java
Executable file
74
java/src/game/worldgen/layer/GenLayerAddSea.java
Executable file
|
@ -0,0 +1,74 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.biome.Biome;
|
||||
|
||||
public class GenLayerAddSea extends GenLayer
|
||||
{
|
||||
private final int rarity;
|
||||
|
||||
public GenLayerAddSea(long p_i45472_1_, GenLayer p_i45472_3_, int rarity)
|
||||
{
|
||||
super(p_i45472_1_);
|
||||
this.parent = p_i45472_3_;
|
||||
this.rarity = rarity < 1 ? 1 : rarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 i = areaX - 1;
|
||||
int j = areaY - 1;
|
||||
int k = areaWidth + 2;
|
||||
int l = areaHeight + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int i1 = 0; i1 < areaHeight; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < areaWidth; ++j1)
|
||||
{
|
||||
int k1 = aint[j1 + 1 + (i1 + 1 - 1) * (areaWidth + 2)];
|
||||
int l1 = aint[j1 + 1 + 1 + (i1 + 1) * (areaWidth + 2)];
|
||||
int i2 = aint[j1 + 1 - 1 + (i1 + 1) * (areaWidth + 2)];
|
||||
int j2 = aint[j1 + 1 + (i1 + 1 + 1) * (areaWidth + 2)];
|
||||
int k2 = aint[j1 + 1 + (i1 + 1) * k];
|
||||
int l2 = 0;
|
||||
|
||||
if (k1 == 4)
|
||||
{
|
||||
++l2;
|
||||
}
|
||||
|
||||
if (l1 == 4)
|
||||
{
|
||||
++l2;
|
||||
}
|
||||
|
||||
if (i2 == 4)
|
||||
{
|
||||
++l2;
|
||||
}
|
||||
|
||||
if (j2 == 4)
|
||||
{
|
||||
++l2;
|
||||
}
|
||||
|
||||
this.initChunkSeed((long)(areaX + j1), (long)(areaY + i1));
|
||||
if (k2 == 0 && this.nextInt(this.rarity) == 0)
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = l2 > 1 ? Biome.frozenSea.id : Biome.sea.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = k2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
}
|
62
java/src/game/worldgen/layer/GenLayerAddSnow.java
Executable file
62
java/src/game/worldgen/layer/GenLayerAddSnow.java
Executable file
|
@ -0,0 +1,62 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerAddSnow extends GenLayer
|
||||
{
|
||||
private final int rarity;
|
||||
|
||||
public GenLayerAddSnow(long p_i2121_1_, GenLayer p_i2121_3_, int snowRarity)
|
||||
{
|
||||
super(p_i2121_1_);
|
||||
this.parent = p_i2121_3_;
|
||||
this.rarity = snowRarity < 1 ? 1 : snowRarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 i = areaX - 1;
|
||||
int j = areaY - 1;
|
||||
int k = areaWidth + 2;
|
||||
int l = areaHeight + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int i1 = 0; i1 < areaHeight; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < areaWidth; ++j1)
|
||||
{
|
||||
int k1 = aint[j1 + 1 + (i1 + 1) * k];
|
||||
this.initChunkSeed((long)(j1 + areaX), (long)(i1 + areaY));
|
||||
|
||||
if (k1 == 0)
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int l1 = this.nextInt(this.rarity);
|
||||
|
||||
if (l1 == 0)
|
||||
{
|
||||
l1 = 4;
|
||||
}
|
||||
else if (l1 <= 1)
|
||||
{
|
||||
l1 = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
l1 = 1;
|
||||
}
|
||||
|
||||
aint1[j1 + i1 * areaWidth] = l1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
}
|
30
java/src/game/worldgen/layer/GenLayerBase.java
Executable file
30
java/src/game/worldgen/layer/GenLayerBase.java
Executable file
|
@ -0,0 +1,30 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerBase extends GenLayer
|
||||
{
|
||||
public GenLayerBase(long base)
|
||||
{
|
||||
super(base);
|
||||
}
|
||||
|
||||
public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight)
|
||||
{
|
||||
int[] aint = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int i = 0; i < areaHeight; ++i)
|
||||
{
|
||||
for (int j = 0; j < areaWidth; ++j)
|
||||
{
|
||||
this.initChunkSeed((long)(areaX + j), (long)(areaY + i));
|
||||
aint[j + i * areaWidth] = this.nextInt(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (areaX > -areaWidth && areaX <= 0 && areaY > -areaHeight && areaY <= 0)
|
||||
{
|
||||
aint[-areaX + -areaY * areaWidth] = 1;
|
||||
}
|
||||
|
||||
return aint;
|
||||
}
|
||||
}
|
71
java/src/game/worldgen/layer/GenLayerBiome.java
Executable file
71
java/src/game/worldgen/layer/GenLayerBiome.java
Executable file
|
@ -0,0 +1,71 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.biome.Biome;
|
||||
|
||||
public class GenLayerBiome extends GenLayer
|
||||
{
|
||||
private final Biome[] hot;
|
||||
private final Biome[] medium;
|
||||
private final Biome[] cold;
|
||||
private final Biome[] frost;
|
||||
private final int def;
|
||||
private final int fixed;
|
||||
|
||||
public GenLayerBiome(long base, GenLayer parent, Biome[] hot, Biome[] medium, Biome[] cold, Biome[] frost, Biome def, boolean fixed)
|
||||
{
|
||||
super(base);
|
||||
this.parent = parent;
|
||||
this.def = def.id;
|
||||
this.fixed = fixed ? def.id : -1;
|
||||
this.hot = hot;
|
||||
this.medium = medium;
|
||||
this.cold = cold;
|
||||
this.frost = frost;
|
||||
}
|
||||
|
||||
public int[] getInts(int x, int z, int width, int height)
|
||||
{
|
||||
int[] pre = this.parent.getInts(x, z, width, height);
|
||||
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 + i * width];
|
||||
|
||||
if (this.fixed >= 0)
|
||||
{
|
||||
data[j + i * width] = this.fixed;
|
||||
}
|
||||
else if (id == 0 || isSea(id))
|
||||
{
|
||||
data[j + i * width] = id;
|
||||
}
|
||||
else if (id == 1)
|
||||
{
|
||||
data[j + i * width] = this.hot[this.nextInt(this.hot.length)].id;
|
||||
}
|
||||
else if (id == 2)
|
||||
{
|
||||
data[j + i * width] = this.medium[this.nextInt(this.medium.length)].id;
|
||||
}
|
||||
else if (id == 3)
|
||||
{
|
||||
data[j + i * width] = this.cold[this.nextInt(this.cold.length)].id;
|
||||
}
|
||||
else if (id == 4)
|
||||
{
|
||||
data[j + i * width] = this.frost[this.nextInt(this.frost.length)].id;
|
||||
}
|
||||
else
|
||||
{
|
||||
data[j + i * width] = this.def;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
166
java/src/game/worldgen/layer/GenLayerBiomeEdge.java
Executable file
166
java/src/game/worldgen/layer/GenLayerBiomeEdge.java
Executable file
|
@ -0,0 +1,166 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.biome.Biome;
|
||||
|
||||
public class GenLayerBiomeEdge extends GenLayer
|
||||
{
|
||||
public GenLayerBiomeEdge(long p_i45475_1_, GenLayer p_i45475_3_)
|
||||
{
|
||||
super(p_i45475_1_);
|
||||
this.parent = p_i45475_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.extremeHills.id, Biome.extremeHillsEdge.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.megaTaiga.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.icePlains.id && i2 != Biome.icePlains.id && j2 != Biome.icePlains.id && k2 != Biome.icePlains.id)
|
||||
{
|
||||
aint1[j + i * areaWidth] = k;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j + i * areaWidth] = Biome.extremeHillsPlus.id;
|
||||
}
|
||||
}
|
||||
else if (k == Biome.swampland.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.coldTaiga.id && i1 != Biome.coldTaiga.id && j1 != Biome.coldTaiga.id && k1 != Biome.coldTaiga.id && l != Biome.icePlains.id && i1 != Biome.icePlains.id && j1 != Biome.icePlains.id && k1 != Biome.icePlains.id)
|
||||
{
|
||||
if (l != Biome.jungle.id && k1 != Biome.jungle.id && i1 != Biome.jungle.id && j1 != Biome.jungle.id)
|
||||
{
|
||||
aint1[j + i * areaWidth] = k;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j + i * areaWidth] = Biome.jungleEdge.id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j + i * areaWidth] = Biome.plains.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 = Biome.getBiome(p_151634_1_);
|
||||
Biome biomegenbase1 = Biome.getBiome(p_151634_2_);
|
||||
|
||||
if (biomegenbase != null && biomegenbase1 != null)
|
||||
{
|
||||
Biome.TempCategory biomegenbase$tempcategory = biomegenbase.getTempCategory();
|
||||
Biome.TempCategory biomegenbase$tempcategory1 = biomegenbase1.getTempCategory();
|
||||
return biomegenbase$tempcategory == biomegenbase$tempcategory1 || biomegenbase$tempcategory == Biome.TempCategory.MEDIUM || biomegenbase$tempcategory1 == Biome.TempCategory.MEDIUM;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
111
java/src/game/worldgen/layer/GenLayerEdge.java
Executable file
111
java/src/game/worldgen/layer/GenLayerEdge.java
Executable file
|
@ -0,0 +1,111 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerEdge extends GenLayer
|
||||
{
|
||||
private final GenLayerEdge.Mode mode;
|
||||
|
||||
public GenLayerEdge(long p_i45474_1_, GenLayer p_i45474_3_, GenLayerEdge.Mode p_i45474_4_)
|
||||
{
|
||||
super(p_i45474_1_);
|
||||
this.parent = p_i45474_3_;
|
||||
this.mode = p_i45474_4_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
switch (this.mode)
|
||||
{
|
||||
case COOL_WARM:
|
||||
default:
|
||||
return this.getIntsCoolWarm(areaX, areaY, areaWidth, areaHeight);
|
||||
|
||||
case HEAT_ICE:
|
||||
return this.getIntsHeatIce(areaX, areaY, areaWidth, areaHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private int[] getIntsCoolWarm(int p_151626_1_, int p_151626_2_, int p_151626_3_, int p_151626_4_)
|
||||
{
|
||||
int i = p_151626_1_ - 1;
|
||||
int j = p_151626_2_ - 1;
|
||||
int k = 1 + p_151626_3_ + 1;
|
||||
int l = 1 + p_151626_4_ + 1;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(p_151626_3_ * p_151626_4_);
|
||||
|
||||
for (int i1 = 0; i1 < p_151626_4_; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < p_151626_3_; ++j1)
|
||||
{
|
||||
this.initChunkSeed((long)(j1 + p_151626_1_), (long)(i1 + p_151626_2_));
|
||||
int k1 = aint[j1 + 1 + (i1 + 1) * k];
|
||||
|
||||
if (k1 == 1)
|
||||
{
|
||||
int l1 = aint[j1 + 1 + (i1 + 1 - 1) * k];
|
||||
int i2 = aint[j1 + 1 + 1 + (i1 + 1) * k];
|
||||
int j2 = aint[j1 + 1 - 1 + (i1 + 1) * k];
|
||||
int k2 = aint[j1 + 1 + (i1 + 1 + 1) * k];
|
||||
boolean flag = l1 == 3 || i2 == 3 || j2 == 3 || k2 == 3;
|
||||
boolean flag1 = l1 == 4 || i2 == 4 || j2 == 4 || k2 == 4;
|
||||
|
||||
if (flag || flag1)
|
||||
{
|
||||
k1 = 2;
|
||||
}
|
||||
}
|
||||
|
||||
aint1[j1 + i1 * p_151626_3_] = k1;
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
|
||||
private int[] getIntsHeatIce(int p_151624_1_, int p_151624_2_, int p_151624_3_, int p_151624_4_)
|
||||
{
|
||||
int i = p_151624_1_ - 1;
|
||||
int j = p_151624_2_ - 1;
|
||||
int k = 1 + p_151624_3_ + 1;
|
||||
int l = 1 + p_151624_4_ + 1;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(p_151624_3_ * p_151624_4_);
|
||||
|
||||
for (int i1 = 0; i1 < p_151624_4_; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < p_151624_3_; ++j1)
|
||||
{
|
||||
int k1 = aint[j1 + 1 + (i1 + 1) * k];
|
||||
|
||||
if (k1 == 4)
|
||||
{
|
||||
int l1 = aint[j1 + 1 + (i1 + 1 - 1) * k];
|
||||
int i2 = aint[j1 + 1 + 1 + (i1 + 1) * k];
|
||||
int j2 = aint[j1 + 1 - 1 + (i1 + 1) * k];
|
||||
int k2 = aint[j1 + 1 + (i1 + 1 + 1) * k];
|
||||
boolean flag = l1 == 2 || i2 == 2 || j2 == 2 || k2 == 2;
|
||||
boolean flag1 = l1 == 1 || i2 == 1 || j2 == 1 || k2 == 1;
|
||||
|
||||
if (flag1 || flag)
|
||||
{
|
||||
k1 = 3;
|
||||
}
|
||||
}
|
||||
|
||||
aint1[j1 + i1 * p_151624_3_] = k1;
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
|
||||
public static enum Mode
|
||||
{
|
||||
COOL_WARM,
|
||||
HEAT_ICE;
|
||||
}
|
||||
}
|
17
java/src/game/worldgen/layer/GenLayerFuzzyZoom.java
Executable file
17
java/src/game/worldgen/layer/GenLayerFuzzyZoom.java
Executable file
|
@ -0,0 +1,17 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerFuzzyZoom extends GenLayerZoom
|
||||
{
|
||||
public GenLayerFuzzyZoom(long p_i2123_1_, GenLayer p_i2123_3_)
|
||||
{
|
||||
super(p_i2123_1_, p_i2123_3_);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the most frequently occurring number of the set, or a random number from those provided
|
||||
*/
|
||||
protected int getFrequent(int p_151617_1_, int p_151617_2_, int p_151617_3_, int p_151617_4_)
|
||||
{
|
||||
return this.getRandom(p_151617_1_, p_151617_2_, p_151617_3_, p_151617_4_);
|
||||
}
|
||||
}
|
198
java/src/game/worldgen/layer/GenLayerHills.java
Executable file
198
java/src/game/worldgen/layer/GenLayerHills.java
Executable file
|
@ -0,0 +1,198 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.Log;
|
||||
import game.biome.Biome;
|
||||
|
||||
public class GenLayerHills extends GenLayer
|
||||
{
|
||||
private GenLayer field_151628_d;
|
||||
private final int def;
|
||||
|
||||
public GenLayerHills(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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.JNI.warn("Altes Biom (" + k + ")!");
|
||||
}
|
||||
|
||||
if (k != 0 && l >= 2 && (l - 2) % 29 == 1 && k < 128)
|
||||
{
|
||||
if (Biome.getBiome(k + 128) != null)
|
||||
{
|
||||
aint2[j + i * areaWidth] = k + 128;
|
||||
}
|
||||
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.desertHills.id;
|
||||
}
|
||||
else if (k == Biome.forest.id)
|
||||
{
|
||||
i1 = Biome.forestHills.id;
|
||||
}
|
||||
else if (k == Biome.birchForest.id)
|
||||
{
|
||||
i1 = Biome.birchForestHills.id;
|
||||
}
|
||||
else if (k == Biome.roofedForest.id)
|
||||
{
|
||||
i1 = Biome.plains.id;
|
||||
}
|
||||
else if (k == Biome.taiga.id)
|
||||
{
|
||||
i1 = Biome.taigaHills.id;
|
||||
}
|
||||
else if (k == Biome.megaTaiga.id)
|
||||
{
|
||||
i1 = Biome.megaTaigaHills.id;
|
||||
}
|
||||
else if (k == Biome.coldTaiga.id)
|
||||
{
|
||||
i1 = Biome.coldTaigaHills.id;
|
||||
}
|
||||
else if (k == Biome.plains.id)
|
||||
{
|
||||
if (this.nextInt(3) == 0)
|
||||
{
|
||||
i1 = Biome.forestHills.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
i1 = Biome.forest.id;
|
||||
}
|
||||
}
|
||||
else if (k == Biome.icePlains.id)
|
||||
{
|
||||
i1 = Biome.iceMountains.id;
|
||||
}
|
||||
else if (k == Biome.jungle.id)
|
||||
{
|
||||
i1 = Biome.jungleHills.id;
|
||||
}
|
||||
else if (k == Biome.none.id)
|
||||
{
|
||||
i1 = this.def;
|
||||
}
|
||||
else if (k == Biome.extremeHills.id)
|
||||
{
|
||||
i1 = Biome.extremeHillsPlus.id;
|
||||
}
|
||||
else if (k == Biome.savanna.id)
|
||||
{
|
||||
i1 = Biome.savannaPlateau.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.plains.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
i1 = Biome.forest.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag && i1 != k)
|
||||
{
|
||||
if (Biome.getBiome(i1 + 128) != null)
|
||||
{
|
||||
i1 += 128;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
45
java/src/game/worldgen/layer/GenLayerRemoveEmpty.java
Executable file
45
java/src/game/worldgen/layer/GenLayerRemoveEmpty.java
Executable file
|
@ -0,0 +1,45 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerRemoveEmpty extends GenLayer
|
||||
{
|
||||
public GenLayerRemoveEmpty(long p_i45480_1_, GenLayer p_i45480_3_)
|
||||
{
|
||||
super(p_i45480_1_);
|
||||
this.parent = p_i45480_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 i = areaX - 1;
|
||||
int j = areaY - 1;
|
||||
int k = areaWidth + 2;
|
||||
int l = areaHeight + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int i1 = 0; i1 < areaHeight; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < areaWidth; ++j1)
|
||||
{
|
||||
int k1 = aint[j1 + 1 + (i1 + 1 - 1) * (areaWidth + 2)];
|
||||
int l1 = aint[j1 + 1 + 1 + (i1 + 1) * (areaWidth + 2)];
|
||||
int i2 = aint[j1 + 1 - 1 + (i1 + 1) * (areaWidth + 2)];
|
||||
int j2 = aint[j1 + 1 + (i1 + 1 + 1) * (areaWidth + 2)];
|
||||
int k2 = aint[j1 + 1 + (i1 + 1) * k];
|
||||
aint1[j1 + i1 * areaWidth] = k2;
|
||||
this.initChunkSeed((long)(j1 + areaX), (long)(i1 + areaY));
|
||||
|
||||
if (k2 == 0 && k1 == 0 && l1 == 0 && i2 == 0 && j2 == 0 && this.nextInt(2) == 0)
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
}
|
54
java/src/game/worldgen/layer/GenLayerRiver.java
Executable file
54
java/src/game/worldgen/layer/GenLayerRiver.java
Executable file
|
@ -0,0 +1,54 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.biome.Biome;
|
||||
|
||||
public class GenLayerRiver extends GenLayer
|
||||
{
|
||||
public GenLayerRiver(long p_i2128_1_, GenLayer p_i2128_3_)
|
||||
{
|
||||
super(p_i2128_1_);
|
||||
super.parent = p_i2128_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 i = areaX - 1;
|
||||
int j = areaY - 1;
|
||||
int k = areaWidth + 2;
|
||||
int l = areaHeight + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int i1 = 0; i1 < areaHeight; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < areaWidth; ++j1)
|
||||
{
|
||||
int k1 = this.func_151630_c(aint[j1 + 0 + (i1 + 1) * k]);
|
||||
int l1 = this.func_151630_c(aint[j1 + 2 + (i1 + 1) * k]);
|
||||
int i2 = this.func_151630_c(aint[j1 + 1 + (i1 + 0) * k]);
|
||||
int j2 = this.func_151630_c(aint[j1 + 1 + (i1 + 2) * k]);
|
||||
int k2 = this.func_151630_c(aint[j1 + 1 + (i1 + 1) * k]);
|
||||
|
||||
if (k2 == k1 && k2 == i2 && k2 == l1 && k2 == j2)
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j1 + i1 * areaWidth] = Biome.river.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
|
||||
private int func_151630_c(int p_151630_1_)
|
||||
{
|
||||
return p_151630_1_ >= 2 ? 2 + (p_151630_1_ & 1) : p_151630_1_;
|
||||
}
|
||||
}
|
31
java/src/game/worldgen/layer/GenLayerRiverInit.java
Executable file
31
java/src/game/worldgen/layer/GenLayerRiverInit.java
Executable file
|
@ -0,0 +1,31 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerRiverInit extends GenLayer
|
||||
{
|
||||
public GenLayerRiverInit(long p_i2127_1_, GenLayer p_i2127_3_)
|
||||
{
|
||||
super(p_i2127_1_);
|
||||
this.parent = p_i2127_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, areaY, areaWidth, areaHeight);
|
||||
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));
|
||||
aint1[j + i * areaWidth] = aint[j + i * areaWidth] > 0 ? this.nextInt(299999) + 2 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
}
|
73
java/src/game/worldgen/layer/GenLayerRiverMix.java
Executable file
73
java/src/game/worldgen/layer/GenLayerRiverMix.java
Executable file
|
@ -0,0 +1,73 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import game.biome.Biome;
|
||||
|
||||
public class GenLayerRiverMix extends GenLayer
|
||||
{
|
||||
private GenLayer biomePatternGeneratorChain;
|
||||
private GenLayer riverPatternGeneratorChain;
|
||||
private final int def;
|
||||
|
||||
public GenLayerRiverMix(long p_i2129_1_, GenLayer p_i2129_3_, GenLayer p_i2129_4_, Biome def)
|
||||
{
|
||||
super(p_i2129_1_);
|
||||
this.biomePatternGeneratorChain = p_i2129_3_;
|
||||
this.riverPatternGeneratorChain = p_i2129_4_;
|
||||
this.def = def.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize layer's local worldGenSeed based on its own baseSeed and the world's global seed (passed in as an
|
||||
* argument).
|
||||
*/
|
||||
public void initWorldGenSeed(long seed)
|
||||
{
|
||||
this.biomePatternGeneratorChain.initWorldGenSeed(seed);
|
||||
this.riverPatternGeneratorChain.initWorldGenSeed(seed);
|
||||
super.initWorldGenSeed(seed);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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[] 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)
|
||||
{
|
||||
if(biome[i] == Biome.none.id)
|
||||
{
|
||||
out[i] = this.def;
|
||||
}
|
||||
else if(biome[i] == Biome.sea.id || biome[i] == Biome.frozenSea.id)
|
||||
{
|
||||
out[i] = biome[i];
|
||||
}
|
||||
else if (river[i] == Biome.river.id)
|
||||
{
|
||||
if (biome[i] == Biome.icePlains.id)
|
||||
{
|
||||
out[i] = Biome.frozenRiver.id;
|
||||
}
|
||||
else // if (biome[i] != Biome.mushroomPlains.id && biome[i] != Biome.mushroomPlainsEdge.id)
|
||||
{
|
||||
out[i] = Biome.river.id;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// out[i] = Biome.mushroomPlainsEdge.id;
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
out[i] = biome[i];
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
163
java/src/game/worldgen/layer/GenLayerShore.java
Executable file
163
java/src/game/worldgen/layer/GenLayerShore.java
Executable file
|
@ -0,0 +1,163 @@
|
|||
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.snowyGen)
|
||||
{
|
||||
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.waterGen)
|
||||
{
|
||||
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;
|
||||
// }
|
||||
}
|
66
java/src/game/worldgen/layer/GenLayerSmooth.java
Executable file
66
java/src/game/worldgen/layer/GenLayerSmooth.java
Executable file
|
@ -0,0 +1,66 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerSmooth extends GenLayer
|
||||
{
|
||||
public GenLayerSmooth(long p_i2131_1_, GenLayer p_i2131_3_)
|
||||
{
|
||||
super(p_i2131_1_);
|
||||
super.parent = p_i2131_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 i = areaX - 1;
|
||||
int j = areaY - 1;
|
||||
int k = areaWidth + 2;
|
||||
int l = areaHeight + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int i1 = 0; i1 < areaHeight; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < areaWidth; ++j1)
|
||||
{
|
||||
int k1 = aint[j1 + 0 + (i1 + 1) * k];
|
||||
int l1 = aint[j1 + 2 + (i1 + 1) * k];
|
||||
int i2 = aint[j1 + 1 + (i1 + 0) * k];
|
||||
int j2 = aint[j1 + 1 + (i1 + 2) * k];
|
||||
int k2 = aint[j1 + 1 + (i1 + 1) * k];
|
||||
|
||||
if (k1 == l1 && i2 == j2)
|
||||
{
|
||||
this.initChunkSeed((long)(j1 + areaX), (long)(i1 + areaY));
|
||||
|
||||
if (this.nextInt(2) == 0)
|
||||
{
|
||||
k2 = k1;
|
||||
}
|
||||
else
|
||||
{
|
||||
k2 = i2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (k1 == l1)
|
||||
{
|
||||
k2 = k1;
|
||||
}
|
||||
|
||||
if (i2 == j2)
|
||||
{
|
||||
k2 = i2;
|
||||
}
|
||||
}
|
||||
|
||||
aint1[j1 + i1 * areaWidth] = k2;
|
||||
}
|
||||
}
|
||||
|
||||
return aint1;
|
||||
}
|
||||
}
|
95
java/src/game/worldgen/layer/GenLayerVoronoiZoom.java
Executable file
95
java/src/game/worldgen/layer/GenLayerVoronoiZoom.java
Executable file
|
@ -0,0 +1,95 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerVoronoiZoom extends GenLayer
|
||||
{
|
||||
public GenLayerVoronoiZoom(long p_i2133_1_, GenLayer p_i2133_3_)
|
||||
{
|
||||
super(p_i2133_1_);
|
||||
super.parent = p_i2133_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
areaX = areaX - 2;
|
||||
areaY = areaY - 2;
|
||||
int i = areaX >> 2;
|
||||
int j = areaY >> 2;
|
||||
int k = (areaWidth >> 2) + 2;
|
||||
int l = (areaHeight >> 2) + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int i1 = k - 1 << 2;
|
||||
int j1 = l - 1 << 2;
|
||||
int[] aint1 = IntCache.getIntCache(i1 * j1);
|
||||
|
||||
for (int k1 = 0; k1 < l - 1; ++k1)
|
||||
{
|
||||
int l1 = 0;
|
||||
int i2 = aint[l1 + 0 + (k1 + 0) * k];
|
||||
|
||||
for (int j2 = aint[l1 + 0 + (k1 + 1) * k]; l1 < k - 1; ++l1)
|
||||
{
|
||||
double d0 = 3.6D;
|
||||
this.initChunkSeed((long)(l1 + i << 2), (long)(k1 + j << 2));
|
||||
double d1 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D;
|
||||
double d2 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D;
|
||||
this.initChunkSeed((long)(l1 + i + 1 << 2), (long)(k1 + j << 2));
|
||||
double d3 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
||||
double d4 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D;
|
||||
this.initChunkSeed((long)(l1 + i << 2), (long)(k1 + j + 1 << 2));
|
||||
double d5 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D;
|
||||
double d6 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
||||
this.initChunkSeed((long)(l1 + i + 1 << 2), (long)(k1 + j + 1 << 2));
|
||||
double d7 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
||||
double d8 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D;
|
||||
int k2 = aint[l1 + 1 + (k1 + 0) * k] & 255;
|
||||
int l2 = aint[l1 + 1 + (k1 + 1) * k] & 255;
|
||||
|
||||
for (int i3 = 0; i3 < 4; ++i3)
|
||||
{
|
||||
int j3 = ((k1 << 2) + i3) * i1 + (l1 << 2);
|
||||
|
||||
for (int k3 = 0; k3 < 4; ++k3)
|
||||
{
|
||||
double d9 = ((double)i3 - d2) * ((double)i3 - d2) + ((double)k3 - d1) * ((double)k3 - d1);
|
||||
double d10 = ((double)i3 - d4) * ((double)i3 - d4) + ((double)k3 - d3) * ((double)k3 - d3);
|
||||
double d11 = ((double)i3 - d6) * ((double)i3 - d6) + ((double)k3 - d5) * ((double)k3 - d5);
|
||||
double d12 = ((double)i3 - d8) * ((double)i3 - d8) + ((double)k3 - d7) * ((double)k3 - d7);
|
||||
|
||||
if (d9 < d10 && d9 < d11 && d9 < d12)
|
||||
{
|
||||
aint1[j3++] = i2;
|
||||
}
|
||||
else if (d10 < d9 && d10 < d11 && d10 < d12)
|
||||
{
|
||||
aint1[j3++] = k2;
|
||||
}
|
||||
else if (d11 < d9 && d11 < d10 && d11 < d12)
|
||||
{
|
||||
aint1[j3++] = j2;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint1[j3++] = l2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i2 = k2;
|
||||
j2 = l2;
|
||||
}
|
||||
}
|
||||
|
||||
int[] aint2 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int l3 = 0; l3 < areaHeight; ++l3)
|
||||
{
|
||||
System.arraycopy(aint1, (l3 + (areaY & 3)) * i1 + (areaX & 3), aint2, l3 * areaWidth, areaWidth);
|
||||
}
|
||||
|
||||
return aint2;
|
||||
}
|
||||
}
|
70
java/src/game/worldgen/layer/GenLayerZoom.java
Executable file
70
java/src/game/worldgen/layer/GenLayerZoom.java
Executable file
|
@ -0,0 +1,70 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
public class GenLayerZoom extends GenLayer
|
||||
{
|
||||
public GenLayerZoom(long p_i2134_1_, GenLayer p_i2134_3_)
|
||||
{
|
||||
super(p_i2134_1_);
|
||||
super.parent = p_i2134_3_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 i = areaX >> 1;
|
||||
int j = areaY >> 1;
|
||||
int k = (areaWidth >> 1) + 2;
|
||||
int l = (areaHeight >> 1) + 2;
|
||||
int[] aint = this.parent.getInts(i, j, k, l);
|
||||
int i1 = k - 1 << 1;
|
||||
int j1 = l - 1 << 1;
|
||||
int[] aint1 = IntCache.getIntCache(i1 * j1);
|
||||
|
||||
for (int k1 = 0; k1 < l - 1; ++k1)
|
||||
{
|
||||
int l1 = (k1 << 1) * i1;
|
||||
int i2 = 0;
|
||||
int j2 = aint[i2 + 0 + (k1 + 0) * k];
|
||||
|
||||
for (int k2 = aint[i2 + 0 + (k1 + 1) * k]; i2 < k - 1; ++i2)
|
||||
{
|
||||
this.initChunkSeed((long)(i2 + i << 1), (long)(k1 + j << 1));
|
||||
int l2 = aint[i2 + 1 + (k1 + 0) * k];
|
||||
int i3 = aint[i2 + 1 + (k1 + 1) * k];
|
||||
aint1[l1] = j2;
|
||||
aint1[l1++ + i1] = this.getRandom(j2, k2);
|
||||
aint1[l1] = this.getRandom(j2, l2);
|
||||
aint1[l1++ + i1] = this.getFrequent(j2, l2, k2, i3);
|
||||
j2 = l2;
|
||||
k2 = i3;
|
||||
}
|
||||
}
|
||||
|
||||
int[] aint2 = IntCache.getIntCache(areaWidth * areaHeight);
|
||||
|
||||
for (int j3 = 0; j3 < areaHeight; ++j3)
|
||||
{
|
||||
System.arraycopy(aint1, (j3 + (areaY & 1)) * i1 + (areaX & 1), aint2, j3 * areaWidth, areaWidth);
|
||||
}
|
||||
|
||||
return aint2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magnify a layer. Parms are seed adjustment, layer, number of times to magnify
|
||||
*/
|
||||
public static GenLayer magnify(long p_75915_0_, GenLayer p_75915_2_, int p_75915_3_)
|
||||
{
|
||||
GenLayer genlayer = p_75915_2_;
|
||||
|
||||
for (int i = 0; i < p_75915_3_; ++i)
|
||||
{
|
||||
genlayer = new GenLayerZoom(p_75915_0_ + (long)i, genlayer);
|
||||
}
|
||||
|
||||
return genlayer;
|
||||
}
|
||||
}
|
84
java/src/game/worldgen/layer/IntCache.java
Executable file
84
java/src/game/worldgen/layer/IntCache.java
Executable file
|
@ -0,0 +1,84 @@
|
|||
package game.worldgen.layer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.collect.Lists;
|
||||
|
||||
public class IntCache
|
||||
{
|
||||
private static int intCacheSize = 256;
|
||||
private static List<int[]> freeSmallArrays = Lists.<int[]>newArrayList();
|
||||
private static List<int[]> inUseSmallArrays = Lists.<int[]>newArrayList();
|
||||
private static List<int[]> freeLargeArrays = Lists.<int[]>newArrayList();
|
||||
private static List<int[]> inUseLargeArrays = Lists.<int[]>newArrayList();
|
||||
|
||||
public static synchronized int[] getIntCache(int p_76445_0_)
|
||||
{
|
||||
if (p_76445_0_ <= 256)
|
||||
{
|
||||
if (freeSmallArrays.isEmpty())
|
||||
{
|
||||
int[] aint4 = new int[256];
|
||||
inUseSmallArrays.add(aint4);
|
||||
return aint4;
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] aint3 = (int[])freeSmallArrays.remove(freeSmallArrays.size() - 1);
|
||||
inUseSmallArrays.add(aint3);
|
||||
return aint3;
|
||||
}
|
||||
}
|
||||
else if (p_76445_0_ > intCacheSize)
|
||||
{
|
||||
intCacheSize = p_76445_0_;
|
||||
freeLargeArrays.clear();
|
||||
inUseLargeArrays.clear();
|
||||
int[] aint2 = new int[intCacheSize];
|
||||
inUseLargeArrays.add(aint2);
|
||||
return aint2;
|
||||
}
|
||||
else if (freeLargeArrays.isEmpty())
|
||||
{
|
||||
int[] aint1 = new int[intCacheSize];
|
||||
inUseLargeArrays.add(aint1);
|
||||
return aint1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] aint = (int[])freeLargeArrays.remove(freeLargeArrays.size() - 1);
|
||||
inUseLargeArrays.add(aint);
|
||||
return aint;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark all pre-allocated arrays as available for re-use by moving them to the appropriate free lists.
|
||||
*/
|
||||
public static synchronized void resetIntCache()
|
||||
{
|
||||
if (!freeLargeArrays.isEmpty())
|
||||
{
|
||||
freeLargeArrays.remove(freeLargeArrays.size() - 1);
|
||||
}
|
||||
|
||||
if (!freeSmallArrays.isEmpty())
|
||||
{
|
||||
freeSmallArrays.remove(freeSmallArrays.size() - 1);
|
||||
}
|
||||
|
||||
freeLargeArrays.addAll(inUseLargeArrays);
|
||||
freeSmallArrays.addAll(inUseSmallArrays);
|
||||
inUseLargeArrays.clear();
|
||||
inUseSmallArrays.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a human-readable string that indicates the sizes of all the cache fields. Basically a synchronized static
|
||||
* toString.
|
||||
*/
|
||||
public static synchronized String getCacheSizes()
|
||||
{
|
||||
return "cache: " + freeLargeArrays.size() + ", tcache: " + freeSmallArrays.size() + ", allocated: " + inUseLargeArrays.size() + ", tallocated: " + inUseSmallArrays.size();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue