-
-
Save Elix-x/4d28c4813c4064f82e00 to your computer and use it in GitHub Desktop.
World Generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WCSWChunkManager extends WorldChunkManager { | |
private World worldObj; | |
public WCSWChunkManager(World world) { | |
super(); | |
this.worldObj = world; | |
GenLayer[] agenlayer = WCSWGenLayer.initializeAllBiomeGenerators(world.getSeed(), world); | |
agenlayer = getModdedBiomeGenerators(world.getWorldInfo().getTerrainType(), world.getSeed(), agenlayer); | |
ObfuscationReflectionHelper.setPrivateValue(WorldChunkManager.class, this, agenlayer[0], "genBiomes", "field_76944_d"); | |
ObfuscationReflectionHelper.setPrivateValue(WorldChunkManager.class, this, agenlayer[1], "biomeIndexLayer", "field_76945_e"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WCSWChunkProvider implements IChunkProvider { | |
private Random rand; | |
private World worldObj; | |
/** are map structures going to be generated (e.g. strongholds) */ | |
private final boolean mapFeaturesEnabled; | |
private WorldType worldType; | |
/**Caves Generator*/ | |
private MapGenBase caveGenerator = TerrainGen.getModdedMapGen(new MapGenCaves(), CAVE); | |
/** Stronghold Generator */ | |
private MapGenStronghold strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(new MapGenStronghold(), STRONGHOLD); | |
/** Village Generator */ | |
private MapGenVillage villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(new MapGenVillage(), VILLAGE); | |
/** Mineshaft Generator */ | |
private MapGenMineshaft mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(new MapGenMineshaft(), MINESHAFT); | |
private MapGenScatteredFeature scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(new MapGenScatteredFeature(), SCATTERED_FEATURE); | |
/** Ravine Generator */ | |
private MapGenBase ravineGenerator = TerrainGen.getModdedMapGen(new MapGenRavine(), RAVINE); | |
/** | |
* Noises | |
*/ | |
private NoiseGeneratorOctaves noiseGen1Octaves1; | |
private NoiseGeneratorOctaves noiseGen2Octaves2; | |
private NoiseGeneratorOctaves noiseGen3Octaves3; | |
private NoiseGeneratorPerlin noiseGen4Perlin1; | |
/** A NoiseGeneratorOctaves used in generating terrain */ | |
public NoiseGeneratorOctaves noiseGen5Octaves4; | |
/** A NoiseGeneratorOctaves used in generating terrain */ | |
public NoiseGeneratorOctaves noiseGen6Octaves6; | |
public NoiseGeneratorOctaves mobSpawnerNoise; | |
/** | |
* Holds terrain noise | |
*/ | |
double[] noiseGen3Octaves3DataHolder; | |
double[] noiseGen1Octaves1DataHolder; | |
double[] noiseGen2Octaves2DataHolder; | |
double[] noiseGen6Octaves6DataHolder; | |
/** | |
* Noise field holding noises for further chunk generation | |
*/ | |
private final double[] noiseField; | |
private double[] stoneNoiseOrnoiseGen4Perlin1DataHolder = new double[256]; | |
/** | |
* Used to store the 5x5 parabolic field that is used during terrain generation. | |
*/ | |
private final float[] parabolicField; | |
/** | |
* Temp array holding biomes for current chunk gen. | |
*/ | |
private BiomeGenBase[] biomesForGeneration; | |
/** | |
* Position of chunk that is currently being generated. | |
*/ | |
private ChunkPosition currentChunkGenPos; | |
public WCSWChunkProvider(World world) { | |
this.worldObj = world; | |
this.mapFeaturesEnabled = world.getWorldInfo().isMapFeaturesEnabled(); | |
this.worldType = world.getWorldInfo().getTerrainType(); | |
this.rand = new Random(world.getSeed()); | |
this.noiseGen1Octaves1 = new NoiseGeneratorOctaves(this.rand, 16); | |
this.noiseGen2Octaves2 = new NoiseGeneratorOctaves(this.rand, 16); | |
this.noiseGen3Octaves3 = new NoiseGeneratorOctaves(this.rand, 8); | |
this.noiseGen4Perlin1 = new NoiseGeneratorPerlin(this.rand, 4); | |
this.noiseGen5Octaves4 = new NoiseGeneratorOctaves(this.rand, 10); | |
this.noiseGen6Octaves6 = new NoiseGeneratorOctaves(this.rand, 16); | |
this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8); | |
this.noiseField = new double[825]; | |
this.parabolicField = new float[25]; | |
for (int j = -2; j <= 2; ++j) | |
{ | |
for (int k = -2; k <= 2; ++k) | |
{ | |
float f = 10.0F / MathHelper.sqrt_float((float)(j * j + k * k) + 0.2F); | |
this.parabolicField[j + 2 + (k + 2) * 5] = f; | |
} | |
} | |
NoiseGenerator[] noiseGens = {noiseGen1Octaves1, noiseGen2Octaves2, noiseGen3Octaves3, noiseGen4Perlin1, noiseGen5Octaves4, noiseGen6Octaves6, mobSpawnerNoise}; | |
noiseGens = TerrainGen.getModdedNoiseGenerators(world, this.rand, noiseGens); | |
this.noiseGen1Octaves1 = (NoiseGeneratorOctaves)noiseGens[0]; | |
this.noiseGen2Octaves2 = (NoiseGeneratorOctaves)noiseGens[1]; | |
this.noiseGen3Octaves3 = (NoiseGeneratorOctaves)noiseGens[2]; | |
this.noiseGen4Perlin1 = (NoiseGeneratorPerlin)noiseGens[3]; | |
this.noiseGen5Octaves4 = (NoiseGeneratorOctaves)noiseGens[4]; | |
this.noiseGen6Octaves6 = (NoiseGeneratorOctaves)noiseGens[5]; | |
this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6]; | |
} | |
@Override | |
public Chunk loadChunk(int x, int z) { | |
return provideChunk(x, z); | |
} | |
public Chunk provideChunk(int x, int z) { | |
WCSWBase.logger.info("Providing chunk at " + x + ", " + z); | |
currentChunkGenPos = new ChunkPosition(x, z); | |
this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L); | |
Block[] blocks = new Block[65536]; | |
byte[] metadata = new byte[65536]; | |
this.generateTerrain(x, z, blocks); | |
this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16); | |
this.replaceBlocksForBiome(x, z, blocks, metadata, this.biomesForGeneration); | |
this.caveGenerator.func_151539_a(this, this.worldObj, x, z, blocks); | |
this.ravineGenerator.func_151539_a(this, this.worldObj, x, z, blocks); | |
if (this.mapFeaturesEnabled) { | |
this.mineshaftGenerator.func_151539_a(this, this.worldObj, x, z, blocks); | |
this.villageGenerator.func_151539_a(this, this.worldObj, x, z, blocks); | |
this.strongholdGenerator.func_151539_a(this, this.worldObj, x, z, blocks); | |
this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, x, z, blocks); | |
} | |
Chunk chunk = new Chunk(this.worldObj, blocks, metadata, x, z); | |
byte[] abyte1 = chunk.getBiomeArray(); | |
for (int k = 0; k < abyte1.length; ++k) | |
{ | |
abyte1[k] = (byte)this.biomesForGeneration[k].biomeID; | |
} | |
chunk.generateSkylightMap(); | |
currentChunkGenPos = null; | |
return chunk; | |
} | |
public void generateTerrain(int x, int z, Block[] blocks) { | |
this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10); | |
this.initNoiseField(x * 4, 0, z * 4); | |
for (int k = 0; k < 4; ++k) { | |
int l = k * 5; | |
int i1 = (k + 1) * 5; | |
for (int j1 = 0; j1 < 4; ++j1) { | |
int k1 = (l + j1) * 33; | |
int l1 = (l + j1 + 1) * 33; | |
int i2 = (i1 + j1) * 33; | |
int j2 = (i1 + j1 + 1) * 33; | |
for (int k2 = 0; k2 < 32; ++k2) { | |
double d1 = this.noiseField[k1 + k2]; | |
double d2 = this.noiseField[l1 + k2]; | |
double d3 = this.noiseField[i2 + k2]; | |
double d4 = this.noiseField[j2 + k2]; | |
double d5 = (this.noiseField[k1 + k2 + 1] - d1) * 0.125D; | |
double d6 = (this.noiseField[l1 + k2 + 1] - d2) * 0.125D; | |
double d7 = (this.noiseField[i2 + k2 + 1] - d3) * 0.125D; | |
double d8 = (this.noiseField[j2 + k2 + 1] - d4) * 0.125D; | |
for (int l2 = 0; l2 < 8; ++l2) { | |
for (int i3 = 0; i3 < 4; ++i3) { | |
int nextY = k2 * 8 + l2; | |
int nextBlock = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | nextY; | |
short worldHeight = 256; | |
nextBlock -= worldHeight; | |
double d16 = (d2 - d1) * 0.25D; | |
double d15 = d1 - d16; | |
for (int k3 = 0; k3 < 4; ++k3) { | |
if ((d15 += d16) > 0.0D) { | |
blocks[nextBlock += worldHeight] = Blocks.stone; | |
}/* else if (nextY < 63) { | |
blocks[nextBlock += worldHeight] = Blocks.water; | |
}*/ | |
else if(nextY == 62) { | |
blocks[nextBlock += worldHeight] = Blocks.grass; | |
} else if(nextY < 62) { | |
blocks[nextBlock += worldHeight] = Blocks.dirt; | |
} else { | |
blocks[nextBlock += worldHeight] = null; | |
} | |
} | |
d1 += (d3 - d1) * 0.25D; | |
d2 += (d4 - d2) * 0.25D; | |
} | |
d1 += d5; | |
d2 += d6; | |
d3 += d7; | |
d4 += d8; | |
} | |
} | |
} | |
} | |
} | |
private void initNoiseField(int noiseOffestX, int noiseOffestY, int noiseOffestZ) { | |
final double noiseScaleNoiseGen1Octaves1 = 684.412D; | |
final double noiseScaleNoiseGen2Octaves2 = 684.412D; | |
final double noiseDivNoiseGen1Octaves1 = 512.0D; | |
final double noiseDivNoiseGen2Octaves2 = 512.0D; | |
this.noiseGen6Octaves6DataHolder = this.noiseGen6Octaves6.generateNoiseOctaves(this.noiseGen6Octaves6DataHolder, noiseOffestX, noiseOffestZ, 5, 5, 200.0D, 200.0D, 0.5D); | |
this.noiseGen3Octaves3DataHolder = this.noiseGen3Octaves3.generateNoiseOctaves(this.noiseGen3Octaves3DataHolder, noiseOffestX, noiseOffestY, noiseOffestZ, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); | |
this.noiseGen1Octaves1DataHolder = this.noiseGen1Octaves1.generateNoiseOctaves(this.noiseGen1Octaves1DataHolder, noiseOffestX, noiseOffestY, noiseOffestZ, 5, 33, 5, noiseScaleNoiseGen1Octaves1, noiseScaleNoiseGen1Octaves1, noiseScaleNoiseGen1Octaves1); | |
this.noiseGen2Octaves2DataHolder = this.noiseGen2Octaves2.generateNoiseOctaves(this.noiseGen2Octaves2DataHolder, noiseOffestX, noiseOffestY, noiseOffestZ, 5, 33, 5, noiseScaleNoiseGen2Octaves2, noiseScaleNoiseGen2Octaves2, noiseScaleNoiseGen2Octaves2); | |
int nextNoiseId = 0; | |
int nextNoiseIdNoiseGen6Octaves6 = 0; | |
final double totalBiomesRootHeightModifier = 8.5D; | |
for (int j1 = 0; j1 < 5; ++j1) | |
{ | |
for (int k1 = 0; k1 < 5; ++k1) | |
{ | |
float totalBiomesHeightVariation = 0.0F; | |
float totalBiomesRootHeight = 0.0F; | |
float totalParabolicField = 0.0F; | |
byte range = 2; | |
BiomeGenBase compareToBiome = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; | |
for (int xFromRange = -range; xFromRange <= range; ++xFromRange) | |
{ | |
for (int zFromRange = -range; zFromRange <= range; ++zFromRange) | |
{ | |
BiomeGenBase nextBiome = this.biomesForGeneration[j1 + xFromRange + 2 + (k1 + zFromRange + 2) * 10]; | |
float nextBiomeRootHeight = ClimatHelper.getRootHeight(worldObj, currentChunkGenPos, nextBiome); | |
float nextBiomeHeightVariation = ClimatHelper.getHeightVariation(worldObj, currentChunkGenPos, nextBiome); | |
float nextParabolicFieldValue = this.parabolicField[xFromRange + 2 + (zFromRange + 2) * 5] / (nextBiomeRootHeight + 2.0F); | |
if (nextBiome.rootHeight > compareToBiome.rootHeight) | |
{ | |
nextParabolicFieldValue /= 2.0F; | |
} | |
totalBiomesHeightVariation += nextBiomeHeightVariation * nextParabolicFieldValue; | |
totalBiomesRootHeight += nextBiomeRootHeight * nextParabolicFieldValue; | |
totalParabolicField += nextParabolicFieldValue; | |
} | |
} | |
totalBiomesHeightVariation /= totalParabolicField; | |
totalBiomesRootHeight /= totalParabolicField; | |
totalBiomesHeightVariation = totalBiomesHeightVariation * 0.9F + 0.1F; | |
totalBiomesRootHeight = (totalBiomesRootHeight * 4.0F - 1.0F) / 8.0F; | |
double nextNoiseInNoiseGen6Octaves6 = this.noiseGen6Octaves6DataHolder[nextNoiseIdNoiseGen6Octaves6] / 8000.0D; | |
if (nextNoiseInNoiseGen6Octaves6 < 0.0D) | |
{ | |
nextNoiseInNoiseGen6Octaves6 = -nextNoiseInNoiseGen6Octaves6 * 0.3D; | |
} | |
nextNoiseInNoiseGen6Octaves6 = nextNoiseInNoiseGen6Octaves6 * 3.0D - 2.0D; | |
if (nextNoiseInNoiseGen6Octaves6 < 0.0D) | |
{ | |
nextNoiseInNoiseGen6Octaves6 /= 2.0D; | |
if (nextNoiseInNoiseGen6Octaves6 < -1.0D) | |
{ | |
nextNoiseInNoiseGen6Octaves6 = -1.0D; | |
} | |
nextNoiseInNoiseGen6Octaves6 /= 1.4D; | |
nextNoiseInNoiseGen6Octaves6 /= 2.0D; | |
} | |
else | |
{ | |
if (nextNoiseInNoiseGen6Octaves6 > 1.0D) | |
{ | |
nextNoiseInNoiseGen6Octaves6 = 1.0D; | |
} | |
nextNoiseInNoiseGen6Octaves6 /= 8.0D; | |
} | |
++nextNoiseIdNoiseGen6Octaves6; | |
double totalBiomesRootHeightDouble = (double)totalBiomesRootHeight; | |
double totalBiomesHeightVariationDouble = (double)totalBiomesHeightVariation; | |
totalBiomesRootHeightDouble += nextNoiseInNoiseGen6Octaves6 * 0.2D; | |
totalBiomesRootHeightDouble = totalBiomesRootHeightDouble * totalBiomesRootHeightModifier / 8.0D; | |
double totalBiomesRootHeightDoubleModified = totalBiomesRootHeightModifier + totalBiomesRootHeightDouble * 4.0D; | |
for (int j2 = 0; j2 < 33; ++j2) | |
{ | |
double totalBiomesHeight = ((double)j2 - totalBiomesRootHeightDoubleModified) * 12.0D * 128.0D / 256.0D / totalBiomesHeightVariationDouble; | |
if (totalBiomesHeight < 0.0D) | |
{ | |
totalBiomesHeight *= 4.0D; | |
} | |
double noiseGen1Octaves1Result = this.noiseGen1Octaves1DataHolder[nextNoiseId] / noiseDivNoiseGen1Octaves1; | |
double noiseGen2Octaves2Result = this.noiseGen2Octaves2DataHolder[nextNoiseId] / noiseDivNoiseGen2Octaves2; | |
double noiseGen3Octaves3Result = (this.noiseGen3Octaves3DataHolder[nextNoiseId] / 10.0D + 1.0D) / 2.0D; | |
double nextNoise = MathHelper.denormalizeClamp(noiseGen1Octaves1Result, noiseGen2Octaves2Result, noiseGen3Octaves3Result) - totalBiomesHeight; | |
if (j2 > 29) | |
{ | |
double d11 = (double)((float)(j2 - 29) / 3.0F); | |
nextNoise = nextNoise * (1.0D - d11) + -10.0D * d11; | |
} | |
this.noiseField[nextNoiseId] = nextNoise; | |
++nextNoiseId; | |
} | |
} | |
} | |
} | |
public void replaceBlocksForBiome(int x, int y, Block[] blocks, byte[] meta, BiomeGenBase[] biomes) { | |
ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, x, y, blocks, meta, biomes, this.worldObj); | |
MinecraftForge.EVENT_BUS.post(event); | |
if (event.getResult() == Result.DENY) return; | |
double d0 = 0.03125D; | |
this.stoneNoiseOrnoiseGen4Perlin1DataHolder = this.noiseGen4Perlin1.func_151599_a(this.stoneNoiseOrnoiseGen4Perlin1DataHolder, (double)(x * 16), (double)(y * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); | |
for (int k = 0; k < 16; ++k) | |
{ | |
for (int l = 0; l < 16; ++l) | |
{ | |
BiomeGenBase biomegenbase = biomes[l + k * 16]; | |
biomegenbase.genTerrainBlocks(this.worldObj, this.rand, blocks, meta, x * 16 + k, y * 16 + l, this.stoneNoiseOrnoiseGen4Perlin1DataHolder[l + k * 16]); | |
} | |
} | |
} | |
/* | |
* Entities | |
*/ | |
@Override | |
public List getPossibleCreatures(EnumCreatureType type, int x, int y, int z) { | |
BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(x, z); | |
return type == EnumCreatureType.monster && this.scatteredFeatureGenerator.func_143030_a(x, y, z) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(type); | |
} | |
/* | |
* Unknown | |
*/ | |
@Override | |
public net.minecraft.world.ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) { | |
return null; | |
} | |
/* | |
* Population | |
*/ | |
@Override | |
public void populate(IChunkProvider provider, int x, int y) { | |
BlockFalling.fallInstantly = true; | |
int k = x * 16; | |
int l = y * 16; | |
BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); | |
this.rand.setSeed(this.worldObj.getSeed()); | |
long i1 = this.rand.nextLong() / 2L * 2L + 1L; | |
long j1 = this.rand.nextLong() / 2L * 2L + 1L; | |
this.rand.setSeed((long)x * i1 + (long)y * j1 ^ this.worldObj.getSeed()); | |
boolean flag = false; | |
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(provider, worldObj, rand, x, y, flag)); | |
if (this.mapFeaturesEnabled) | |
{ | |
this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, x, y); | |
flag = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, x, y); | |
this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, x, y); | |
this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, x, y); | |
} | |
int k1; | |
int l1; | |
int i2; | |
/*if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && !flag && this.rand.nextInt(4) == 0 && TerrainGen.populate(provider, worldObj, rand, x, y, flag, LAKE)) | |
{ | |
k1 = k + this.rand.nextInt(16) + 8; | |
l1 = this.rand.nextInt(256); | |
i2 = l + this.rand.nextInt(16) + 8; | |
(new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, k1, l1, i2); | |
}*/ | |
if (TerrainGen.populate(provider, worldObj, rand, x, y, flag, LAVA) && !flag && this.rand.nextInt(8) == 0) | |
{ | |
k1 = k + this.rand.nextInt(16) + 8; | |
l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); | |
i2 = l + this.rand.nextInt(16) + 8; | |
if (l1 < 63 || this.rand.nextInt(10) == 0) | |
{ | |
(new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, k1, l1, i2); | |
} | |
} | |
boolean doGen = TerrainGen.populate(provider, worldObj, rand, x, y, flag, DUNGEON); | |
for (k1 = 0; doGen && k1 < 8; ++k1) | |
{ | |
l1 = k + this.rand.nextInt(16) + 8; | |
i2 = this.rand.nextInt(256); | |
int j2 = l + this.rand.nextInt(16) + 8; | |
(new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); | |
} | |
biomegenbase.decorate(this.worldObj, this.rand, k, l); | |
if (TerrainGen.populate(provider, worldObj, rand, x, y, flag, ANIMALS)) | |
{ | |
SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand); | |
} | |
k += 8; | |
l += 8; | |
doGen = TerrainGen.populate(provider, worldObj, rand, x, y, flag, ICE); | |
for (k1 = 0; doGen && k1 < 16; ++k1) | |
{ | |
for (l1 = 0; l1 < 16; ++l1) | |
{ | |
i2 = this.worldObj.getPrecipitationHeight(k + k1, l + l1); | |
if (this.worldObj.isBlockFreezable(k1 + k, i2 - 1, l1 + l)) | |
{ | |
this.worldObj.setBlock(k1 + k, i2 - 1, l1 + l, Blocks.ice, 0, 2); | |
} | |
if (this.worldObj.func_147478_e(k1 + k, i2, l1 + l, true)) | |
{ | |
this.worldObj.setBlock(k1 + k, i2, l1 + l, Blocks.snow_layer, 0, 2); | |
} | |
} | |
} | |
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(provider, worldObj, rand, x, y, flag)); | |
BlockFalling.fallInstantly = false; | |
} | |
/* | |
* Structures | |
*/ | |
@Override | |
public void recreateStructures(int x, int y) { | |
if (this.mapFeaturesEnabled) | |
{ | |
this.mineshaftGenerator.func_151539_a(this, this.worldObj, x, y, (Block[])null); | |
this.villageGenerator.func_151539_a(this, this.worldObj, x, y, (Block[])null); | |
this.strongholdGenerator.func_151539_a(this, this.worldObj, x, y, (Block[])null); | |
this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, x, y, (Block[])null); | |
} | |
} | |
/* | |
* Debug menu | |
*/ | |
@Override | |
public String makeString() { | |
return "WCSW Level Source"; | |
} | |
/* | |
* Unused | |
*/ | |
/** | |
* Unused | |
*/ | |
@Override | |
public boolean chunkExists(int x, int y) { | |
return true; | |
} | |
/** | |
* Unused | |
*/ | |
@Override | |
public boolean unloadQueuedChunks() { | |
return false; | |
} | |
@Override | |
public int getLoadedChunkCount() { | |
return 0; | |
} | |
/** | |
* Unused | |
*/ | |
@Override | |
public boolean canSave() { | |
return true; | |
} | |
/** | |
* Unused | |
*/ | |
@Override | |
public boolean saveChunks(boolean b, IProgressUpdate p) { | |
return true; | |
} | |
/** | |
* Unused | |
*/ | |
@Override | |
public void saveExtraData() { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class WCSWGenLayer extends GenLayer { | |
public WCSWGenLayer(long seed) | |
{ | |
super(seed); | |
} | |
public static GenLayer[] initializeAllBiomeGenerators(long seed, World world) | |
{ | |
GenLayerIsland genlayerisland = new GenLayerIsland(1L); | |
GenLayerFuzzyZoom genlayerfuzzyzoom = new GenLayerFuzzyZoom(2000L, genlayerisland); | |
GenLayerAddIsland genlayeraddisland = new GenLayerAddIsland(1L, genlayerfuzzyzoom); | |
GenLayerZoom genlayerzoom = new GenLayerZoom(2001L, genlayeraddisland); | |
genlayeraddisland = new GenLayerAddIsland(2L, genlayerzoom); | |
genlayeraddisland = new GenLayerAddIsland(50L, genlayeraddisland); | |
genlayeraddisland = new GenLayerAddIsland(70L, genlayeraddisland); | |
// GenLayerRemoveTooMuchOcean genlayerremovetoomuchocean = new GenLayerRemoveTooMuchOcean(2L, genlayeraddisland); | |
// GenLayerAddSnow genlayeraddsnow = new GenLayerAddSnow(2L, genlayerremovetoomuchocean); | |
GenLayerAddSnow genlayeraddsnow = new GenLayerAddSnow(2L, genlayeraddisland); | |
genlayeraddisland = new GenLayerAddIsland(3L, genlayeraddsnow); | |
GenLayerEdge genlayeredge = new GenLayerEdge(2L, genlayeraddisland, GenLayerEdge.Mode.COOL_WARM); | |
genlayeredge = new GenLayerEdge(2L, genlayeredge, GenLayerEdge.Mode.HEAT_ICE); | |
genlayeredge = new GenLayerEdge(3L, genlayeredge, GenLayerEdge.Mode.SPECIAL); | |
genlayerzoom = new GenLayerZoom(2002L, genlayeredge); | |
genlayerzoom = new GenLayerZoom(2003L, genlayerzoom); | |
genlayeraddisland = new GenLayerAddIsland(4L, genlayerzoom); | |
GenLayerAddMushroomIsland genlayeraddmushroomisland = new GenLayerAddMushroomIsland(5L, genlayeraddisland); | |
GenLayerDeepOcean genlayerdeepocean = new GenLayerDeepOcean(4L, genlayeraddmushroomisland); | |
GenLayer genlayer2 = GenLayerZoom.magnify(1000L, genlayerdeepocean, 0); | |
byte biomesSize = 4; | |
// byte biomesSize = WCSWWorldGenData.getData(world).getBiomesSize(); | |
GenLayer genlayer = GenLayerZoom.magnify(1000L, genlayer2, 0); | |
GenLayer biomeGenLayer = new WCSWGenLayerBiomes(200L, genlayer2); | |
biomeGenLayer = GenLayerZoom.magnify(1000L, biomeGenLayer, 2); | |
biomeGenLayer = new GenLayerBiomeEdge(1000L, biomeGenLayer); | |
GenLayer genlayer1 = GenLayerZoom.magnify(1000L, genlayer, 2); | |
GenLayerHills genlayerhills = new GenLayerHills(1000L, (GenLayer)biomeGenLayer, genlayer1); | |
genlayer = GenLayerZoom.magnify(1000L, genlayer, biomesSize); | |
biomeGenLayer = new GenLayerRareBiome(1001L, genlayerhills); | |
for (int j = 0; j < biomesSize; ++j) | |
{ | |
biomeGenLayer = new GenLayerZoom((long)(1000 + j), (GenLayer)biomeGenLayer); | |
if (j == 0) | |
{ | |
biomeGenLayer = new GenLayerAddIsland(3L, (GenLayer)biomeGenLayer); | |
} | |
if (j == 1) | |
{ | |
biomeGenLayer = new GenLayerShore(1000L, (GenLayer)biomeGenLayer); | |
} | |
} | |
GenLayerSmooth genlayersmooth1 = new GenLayerSmooth(1000L, (GenLayer)biomeGenLayer); | |
GenLayerVoronoiZoom genlayervoronoizoom = new GenLayerVoronoiZoom(10L, genlayersmooth1); | |
genlayervoronoizoom.initWorldGenSeed(seed); | |
return new GenLayer[]{genlayersmooth1, genlayervoronoizoom, genlayersmooth1}; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WCSWGenLayerBiomes extends GenLayer { | |
private List<BiomeEntry>[] biomes = new ArrayList[BiomeManager.BiomeType.values().length]; | |
private static final String __OBFID = "CL_00000555"; | |
public WCSWGenLayerBiomes(long seed, GenLayer parent) | |
{ | |
super(seed); | |
this.parent = parent; | |
for (BiomeManager.BiomeType type : BiomeManager.BiomeType.values()) | |
{ | |
com.google.common.collect.ImmutableList<BiomeEntry> biomesToAdd = BiomeManager.getBiomes(type); | |
int idx = type.ordinal(); | |
if (biomes[idx] == null) biomes[idx] = new ArrayList<BiomeEntry>(); | |
if (biomesToAdd != null) biomes[idx].addAll(biomesToAdd); | |
} | |
int desertIdx = BiomeManager.BiomeType.DESERT.ordinal(); | |
biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.desert, 30)); | |
biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.savanna, 20)); | |
biomes[desertIdx].add(new BiomeEntry(BiomeGenBase.plains, 10)); | |
} | |
/** | |
* 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 xPos, int zPos, int xSize, int zSize) { | |
int[] inputBiomeIds = this.parent.getInts(xPos, zPos, xSize, zSize); | |
int[] outputBiomeIDs = IntCache.getIntCache(xSize * zSize); | |
// WCSWBase.logger.info("Generating biomes at " + xPos + ", " + zPos + " - " + xSize + "*" + zSize); | |
for (int x = 0; x < zSize; ++x) { | |
for (int z = 0; z < xSize; ++z) { | |
this.initChunkSeed((long)(z + xPos), (long)(x + zPos)); | |
int nextBiomeCategoryId = inputBiomeIds[z + x * xSize]; | |
int l1 = (nextBiomeCategoryId & 3840) >> 8; | |
boolean keepNextBiome = l1 > 0; | |
nextBiomeCategoryId &= -3841; | |
if (isBiomeOceanic(nextBiomeCategoryId)) { | |
//Ocean | |
outputBiomeIDs[z + x * xSize] = nextBiomeCategoryId; | |
} else if (nextBiomeCategoryId == BiomeGenBase.mushroomIsland.biomeID){ | |
outputBiomeIDs[z + x * xSize] = nextBiomeCategoryId; | |
} else if (nextBiomeCategoryId == 1) { | |
//Hot biomes | |
if (keepNextBiome) { | |
if (this.nextInt(3) == 0) { | |
outputBiomeIDs[z + x * xSize] = BiomeGenBase.mesaPlateau.biomeID; | |
} else { | |
outputBiomeIDs[z + x * xSize] = BiomeGenBase.mesaPlateau_F.biomeID; | |
} | |
} else { | |
outputBiomeIDs[z + x * xSize] = getWeightedBiomeEntry(BiomeManager.BiomeType.DESERT).biome.biomeID; | |
} | |
} else if (nextBiomeCategoryId == 2) { | |
//Warm biomes | |
if (keepNextBiome) { | |
outputBiomeIDs[z + x * xSize] = BiomeGenBase.jungle.biomeID; | |
} else { | |
outputBiomeIDs[z + x * xSize] = getWeightedBiomeEntry(BiomeManager.BiomeType.WARM).biome.biomeID; | |
} | |
} else if (nextBiomeCategoryId == 3) { | |
//Cool biomes | |
if (keepNextBiome) { | |
outputBiomeIDs[z + x * xSize] = BiomeGenBase.megaTaiga.biomeID; | |
} else { | |
outputBiomeIDs[z + x * xSize] = getWeightedBiomeEntry(BiomeManager.BiomeType.COOL).biome.biomeID; | |
} | |
} else if (nextBiomeCategoryId == 4) { | |
//Cold biomes | |
outputBiomeIDs[z + x * xSize] = getWeightedBiomeEntry(BiomeManager.BiomeType.ICY).biome.biomeID; | |
} else { | |
outputBiomeIDs[z + x * xSize] = BiomeGenBase.mushroomIsland.biomeID; | |
} | |
} | |
} | |
return outputBiomeIDs; | |
} | |
protected BiomeEntry getWeightedBiomeEntry(BiomeManager.BiomeType type) | |
{ | |
List<BiomeEntry> biomeList = biomes[type.ordinal()]; | |
int totalWeight = WeightedRandom.getTotalWeight(biomeList); | |
int weight = BiomeManager.isTypeListModded(type)?nextInt(totalWeight):nextInt(totalWeight / 10) * 10; | |
return (BiomeEntry)WeightedRandom.getItem(biomeList, weight); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WCSWWorldType extends WorldType { | |
public WCSWWorldType(String name) { | |
super(name); | |
} | |
@Override | |
public WorldChunkManager getChunkManager(World world) { | |
return new WCSWChunkManager(world); | |
} | |
@Override | |
public IChunkProvider getChunkGenerator(World world, String generatorOptions) { | |
return new WCSWChunkProvider(world); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment