started working on layer generator for promised lands
This commit is contained in:
parent
94d64d53a8
commit
53283f7e64
3 changed files with 208 additions and 0 deletions
85
src/minecraft/biomesoplenty/world/layer/BiomeLayer.java
Normal file
85
src/minecraft/biomesoplenty/world/layer/BiomeLayer.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package biomesoplenty.world.layer;
|
||||
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.gen.layer.GenLayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.terraingen.WorldTypeEvent;
|
||||
|
||||
public abstract class BiomeLayer
|
||||
{
|
||||
private long worldGenSeed;
|
||||
protected BiomeLayer parent;
|
||||
private long chunkSeed;
|
||||
private long baseSeed;
|
||||
|
||||
public static BiomeLayer[] initializeAllBiomeGenerators(long seed, WorldType worldtype)
|
||||
{
|
||||
BiomeLayer obj = new BiomeLayerCreate(1L);
|
||||
|
||||
return new BiomeLayer[] {};
|
||||
}
|
||||
|
||||
public BiomeLayer(long seed)
|
||||
{
|
||||
this.baseSeed = seed;
|
||||
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.baseSeed += seed;
|
||||
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.baseSeed += seed;
|
||||
this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.baseSeed += seed;
|
||||
}
|
||||
|
||||
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 par1, long par3)
|
||||
{
|
||||
this.chunkSeed = this.worldGenSeed;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += par1;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += par3;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += par1;
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += par3;
|
||||
}
|
||||
|
||||
protected int nextInt(int par1)
|
||||
{
|
||||
int j = (int)((this.chunkSeed >> 24) % (long)par1);
|
||||
|
||||
if (j < 0)
|
||||
{
|
||||
j += par1;
|
||||
}
|
||||
|
||||
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
|
||||
this.chunkSeed += this.worldGenSeed;
|
||||
return j;
|
||||
}
|
||||
|
||||
public abstract int[] getInts(int i, int j, int k, int l);
|
||||
|
||||
public static byte getModdedBiomeSize(WorldType worldType, byte original)
|
||||
{
|
||||
WorldTypeEvent.BiomeSize event = new WorldTypeEvent.BiomeSize(worldType, original);
|
||||
MinecraftForge.TERRAIN_GEN_BUS.post(event);
|
||||
return event.newSize;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package biomesoplenty.world.layer;
|
||||
|
||||
public class BiomeLayerCreate extends BiomeLayer
|
||||
{
|
||||
public BiomeLayerCreate(long par1)
|
||||
{
|
||||
super(par1);
|
||||
}
|
||||
|
||||
public int[] getInts(int par1, int par2, int par3, int par4)
|
||||
{
|
||||
int[] var5 = LayerIntCache.getIntCache(par3 * par4);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return var5;
|
||||
}
|
||||
}
|
99
src/minecraft/biomesoplenty/world/layer/LayerIntCache.java
Normal file
99
src/minecraft/biomesoplenty/world/layer/LayerIntCache.java
Normal file
|
@ -0,0 +1,99 @@
|
|||
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();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue