diff --git a/src/minecraft/biomesoplenty/world/WorldChunkManagerBOP.java b/src/minecraft/biomesoplenty/world/WorldChunkManagerBOP.java index c3ae1a13a..64b9452d3 100644 --- a/src/minecraft/biomesoplenty/world/WorldChunkManagerBOP.java +++ b/src/minecraft/biomesoplenty/world/WorldChunkManagerBOP.java @@ -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) diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayer.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayer.java index 755c82916..57ec15723 100644 --- a/src/minecraft/biomesoplenty/world/layer/BiomeLayer.java +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayer.java @@ -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)); + + 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 }); } - - //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 }); } public BiomeLayer(long seed) diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerBiomes.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerBiomes.java index 88c87126c..a6fd84743 100644 --- a/src/minecraft/biomesoplenty/world/layer/BiomeLayerBiomes.java +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerBiomes.java @@ -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 oceanBiomes = new ArrayList(); private static ArrayList netherBiomes = new ArrayList(); private static ArrayList promisedBiomes = new ArrayList(); @@ -30,6 +32,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,15 +84,46 @@ 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) { for (int var8 = 0; var8 < par3; ++var8) { 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; } diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerCreate.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerCreate.java index 33a65e96b..2d145e978 100644 --- a/src/minecraft/biomesoplenty/world/layer/BiomeLayerCreate.java +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerCreate.java @@ -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; } } \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerFuzzyZoom.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerFuzzyZoom.java index 8cfa83097..802997981 100644 --- a/src/minecraft/biomesoplenty/world/layer/BiomeLayerFuzzyZoom.java +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerFuzzyZoom.java @@ -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) { diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerIsland.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerIsland.java new file mode 100644 index 000000000..ffa2ff826 --- /dev/null +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerIsland.java @@ -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; + } +} \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiver.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiver.java new file mode 100644 index 000000000..2a5acd60a --- /dev/null +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiver.java @@ -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; + } +} \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiverInit.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiverInit.java new file mode 100644 index 000000000..ecdd28a9a --- /dev/null +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiverInit.java @@ -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; + } +} \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiverMix.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiverMix.java new file mode 100644 index 000000000..9051c0953 --- /dev/null +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerRiverMix.java @@ -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; + } +} \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerShore.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerShore.java new file mode 100644 index 000000000..48e2cc7a6 --- /dev/null +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerShore.java @@ -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; + } +} \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerSmooth.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerSmooth.java new file mode 100644 index 000000000..1826ad22d --- /dev/null +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerSmooth.java @@ -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; + } +} \ No newline at end of file diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerVoronoiZoom.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerVoronoiZoom.java index 42f862824..20377d8d6 100644 --- a/src/minecraft/biomesoplenty/world/layer/BiomeLayerVoronoiZoom.java +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerVoronoiZoom.java @@ -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) { diff --git a/src/minecraft/biomesoplenty/world/layer/BiomeLayerZoom.java b/src/minecraft/biomesoplenty/world/layer/BiomeLayerZoom.java index d978a869a..5d93fd06f 100644 --- a/src/minecraft/biomesoplenty/world/layer/BiomeLayerZoom.java +++ b/src/minecraft/biomesoplenty/world/layer/BiomeLayerZoom.java @@ -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) { diff --git a/src/minecraft/biomesoplenty/world/layer/LayerIntCache.java b/src/minecraft/biomesoplenty/world/layer/LayerIntCache.java deleted file mode 100644 index 4ed1c58b6..000000000 --- a/src/minecraft/biomesoplenty/world/layer/LayerIntCache.java +++ /dev/null @@ -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(); - } -}