Re-added ocean biome gen, Fixed memory crash

This commit is contained in:
ted80-PC 2013-05-26 14:17:58 +02:00
parent ead9eb8539
commit e632668e97
14 changed files with 501 additions and 132 deletions

View file

@ -14,15 +14,16 @@ import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.IntCache;
import biomesoplenty.api.Biomes;
import biomesoplenty.world.layer.BiomeLayer;
import com.google.common.base.Optional;
public class WorldChunkManagerBOP extends WorldChunkManager
{
private GenLayer genBiomes;
private BiomeLayer genBiomes;
/** A GenLayer containing the indices into BiomeGenBase.biomeList[] */
private GenLayer biomeIndexLayer;
private BiomeLayer biomeIndexLayer;
/** The BiomeCache object for this world. */
private BiomeCache biomeCache;
@ -103,9 +104,9 @@ public class WorldChunkManagerBOP extends WorldChunkManager
public WorldChunkManagerBOP(long par1, WorldType par3WorldType)
{
this();
GenLayer[] var4 = GenLayer.initializeAllBiomeGenerators(par1, par3WorldType);
this.genBiomes = (GenLayer) var4[0];
this.biomeIndexLayer = (GenLayer) var4[1];
BiomeLayer[] var4 = BiomeLayer.initializeAllBiomeGenerators(par1, par3WorldType, 0);
this.genBiomes = (BiomeLayer) var4[0];
this.biomeIndexLayer = (BiomeLayer) var4[1];
}
public WorldChunkManagerBOP(World par1World)

View file

@ -15,24 +15,71 @@ public abstract class BiomeLayer
//dim: 0 = surface, 1 = hell, 2 = promised
public static BiomeLayer[] initializeAllBiomeGenerators(long seed, WorldType worldtype, int dim)
{
int biomesize = 3;
if(dim == 1)
if(dim == 0)
{
biomesize = 2;
}
BiomeLayer obj = new BiomeLayerCreate(1L, true);
obj = new BiomeLayerFuzzyZoom(2000L, (BiomeLayer)(obj));
obj = new BiomeLayerIsland(1L, (BiomeLayer)(obj));
obj = new BiomeLayerZoom(2001L, (BiomeLayer)(obj));
obj = new BiomeLayerIsland(2L, (BiomeLayer)(obj));
obj = new BiomeLayerZoom(2002L, (BiomeLayer)(obj));
obj = new BiomeLayerIsland(3L, (BiomeLayer)(obj));
obj = new BiomeLayerZoom(2003L, (BiomeLayer)(obj));
obj = new BiomeLayerIsland(4L, (BiomeLayer)(obj));
//Hell and promised biome gen
BiomeLayer obj = new BiomeLayerCreate(1L);
obj = new BiomeLayerFuzzyZoom(2000L, (BiomeLayer)(obj));
for(int i = 1; i < 3; i++) { obj = new BiomeLayerZoom(2000L + i, (BiomeLayer)(obj)); }
obj = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj)), 0);
obj = new BiomeLayerBiomes(200L, ((BiomeLayer)(obj)), worldtype, dim);
obj = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj)), 2);
for(int j = 0; j < biomesize; j++) { obj = new BiomeLayerZoom(1000L + j, (BiomeLayer)(obj)); }
BiomeLayerVoronoiZoom genlayervoronoizoom = new BiomeLayerVoronoiZoom(10L, ((BiomeLayer)(obj)));
((BiomeLayer)(obj)).initWorldGenSeed(seed);
genlayervoronoizoom.initWorldGenSeed(seed);
return (new BiomeLayer[] { obj, genlayervoronoizoom });
byte size = 4;
BiomeLayer obj1 = obj;
obj1 = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj1)), 0);
obj1 = new BiomeLayerRiverInit(100L, ((BiomeLayer)(obj1)));
obj1 = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj1)), size + 2);
obj1 = new BiomeLayerRiver(1L, ((BiomeLayer)(obj1)));
obj1 = new BiomeLayerSmooth(1000L, ((BiomeLayer)(obj1)));
BiomeLayer obj2 = obj;
obj2 = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj2)), 0);
obj2 = new BiomeLayerBiomes(200L, ((BiomeLayer)(obj2)), worldtype, 0);
obj2 = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj2)), 2);
//obj2 = new BWG4LayerHills(1000L, ((BiomeLayer)(obj2)), generatorSettings);
obj2 = new BiomeLayerZoom(1000, ((BiomeLayer)(obj2)));
//obj2 = new BiomeLayerShore(1000L, ((BiomeLayer)(obj2)));
for (int i = 0 + 1; i < size; i++)
{
obj2 = new BiomeLayerZoom(1000 + i, ((BiomeLayer)(obj2)));
}
obj2 = new BiomeLayerSmooth(1000L, ((BiomeLayer)(obj2)));
obj2 = new BiomeLayerRiverMix(100L, ((BiomeLayer)(obj2)), ((BiomeLayer)(obj1)));
BiomeLayerRiverMix bwg4layerrivermix = ((BiomeLayerRiverMix)(obj2));
BiomeLayerVoronoiZoom genlayervoronoizoom = new BiomeLayerVoronoiZoom(10L, ((BiomeLayer)(obj2)));
((BiomeLayer)(obj2)).initWorldGenSeed(seed);
genlayervoronoizoom.initWorldGenSeed(seed);
return (new BiomeLayer[]
{
obj2, genlayervoronoizoom, bwg4layerrivermix
});
}
else
{
int biomesize = 3;
if(dim == 1)
{
biomesize = 2;
}
//Hell and promised biome gen
BiomeLayer obj = new BiomeLayerCreate(1L, false);
obj = new BiomeLayerFuzzyZoom(2000L, (BiomeLayer)(obj));
for(int i = 1; i < 3; i++) { obj = new BiomeLayerZoom(2000L + i, (BiomeLayer)(obj)); }
obj = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj)), 0);
obj = new BiomeLayerBiomes(200L, ((BiomeLayer)(obj)), worldtype, dim);
obj = BiomeLayerZoom.func_75915_a(1000L, ((BiomeLayer)(obj)), 2);
for(int j = 0; j < biomesize; j++) { obj = new BiomeLayerZoom(1000L + j, (BiomeLayer)(obj)); }
BiomeLayerVoronoiZoom genlayervoronoizoom = new BiomeLayerVoronoiZoom(10L, ((BiomeLayer)(obj)));
((BiomeLayer)(obj)).initWorldGenSeed(seed);
genlayervoronoizoom.initWorldGenSeed(seed);
return (new BiomeLayer[] { obj, genlayervoronoizoom });
}
}
public BiomeLayer(long seed)

View file

@ -13,12 +13,14 @@ import biomesoplenty.configuration.BOPConfiguration;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerBiomes extends BiomeLayer
{
private int dimension = 0;
private BiomeGenBase[] surfaceBiomes;
private static ArrayList<BiomeGenBase> oceanBiomes = new ArrayList<BiomeGenBase>();
private static ArrayList<BiomeGenBase> netherBiomes = new ArrayList<BiomeGenBase>();
private static ArrayList<BiomeGenBase> promisedBiomes = new ArrayList<BiomeGenBase>();
@ -31,6 +33,17 @@ public class BiomeLayerBiomes extends BiomeLayer
//SURFACE BIOMES
surfaceBiomes = par4WorldType.getBiomesForWorldType();
//OCEAN BIOMES
oceanBiomes.add(BiomeGenBase.ocean);
if (Biomes.oceanCoral.isPresent())
{
oceanBiomes.add(Biomes.oceanCoral.get());
}
if (Biomes.oceanKelp.isPresent())
{
oceanBiomes.add(Biomes.oceanKelp.get());
}
//NETHER BIOMES
if (Biomes.netherBase.isPresent())
{
@ -71,7 +84,10 @@ public class BiomeLayerBiomes extends BiomeLayer
public int[] getInts(int par1, int par2, int par3, int par4)
{
int[] var5 = this.parent.getInts(par1, par2, par3, par4);
int[] var6 = LayerIntCache.getIntCache(par3 * par4);
int[] var6 = IntCache.getIntCache(par3 * par4);
boolean coral = Biomes.oceanCoral.isPresent();
boolean kelp = Biomes.oceanKelp.isPresent();
for (int var7 = 0; var7 < par4; ++var7)
{
@ -79,7 +95,35 @@ public class BiomeLayerBiomes extends BiomeLayer
{
this.initChunkSeed((long)(var8 + par1), (long)(var7 + par2));
int var9 = var5[var8 + var7 * par3];
if(dimension == 1) //HELL BIOMES
if(dimension == 0) //SURFACE BIOMES
{
if (var9 == 0)
{
var6[var8 + var7 * par3] = 0;
}
else
{
var6[var8 + var7 * par3] = surfaceBiomes[this.nextInt(surfaceBiomes.length)].biomeID;
}
if (coral)
{
if(var9 == Biomes.oceanCoral.get().biomeID)
{
var6[var8 + var7 * par3] = oceanBiomes.get(this.nextInt(oceanBiomes.size())).biomeID;
}
}
if (kelp)
{
if(var9 == Biomes.oceanKelp.get().biomeID)
{
var6[var8 + var7 * par3] = oceanBiomes.get(this.nextInt(oceanBiomes.size())).biomeID;
}
}
}
else if(dimension == 1) //HELL BIOMES
{
var6[var8 + var7 * par3] = netherBiomes.get(this.nextInt(netherBiomes.size())).biomeID;
}

View file

@ -1,24 +1,51 @@
package biomesoplenty.world.layer;
import net.minecraft.world.gen.layer.IntCache;
import biomesoplenty.api.Biomes;
public class BiomeLayerCreate extends BiomeLayer
{
public BiomeLayerCreate(long par1)
private boolean ocean;
public BiomeLayerCreate(long par1, boolean o)
{
super(par1);
ocean = o;
}
public int[] getInts(int par1, int par2, int par3, int par4)
{
int[] var5 = LayerIntCache.getIntCache(par3 * par4);
int[] var5 = IntCache.getIntCache(par3 * par4);
boolean coral = Biomes.oceanCoral.isPresent();
boolean kelp = Biomes.oceanKelp.isPresent();
for (int var6 = 0; var6 < par4; ++var6)
{
for (int var7 = 0; var7 < par3; ++var7)
{
this.initChunkSeed((long)(par1 + var7), (long)(par2 + var6));
var5[var7 + var6 * par3] = 1;
if(ocean)
{
if(coral) { var5[var7 + var6 * par3] = this.nextInt(10) == 0 ? 1 : Biomes.oceanCoral.get().biomeID; }
else if(kelp) { var5[var7 + var6 * par3] = this.nextInt(10) == 0 ? 1 : Biomes.oceanKelp.get().biomeID; }
else { var5[var7 + var6 * par3] = this.nextInt(10) == 0 ? 1 : 0; }
}
else
{
var5[var7 + var6 * par3] = 1;
}
}
}
if(ocean)
{
if (par1 > -par3 && par1 <= 0 && par2 > -par4 && par2 <= 0)
{
var5[-par1 + -par2 * par3] = 1;
}
}
return var5;
}
}

View file

@ -1,5 +1,7 @@
package biomesoplenty.world.layer;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerFuzzyZoom extends BiomeLayer
{
public BiomeLayerFuzzyZoom(long par1, BiomeLayer par3GenLayer)
@ -19,7 +21,7 @@ public class BiomeLayerFuzzyZoom extends BiomeLayer
int k1 = (par3 >> 1) + 3;
int l1 = (par4 >> 1) + 3;
int[] aint = this.parent.getInts(i1, j1, k1, l1);
int[] aint1 = LayerIntCache.getIntCache(k1 * 2 * l1 * 2);
int[] aint1 = IntCache.getIntCache(k1 * 2 * l1 * 2);
int i2 = k1 << 1;
int j2;
@ -44,7 +46,7 @@ public class BiomeLayerFuzzyZoom extends BiomeLayer
}
}
int[] aint2 = LayerIntCache.getIntCache(par3 * par4);
int[] aint2 = IntCache.getIntCache(par3 * par4);
for (j2 = 0; j2 < par4; ++j2)
{

View file

@ -0,0 +1,103 @@
package biomesoplenty.world.layer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerIsland extends BiomeLayer
{
public BiomeLayerIsland(long par1, BiomeLayer par3GenLayer)
{
super(par1);
this.parent = par3GenLayer;
}
/**
* 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 par1, int par2, int par3, int par4)
{
int i1 = par1 - 1;
int j1 = par2 - 1;
int k1 = par3 + 2;
int l1 = par4 + 2;
int[] aint = this.parent.getInts(i1, j1, k1, l1);
int[] aint1 = IntCache.getIntCache(par3 * par4);
for (int i2 = 0; i2 < par4; ++i2)
{
for (int j2 = 0; j2 < par3; ++j2)
{
int k2 = aint[j2 + 0 + (i2 + 0) * k1];
int l2 = aint[j2 + 2 + (i2 + 0) * k1];
int i3 = aint[j2 + 0 + (i2 + 2) * k1];
int j3 = aint[j2 + 2 + (i2 + 2) * k1];
int k3 = aint[j2 + 1 + (i2 + 1) * k1];
this.initChunkSeed((long)(j2 + par1), (long)(i2 + par2));
if (k3 == 0 && (k2 != 0 || l2 != 0 || i3 != 0 || j3 != 0))
{
int l3 = 1;
int i4 = 1;
if (k2 != 0 && this.nextInt(l3++) == 0)
{
i4 = k2;
}
if (l2 != 0 && this.nextInt(l3++) == 0)
{
i4 = l2;
}
if (i3 != 0 && this.nextInt(l3++) == 0)
{
i4 = i3;
}
if (j3 != 0 && this.nextInt(l3++) == 0)
{
i4 = j3;
}
if (this.nextInt(3) == 0)
{
aint1[j2 + i2 * par3] = i4;
}
else if (i4 == BiomeGenBase.icePlains.biomeID)
{
aint1[j2 + i2 * par3] = BiomeGenBase.frozenOcean.biomeID;
}
else
{
aint1[j2 + i2 * par3] = 0;
}
}
else if (k3 > 0 && (k2 == 0 || l2 == 0 || i3 == 0 || j3 == 0))
{
if (this.nextInt(5) == 0)
{
if (k3 == BiomeGenBase.icePlains.biomeID)
{
aint1[j2 + i2 * par3] = BiomeGenBase.frozenOcean.biomeID;
}
else
{
aint1[j2 + i2 * par3] = 0;
}
}
else
{
aint1[j2 + i2 * par3] = k3;
}
}
else
{
aint1[j2 + i2 * par3] = k3;
}
}
}
return aint1;
}
}

View file

@ -0,0 +1,46 @@
package biomesoplenty.world.layer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerRiver extends BiomeLayer
{
public BiomeLayerRiver(long par1, BiomeLayer par3GenLayer)
{
super(par1);
super.parent = par3GenLayer;
}
public int[] getInts(int par1, int par2, int par3, int par4)
{
int i1 = par1 - 1;
int j1 = par2 - 1;
int k1 = par3 + 2;
int l1 = par4 + 2;
int[] aint = this.parent.getInts(i1, j1, k1, l1);
int[] aint1 = IntCache.getIntCache(par3 * par4);
for (int i2 = 0; i2 < par4; ++i2)
{
for (int j2 = 0; j2 < par3; ++j2)
{
int k2 = aint[j2 + 0 + (i2 + 1) * k1];
int l2 = aint[j2 + 2 + (i2 + 1) * k1];
int i3 = aint[j2 + 1 + (i2 + 0) * k1];
int j3 = aint[j2 + 1 + (i2 + 2) * k1];
int k3 = aint[j2 + 1 + (i2 + 1) * k1];
if (k3 != 0 && k2 != 0 && l2 != 0 && i3 != 0 && j3 != 0 && k3 == k2 && k3 == i3 && k3 == l2 && k3 == j3)
{
aint1[j2 + i2 * par3] = -1;
}
else
{
aint1[j2 + i2 * par3] = BiomeGenBase.river.biomeID;
}
}
}
return aint1;
}
}

View file

@ -0,0 +1,29 @@
package biomesoplenty.world.layer;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerRiverInit extends BiomeLayer
{
public BiomeLayerRiverInit(long par1, BiomeLayer par3GenLayer)
{
super(par1);
this.parent = par3GenLayer;
}
public int[] getInts(int par1, int par2, int par3, int par4)
{
int[] aint = this.parent.getInts(par1, par2, par3, par4);
int[] aint1 = IntCache.getIntCache(par3 * par4);
for (int i1 = 0; i1 < par4; ++i1)
{
for (int j1 = 0; j1 < par3; ++j1)
{
this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2));
aint1[j1 + i1 * par3] = aint[j1 + i1 * par3] > 0 ? this.nextInt(2) + 2 : 0;
}
}
return aint1;
}
}

View file

@ -0,0 +1,59 @@
package biomesoplenty.world.layer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerRiverMix extends BiomeLayer
{
private BiomeLayer biomePatternGeneratorChain;
private BiomeLayer riverPatternGeneratorChain;
public BiomeLayerRiverMix(long par1, BiomeLayer par3GenLayer, BiomeLayer par4GenLayer)
{
super(par1);
this.biomePatternGeneratorChain = par3GenLayer;
this.riverPatternGeneratorChain = par4GenLayer;
}
public void initWorldGenSeed(long par1)
{
this.biomePatternGeneratorChain.initWorldGenSeed(par1);
this.riverPatternGeneratorChain.initWorldGenSeed(par1);
super.initWorldGenSeed(par1);
}
public int[] getInts(int par1, int par2, int par3, int par4)
{
int[] var5 = this.biomePatternGeneratorChain.getInts(par1, par2, par3, par4);
int[] var6 = this.riverPatternGeneratorChain.getInts(par1, par2, par3, par4);
int[] var7 = IntCache.getIntCache(par3 * par4);
for (int var8 = 0; var8 < par3 * par4; ++var8)
{
if (var5[var8] == BiomeGenBase.ocean.biomeID)
{
var7[var8] = var5[var8];
}
else if (var6[var8] >= 0)
{
if (var5[var8] == BiomeGenBase.icePlains.biomeID)
{
var7[var8] = BiomeGenBase.frozenRiver.biomeID;
}
else if (var5[var8] != BiomeGenBase.mushroomIsland.biomeID && var5[var8] != BiomeGenBase.mushroomIslandShore.biomeID)
{
var7[var8] = var6[var8];
}
else
{
var7[var8] = BiomeGenBase.mushroomIslandShore.biomeID;
}
}
else
{
var7[var8] = var5[var8];
}
}
return var7;
}
}

View file

@ -0,0 +1,38 @@
package biomesoplenty.world.layer;
import biomesoplenty.api.Biomes;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.IntCache;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
public class BiomeLayerShore extends BiomeLayer
{
public BiomeLayerShore(long par1, BiomeLayer par3GenLayer)
{
super(par1);
this.parent = par3GenLayer;
}
public int[] getInts(int par1, int par2, int par3, int par4)
{
int[] var5 = this.parent.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2);
int[] var6 = IntCache.getIntCache(par3 * par4);
for (int var7 = 0; var7 < par4; ++var7)
{
for (int var8 = 0; var8 < par3; ++var8)
{
this.initChunkSeed((long)(var8 + par1), (long)(var7 + par2));
int var9 = var5[var8 + 1 + (var7 + 1) * (par3 + 2)];
int var10;
int var11;
int var12;
int var13;
var6[var8 + var7 * par3] = var9;
}
}
return var6;
}
}

View file

@ -0,0 +1,68 @@
package biomesoplenty.world.layer;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerSmooth extends BiomeLayer
{
public BiomeLayerSmooth(long par1, BiomeLayer par3GenLayer)
{
super(par1);
super.parent = par3GenLayer;
}
/**
* 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 par1, int par2, int par3, int par4)
{
int i1 = par1 - 1;
int j1 = par2 - 1;
int k1 = par3 + 2;
int l1 = par4 + 2;
int[] aint = this.parent.getInts(i1, j1, k1, l1);
int[] aint1 = IntCache.getIntCache(par3 * par4);
for (int i2 = 0; i2 < par4; ++i2)
{
for (int j2 = 0; j2 < par3; ++j2)
{
int k2 = aint[j2 + 0 + (i2 + 1) * k1];
int l2 = aint[j2 + 2 + (i2 + 1) * k1];
int i3 = aint[j2 + 1 + (i2 + 0) * k1];
int j3 = aint[j2 + 1 + (i2 + 2) * k1];
int k3 = aint[j2 + 1 + (i2 + 1) * k1];
if (k2 == l2 && i3 == j3)
{
this.initChunkSeed((long)(j2 + par1), (long)(i2 + par2));
if (this.nextInt(2) == 0)
{
k3 = k2;
}
else
{
k3 = i3;
}
}
else
{
if (k2 == l2)
{
k3 = k2;
}
if (i3 == j3)
{
k3 = i3;
}
}
aint1[j2 + i2 * par3] = k3;
}
}
return aint1;
}
}

View file

@ -1,5 +1,7 @@
package biomesoplenty.world.layer;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerVoronoiZoom extends BiomeLayer
{
public BiomeLayerVoronoiZoom(long par1, BiomeLayer par3GenLayer)
@ -25,7 +27,7 @@ package biomesoplenty.world.layer;
int[] aint = this.parent.getInts(j1, k1, l1, i2);
int j2 = l1 << b0;
int k2 = i2 << b0;
int[] aint1 = LayerIntCache.getIntCache(j2 * k2);
int[] aint1 = IntCache.getIntCache(j2 * k2);
int l2;
for (int i3 = 0; i3 < i2 - 1; ++i3)
@ -86,7 +88,7 @@ package biomesoplenty.world.layer;
}
}
int[] aint2 = LayerIntCache.getIntCache(par3 * par4);
int[] aint2 = IntCache.getIntCache(par3 * par4);
for (l2 = 0; l2 < par4; ++l2)
{

View file

@ -1,5 +1,7 @@
package biomesoplenty.world.layer;
import net.minecraft.world.gen.layer.IntCache;
public class BiomeLayerZoom extends BiomeLayer
{
public BiomeLayerZoom(long par1, BiomeLayer par3GenLayer)
@ -15,7 +17,7 @@ public class BiomeLayerZoom extends BiomeLayer
int k1 = (par3 >> 1) + 3;
int l1 = (par4 >> 1) + 3;
int[] aint = this.parent.getInts(i1, j1, k1, l1);
int[] aint1 = LayerIntCache.getIntCache(k1 * 2 * l1 * 2);
int[] aint1 = IntCache.getIntCache(k1 * 2 * l1 * 2);
int i2 = k1 << 1;
int j2;
@ -40,7 +42,7 @@ public class BiomeLayerZoom extends BiomeLayer
}
}
int[] aint2 = LayerIntCache.getIntCache(par3 * par4);
int[] aint2 = IntCache.getIntCache(par3 * par4);
for (j2 = 0; j2 < par4; ++j2)
{

View file

@ -1,99 +0,0 @@
package biomesoplenty.world.layer;
import java.util.ArrayList;
import java.util.List;
public class LayerIntCache
{
private static int intCacheSize = 256;
/**
* A list of pre-allocated int[256] arrays that are currently unused and can be returned by getIntCache()
*/
private static List freeSmallArrays = new ArrayList();
/**
* A list of pre-allocated int[256] arrays that were previously returned by getIntCache() and which will not be re-
* used again until resetIntCache() is called.
*/
private static List inUseSmallArrays = new ArrayList();
/**
* A list of pre-allocated int[cacheSize] arrays that are currently unused and can be returned by getIntCache()
*/
private static List freeLargeArrays = new ArrayList();
/**
* A list of pre-allocated int[cacheSize] arrays that were previously returned by getIntCache() and which will not
* be re-used again until resetIntCache() is called.
*/
private static List inUseLargeArrays = new ArrayList();
public static synchronized int[] getIntCache(int par0)
{
int[] aint;
if (par0 <= 256)
{
if (freeSmallArrays.isEmpty())
{
aint = new int[256];
inUseSmallArrays.add(aint);
return aint;
}
else
{
aint = (int[])freeSmallArrays.remove(freeSmallArrays.size() - 1);
inUseSmallArrays.add(aint);
return aint;
}
}
else if (par0 > intCacheSize)
{
intCacheSize = par0;
freeLargeArrays.clear();
inUseLargeArrays.clear();
aint = new int[intCacheSize];
inUseLargeArrays.add(aint);
return aint;
}
else if (freeLargeArrays.isEmpty())
{
aint = new int[intCacheSize];
inUseLargeArrays.add(aint);
return aint;
}
else
{
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();
}
public static synchronized String func_85144_b()
{
return "cache: " + freeLargeArrays.size() + ", tcache: " + freeSmallArrays.size() + ", allocated: " + inUseLargeArrays.size() + ", tallocated: " + inUseSmallArrays.size();
}
}