initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
282
java/src/game/worldgen/BiomeGenLayered.java
Executable file
282
java/src/game/worldgen/BiomeGenLayered.java
Executable file
|
@ -0,0 +1,282 @@
|
|||
package game.worldgen;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.collect.Lists;
|
||||
import game.world.BlockPos;
|
||||
import game.world.LongHashMap;
|
||||
import game.worldgen.layer.GenLayer;
|
||||
import game.worldgen.layer.GenLayerAddAreas;
|
||||
import game.worldgen.layer.GenLayerAddExtra;
|
||||
import game.worldgen.layer.GenLayerAddSea;
|
||||
import game.worldgen.layer.GenLayerAddSnow;
|
||||
import game.worldgen.layer.GenLayerBase;
|
||||
import game.worldgen.layer.GenLayerBiome;
|
||||
import game.worldgen.layer.GenLayerBiomeEdge;
|
||||
import game.worldgen.layer.GenLayerEdge;
|
||||
import game.worldgen.layer.GenLayerFuzzyZoom;
|
||||
import game.worldgen.layer.GenLayerHills;
|
||||
import game.worldgen.layer.GenLayerRemoveEmpty;
|
||||
import game.worldgen.layer.GenLayerRiver;
|
||||
import game.worldgen.layer.GenLayerRiverInit;
|
||||
import game.worldgen.layer.GenLayerRiverMix;
|
||||
import game.worldgen.layer.GenLayerShore;
|
||||
import game.worldgen.layer.GenLayerSmooth;
|
||||
import game.worldgen.layer.GenLayerVoronoiZoom;
|
||||
import game.worldgen.layer.GenLayerZoom;
|
||||
import game.worldgen.layer.IntCache;
|
||||
|
||||
public class BiomeGenLayered implements BiomeGenerator {
|
||||
private class CacheBlock
|
||||
{
|
||||
public final double[] factors = new double[256];
|
||||
public final Biome[] biomes = new Biome[256];
|
||||
public int xPosition;
|
||||
public int zPosition;
|
||||
public long lastAccessTime;
|
||||
|
||||
public CacheBlock(int x, int z)
|
||||
{
|
||||
this.xPosition = x;
|
||||
this.zPosition = z;
|
||||
BiomeGenLayered.this.getFactors(this.factors, x << 4, z << 4, 16, 16);
|
||||
BiomeGenLayered.this.getBiomes(this.biomes, x << 4, z << 4, 16, 16, false);
|
||||
}
|
||||
|
||||
public Biome getBiomeGenAt(int x, int z)
|
||||
{
|
||||
return this.biomes[x & 15 | (z & 15) << 4];
|
||||
}
|
||||
}
|
||||
|
||||
private final GenLayer genBiomes;
|
||||
private final GenLayer biomeIndexLayer;
|
||||
private final LongHashMap<CacheBlock> cacheMap = new LongHashMap();
|
||||
private final List<CacheBlock> cache = Lists.<CacheBlock>newArrayList();
|
||||
private long lastCleanupTime;
|
||||
|
||||
// public BiomeGenNew(long seed, GeneratorSettings options) {
|
||||
// this(seed, options.biomeMode, options.fixedBiome, options.genMode == 2, options.biomeSize,
|
||||
// options.riverSize, options.snowRarity, options.seaRarity, options.shroomRarity, options.biomeRarity);
|
||||
// }
|
||||
|
||||
// public BiomeGenLayered(Dimension dim, Random rand) {
|
||||
// this();
|
||||
// }
|
||||
|
||||
public BiomeGenLayered(long seed, Biome def, boolean fixed, int biomeSize, int riverSize, int snowRarity, int seaRarity,
|
||||
Biome[] add, int addRarity, Biome[] hot, Biome[] medium, Biome[] cold, Biome[] frost) {
|
||||
// GenLayer[] layers = GenLayer.getLayers(seed, fixedBiome, biomeSize, riverSize, snowRarity, seaRarity, shroomRarity, biomeRarity);
|
||||
GenLayer layer0t1 = new GenLayerBase(1L);
|
||||
layer0t1 = new GenLayerFuzzyZoom(2000L, layer0t1);
|
||||
GenLayerAddAreas layer2 = new GenLayerAddAreas(1L, layer0t1);
|
||||
GenLayerZoom layer3 = new GenLayerZoom(2001L, layer2);
|
||||
GenLayerAddAreas layer4t6 = new GenLayerAddAreas(2L, layer3);
|
||||
layer4t6 = new GenLayerAddAreas(50L, layer4t6);
|
||||
layer4t6 = new GenLayerAddAreas(70L, layer4t6);
|
||||
GenLayerRemoveEmpty layer7 = new GenLayerRemoveEmpty(2L, layer4t6);
|
||||
GenLayerAddSnow layer8 = new GenLayerAddSnow(2L, layer7, snowRarity);
|
||||
GenLayerAddAreas layer9 = new GenLayerAddAreas(3L, layer8);
|
||||
GenLayerEdge layer10t12 = new GenLayerEdge(2L, layer9, GenLayerEdge.Mode.COOL_WARM);
|
||||
layer10t12 = new GenLayerEdge(2L, layer10t12, GenLayerEdge.Mode.HEAT_ICE);
|
||||
// layer10t12 = new GenLayerEdge(3L, layer10t12, GenLayerEdge.Mode.SPECIAL);
|
||||
GenLayerZoom layer13t14 = new GenLayerZoom(2002L, layer10t12);
|
||||
layer13t14 = new GenLayerZoom(2003L, layer13t14);
|
||||
GenLayerAddAreas layer15 = new GenLayerAddAreas(4L, layer13t14);
|
||||
GenLayerAddExtra layer16 = new GenLayerAddExtra(5L, layer15, add, addRarity);
|
||||
GenLayerAddSea layer17 = new GenLayerAddSea(4L, layer16, seaRarity);
|
||||
GenLayer layer18 = GenLayerZoom.magnify(1000L, layer17, 0);
|
||||
GenLayer layer19 = GenLayerZoom.magnify(1000L, layer18, 0);
|
||||
GenLayerRiverInit layer20 = new GenLayerRiverInit(100L, layer19);
|
||||
GenLayerBiome layer21n = new GenLayerBiome(200L, layer18, hot, medium, cold, frost, def, fixed);
|
||||
GenLayer layer22n = GenLayerZoom.magnify(1000L, layer21n, 2);
|
||||
GenLayerBiomeEdge layer23n = new GenLayerBiomeEdge(1000L, layer22n);
|
||||
GenLayer layer21l = GenLayerZoom.magnify(1000L, layer20, 2);
|
||||
GenLayer layer24n = new GenLayerHills(1000L, layer23n, layer21l, def);
|
||||
GenLayer layer21t22a = GenLayerZoom.magnify(1000L, layer20, 2);
|
||||
layer21t22a = GenLayerZoom.magnify(1000L, layer21t22a, riverSize);
|
||||
GenLayerRiver layer23a = new GenLayerRiver(1L, layer21t22a);
|
||||
GenLayerSmooth layer24a = new GenLayerSmooth(1000L, layer23a);
|
||||
// layer24n = new GenLayerRareBiome(1001L, layer24n, biomeRarity);
|
||||
for(int k = 0; k < biomeSize; ++k) {
|
||||
layer24n = new GenLayerZoom((long)(1000 + k), layer24n);
|
||||
if(k == 0) {
|
||||
layer24n = new GenLayerAddAreas(3L, layer24n);
|
||||
}
|
||||
if(k == 1 || biomeSize == 1) {
|
||||
layer24n = new GenLayerShore(1000L, layer24n);
|
||||
}
|
||||
}
|
||||
GenLayerSmooth layer25n = new GenLayerSmooth(1000L, layer24n);
|
||||
GenLayerRiverMix layerOut = new GenLayerRiverMix(100L, layer25n, layer24a, def);
|
||||
GenLayer layerIndex = // perlinGen ? new GenLayerRiverMix(100L, layer25n, layer24a) :
|
||||
new GenLayerVoronoiZoom(10L, layerOut);
|
||||
layerOut.initWorldGenSeed(seed);
|
||||
layerIndex.initWorldGenSeed(seed);
|
||||
// return new GenLayer[] {layerOut, layerIndex};
|
||||
this.genBiomes = layerOut;
|
||||
this.biomeIndexLayer = layerIndex;
|
||||
}
|
||||
|
||||
private CacheBlock getBiomeCacheBlock(int x, int z)
|
||||
{
|
||||
x = x >> 4;
|
||||
z = z >> 4;
|
||||
long i = LongHashMap.packInt(x, z); // (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
|
||||
CacheBlock blk = this.cacheMap.getValueByKey(i);
|
||||
|
||||
if (blk == null)
|
||||
{
|
||||
blk = new CacheBlock(x, z);
|
||||
this.cacheMap.add(i, blk);
|
||||
this.cache.add(blk);
|
||||
}
|
||||
|
||||
blk.lastAccessTime = System.currentTimeMillis();
|
||||
return blk;
|
||||
}
|
||||
|
||||
public void cleanupCache()
|
||||
{
|
||||
long i = System.currentTimeMillis();
|
||||
long j = i - this.lastCleanupTime;
|
||||
|
||||
if (j > 7500L || j < 0L)
|
||||
{
|
||||
this.lastCleanupTime = i;
|
||||
|
||||
for (int k = 0; k < this.cache.size(); ++k)
|
||||
{
|
||||
CacheBlock blk = this.cache.get(k);
|
||||
long l = i - blk.lastAccessTime;
|
||||
|
||||
if (l > 30000L || l < 0L)
|
||||
{
|
||||
this.cache.remove(k--);
|
||||
long i1 = LongHashMap.packInt(blk.xPosition, blk.zPosition) ; // (long)biomecache$block.xPosition & 4294967295L | ((long)biomecache$block.zPosition & 4294967295L) << 32;
|
||||
this.cacheMap.remove(i1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Biome getBiomeGenerator(BlockPos pos, Biome def) {
|
||||
int x = pos.getX();
|
||||
int z = pos.getZ();
|
||||
Biome biome = this.getBiomeCacheBlock(x, z).getBiomeGenAt(x, z);
|
||||
return biome == null ? def : biome;
|
||||
}
|
||||
|
||||
public void getFactors(double[] listToReuse, int x, int z, int width, int length) {
|
||||
IntCache.resetIntCache();
|
||||
|
||||
int[] aint = this.biomeIndexLayer.getInts(x, z, width, length);
|
||||
|
||||
for(int i = 0; i < width * length; ++i) {
|
||||
Biome biome = Biome.getBiomeFromBiomeList(aint[i], Biome.DEF_BIOME);
|
||||
float f = biome.humidity * biome.temperature;
|
||||
if(f > 1.0F)
|
||||
f = 1.0F;
|
||||
listToReuse[i] = (double)f;
|
||||
}
|
||||
}
|
||||
|
||||
public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ) {
|
||||
IntCache.resetIntCache();
|
||||
|
||||
if(true && sizeX == 16 && sizeZ == 16 && (xPos & 15) == 0 && (zPos & 15) == 0) {
|
||||
double[] cachedFacts = this.getBiomeCacheBlock(xPos, zPos).factors;
|
||||
System.arraycopy(cachedFacts, 0, factors, 0, sizeX * sizeZ);
|
||||
}
|
||||
else {
|
||||
int[] aint = this.biomeIndexLayer.getInts(xPos, zPos, sizeX, sizeZ);
|
||||
|
||||
for(int i = 0; i < sizeX * sizeZ; ++i) {
|
||||
Biome biome = Biome.getBiomeFromBiomeList(aint[i], Biome.DEF_BIOME);
|
||||
float f = biome.humidity * biome.temperature;
|
||||
if(f > 1.0F)
|
||||
f = 1.0F;
|
||||
factors[i] = (double)f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getGenBiomes(Biome[] biomes, int x, int z, int width, int height) {
|
||||
IntCache.resetIntCache();
|
||||
|
||||
int[] aint = this.genBiomes.getInts(x, z, width, height);
|
||||
|
||||
for(int i = 0; i < width * height; ++i) {
|
||||
biomes[i] = Biome.getBiomeFromBiomeList(aint[i], Biome.DEF_BIOME);
|
||||
}
|
||||
}
|
||||
|
||||
public void getChunkBiomes(Biome[] oldBiomeList, int x, int z, int width, int depth) {
|
||||
this.getBiomes(oldBiomeList, x, z, width, depth, true);
|
||||
}
|
||||
|
||||
public void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cache) {
|
||||
IntCache.resetIntCache();
|
||||
|
||||
if(cache && width == 16 && length == 16 && (x & 15) == 0 && (z & 15) == 0) {
|
||||
Biome[] biomes = this.getBiomeCacheBlock(x, z).biomes;
|
||||
System.arraycopy(biomes, 0, listToReuse, 0, width * length);
|
||||
}
|
||||
else {
|
||||
int[] aint = this.biomeIndexLayer.getInts(x, z, width, length);
|
||||
|
||||
for(int i = 0; i < width * length; ++i) {
|
||||
listToReuse[i] = Biome.getBiomeFromBiomeList(aint[i], Biome.DEF_BIOME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean areBiomesViable(int x, int z, int size, Set<Biome> allowed) {
|
||||
IntCache.resetIntCache();
|
||||
int i = x - size >> 2;
|
||||
int j = z - size >> 2;
|
||||
int k = x + size >> 2;
|
||||
int l = z + size >> 2;
|
||||
int i1 = k - i + 1;
|
||||
int j1 = l - j + 1;
|
||||
int[] aint = this.genBiomes.getInts(i, j, i1, j1);
|
||||
|
||||
for(int k1 = 0; k1 < i1 * j1; ++k1) {
|
||||
Biome biome = Biome.getBiome(aint[k1]);
|
||||
|
||||
if(!allowed.contains(biome)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// public BlockPos findBiomePosition(int x, int z, int range, Set<Biome> biomes, Random rand) {
|
||||
// IntCache.resetIntCache();
|
||||
// int x1 = x - range >> 2;
|
||||
// int z1 = z - range >> 2;
|
||||
// int x2 = x + range >> 2;
|
||||
// int z2 = z + range >> 2;
|
||||
// int xs = x2 - x1 + 1;
|
||||
// int zs = z2 - z1 + 1;
|
||||
// int[] ints = this.genBiomes.getInts(x1, z1, xs, zs);
|
||||
// BlockPos pos = null;
|
||||
// int count = 0;
|
||||
//
|
||||
// for(int n = 0; n < xs * zs; ++n) {
|
||||
// int bx = x1 + n % xs << 2;
|
||||
// int bz = z1 + n / xs << 2;
|
||||
// Biome biome = Biome.getBiome(ints[n]);
|
||||
//
|
||||
// if(biomes.contains(biome) && (pos == null || rand.zrange(count + 1) == 0)) {
|
||||
// pos = new BlockPos(bx, 0, bz);
|
||||
// ++count;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return pos;
|
||||
// }
|
||||
}
|
50
java/src/game/worldgen/BiomeGenPerlin.java
Executable file
50
java/src/game/worldgen/BiomeGenPerlin.java
Executable file
|
@ -0,0 +1,50 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.rng.PerlinGenOld;
|
||||
import game.rng.Random;
|
||||
|
||||
public class BiomeGenPerlin {
|
||||
private final PerlinGenOld tempNoiseGen;
|
||||
private final PerlinGenOld rainNoiseGen;
|
||||
private final PerlinGenOld multNoiseGen;
|
||||
private final double[] tempMult = new double[256];
|
||||
private final double[] temperature = new double[256];
|
||||
private final double[] humidity = new double[256];
|
||||
|
||||
public BiomeGenPerlin(long seed) {
|
||||
this.tempNoiseGen = new PerlinGenOld(new Random(seed * 9871L), 4);
|
||||
this.rainNoiseGen = new PerlinGenOld(new Random(seed * 39811L), 4);
|
||||
this.multNoiseGen = new PerlinGenOld(new Random(seed * 0x84a59L), 2);
|
||||
}
|
||||
|
||||
public void generate(double[] factors, int xPos, int zPos) {
|
||||
xPos *= 16;
|
||||
zPos *= 16;
|
||||
this.tempNoiseGen.generate(this.temperature, xPos, zPos, 16, 16, 0.02500000037252903D, 0.02500000037252903D, 0.25D);
|
||||
this.rainNoiseGen.generate(this.humidity, xPos, zPos, 16, 16, 0.05000000074505806D, 0.05000000074505806D, 0.33333333333333331D);
|
||||
this.multNoiseGen.generate(this.tempMult, xPos, zPos, 16, 16, 0.25D, 0.25D, 0.58823529411764708D);
|
||||
int pos = 0;
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
double tempMul = this.tempMult[pos] * 1.1000000000000001D + 0.5D;
|
||||
double factor = 0.01D;
|
||||
double ifactor = 1.0D - factor;
|
||||
double temp = (this.temperature[pos] * 0.14999999999999999D + 0.69999999999999996D) * ifactor + tempMul * factor;
|
||||
factor = 0.002D;
|
||||
ifactor = 1.0D - factor;
|
||||
double rain = (this.humidity[pos] * 0.14999999999999999D + 0.5D) * ifactor + tempMul * factor;
|
||||
temp = 1.0D - (1.0D - temp) * (1.0D - temp);
|
||||
if(temp < 0.0D)
|
||||
temp = 0.0D;
|
||||
if(rain < 0.0D)
|
||||
rain = 0.0D;
|
||||
if(temp > 1.0D)
|
||||
temp = 1.0D;
|
||||
if(rain > 1.0D)
|
||||
rain = 1.0D;
|
||||
factors[z * 16 + x] = temp * rain;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
java/src/game/worldgen/BiomeGenSingle.java
Executable file
47
java/src/game/worldgen/BiomeGenSingle.java
Executable file
|
@ -0,0 +1,47 @@
|
|||
package game.worldgen;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.world.BlockPos;
|
||||
|
||||
public class BiomeGenSingle implements BiomeGenerator {
|
||||
private final Biome biome;
|
||||
|
||||
public BiomeGenSingle(Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
public Biome getBiomeGenerator(BlockPos pos, Biome def) {
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public void getGenBiomes(Biome[] biomes, int x, int z, int width, int height) {
|
||||
Arrays.fill(biomes, 0, width * height, this.biome);
|
||||
}
|
||||
|
||||
public void getChunkBiomes(Biome[] oldBiomeList, int x, int z, int width, int depth) {
|
||||
Arrays.fill(oldBiomeList, 0, width * depth, this.biome);
|
||||
}
|
||||
|
||||
public void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cache) {
|
||||
Arrays.fill(listToReuse, 0, width * length, this.biome);
|
||||
}
|
||||
|
||||
// public BlockPos findBiomePosition(int x, int z, int range, Set<Biome> biomes, Random random) {
|
||||
// return biomes.contains(this.biome) ? new BlockPos(x - range + random.zrange(range * 2 + 1), 0, z - range + random.zrange(range * 2 + 1))
|
||||
// : null;
|
||||
// }
|
||||
|
||||
public boolean areBiomesViable(int x, int z, int size, Set<Biome> allowed) {
|
||||
return allowed.contains(this.biome);
|
||||
}
|
||||
|
||||
public void cleanupCache() {
|
||||
}
|
||||
|
||||
public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ) {
|
||||
Arrays.fill(factors, 0, sizeX * sizeZ, this.biome.humidity * this.biome.temperature);
|
||||
}
|
||||
}
|
16
java/src/game/worldgen/BiomeGenerator.java
Executable file
16
java/src/game/worldgen/BiomeGenerator.java
Executable file
|
@ -0,0 +1,16 @@
|
|||
package game.worldgen;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.world.BlockPos;
|
||||
|
||||
public interface BiomeGenerator {
|
||||
public void genFactors(double[] factors, int xPos, int zPos, int sizeX, int sizeZ);
|
||||
public Biome getBiomeGenerator(BlockPos pos, Biome def);
|
||||
public void getGenBiomes(Biome[] biomes, int x, int z, int width, int height);
|
||||
public void getChunkBiomes(Biome[] oldBiomeList, int x, int z, int width, int depth);
|
||||
public void getBiomes(Biome[] listToReuse, int x, int z, int width, int length, boolean cacheFlag);
|
||||
public boolean areBiomesViable(int x, int z, int size, Set<Biome> allowed);
|
||||
public void cleanupCache();
|
||||
}
|
9
java/src/game/worldgen/BlockReplacer.java
Executable file
9
java/src/game/worldgen/BlockReplacer.java
Executable file
|
@ -0,0 +1,9 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.rng.Random;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public interface BlockReplacer {
|
||||
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes);
|
||||
}
|
8
java/src/game/worldgen/ChunkGenerator.java
Executable file
8
java/src/game/worldgen/ChunkGenerator.java
Executable file
|
@ -0,0 +1,8 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.world.WorldServer;
|
||||
|
||||
public interface ChunkGenerator {
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer);
|
||||
public int getMaximumHeight();
|
||||
}
|
24
java/src/game/worldgen/ChunkPrimer.java
Executable file
24
java/src/game/worldgen/ChunkPrimer.java
Executable file
|
@ -0,0 +1,24 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.init.BlockRegistry;
|
||||
import game.init.Blocks;
|
||||
import game.world.State;
|
||||
|
||||
public class ChunkPrimer {
|
||||
public final int height;
|
||||
private final short[] data;
|
||||
|
||||
public ChunkPrimer(int height) {
|
||||
this.data = new short[Math.max(height, 256) * 256];
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public State get(int x, int y, int z) {
|
||||
State state = BlockRegistry.STATEMAP.getByValue(this.data[x << 4 | z | y << 8]);
|
||||
return state != null ? state : Blocks.air.getState();
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z, State state) {
|
||||
this.data[x << 4 | z | y << 8] = (short)BlockRegistry.STATEMAP.get(state);
|
||||
}
|
||||
}
|
178
java/src/game/worldgen/FeatureDungeons.java
Executable file
178
java/src/game/worldgen/FeatureDungeons.java
Executable file
|
@ -0,0 +1,178 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.Log;
|
||||
import game.init.Blocks;
|
||||
import game.init.Items;
|
||||
import game.item.RngLoot;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
import game.tileentity.TileEntity;
|
||||
import game.tileentity.TileEntityChest;
|
||||
import game.tileentity.TileEntityMobSpawner;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class FeatureDungeons
|
||||
{
|
||||
private static final String[] SPAWNERTYPES = new String[] {"Undead", "Zombie", "Zombie", "Arachnoid"};
|
||||
|
||||
private final int chance;
|
||||
|
||||
public FeatureDungeons(int chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
|
||||
boolean flag = false;
|
||||
for(int z = 0; z < this.chance; z++) {
|
||||
flag |= this.generateDungeon(worldIn, rand, position.add(rand.chOffset(), rand.zrange(256), rand.chOffset()));
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean generateDungeon(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = 3;
|
||||
int j = rand.zrange(2) + 2;
|
||||
int k = -j - 1;
|
||||
int l = j + 1;
|
||||
int i1 = -1;
|
||||
int j1 = 4;
|
||||
int k1 = rand.zrange(2) + 2;
|
||||
int l1 = -k1 - 1;
|
||||
int i2 = k1 + 1;
|
||||
int j2 = 0;
|
||||
|
||||
for (int k2 = k; k2 <= l; ++k2)
|
||||
{
|
||||
for (int l2 = -1; l2 <= 4; ++l2)
|
||||
{
|
||||
for (int i3 = l1; i3 <= i2; ++i3)
|
||||
{
|
||||
BlockPos blockpos = position.add(k2, l2, i3);
|
||||
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
|
||||
boolean flag = material.isSolid();
|
||||
|
||||
if (l2 == -1 && !flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (l2 == 4 && !flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((k2 == k || k2 == l || i3 == l1 || i3 == i2) && l2 == 0 && worldIn.isAirBlock(blockpos) && worldIn.isAirBlock(blockpos.up()))
|
||||
{
|
||||
++j2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (j2 >= 1 && j2 <= 5)
|
||||
{
|
||||
for (int k3 = k; k3 <= l; ++k3)
|
||||
{
|
||||
for (int i4 = 3; i4 >= -1; --i4)
|
||||
{
|
||||
for (int k4 = l1; k4 <= i2; ++k4)
|
||||
{
|
||||
BlockPos blockpos1 = position.add(k3, i4, k4);
|
||||
|
||||
if (k3 != k && i4 != -1 && k4 != l1 && k3 != l && i4 != 4 && k4 != i2)
|
||||
{
|
||||
if (worldIn.getState(blockpos1).getBlock() != Blocks.chest)
|
||||
{
|
||||
worldIn.setBlockToAir(blockpos1);
|
||||
}
|
||||
}
|
||||
else if (blockpos1.getY() >= 0 && !worldIn.getState(blockpos1.down()).getBlock().getMaterial().isSolid())
|
||||
{
|
||||
worldIn.setBlockToAir(blockpos1);
|
||||
}
|
||||
else if (worldIn.getState(blockpos1).getBlock().getMaterial().isSolid() && worldIn.getState(blockpos1).getBlock() != Blocks.chest)
|
||||
{
|
||||
if (i4 == -1 && rand.zrange(4) != 0)
|
||||
{
|
||||
worldIn.setState(blockpos1, Blocks.mossy_cobblestone.getState(), 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldIn.setState(blockpos1, Blocks.cobblestone.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int l3 = 0; l3 < 2; ++l3)
|
||||
{
|
||||
for (int j4 = 0; j4 < 3; ++j4)
|
||||
{
|
||||
int l4 = position.getX() + rand.zrange(j * 2 + 1) - j;
|
||||
int i5 = position.getY();
|
||||
int j5 = position.getZ() + rand.zrange(k1 * 2 + 1) - k1;
|
||||
BlockPos blockpos2 = new BlockPos(l4, i5, j5);
|
||||
|
||||
if (worldIn.isAirBlock(blockpos2))
|
||||
{
|
||||
int j3 = 0;
|
||||
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
|
||||
{
|
||||
if (worldIn.getState(blockpos2.offset(enumfacing)).getBlock().getMaterial().isSolid())
|
||||
{
|
||||
++j3;
|
||||
}
|
||||
}
|
||||
|
||||
if (j3 == 1)
|
||||
{
|
||||
worldIn.setState(blockpos2, Blocks.chest.correctFacing(worldIn, blockpos2, Blocks.chest.getState()), 2);
|
||||
WeightedList<RngLoot> list = RngLoot.addToList(LootConstants.DUNGEON_CHEST, Items.enchanted_book.getRandom(rand));
|
||||
TileEntity tileentity1 = worldIn.getTileEntity(blockpos2);
|
||||
|
||||
if (tileentity1 instanceof TileEntityChest)
|
||||
{
|
||||
RngLoot.generateChestContents(rand, list, (TileEntityChest)tileentity1, 8);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
worldIn.setState(position, Blocks.mob_spawner.getState(), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(position);
|
||||
|
||||
if (tileentity instanceof TileEntityMobSpawner)
|
||||
{
|
||||
((TileEntityMobSpawner)tileentity).setEntityName(this.pickMobSpawner(rand));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.JNI.warn("Konnte kein Mob-Spawner-Objekt bei (" + position.getX() + ", " + position.getY() + ", " + position.getZ() + ") erstellen");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly decides which spawner to use in a dungeon
|
||||
*/
|
||||
private String pickMobSpawner(Random p_76543_1_)
|
||||
{
|
||||
return SPAWNERTYPES[p_76543_1_.zrange(SPAWNERTYPES.length)];
|
||||
}
|
||||
}
|
35
java/src/game/worldgen/FeatureGenerator.java
Executable file
35
java/src/game/worldgen/FeatureGenerator.java
Executable file
|
@ -0,0 +1,35 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public abstract class FeatureGenerator
|
||||
{
|
||||
private final boolean doBlockNotify;
|
||||
|
||||
public FeatureGenerator()
|
||||
{
|
||||
this(false);
|
||||
}
|
||||
|
||||
public FeatureGenerator(boolean notify)
|
||||
{
|
||||
this.doBlockNotify = notify;
|
||||
}
|
||||
|
||||
public abstract boolean generate(WorldServer worldIn, Random rand, BlockPos position);
|
||||
|
||||
protected void setBlockAndNotifyAdequately(WorldServer worldIn, BlockPos pos, State state)
|
||||
{
|
||||
if (this.doBlockNotify)
|
||||
{
|
||||
worldIn.setState(pos, state, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldIn.setState(pos, state, 2);
|
||||
}
|
||||
}
|
||||
}
|
221
java/src/game/worldgen/FeatureLakes.java
Executable file
221
java/src/game/worldgen/FeatureLakes.java
Executable file
|
@ -0,0 +1,221 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.LightType;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class FeatureLakes
|
||||
{
|
||||
public final State state;
|
||||
private final Block block;
|
||||
public final State filler;
|
||||
// public final Block replace;
|
||||
public final State top;
|
||||
public final int chance;
|
||||
public final int minHeight;
|
||||
public final int maxHeight;
|
||||
public final boolean ratiod;
|
||||
|
||||
public FeatureLakes(State state, State filler, /* Block replace, */ State top, int chance, int minHeight, int maxHeight,
|
||||
boolean ratiod)
|
||||
{
|
||||
this.state = state;
|
||||
this.block = state.getBlock();
|
||||
this.filler = filler;
|
||||
// this.replace = replace;
|
||||
this.top = top;
|
||||
this.chance = chance;
|
||||
this.ratiod = ratiod;
|
||||
if(minHeight > maxHeight) {
|
||||
this.minHeight = maxHeight;
|
||||
this.maxHeight = minHeight;
|
||||
}
|
||||
else {
|
||||
this.minHeight = minHeight;
|
||||
this.maxHeight = maxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// public WorldGenLakes(Block block)
|
||||
// {
|
||||
// this(block, block == Blocks.lava ? Blocks.stone.getDefaultState() : null, Blocks.dirt, Blocks.grass.getDefaultState());
|
||||
// }
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
|
||||
if(this.ratiod) {
|
||||
if(this.chance >= 1 && rand.chance(this.chance)) {
|
||||
int y = rand.range(this.minHeight, this.maxHeight); // rand.zrange(rand.zrange(248) + 8);
|
||||
if(y < worldIn.getSeaLevel() || rand.chance(this.chance * 5 / 4))
|
||||
return this.generateLake(worldIn, rand, position.add(rand.chOffset(), y, rand.chOffset()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(this.chance >= 1 && rand.chance(this.chance))
|
||||
return this.generateLake(worldIn, rand, position.add(rand.chOffset(), rand.range(this.minHeight, this.maxHeight),
|
||||
rand.chOffset()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean generateLake(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (position = position.add(-8, 0, -8); position.getY() > 5 && worldIn.isAirBlock(position); position = position.down())
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (position.getY() <= 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
position = position.down(4);
|
||||
boolean[] aboolean = new boolean[2048];
|
||||
int i = rand.zrange(4) + 4;
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double d0 = rand.doublev() * 6.0D + 3.0D;
|
||||
double d1 = rand.doublev() * 4.0D + 2.0D;
|
||||
double d2 = rand.doublev() * 6.0D + 3.0D;
|
||||
double d3 = rand.doublev() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
|
||||
double d4 = rand.doublev() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D;
|
||||
double d5 = rand.doublev() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;
|
||||
|
||||
for (int l = 1; l < 15; ++l)
|
||||
{
|
||||
for (int i1 = 1; i1 < 15; ++i1)
|
||||
{
|
||||
for (int j1 = 1; j1 < 7; ++j1)
|
||||
{
|
||||
double d6 = ((double)l - d3) / (d0 / 2.0D);
|
||||
double d7 = ((double)j1 - d4) / (d1 / 2.0D);
|
||||
double d8 = ((double)i1 - d5) / (d2 / 2.0D);
|
||||
double d9 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
if (d9 < 1.0D)
|
||||
{
|
||||
aboolean[(l * 16 + i1) * 8 + j1] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int k1 = 0; k1 < 16; ++k1)
|
||||
{
|
||||
for (int l2 = 0; l2 < 16; ++l2)
|
||||
{
|
||||
for (int k = 0; k < 8; ++k)
|
||||
{
|
||||
boolean flag = !aboolean[(k1 * 16 + l2) * 8 + k] && (k1 < 15 && aboolean[((k1 + 1) * 16 + l2) * 8 + k] || k1 > 0 && aboolean[((k1 - 1) * 16 + l2) * 8 + k] || l2 < 15 && aboolean[(k1 * 16 + l2 + 1) * 8 + k] || l2 > 0 && aboolean[(k1 * 16 + (l2 - 1)) * 8 + k] || k < 7 && aboolean[(k1 * 16 + l2) * 8 + k + 1] || k > 0 && aboolean[(k1 * 16 + l2) * 8 + (k - 1)]);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
Material material = worldIn.getState(position.add(k1, k, l2)).getBlock().getMaterial();
|
||||
|
||||
if (k >= 4 && material.isLiquid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (k < 4 && !material.isSolid() && worldIn.getState(position.add(k1, k, l2)).getBlock() != this.block)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int l1 = 0; l1 < 16; ++l1)
|
||||
{
|
||||
for (int i3 = 0; i3 < 16; ++i3)
|
||||
{
|
||||
for (int i4 = 0; i4 < 8; ++i4)
|
||||
{
|
||||
if (aboolean[(l1 * 16 + i3) * 8 + i4])
|
||||
{
|
||||
worldIn.setState(position.add(l1, i4, i3), i4 >= 4 ? Blocks.air.getState() : this.state, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.top != null) {
|
||||
Block replace = worldIn.dimension.getTop().getBlock();
|
||||
for (int i2 = 0; i2 < 16; ++i2)
|
||||
{
|
||||
for (int j3 = 0; j3 < 16; ++j3)
|
||||
{
|
||||
for (int j4 = 4; j4 < 8; ++j4)
|
||||
{
|
||||
if (aboolean[(i2 * 16 + j3) * 8 + j4])
|
||||
{
|
||||
BlockPos blockpos = position.add(i2, j4 - 1, j3);
|
||||
|
||||
if (worldIn.getState(blockpos).getBlock() == replace && worldIn.getLightFor(LightType.SKY, position.add(i2, j4, j3)) > 0)
|
||||
{
|
||||
Biome biomegenbase = worldIn.getBiomeGenForCoords(blockpos);
|
||||
|
||||
if (biomegenbase.topBlock.getBlock() == Blocks.mycelium)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.mycelium.getState(), 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldIn.setState(blockpos, this.top, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.filler != null) // && this.block.getMaterial() == Material.lava)
|
||||
{
|
||||
for (int j2 = 0; j2 < 16; ++j2)
|
||||
{
|
||||
for (int k3 = 0; k3 < 16; ++k3)
|
||||
{
|
||||
for (int k4 = 0; k4 < 8; ++k4)
|
||||
{
|
||||
boolean flag1 = !aboolean[(j2 * 16 + k3) * 8 + k4] && (j2 < 15 && aboolean[((j2 + 1) * 16 + k3) * 8 + k4] || j2 > 0 && aboolean[((j2 - 1) * 16 + k3) * 8 + k4] || k3 < 15 && aboolean[(j2 * 16 + k3 + 1) * 8 + k4] || k3 > 0 && aboolean[(j2 * 16 + (k3 - 1)) * 8 + k4] || k4 < 7 && aboolean[(j2 * 16 + k3) * 8 + k4 + 1] || k4 > 0 && aboolean[(j2 * 16 + k3) * 8 + (k4 - 1)]);
|
||||
|
||||
if (flag1 && (k4 < 4 || rand.zrange(2) != 0) && worldIn.getState(position.add(j2, k4, k3)).getBlock().getMaterial().isSolid())
|
||||
{
|
||||
worldIn.setState(position.add(j2, k4, k3), this.filler, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.block.getMaterial() == Material.water)
|
||||
{
|
||||
for (int k2 = 0; k2 < 16; ++k2)
|
||||
{
|
||||
for (int l3 = 0; l3 < 16; ++l3)
|
||||
{
|
||||
int l4 = 3; // not 4 !!
|
||||
|
||||
if (worldIn.canBlockFreeze(position.add(k2, l4, l3), false))
|
||||
{
|
||||
worldIn.setState(position.add(k2, l4, l3), Blocks.ice.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
128
java/src/game/worldgen/FeatureLiquids.java
Executable file
128
java/src/game/worldgen/FeatureLiquids.java
Executable file
|
@ -0,0 +1,128 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.block.Block;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class FeatureLiquids
|
||||
{
|
||||
public final State state;
|
||||
private final Block block;
|
||||
// public final Block replace;
|
||||
public final int chance;
|
||||
public final int minHeight;
|
||||
public final int maxHeight;
|
||||
public final boolean lower;
|
||||
|
||||
// public WorldGenLiquids(Block block)
|
||||
// {
|
||||
// this(block, Blocks.stone);
|
||||
// }
|
||||
|
||||
public FeatureLiquids(State state, /* Block replace, */ int chance, int minHeight, int maxHeight, boolean lower)
|
||||
{
|
||||
this.state = state;
|
||||
this.block = state.getBlock();
|
||||
// replace = replace;
|
||||
this.chance = chance;
|
||||
this.lower = lower;
|
||||
if(minHeight > maxHeight) {
|
||||
this.minHeight = lower && maxHeight < 1 ? 1 : maxHeight;
|
||||
this.maxHeight = minHeight;
|
||||
}
|
||||
else {
|
||||
this.minHeight = lower && minHeight < 1 ? 1 : minHeight;
|
||||
this.maxHeight = maxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
|
||||
Block replace = worldIn.dimension.getFiller().getBlock();
|
||||
boolean flag = false;
|
||||
for(int z = 0; z < this.chance; z++) {
|
||||
if(this.lower)
|
||||
// 8, 247)
|
||||
flag |= this.generateLiquid(worldIn, rand, position.add(rand.chOffset(), rand.zrange(rand.range(this.minHeight,
|
||||
rand.range(this.minHeight, this.maxHeight))), rand.chOffset()), replace);
|
||||
else
|
||||
// int i17 = this.randomGenerator.range(8, 255);
|
||||
flag |= this.generateLiquid(worldIn, rand, position.add(rand.chOffset(), rand.range(this.minHeight,
|
||||
rand.range(this.minHeight, this.maxHeight)), rand.chOffset()), replace);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean generateLiquid(WorldServer worldIn, Random rand, BlockPos position, Block replace)
|
||||
{
|
||||
if (worldIn.getState(position.up()).getBlock() != replace)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (worldIn.getState(position.down()).getBlock() != replace)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (worldIn.getState(position).getBlock().getMaterial() != Material.air && worldIn.getState(position).getBlock() != replace)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (worldIn.getState(position.west()).getBlock() == replace)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (worldIn.getState(position.east()).getBlock() == replace)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (worldIn.getState(position.north()).getBlock() == replace)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (worldIn.getState(position.south()).getBlock() == replace)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
|
||||
if (worldIn.isAirBlock(position.west()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (worldIn.isAirBlock(position.east()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (worldIn.isAirBlock(position.north()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (worldIn.isAirBlock(position.south()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (i == 3 && j == 1)
|
||||
{
|
||||
worldIn.setState(position, this.state, 2);
|
||||
worldIn.forceBlockUpdateTick(this.block, position, rand);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
167
java/src/game/worldgen/FeatureOres.java
Executable file
167
java/src/game/worldgen/FeatureOres.java
Executable file
|
@ -0,0 +1,167 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class FeatureOres
|
||||
{
|
||||
public final State oreBlock;
|
||||
// private final Block replace;
|
||||
public final boolean distributed;
|
||||
private final int spawnTries;
|
||||
private final int moreTries;
|
||||
public final int numberOfBlocks;
|
||||
private final int minHeight;
|
||||
private final int maxHeight;
|
||||
|
||||
public final int spawns;
|
||||
public final int min;
|
||||
public final int max;
|
||||
public final int more;
|
||||
|
||||
// public FeatureOres(IBlockState state, boolean dist, int spawns, int count, int min, int max) {
|
||||
// this(state, dist, spawns, 0, count, min, max);
|
||||
// }
|
||||
|
||||
// public FeatureOres(IBlockState state, boolean dist, int spawns, int more, int count, int min, int max) {
|
||||
// this(state, dist, spawns, more, count, min, max, null);
|
||||
// }
|
||||
|
||||
public FeatureOres(State state, int count, int more, int size, int min, int max, boolean dist) // , Block replace)
|
||||
{
|
||||
this.spawns = count;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.more = more;
|
||||
count = count == 2 ? 3 : count;
|
||||
this.oreBlock = state;
|
||||
this.distributed = dist;
|
||||
if(this.distributed) {
|
||||
min = min < 0 ? 0 : (min > 511 ? 511 : min);
|
||||
max = max < 0 ? 0 : (max > 512 ? 512 : max);
|
||||
if(min + max > 511) {
|
||||
max = 512 - min;
|
||||
}
|
||||
if(min - max < 0) {
|
||||
max = min;
|
||||
}
|
||||
}
|
||||
else {
|
||||
min = min < 0 ? 0 : (min > 512 ? 512 : min);
|
||||
max = max < 0 ? 0 : (max > 512 ? 512 : max);
|
||||
if (max < min)
|
||||
{
|
||||
int i = min;
|
||||
min = max;
|
||||
max = i;
|
||||
}
|
||||
else if (max == min)
|
||||
{
|
||||
if (min < 511)
|
||||
{
|
||||
++max;
|
||||
}
|
||||
else
|
||||
{
|
||||
--min;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.minHeight = min;
|
||||
this.maxHeight = max;
|
||||
int minTries = count <= 0 ? 1 : 0;
|
||||
this.spawnTries = count < 0 ? 0 : count;
|
||||
this.moreTries = more < minTries ? minTries : more;
|
||||
this.numberOfBlocks = size < 1 ? 1 : size;
|
||||
// this.replace = replace;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
|
||||
Block replace = /* this.replace != null ? this.replace : */ worldIn.dimension.getFiller().getBlock();
|
||||
int tries = this.spawnTries == 0 ?
|
||||
(rand.zrange(this.moreTries) == 0 ? 1 : 0) :
|
||||
(this.spawnTries + (this.moreTries == 0 ? 0 : rand.zrange(this.moreTries + 1)));
|
||||
// tries = tries == 0 ? (this.numberOfBlocks == 1 ? (rand.nextInt(10) == 0 ? 1 : 0) : rand.nextInt(2)) : tries;
|
||||
for(int j = 0; j < tries; j++) {
|
||||
BlockPos blockpos;
|
||||
if(this.distributed) {
|
||||
blockpos = position.add(rand.zrange(16), rand.zrange(this.maxHeight) + rand.zrange(this.maxHeight) + this.minHeight - this.maxHeight, rand.zrange(16));
|
||||
}
|
||||
else {
|
||||
blockpos = position.add(rand.zrange(16), rand.zrange(this.maxHeight - this.minHeight) + this.minHeight, rand.zrange(16));
|
||||
}
|
||||
if(this.numberOfBlocks == 1) {
|
||||
if(worldIn.getState(blockpos).getBlock() == replace) {
|
||||
worldIn.setState(blockpos, this.oreBlock, 2);
|
||||
}
|
||||
}
|
||||
else { // if(position.getX() >= -67000000 && position.getZ() >= -67000000 && position.getX() <= 67000000 && position.getZ() <= 67000000) {
|
||||
this.generateVein(worldIn, rand, blockpos, replace); // Fix dist
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void generateVein(WorldServer worldIn, Random rand, BlockPos position, Block replace)
|
||||
{
|
||||
float f = rand.floatv() * (float)Math.PI;
|
||||
double d0 = (double)(/* (float)(position.getX() + 8) */ 8.0f + ExtMath.sin(f) * (float)this.numberOfBlocks / 8.0F);
|
||||
double d1 = (double)(/* (float)(position.getX() + 8) */ 8.0f - ExtMath.sin(f) * (float)this.numberOfBlocks / 8.0F);
|
||||
double d2 = (double)(/* (float)(position.getZ() + 8) */ 8.0f + ExtMath.cos(f) * (float)this.numberOfBlocks / 8.0F);
|
||||
double d3 = (double)(/* (float)(position.getZ() + 8) */ 8.0f - ExtMath.cos(f) * (float)this.numberOfBlocks / 8.0F);
|
||||
double d4 = (double)(/* position.getY() + */ rand.zrange(3) - 2);
|
||||
double d5 = (double)(/* position.getY() + */ rand.zrange(3) - 2);
|
||||
|
||||
for (int i = 0; i < this.numberOfBlocks; ++i)
|
||||
{
|
||||
float f1 = (float)i / (float)this.numberOfBlocks;
|
||||
double d6 = d0 + (d1 - d0) * (double)f1;
|
||||
double d7 = d4 + (d5 - d4) * (double)f1;
|
||||
double d8 = d2 + (d3 - d2) * (double)f1;
|
||||
double d9 = rand.doublev() * (double)this.numberOfBlocks / 16.0D;
|
||||
double d10 = (double)(ExtMath.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
|
||||
double d11 = (double)(ExtMath.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
|
||||
int j = ExtMath.floord(d6 - d10 / 2.0D);
|
||||
int k = ExtMath.floord(d7 - d11 / 2.0D);
|
||||
int l = ExtMath.floord(d8 - d10 / 2.0D);
|
||||
int i1 = ExtMath.floord(d6 + d10 / 2.0D);
|
||||
int j1 = ExtMath.floord(d7 + d11 / 2.0D);
|
||||
int k1 = ExtMath.floord(d8 + d10 / 2.0D);
|
||||
|
||||
for (int l1 = j; l1 <= i1; ++l1)
|
||||
{
|
||||
double d12 = ((double)l1 + 0.5D - d6) / (d10 / 2.0D);
|
||||
|
||||
if (d12 * d12 < 1.0D)
|
||||
{
|
||||
for (int i2 = k; i2 <= j1; ++i2)
|
||||
{
|
||||
double d13 = ((double)i2 + 0.5D - d7) / (d11 / 2.0D);
|
||||
|
||||
if (d12 * d12 + d13 * d13 < 1.0D)
|
||||
{
|
||||
for (int j2 = l; j2 <= k1; ++j2)
|
||||
{
|
||||
double d14 = ((double)j2 + 0.5D - d8) / (d10 / 2.0D);
|
||||
|
||||
if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D)
|
||||
{
|
||||
BlockPos blockpos = position.add(l1, i2, j2); // new BlockPos(l1, i2, j2);
|
||||
|
||||
if (worldIn.getState(blockpos).getBlock() == replace)
|
||||
{
|
||||
worldIn.setState(blockpos, this.oreBlock, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
200
java/src/game/worldgen/GeneratorCavern.java
Executable file
200
java/src/game/worldgen/GeneratorCavern.java
Executable file
|
@ -0,0 +1,200 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.rng.OctaveGen;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorCavern implements ChunkGenerator
|
||||
{
|
||||
private final OctaveGen noiseGen2;
|
||||
private final OctaveGen noiseGen3;
|
||||
private final OctaveGen noiseGen1;
|
||||
// private final OctaveGen noiseGen4;
|
||||
// private final OctaveGen noiseGen5;
|
||||
|
||||
private final double[] noiseField = new double[425];
|
||||
private final double[] noiseData1 = new double[425];
|
||||
private final double[] noiseData2 = new double[425];
|
||||
private final double[] noiseData3 = new double[425];
|
||||
// private final double[] noiseData4 = new double[25];
|
||||
// private final double[] noiseData5 = new double[25];
|
||||
|
||||
private final State filler;
|
||||
private final State liquid;
|
||||
|
||||
// public GeneratorCavern(Dimension dim, Random rand) {
|
||||
// this(rand);
|
||||
// }
|
||||
|
||||
public GeneratorCavern(Random rand, State filler, State liquid)
|
||||
{
|
||||
this.noiseGen2 = new OctaveGen(rand, 16);
|
||||
this.noiseGen3 = new OctaveGen(rand, 16);
|
||||
this.noiseGen1 = new OctaveGen(rand, 8);
|
||||
// this.noiseGen4 = new OctaveGen(rand, 10);
|
||||
// this.noiseGen5 = new OctaveGen(rand, 16);
|
||||
this.filler = filler;
|
||||
this.liquid = liquid;
|
||||
}
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
int range = 4;
|
||||
int lh = world.getSeaLevel() / 2 + 1;
|
||||
int xr = range + 1;
|
||||
int yr = 17;
|
||||
int zr = range + 1;
|
||||
this.genNoisemap(x * range, 0, z * range);
|
||||
|
||||
for (int j1 = 0; j1 < range; ++j1)
|
||||
{
|
||||
for (int k1 = 0; k1 < range; ++k1)
|
||||
{
|
||||
for (int l1 = 0; l1 < 16; ++l1)
|
||||
{
|
||||
double d0 = 0.125D;
|
||||
double d1 = this.noiseField[((j1 + 0) * zr + k1 + 0) * yr + l1 + 0];
|
||||
double d2 = this.noiseField[((j1 + 0) * zr + k1 + 1) * yr + l1 + 0];
|
||||
double d3 = this.noiseField[((j1 + 1) * zr + k1 + 0) * yr + l1 + 0];
|
||||
double d4 = this.noiseField[((j1 + 1) * zr + k1 + 1) * yr + l1 + 0];
|
||||
double d5 = (this.noiseField[((j1 + 0) * zr + k1 + 0) * yr + l1 + 1] - d1) * d0;
|
||||
double d6 = (this.noiseField[((j1 + 0) * zr + k1 + 1) * yr + l1 + 1] - d2) * d0;
|
||||
double d7 = (this.noiseField[((j1 + 1) * zr + k1 + 0) * yr + l1 + 1] - d3) * d0;
|
||||
double d8 = (this.noiseField[((j1 + 1) * zr + k1 + 1) * yr + l1 + 1] - d4) * d0;
|
||||
|
||||
for (int i2 = 0; i2 < 8; ++i2)
|
||||
{
|
||||
double d9 = 0.25D;
|
||||
double d10 = d1;
|
||||
double d11 = d2;
|
||||
double d12 = (d3 - d1) * d9;
|
||||
double d13 = (d4 - d2) * d9;
|
||||
|
||||
for (int j2 = 0; j2 < 4; ++j2)
|
||||
{
|
||||
double d14 = 0.25D;
|
||||
double d15 = d10;
|
||||
double d16 = (d11 - d10) * d14;
|
||||
|
||||
for (int k2 = 0; k2 < 4; ++k2)
|
||||
{
|
||||
State iblockstate = null;
|
||||
|
||||
if (l1 * 8 + i2 < lh)
|
||||
{
|
||||
iblockstate = this.liquid;
|
||||
}
|
||||
|
||||
if (d15 > 0.0D)
|
||||
{
|
||||
iblockstate = this.filler;
|
||||
}
|
||||
|
||||
int l2 = j2 + j1 * 4;
|
||||
int i3 = i2 + l1 * 8;
|
||||
int j3 = k2 + k1 * 4;
|
||||
primer.set(l2, i3, j3, iblockstate);
|
||||
d15 += d16;
|
||||
}
|
||||
|
||||
d10 += d12;
|
||||
d11 += d13;
|
||||
}
|
||||
|
||||
d1 += d5;
|
||||
d2 += d6;
|
||||
d3 += d7;
|
||||
d4 += d8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void genNoisemap(int x, int y, int z)
|
||||
{
|
||||
int xs = 5;
|
||||
int ys = 17;
|
||||
int zs = 5;
|
||||
double d0 = 684.412D;
|
||||
double d1 = 2053.236D;
|
||||
// this.noiseGen4.generate(this.noiseData4, x, y, z, xs, 1, zs, 1.0D, 0.0D, 1.0D);
|
||||
// this.noiseGen5.generate(this.noiseData5, x, y, z, xs, 1, zs, 100.0D, 0.0D, 100.0D);
|
||||
this.noiseGen1.generate(this.noiseData1, x, y, z, xs, ys, zs, d0 / 80.0D, d1 / 60.0D, d0 / 80.0D);
|
||||
this.noiseGen2.generate(this.noiseData2, x, y, z, xs, ys, zs, d0, d1, d0);
|
||||
this.noiseGen3.generate(this.noiseData3, x, y, z, xs, ys, zs, d0, d1, d0);
|
||||
int i = 0;
|
||||
double[] adouble = new double[ys];
|
||||
|
||||
for (int j = 0; j < ys; ++j)
|
||||
{
|
||||
adouble[j] = Math.cos((double)j * Math.PI * 6.0D / (double)ys) * 2.0D;
|
||||
double d2 = (double)j;
|
||||
|
||||
if (j > ys / 2)
|
||||
{
|
||||
d2 = (double)(ys - 1 - j);
|
||||
}
|
||||
|
||||
if (d2 < 4.0D)
|
||||
{
|
||||
d2 = 4.0D - d2;
|
||||
adouble[j] -= d2 * d2 * d2 * 10.0D;
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < xs; ++l)
|
||||
{
|
||||
for (int i1 = 0; i1 < zs; ++i1)
|
||||
{
|
||||
double d3 = 0.0D;
|
||||
|
||||
for (int k = 0; k < ys; ++k)
|
||||
{
|
||||
double d4 = 0.0D;
|
||||
double d5 = adouble[k];
|
||||
double d6 = this.noiseData2[i] / 512.0D;
|
||||
double d7 = this.noiseData3[i] / 512.0D;
|
||||
double d8 = (this.noiseData1[i] / 10.0D + 1.0D) / 2.0D;
|
||||
|
||||
if (d8 < 0.0D)
|
||||
{
|
||||
d4 = d6;
|
||||
}
|
||||
else if (d8 > 1.0D)
|
||||
{
|
||||
d4 = d7;
|
||||
}
|
||||
else
|
||||
{
|
||||
d4 = d6 + (d7 - d6) * d8;
|
||||
}
|
||||
|
||||
d4 = d4 - d5;
|
||||
|
||||
if (k > ys - 4)
|
||||
{
|
||||
double d9 = (double)((float)(k - (ys - 4)) / 3.0F);
|
||||
d4 = d4 * (1.0D - d9) + -10.0D * d9;
|
||||
}
|
||||
|
||||
if ((double)k < d3)
|
||||
{
|
||||
double d10 = (d3 - (double)k) / 4.0D;
|
||||
d10 = ExtMath.clampd(d10, 0.0D, 1.0D);
|
||||
d4 = d4 * (1.0D - d10) + -10.0D * d10;
|
||||
}
|
||||
|
||||
this.noiseField[i] = d4;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
java/src/game/worldgen/GeneratorDebug.java
Executable file
59
java/src/game/worldgen/GeneratorDebug.java
Executable file
|
@ -0,0 +1,59 @@
|
|||
package game.worldgen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.collect.Lists;
|
||||
import game.init.BlockRegistry;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorDebug implements ChunkGenerator
|
||||
{
|
||||
private static final List<State> STATES = Lists.<State>newArrayList();
|
||||
private static final int XSTRETCH;
|
||||
private static final int ZSTRETCH;
|
||||
|
||||
static {
|
||||
for(Block block : BlockRegistry.REGISTRY) {
|
||||
STATES.addAll(block.getValidStates());
|
||||
}
|
||||
XSTRETCH = ExtMath.ceilf(ExtMath.sqrtf((float)STATES.size()));
|
||||
ZSTRETCH = ExtMath.ceilf((float)STATES.size() / (float)XSTRETCH);
|
||||
}
|
||||
|
||||
public static State getState(int x, int z) {
|
||||
State state = null;
|
||||
if(x > 0 && z > 0 && x % 2 != 0 && z % 2 != 0) {
|
||||
x = x / 2;
|
||||
z = z / 2;
|
||||
if(x <= XSTRETCH && z <= ZSTRETCH) {
|
||||
int idx = ExtMath.absi(x * XSTRETCH + z);
|
||||
if(idx < STATES.size()) {
|
||||
state = STATES.get(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return 72;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
int sx = x * 16 + bx;
|
||||
int sz = z * 16 + bz;
|
||||
// primer.set(bx, 60, bz, Blocks.glass.getDefaultState());
|
||||
State state = getState(sx, sz);
|
||||
if(state != null) {
|
||||
primer.set(bx, 1, bz, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
java/src/game/worldgen/GeneratorDestroyed.java
Executable file
38
java/src/game/worldgen/GeneratorDestroyed.java
Executable file
|
@ -0,0 +1,38 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorDestroyed implements ChunkGenerator
|
||||
{
|
||||
private final State block = Blocks.coal_block.getState();
|
||||
private final State alt = Blocks.soul_sand.getState();
|
||||
private final State gap = Blocks.air.getState();
|
||||
private final State liquid = Blocks.lava.getState();
|
||||
private final State top = Blocks.obsidian.getState();
|
||||
private final int height;
|
||||
private final Random rand = new Random(); // NON-DETERMINISTIC!!
|
||||
|
||||
public GeneratorDestroyed(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
for(int by = 0; by < this.height; ++by) {
|
||||
for(int bx = 0; bx < 16; ++bx) {
|
||||
for(int bz = 0; bz < 16; ++bz) {
|
||||
primer.set(bx, by, bz, by >= this.height - this.rand.zrange(3) ? this.gap :
|
||||
(by == this.height - 1 ? this.top : this.rand.chance(this.block, (by == this.height - 3 ?
|
||||
this.liquid : this.alt), 15)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
java/src/game/worldgen/GeneratorFlat.java
Executable file
50
java/src/game/worldgen/GeneratorFlat.java
Executable file
|
@ -0,0 +1,50 @@
|
|||
package game.worldgen;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorFlat implements ChunkGenerator {
|
||||
private final State[] layers;
|
||||
|
||||
public GeneratorFlat(State ... layers) {
|
||||
this.layers = layers;
|
||||
}
|
||||
|
||||
public GeneratorFlat(int height, State layer) {
|
||||
this.layers = new State[height];
|
||||
Arrays.fill(this.layers, layer);
|
||||
}
|
||||
|
||||
// public GeneratorFlat(GeneratorSettings settings)
|
||||
// {
|
||||
// int layers = 0;
|
||||
// for(FlatSettings layer : settings.flatLayers) {
|
||||
// layers += layer.height;
|
||||
// }
|
||||
// layers = layers > 512 ? 512 : layers;
|
||||
// this.flatLayers = new IBlockState[layers];
|
||||
// int pos = 0;
|
||||
// for(FlatSettings layer : settings.flatLayers) {
|
||||
// for(int z = 0; z < layer.height; z++) {
|
||||
// this.flatLayers[pos++] = layer.state;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return this.layers.length;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer) {
|
||||
for(int by = 0; by < this.layers.length; by++) {
|
||||
State state = this.layers[by];
|
||||
for(int bx = 0; bx < 16; bx++) {
|
||||
for(int bz = 0; bz < 16; bz++) {
|
||||
primer.set(bx, by, bz, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
190
java/src/game/worldgen/GeneratorIsland.java
Executable file
190
java/src/game/worldgen/GeneratorIsland.java
Executable file
|
@ -0,0 +1,190 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.rng.OctaveGen;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorIsland implements ChunkGenerator
|
||||
{
|
||||
private final OctaveGen noiseGen1;
|
||||
private final OctaveGen noiseGen2;
|
||||
private final OctaveGen noiseGen3;
|
||||
private final OctaveGen noiseGen4;
|
||||
private final OctaveGen noiseGen5;
|
||||
|
||||
private final double[] densities = new double[297];
|
||||
private final double[] noiseData1 = new double[297];
|
||||
private final double[] noiseData2 = new double[297];
|
||||
private final double[] noiseData3 = new double[297];
|
||||
private final double[] noiseData4 = new double[9];
|
||||
private final double[] noiseData5 = new double[9];
|
||||
|
||||
private final State filler;
|
||||
|
||||
// public GeneratorIsland(Dimension dim, Random rand) {
|
||||
// this(rand, dim.getFiller());
|
||||
// }
|
||||
|
||||
public GeneratorIsland(Random rand, State filler)
|
||||
{
|
||||
this.noiseGen1 = new OctaveGen(rand, 16);
|
||||
this.noiseGen2 = new OctaveGen(rand, 16);
|
||||
this.noiseGen3 = new OctaveGen(rand, 8);
|
||||
this.noiseGen4 = new OctaveGen(rand, 10);
|
||||
this.noiseGen5 = new OctaveGen(rand, 16);
|
||||
this.filler = filler;
|
||||
}
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
int range = 2;
|
||||
int xr = range + 1;
|
||||
int yr = 33;
|
||||
int zr = range + 1;
|
||||
this.genNoisemap(x * range, 0, z * range);
|
||||
|
||||
for (int i1 = 0; i1 < range; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < range; ++j1)
|
||||
{
|
||||
for (int k1 = 0; k1 < 32; ++k1)
|
||||
{
|
||||
double d0 = 0.25D;
|
||||
double d1 = this.densities[((i1 + 0) * zr + j1 + 0) * yr + k1 + 0];
|
||||
double d2 = this.densities[((i1 + 0) * zr + j1 + 1) * yr + k1 + 0];
|
||||
double d3 = this.densities[((i1 + 1) * zr + j1 + 0) * yr + k1 + 0];
|
||||
double d4 = this.densities[((i1 + 1) * zr + j1 + 1) * yr + k1 + 0];
|
||||
double d5 = (this.densities[((i1 + 0) * zr + j1 + 0) * yr + k1 + 1] - d1) * d0;
|
||||
double d6 = (this.densities[((i1 + 0) * zr + j1 + 1) * yr + k1 + 1] - d2) * d0;
|
||||
double d7 = (this.densities[((i1 + 1) * zr + j1 + 0) * yr + k1 + 1] - d3) * d0;
|
||||
double d8 = (this.densities[((i1 + 1) * zr + j1 + 1) * yr + k1 + 1] - d4) * d0;
|
||||
|
||||
for (int l1 = 0; l1 < 4; ++l1)
|
||||
{
|
||||
double d9 = 0.125D;
|
||||
double d10 = d1;
|
||||
double d11 = d2;
|
||||
double d12 = (d3 - d1) * d9;
|
||||
double d13 = (d4 - d2) * d9;
|
||||
|
||||
for (int i2 = 0; i2 < 8; ++i2)
|
||||
{
|
||||
double d14 = 0.125D;
|
||||
double d15 = d10;
|
||||
double d16 = (d11 - d10) * d14;
|
||||
|
||||
for (int j2 = 0; j2 < 8; ++j2)
|
||||
{
|
||||
State iblockstate = null;
|
||||
|
||||
if (d15 > 0.0D)
|
||||
{
|
||||
iblockstate = this.filler;
|
||||
}
|
||||
|
||||
int k2 = i2 + i1 * 8;
|
||||
int l2 = l1 + k1 * 4;
|
||||
int i3 = j2 + j1 * 8;
|
||||
primer.set(k2, l2, i3, iblockstate);
|
||||
d15 += d16;
|
||||
}
|
||||
|
||||
d10 += d12;
|
||||
d11 += d13;
|
||||
}
|
||||
|
||||
d1 += d5;
|
||||
d2 += d6;
|
||||
d3 += d7;
|
||||
d4 += d8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void genNoisemap(int x, int y, int z)
|
||||
{
|
||||
int xs = 3;
|
||||
int ys = 33;
|
||||
int zs = 3;
|
||||
double d0 = 684.412D;
|
||||
double d1 = 684.412D;
|
||||
this.noiseGen4.generate(this.noiseData4, x, z, xs, zs, 1.121D, 1.121D, 0.5D);
|
||||
this.noiseGen5.generate(this.noiseData5, x, z, xs, zs, 200.0D, 200.0D, 0.5D);
|
||||
d0 = d0 * 2.0D;
|
||||
this.noiseGen3.generate(this.noiseData1, x, y, z, xs, ys, zs, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D);
|
||||
this.noiseGen1.generate(this.noiseData2, x, y, z, xs, ys, zs, d0, d1, d0);
|
||||
this.noiseGen2.generate(this.noiseData3, x, y, z, xs, ys, zs, d0, d1, d0);
|
||||
int i = 0;
|
||||
|
||||
for (int j = 0; j < xs; ++j)
|
||||
{
|
||||
for (int k = 0; k < zs; ++k)
|
||||
{
|
||||
float f = (float)(j + x) / 1.0F;
|
||||
float f1 = (float)(k + z) / 1.0F;
|
||||
float f2 = 100.0F - ExtMath.sqrtf(f * f + f1 * f1) * 8.0F;
|
||||
|
||||
if (f2 > 80.0F)
|
||||
{
|
||||
f2 = 80.0F;
|
||||
}
|
||||
|
||||
if (f2 < -100.0F)
|
||||
{
|
||||
f2 = -100.0F;
|
||||
}
|
||||
|
||||
for (int l = 0; l < ys; ++l)
|
||||
{
|
||||
double d2 = 0.0D;
|
||||
double d3 = this.noiseData2[i] / 512.0D;
|
||||
double d4 = this.noiseData3[i] / 512.0D;
|
||||
double d5 = (this.noiseData1[i] / 10.0D + 1.0D) / 2.0D;
|
||||
|
||||
if (d5 < 0.0D)
|
||||
{
|
||||
d2 = d3;
|
||||
}
|
||||
else if (d5 > 1.0D)
|
||||
{
|
||||
d2 = d4;
|
||||
}
|
||||
else
|
||||
{
|
||||
d2 = d3 + (d4 - d3) * d5;
|
||||
}
|
||||
|
||||
d2 = d2 - 8.0D;
|
||||
d2 = d2 + (double)f2;
|
||||
int i1 = 2;
|
||||
|
||||
if (l > ys / 2 - i1)
|
||||
{
|
||||
double d6 = (double)((float)(l - (ys / 2 - i1)) / 64.0F);
|
||||
d6 = ExtMath.clampd(d6, 0.0D, 1.0D);
|
||||
d2 = d2 * (1.0D - d6) + -3000.0D * d6;
|
||||
}
|
||||
|
||||
i1 = 8;
|
||||
|
||||
if (l < i1)
|
||||
{
|
||||
double d7 = (double)((float)(i1 - l) / ((float)i1 - 1.0F));
|
||||
d2 = d2 * (1.0D - d7) + -30.0D * d7;
|
||||
}
|
||||
|
||||
this.densities[i] = d2;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
296
java/src/game/worldgen/GeneratorPerlin.java
Executable file
296
java/src/game/worldgen/GeneratorPerlin.java
Executable file
|
@ -0,0 +1,296 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.biome.Biome;
|
||||
import game.dimension.Dimension;
|
||||
import game.rng.NoiseGen;
|
||||
import game.rng.OctaveGen;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorPerlin implements ChunkGenerator
|
||||
{
|
||||
private static final float[] PARABOLIC = new float[25];
|
||||
|
||||
static {
|
||||
for (int x = -2; x <= 2; ++x)
|
||||
{
|
||||
for (int z = -2; z <= 2; ++z)
|
||||
{
|
||||
float v = 10.0F / ExtMath.sqrtf((float)(x * x + z * z) + 0.2F);
|
||||
PARABOLIC[x + 2 + (z + 2) * 5] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final NoiseGen lowerNoiseGen;
|
||||
private final NoiseGen upperNoiseGen;
|
||||
private final NoiseGen mainNoiseGen;
|
||||
private final NoiseGen depthNoiseGen;
|
||||
private final State block;
|
||||
private final State liquid;
|
||||
private final float coordinateScale;
|
||||
private final float heightScale;
|
||||
private final float upperLimitScale;
|
||||
private final float lowerLimitScale;
|
||||
private final float depthNoiseScaleX;
|
||||
private final float depthNoiseScaleZ;
|
||||
private final float amplification;
|
||||
private final float mainNoiseScaleX;
|
||||
private final float mainNoiseScaleY;
|
||||
private final float mainNoiseScaleZ;
|
||||
private final float baseSize;
|
||||
private final float stretchY;
|
||||
private final float biomeDepthWeight;
|
||||
private final float biomeDepthOffset;
|
||||
private final float biomeScaleWeight;
|
||||
private final float biomeScaleOffset;
|
||||
private final double[] noiseTable = new double[825];
|
||||
private final double[] mainNoise = new double[825];
|
||||
private final double[] lowerNoise = new double[825];
|
||||
private final double[] upperNoise = new double[825];
|
||||
private final double[] depthNoise = new double[25];
|
||||
private final Biome[] biomes = new Biome[100];
|
||||
|
||||
// public GeneratorNew(Random rand, GeneratorSettings settings)
|
||||
// {
|
||||
// this(rand, settings.farlands, settings.seaLevel, Blocks.stone.getDefaultState(),
|
||||
// settings.useLavaSeas ? Blocks.lava.getDefaultState() : Blocks.water.getDefaultState(),
|
||||
// settings.coordinateScale, settings.heightScale, settings.upperLimitScale, settings.lowerLimitScale,
|
||||
// settings.depthNoiseScaleX, settings.depthNoiseScaleZ, settings.amplification, settings.mainNoiseScaleX,
|
||||
// settings.mainNoiseScaleY, settings.mainNoiseScaleZ, settings.baseSize, settings.stretchY, settings.biomeDepthWeight,
|
||||
// settings.biomeDepthOffset, settings.biomeScaleWeight, settings.biomeScaleOffset);
|
||||
// }
|
||||
|
||||
public GeneratorPerlin(Random rand, State block, State liquid, Dimension.GeneratorSettings settings) {
|
||||
this(rand, /* dim.hasFarLands(), dim.getSeaLevel(), */ block, liquid,
|
||||
settings.coordinateScale, settings.heightScale, settings.upperLimitScale, settings.lowerLimitScale,
|
||||
settings.depthNoiseScaleX, settings.depthNoiseScaleZ, settings.amplification, settings.mainNoiseScaleX,
|
||||
settings.mainNoiseScaleY, settings.mainNoiseScaleZ, settings.baseSize, settings.stretchY, settings.biomeDepthWeight,
|
||||
settings.biomeDepthOffset, settings.biomeScaleWeight, settings.biomeScaleOffset);
|
||||
// 684.412F, 684.412F, 512.0F, 512.0F, 200.0F, 200.0F, 0.0F, 80.0F, 160.0F, 80.0F, 8.5F, 12.0F, 1.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
private GeneratorPerlin(Random rand, /* boolean farlands, int seaLevel, */ State block, State liquid,
|
||||
float coordinateScale, float heightScale, float upperLimitScale, float lowerLimitScale, float depthNoiseScaleX,
|
||||
float depthNoiseScaleZ, float amplification, float mainNoiseScaleX, float mainNoiseScaleY, float mainNoiseScaleZ,
|
||||
float baseSize, float stretchY, float biomeDepthWeight, float biomeDepthOffset, float biomeScaleWeight, float biomeScaleOffset)
|
||||
{
|
||||
this.lowerNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
|
||||
this.upperNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
|
||||
this.mainNoiseGen = /* farlands ? new OctaveGenOld(rand, 8) : */ new OctaveGen(rand, 8);
|
||||
this.depthNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
|
||||
this.liquid = liquid;
|
||||
this.block = block;
|
||||
this.coordinateScale = coordinateScale;
|
||||
this.heightScale = heightScale;
|
||||
this.upperLimitScale = upperLimitScale;
|
||||
this.lowerLimitScale = lowerLimitScale;
|
||||
this.depthNoiseScaleX = depthNoiseScaleX;
|
||||
this.depthNoiseScaleZ = depthNoiseScaleZ;
|
||||
this.amplification = amplification;
|
||||
this.mainNoiseScaleX = mainNoiseScaleX;
|
||||
this.mainNoiseScaleY = mainNoiseScaleY;
|
||||
this.mainNoiseScaleZ = mainNoiseScaleZ;
|
||||
this.baseSize = baseSize;
|
||||
this.stretchY = stretchY;
|
||||
this.biomeDepthWeight = biomeDepthWeight;
|
||||
this.biomeDepthOffset = biomeDepthOffset;
|
||||
this.biomeScaleWeight = biomeScaleWeight;
|
||||
this.biomeScaleOffset = biomeScaleOffset;
|
||||
}
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return 256;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
int sea = world.getSeaLevel();
|
||||
world.getBiomeGenerator().getGenBiomes(this.biomes, x * 4 - 2, z * 4 - 2, 10, 10);
|
||||
this.genNoisemap(x * 4, 0, z * 4);
|
||||
|
||||
for (int xb = 0; xb < 4; ++xb)
|
||||
{
|
||||
int x1 = xb * 5;
|
||||
int x2 = (xb + 1) * 5;
|
||||
|
||||
for (int zb = 0; zb < 4; ++zb)
|
||||
{
|
||||
int xz1 = (x1 + zb) * 33;
|
||||
int xz2 = (x1 + zb + 1) * 33;
|
||||
int xz3 = (x2 + zb) * 33;
|
||||
int xz4 = (x2 + zb + 1) * 33;
|
||||
|
||||
for (int yb = 0; yb < 32; ++yb)
|
||||
{
|
||||
double mul1 = 0.125D;
|
||||
double m1 = this.noiseTable[xz1 + yb];
|
||||
double m2 = this.noiseTable[xz2 + yb];
|
||||
double m3 = this.noiseTable[xz3 + yb];
|
||||
double m4 = this.noiseTable[xz4 + yb];
|
||||
double n1 = (this.noiseTable[xz1 + yb + 1] - m1) * mul1;
|
||||
double n2 = (this.noiseTable[xz2 + yb + 1] - m2) * mul1;
|
||||
double n3 = (this.noiseTable[xz3 + yb + 1] - m3) * mul1;
|
||||
double n4 = (this.noiseTable[xz4 + yb + 1] - m4) * mul1;
|
||||
|
||||
for (int ys = 0; ys < 8; ++ys)
|
||||
{
|
||||
double mul2 = 0.25D;
|
||||
double o1 = m1;
|
||||
double o2 = m2;
|
||||
double o3 = (m3 - m1) * mul2;
|
||||
double o4 = (m4 - m2) * mul2;
|
||||
|
||||
for (int xs = 0; xs < 4; ++xs)
|
||||
{
|
||||
double mul3 = 0.25D;
|
||||
double step = (o2 - o1) * mul3;
|
||||
double val = o1 - step;
|
||||
|
||||
for (int zs = 0; zs < 4; ++zs)
|
||||
{
|
||||
if ((val += step) > 0.0D)
|
||||
{
|
||||
primer.set(xb * 4 + xs, yb * 8 + ys, zb * 4 + zs, this.block);
|
||||
}
|
||||
else if (yb * 8 + ys < sea)
|
||||
{
|
||||
primer.set(xb * 4 + xs, yb * 8 + ys, zb * 4 + zs, this.liquid);
|
||||
}
|
||||
}
|
||||
|
||||
o1 += o3;
|
||||
o2 += o4;
|
||||
}
|
||||
|
||||
m1 += n1;
|
||||
m2 += n2;
|
||||
m3 += n3;
|
||||
m4 += n4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void genNoisemap(int x, int y, int z)
|
||||
{
|
||||
this.depthNoiseGen.generate(this.depthNoise, x, z, 5, 5, (double)this.depthNoiseScaleX, (double)this.depthNoiseScaleZ, 0.5);
|
||||
float scale = this.coordinateScale;
|
||||
float height = this.heightScale;
|
||||
this.mainNoiseGen.generate(this.mainNoise, x, y, z, 5, 33, 5, (double)(scale / this.mainNoiseScaleX), (double)(height / this.mainNoiseScaleY), (double)(scale / this.mainNoiseScaleZ));
|
||||
this.lowerNoiseGen.generate(this.lowerNoise, x, y, z, 5, 33, 5, (double)scale, (double)height, (double)scale);
|
||||
this.upperNoiseGen.generate(this.upperNoise, x, y, z, 5, 33, 5, (double)scale, (double)height, (double)scale);
|
||||
z = 0;
|
||||
x = 0;
|
||||
int pos = 0;
|
||||
int dpos = 0;
|
||||
|
||||
for (int u = 0; u < 5; ++u)
|
||||
{
|
||||
for (int v = 0; v < 5; ++v)
|
||||
{
|
||||
float max = 0.0F;
|
||||
float min = 0.0F;
|
||||
float sum = 0.0F;
|
||||
int range = 2;
|
||||
Biome biome = this.biomes[u + 2 + (v + 2) * 10];
|
||||
|
||||
for (int a = -range; a <= range; ++a)
|
||||
{
|
||||
for (int b = -range; b <= range; ++b)
|
||||
{
|
||||
Biome biome2 = this.biomes[u + a + 2 + (v + b + 2) * 10];
|
||||
float bmin = this.biomeDepthOffset + biome2.minHeight * this.biomeDepthWeight;
|
||||
float bmax = this.biomeScaleOffset + biome2.maxHeight * this.biomeScaleWeight;
|
||||
|
||||
if (this.amplification > 0.0F && bmin > 0.0F)
|
||||
{
|
||||
bmin = 1.0F + bmin * this.amplification;
|
||||
bmax = 1.0F + bmax * this.amplification * 2.0F;
|
||||
}
|
||||
|
||||
float fact = PARABOLIC[a + 2 + (b + 2) * 5] / (bmin + 2.0F);
|
||||
|
||||
if (biome2.minHeight > biome.minHeight)
|
||||
{
|
||||
fact /= 2.0F;
|
||||
}
|
||||
|
||||
max += bmax * fact;
|
||||
min += bmin * fact;
|
||||
sum += fact;
|
||||
}
|
||||
}
|
||||
|
||||
max = max / sum;
|
||||
min = min / sum;
|
||||
max = max * 0.9F + 0.1F;
|
||||
min = (min * 4.0F - 1.0F) / 8.0F;
|
||||
double depth = this.depthNoise[dpos] / 8000.0D;
|
||||
|
||||
if (depth < 0.0D)
|
||||
{
|
||||
depth = -depth * 0.3D;
|
||||
}
|
||||
|
||||
depth = depth * 3.0D - 2.0D;
|
||||
|
||||
if (depth < 0.0D)
|
||||
{
|
||||
depth = depth / 2.0D;
|
||||
|
||||
if (depth < -1.0D)
|
||||
{
|
||||
depth = -1.0D;
|
||||
}
|
||||
|
||||
depth = depth / 1.4D;
|
||||
depth = depth / 2.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (depth > 1.0D)
|
||||
{
|
||||
depth = 1.0D;
|
||||
}
|
||||
|
||||
depth = depth / 8.0D;
|
||||
}
|
||||
|
||||
++dpos;
|
||||
double low = (double)min;
|
||||
double high = (double)max;
|
||||
low = low + depth * 0.2D;
|
||||
low = low * (double)this.baseSize / 8.0D;
|
||||
double shift = (double)this.baseSize + low * 4.0D;
|
||||
|
||||
for (int w = 0; w < 33; ++w)
|
||||
{
|
||||
double damp = ((double)w - shift) * (double)this.stretchY * 128.0D / 256.0D / high;
|
||||
|
||||
if (damp < 0.0D)
|
||||
{
|
||||
damp *= 4.0D;
|
||||
}
|
||||
|
||||
double lower = this.lowerNoise[pos] / (double)this.lowerLimitScale;
|
||||
double upper = this.upperNoise[pos] / (double)this.upperLimitScale;
|
||||
double base = (this.mainNoise[pos] / 10.0D + 1.0D) / 2.0D;
|
||||
double noise = (base < 0.0D ? lower : (base > 1.0D ? upper : lower + (upper - lower) * base)) - damp;
|
||||
|
||||
if (w > 29)
|
||||
{
|
||||
double attn = (double)((float)(w - 29) / 3.0F);
|
||||
noise = noise * (1.0D - attn) + -10.0D * attn;
|
||||
}
|
||||
|
||||
this.noiseTable[pos] = noise;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
235
java/src/game/worldgen/GeneratorSimple.java
Executable file
235
java/src/game/worldgen/GeneratorSimple.java
Executable file
|
@ -0,0 +1,235 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.rng.NoiseGen;
|
||||
import game.rng.OctaveGen;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class GeneratorSimple implements ChunkGenerator
|
||||
{
|
||||
private final BiomeGenPerlin biomeGen;
|
||||
private final NoiseGen lowerNoiseGen;
|
||||
private final NoiseGen upperNoiseGen;
|
||||
private final NoiseGen mainNoiseGen;
|
||||
private final NoiseGen biomeNoiseGen;
|
||||
private final NoiseGen depthNoiseGen;
|
||||
|
||||
private final State filler;
|
||||
private final State liquid;
|
||||
private final double noiseTable[] = new double[425];
|
||||
private final double mainNoise[] = new double[425];
|
||||
private final double lowerNoise[] = new double[425];
|
||||
private final double upperNoise[] = new double[425];
|
||||
private final double biomeNoise[] = new double[25];
|
||||
private final double depthNoise[] = new double[25];
|
||||
private final double[] factors = new double[256];
|
||||
|
||||
// public GeneratorSimple(long seed, Random rand, GeneratorSettings settings)
|
||||
// {
|
||||
// this(rand, settings.farlands, Blocks.stone.getDefaultState(),
|
||||
// settings.useLavaSeas ? Blocks.lava.getDefaultState() : Blocks.water.getDefaultState(),
|
||||
// settings.biomeMode == 2 ? new BiomeGenPerlin(seed) : null);
|
||||
// }
|
||||
|
||||
// public GeneratorSimple(Dimension dim, Random rand)
|
||||
// {
|
||||
// this(rand, /* dim.hasFarLands(), */ dim.getFiller(), dim.getLiquid(),
|
||||
// dim.hasBiomes() ? null : new BiomeGenPerlin(rand.longv()));
|
||||
// }
|
||||
|
||||
public GeneratorSimple(Random rand, /* boolean farlands, */ State filler, State liquid, BiomeGenPerlin biomeGen)
|
||||
{
|
||||
this.lowerNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
|
||||
this.upperNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
|
||||
this.mainNoiseGen = /* farlands ? new OctaveGenOld(rand, 8) : */ new OctaveGen(rand, 8);
|
||||
this.biomeNoiseGen = /* farlands ? new OctaveGenOld(rand, 10) : */ new OctaveGen(rand, 10);
|
||||
this.depthNoiseGen = /* farlands ? new OctaveGenOld(rand, 16) : */ new OctaveGen(rand, 16);
|
||||
this.filler = filler;
|
||||
this.liquid = liquid;
|
||||
this.biomeGen = biomeGen;
|
||||
}
|
||||
|
||||
public int getMaximumHeight() {
|
||||
return 128;
|
||||
}
|
||||
|
||||
public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer)
|
||||
{
|
||||
if(this.biomeGen == null)
|
||||
world.getBiomeGenerator().genFactors(this.factors, x * 16, z * 16, 16, 16);
|
||||
else
|
||||
this.biomeGen.generate(this.factors, x, z);
|
||||
byte range = 4;
|
||||
int sea = world.getSeaLevel();
|
||||
int xr = range + 1;
|
||||
byte yr = 17;
|
||||
int zr = range + 1;
|
||||
this.genNoisemap(x * range, 0, z * range);
|
||||
for(int xb = 0; xb < range; xb++)
|
||||
{
|
||||
for(int zb = 0; zb < range; zb++)
|
||||
{
|
||||
for(int yb = 0; yb < 16; yb++)
|
||||
{
|
||||
double mul1 = 0.125D;
|
||||
double d1 = this.noiseTable[((xb + 0) * zr + (zb + 0)) * yr + (yb + 0)];
|
||||
double d2 = this.noiseTable[((xb + 0) * zr + (zb + 1)) * yr + (yb + 0)];
|
||||
double d3 = this.noiseTable[((xb + 1) * zr + (zb + 0)) * yr + (yb + 0)];
|
||||
double d4 = this.noiseTable[((xb + 1) * zr + (zb + 1)) * yr + (yb + 0)];
|
||||
double d5 = (this.noiseTable[((xb + 0) * zr + (zb + 0)) * yr + (yb + 1)] - d1) * mul1;
|
||||
double d6 = (this.noiseTable[((xb + 0) * zr + (zb + 1)) * yr + (yb + 1)] - d2) * mul1;
|
||||
double d7 = (this.noiseTable[((xb + 1) * zr + (zb + 0)) * yr + (yb + 1)] - d3) * mul1;
|
||||
double d8 = (this.noiseTable[((xb + 1) * zr + (zb + 1)) * yr + (yb + 1)] - d4) * mul1;
|
||||
for(int ys = 0; ys < 8; ys++)
|
||||
{
|
||||
double mul2 = 0.25D;
|
||||
double n1 = d1;
|
||||
double n2 = d2;
|
||||
double n3 = (d3 - d1) * mul2;
|
||||
double n4 = (d4 - d2) * mul2;
|
||||
for(int xs = 0; xs < 4; xs++)
|
||||
{
|
||||
// int off = xs + xb * 4 << 11 | 0 + zb * 4 << 7 | yb * 8 + ys;
|
||||
// char zo = '\200';
|
||||
double mul3 = 0.25D;
|
||||
double val = n1;
|
||||
double step = (n2 - n1) * mul3;
|
||||
for(int zs = 0; zs < 4; zs++)
|
||||
{
|
||||
if(val > 0.0D)
|
||||
{
|
||||
primer.set(xs + xb * 4, ys + yb * 8, zs + zb * 4, this.filler);
|
||||
// primer.setBlockStateLegacy(off, this.filler);
|
||||
}
|
||||
else if(yb * 8 + ys < sea)
|
||||
{
|
||||
primer.set(xs + xb * 4, ys + yb * 8, zs + zb * 4, this.liquid);
|
||||
// primer.setBlockStateLegacy(off, this.liquid);
|
||||
}
|
||||
// off += zo;
|
||||
val += step;
|
||||
}
|
||||
|
||||
n1 += n3;
|
||||
n2 += n4;
|
||||
}
|
||||
|
||||
d1 += d5;
|
||||
d2 += d6;
|
||||
d3 += d7;
|
||||
d4 += d8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void genNoisemap(int x, int y, int z)
|
||||
{
|
||||
int xs = 5;
|
||||
int ys = 17;
|
||||
int zs = 5;
|
||||
double scale = 684.41200000000003D;
|
||||
double height = 684.41200000000003D;
|
||||
// double temps[] = this.biomeGen.temperature;
|
||||
// double rains[] = this.biomeGen.humidity;
|
||||
this.biomeNoiseGen.generate(this.biomeNoise, x, z, xs, zs, 1.121D, 1.121D, 0.5D);
|
||||
this.depthNoiseGen.generate(this.depthNoise, x, z, xs, zs, 200D, 200D, 0.5D);
|
||||
this.mainNoiseGen.generate(this.mainNoise, x, y, z, xs, ys, zs, scale / 80D, height / 160D, scale / 80D);
|
||||
this.lowerNoiseGen.generate(this.lowerNoise, x, y, z, xs, ys, zs, scale, height, scale);
|
||||
this.upperNoiseGen.generate(this.upperNoise, x, y, z, xs, ys, zs, scale, height, scale);
|
||||
int pos = 0;
|
||||
int dpos = 0;
|
||||
int ps = 16 / xs;
|
||||
for(int u = 0; u < xs; u++)
|
||||
{
|
||||
int px = u * ps + ps / 2;
|
||||
for(int v = 0; v < zs; v++)
|
||||
{
|
||||
int pz = v * ps + ps / 2;
|
||||
// double temp = temps[px * 16 + pz];
|
||||
// double rain = rains[px * 16 + pz] * temp;
|
||||
double fact = 1.0D - this.factors[pz * 16 + px];
|
||||
fact *= fact;
|
||||
fact *= fact;
|
||||
fact = 1.0D - fact;
|
||||
double high = (this.biomeNoise[dpos] + 256D) / 512D;
|
||||
high *= fact;
|
||||
if(high > 1.0D)
|
||||
{
|
||||
high = 1.0D;
|
||||
}
|
||||
double depth = this.depthNoise[dpos] / 8000D;
|
||||
if(depth < 0.0D)
|
||||
{
|
||||
depth = -depth * 0.29999999999999999D;
|
||||
}
|
||||
depth = depth * 3D - 2D;
|
||||
if(depth < 0.0D)
|
||||
{
|
||||
depth /= 2D;
|
||||
if(depth < -1D)
|
||||
{
|
||||
depth = -1D;
|
||||
}
|
||||
depth /= 1.3999999999999999D;
|
||||
depth /= 2D;
|
||||
high = 0.0D;
|
||||
} else
|
||||
{
|
||||
if(depth > 1.0D)
|
||||
{
|
||||
depth = 1.0D;
|
||||
}
|
||||
depth /= 8D;
|
||||
}
|
||||
if(high < 0.0D)
|
||||
{
|
||||
high = 0.0D;
|
||||
}
|
||||
high += 0.5D;
|
||||
depth = (depth * (double)ys) / 16D;
|
||||
double shift = (double)ys / 2D + depth * 4D;
|
||||
dpos++;
|
||||
for(int w = 0; w < ys; w++)
|
||||
{
|
||||
double noise = 0.0D;
|
||||
double damp = (((double)w - shift) * 12D) / high;
|
||||
if(damp < 0.0D)
|
||||
{
|
||||
damp *= 4D;
|
||||
}
|
||||
double lower = this.lowerNoise[pos] / 512D;
|
||||
double upper = this.upperNoise[pos] / 512D;
|
||||
double base = (this.mainNoise[pos] / 10D + 1.0D) / 2D;
|
||||
if(base < 0.0D)
|
||||
{
|
||||
noise = lower;
|
||||
} else
|
||||
if(base > 1.0D)
|
||||
{
|
||||
noise = upper;
|
||||
} else
|
||||
{
|
||||
noise = lower + (upper - lower) * base;
|
||||
}
|
||||
noise -= damp;
|
||||
if(w > ys - 4)
|
||||
{
|
||||
double d13 = (float)(w - (ys - 4)) / 3F;
|
||||
noise = noise * (1.0D - d13) + -10D * d13;
|
||||
}
|
||||
this.noiseTable[pos] = noise;
|
||||
pos++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
102
java/src/game/worldgen/LootConstants.java
Executable file
102
java/src/game/worldgen/LootConstants.java
Executable file
|
@ -0,0 +1,102 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.color.DyeColor;
|
||||
import game.entity.npc.EntityDarkMage;
|
||||
import game.entity.npc.EntityMage;
|
||||
import game.entity.npc.EntityMagma;
|
||||
import game.entity.npc.EntityTiefling;
|
||||
import game.entity.npc.EntityUndead;
|
||||
import game.entity.projectile.RngFishable;
|
||||
import game.init.Blocks;
|
||||
import game.init.ItemRegistry;
|
||||
import game.init.Items;
|
||||
import game.item.ItemFishFood;
|
||||
import game.item.ItemStack;
|
||||
import game.item.RngLoot;
|
||||
import game.rng.WeightedList;
|
||||
|
||||
public abstract class LootConstants {
|
||||
public static final WeightedList<RngFishable> FISHING_JUNK = new WeightedList<RngFishable>(
|
||||
(new RngFishable(new ItemStack(Items.leather_boots), 10)).setMaxDamagePercent(0.9F), new RngFishable(new ItemStack(Items.leather), 10),
|
||||
new RngFishable(new ItemStack(Items.bone), 10), new RngFishable(new ItemStack(Items.potion), 10),
|
||||
new RngFishable(new ItemStack(Items.string), 5), (new RngFishable(new ItemStack(Items.fishing_rod), 2)).setMaxDamagePercent(0.9F),
|
||||
new RngFishable(new ItemStack(Items.bowl), 10), new RngFishable(new ItemStack(Items.stick), 5),
|
||||
new RngFishable(new ItemStack(Items.dye, 10, DyeColor.BLACK.getDyeDamage()), 1),
|
||||
new RngFishable(new ItemStack(Blocks.tripwire_hook), 10), new RngFishable(new ItemStack(Items.rotten_flesh), 10));
|
||||
public static final WeightedList<RngFishable> FISHING_TREASURE = new WeightedList<RngFishable>(
|
||||
new RngFishable(new ItemStack(Blocks.waterlily), 1), new RngFishable(new ItemStack(Items.name_tag), 1),
|
||||
new RngFishable(new ItemStack(Items.saddle), 1),
|
||||
(new RngFishable(new ItemStack(Items.bow), 1)).setMaxDamagePercent(0.25F).setEnchantable(),
|
||||
(new RngFishable(new ItemStack(Items.fishing_rod), 1)).setMaxDamagePercent(0.25F).setEnchantable(),
|
||||
(new RngFishable(new ItemStack(Items.book), 1)).setEnchantable());
|
||||
public static final WeightedList<RngFishable> FISH_TYPES = new WeightedList<RngFishable>(
|
||||
new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.COD.getMetadata()), 60),
|
||||
new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.SALMON.getMetadata()), 25),
|
||||
new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.CLOWNFISH.getMetadata()), 2),
|
||||
new RngFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.PUFFERFISH.getMetadata()), 13));
|
||||
public static final WeightedList<RngLoot> VILLAGE_BLACKSMITH = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3),
|
||||
new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.bread, 0, 1, 3, 15),
|
||||
new RngLoot(Items.apple, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 5), new RngLoot(Items.iron_sword, 0, 1, 1, 5),
|
||||
new RngLoot(Items.iron_chestplate, 0, 1, 1, 5), new RngLoot(Items.iron_helmet, 0, 1, 1, 5), new RngLoot(Items.iron_leggings, 0, 1, 1, 5),
|
||||
new RngLoot(Items.iron_boots, 0, 1, 1, 5), new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 0, 3, 7, 5),
|
||||
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_sapling), 0, 3, 7, 5), new RngLoot(Items.saddle, 0, 1, 1, 3),
|
||||
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1),
|
||||
new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> STRONGHOLD_CHEST = new WeightedList(new RngLoot(Items.orb, 0, 1, 1, 10),
|
||||
new RngLoot(Items.diamond, 0, 1, 3, 3), new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 1, 3, 5),
|
||||
new RngLoot(Items.redstone, 0, 4, 9, 5), new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.apple, 0, 1, 3, 15),
|
||||
new RngLoot(Items.iron_pickaxe, 0, 1, 1, 5), new RngLoot(Items.iron_sword, 0, 1, 1, 5), new RngLoot(Items.iron_chestplate, 0, 1, 1, 5),
|
||||
new RngLoot(Items.iron_helmet, 0, 1, 1, 5), new RngLoot(Items.iron_leggings, 0, 1, 1, 5), new RngLoot(Items.iron_boots, 0, 1, 1, 5),
|
||||
new RngLoot(Items.golden_apple, 0, 1, 1, 1), new RngLoot(Items.saddle, 0, 1, 1, 1), new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1),
|
||||
new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> STRONGHOLD_LIBRARY = new WeightedList(new RngLoot(Items.book, 0, 1, 3, 20),
|
||||
new RngLoot(Items.paper, 0, 2, 7, 20), new RngLoot(Items.string, 0, 1, 1, 1), new RngLoot(Items.navigator, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> STRONGHOLD_CROSS = new WeightedList(new RngLoot(Items.iron_ingot, 0, 1, 5, 10),
|
||||
new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.redstone, 0, 4, 9, 5), new RngLoot(Items.coal, 0, 3, 8, 10),
|
||||
new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.apple, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> DESERT_PYRAMID = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3),
|
||||
new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 2, 7, 15), new RngLoot(Items.emerald, 0, 1, 3, 2),
|
||||
new RngLoot(Items.bone, 0, 4, 6, 20), new RngLoot(Items.rotten_flesh, 0, 3, 7, 16), new RngLoot(Items.saddle, 0, 1, 1, 3),
|
||||
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1),
|
||||
new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> JUNGLE_MAIN = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 3),
|
||||
new RngLoot(Items.iron_ingot, 0, 1, 5, 10), new RngLoot(Items.gold_ingot, 0, 2, 7, 15), new RngLoot(Items.emerald, 0, 1, 3, 2),
|
||||
new RngLoot(Items.bone, 0, 4, 6, 20), new RngLoot(Items.rotten_flesh, 0, 3, 7, 16), new RngLoot(Items.saddle, 0, 1, 1, 3),
|
||||
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 1),
|
||||
new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> JUNGLE_TRAP = new WeightedList(new RngLoot(Items.arrow, 0, 2, 7, 30));
|
||||
public static final WeightedList<RngLoot> MINESHAFT_CHEST = new WeightedList(new RngLoot(Items.iron_ingot, 0, 1, 5, 10),
|
||||
new RngLoot(Items.gold_ingot, 0, 1, 3, 5), new RngLoot(Items.redstone, 0, 4, 9, 5),
|
||||
new RngLoot(Items.dye, DyeColor.BLUE.getDyeDamage(), 4, 9, 5), new RngLoot(Items.diamond, 0, 1, 2, 3),
|
||||
new RngLoot(Items.coal, 0, 3, 8, 10), new RngLoot(Items.bread, 0, 1, 3, 15), new RngLoot(Items.iron_pickaxe, 0, 1, 1, 1),
|
||||
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.rail), 0, 4, 8, 1), new RngLoot(Items.melon_stem, 0, 2, 4, 10),
|
||||
new RngLoot(Items.pumpkin_stem, 0, 2, 4, 10), new RngLoot(Items.saddle, 0, 1, 1, 3), new RngLoot(Items.iron_horse_armor, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> HELL_FORTRESS = new WeightedList(new RngLoot(Items.diamond, 0, 1, 3, 5),
|
||||
new RngLoot(Items.iron_ingot, 0, 1, 5, 5), new RngLoot(Items.gold_ingot, 0, 1, 3, 15), new RngLoot(Items.gold_sword, 0, 1, 1, 5),
|
||||
new RngLoot(Items.gold_chestplate, 0, 1, 1, 5), new RngLoot(Items.flint_and_steel, 0, 1, 1, 5),
|
||||
new RngLoot(Items.soul_wart, 0, 3, 7, 5), new RngLoot(Items.saddle, 0, 1, 1, 10), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 8),
|
||||
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 5), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 3),
|
||||
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.obsidian), 0, 2, 4, 2));
|
||||
public static final WeightedList<RngLoot> DUNGEON_CHEST = new WeightedList(new RngLoot(Items.saddle, 0, 1, 1, 11),
|
||||
new RngLoot(Items.iron_ingot, 0, 1, 4, 11), new RngLoot(Items.bread, 0, 1, 1, 11), new RngLoot(Items.wheats, 0, 1, 4, 11),
|
||||
new RngLoot(Items.gunpowder, 0, 1, 4, 11), new RngLoot(Items.string, 0, 1, 4, 11), new RngLoot(Items.bucket, 0, 1, 1, 11),
|
||||
new RngLoot(Items.golden_apple, 0, 1, 1, 1), new RngLoot(Items.redstone, 0, 1, 4, 11), new RngLoot(Items.aluminium_ingot, 0, 1, 1, 5),
|
||||
new RngLoot(Items.copper_ingot, 0, 1, 1, 5), new RngLoot(Items.name_tag, 0, 1, 1, 11), new RngLoot(Items.gold_horse_armor, 0, 1, 1, 3),
|
||||
new RngLoot(Items.iron_horse_armor, 0, 1, 1, 6), new RngLoot(Items.diamond_horse_armor, 0, 1, 1, 2),
|
||||
new RngLoot(Items.record_13, 0, 1, 1, 1), new RngLoot(Items.record_cat, 0, 1, 1, 1), new RngLoot(Items.record_blocks, 0, 1, 1, 1),
|
||||
new RngLoot(Items.record_chirp, 0, 1, 1, 1), new RngLoot(Items.record_far, 0, 1, 1, 1), new RngLoot(Items.record_mall, 0, 1, 1, 1),
|
||||
new RngLoot(Items.record_mellohi, 0, 1, 1, 1), new RngLoot(Items.record_stal, 0, 1, 1, 1), new RngLoot(Items.record_strad, 0, 1, 1, 1),
|
||||
new RngLoot(Items.record_ward, 0, 1, 1, 1), new RngLoot(Items.record_11, 0, 1, 1, 1), new RngLoot(Items.record_wait, 0, 1, 1, 1),
|
||||
new RngLoot(Items.record_delay, 0, 1, 1, 1), new RngLoot(Items.record_extend, 0, 1, 1, 1));
|
||||
public static final WeightedList<RngLoot> ABANDONED_ITEMS = new WeightedList(new RngLoot(Items.stick, 0, 1, 3, 10),
|
||||
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_planks), 0, 1, 3, 10),
|
||||
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.oak_log), 0, 1, 3, 10), new RngLoot(Items.stone_axe, 0, 1, 1, 3),
|
||||
new RngLoot(Items.wood_axe, 0, 1, 1, 5), new RngLoot(Items.stone_pickaxe, 0, 1, 1, 3), new RngLoot(Items.wood_pickaxe, 0, 1, 1, 5),
|
||||
new RngLoot(Items.apple, 0, 2, 3, 5), new RngLoot(Items.bread, 0, 2, 3, 3),
|
||||
new RngLoot(ItemRegistry.getItemFromBlock(Blocks.acacia_log), 0, 1, 3, 10));
|
||||
public static final WeightedList<Biome.RngSpawn> MAGEHUT_MOBS = new WeightedList<Biome.RngSpawn>(new Biome.RngSpawn(EntityMage.class, 1, 1, 1));
|
||||
public static final WeightedList<Biome.RngSpawn> FORTRESS_MOBS = new WeightedList<Biome.RngSpawn>(new Biome.RngSpawn(EntityDarkMage.class, 10, 2, 3),
|
||||
new Biome.RngSpawn(EntityTiefling.class, 5, 4, 4), new Biome.RngSpawn(EntityUndead.class, 10, 4, 4),
|
||||
new Biome.RngSpawn(EntityMagma.class, 3, 4, 4));
|
||||
}
|
130
java/src/game/worldgen/ReplacerAltBiome.java
Executable file
130
java/src/game/worldgen/ReplacerAltBiome.java
Executable file
|
@ -0,0 +1,130 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.NoiseGen;
|
||||
import game.rng.OctaveGen;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class ReplacerAltBiome implements BlockReplacer
|
||||
{
|
||||
private final NoiseGen altNoiseGen;
|
||||
private final NoiseGen exclNoiseGen;
|
||||
|
||||
private final State filler;
|
||||
private final State liquid;
|
||||
private final State alt1;
|
||||
private final State alt2;
|
||||
private final Block block;
|
||||
private final double alt2Noise[] = new double[256];
|
||||
private final double alt1Noise[] = new double[256];
|
||||
private final double exclNoise[] = new double[256];
|
||||
|
||||
// public ReplacerAltBiome(Random rand, GeneratorSettings settings)
|
||||
// {
|
||||
// this(rand, settings.farlands, Blocks.stone.getDefaultState(),
|
||||
// settings.useLavaSeas ? Blocks.lava.getDefaultState() : Blocks.water.getDefaultState(),
|
||||
// Blocks.sand.getDefaultState(), Blocks.gravel.getDefaultState());
|
||||
// }
|
||||
|
||||
// public ReplacerAltBiome(Dimension dim, Random rand)
|
||||
// {
|
||||
// this(rand, /* dim.hasFarLands(), */ dim.getFiller(), dim.getLiquid(), dim.getAltFiller2(), dim.getAltFiller1());
|
||||
// }
|
||||
|
||||
public ReplacerAltBiome(Random rand, /* boolean farlands, */ State filler, State liquid, State alt1, State alt2)
|
||||
{
|
||||
this.altNoiseGen = /* farlands ? new OctaveGenOld(rand, 4) : */ new OctaveGen(rand, 4);
|
||||
this.exclNoiseGen = /* farlands ? new OctaveGenOld(rand, 4) : */ new OctaveGen(rand, 4);
|
||||
this.filler = filler;
|
||||
this.liquid = liquid;
|
||||
this.alt1 = alt1;
|
||||
this.alt2 = alt2;
|
||||
this.block = filler.getBlock();
|
||||
}
|
||||
|
||||
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes)
|
||||
{
|
||||
int seaLevel = world.getSeaLevel();
|
||||
double scale = 0.03125D;
|
||||
this.altNoiseGen.generate( this.alt2Noise , x * 16, 0 /*.0D */ , z * 16, 16, 1, 16, scale, 1.0D, scale);
|
||||
this.altNoiseGen.generate(this.alt1Noise, z * 16, 109 /*.0134D */, x * 16, 16, 1, 16, scale, 1.0D, scale);
|
||||
this.exclNoiseGen.generate( this.exclNoise , x * 16, 0 /*.0D */ , z * 16, 16, 1, 16, scale * 2D, scale * 2D, scale * 2D);
|
||||
for(int pz = 0; pz < 16; pz++)
|
||||
{
|
||||
for(int px = 0; px < 16; px++)
|
||||
{
|
||||
Biome biome = biomes[pz * 16 + px];
|
||||
boolean alt2 = this.alt2Noise[pz + px * 16] + rand.doublev() * 0.20000000000000001D > 0.0D;
|
||||
boolean alt1 = this.alt1Noise[px + pz * 16] + rand.doublev() * 0.20000000000000001D > 3D;
|
||||
int excl = (int)(this.exclNoise[pz + px * 16] / 3D + 3D + rand.doublev() * 0.25D);
|
||||
int rockHeight = -1;
|
||||
State topBlock = biome.topBlock;
|
||||
State fillerBlock = biome.fillerBlock;
|
||||
for(int py = primer.height - 1; py >= 0; py--)
|
||||
{
|
||||
Block currentBlock = primer.get(px, py, pz).getBlock();
|
||||
if(currentBlock == Blocks.air)
|
||||
{
|
||||
rockHeight = -1;
|
||||
continue;
|
||||
}
|
||||
if(currentBlock != this.block)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(rockHeight == -1)
|
||||
{
|
||||
if(excl <= 0)
|
||||
{
|
||||
topBlock = Blocks.air.getState();
|
||||
fillerBlock = this.filler;
|
||||
} else
|
||||
if(py >= seaLevel - 4 && py <= seaLevel + 1)
|
||||
{
|
||||
topBlock = biome.topBlock;
|
||||
fillerBlock = biome.fillerBlock;
|
||||
if(alt1)
|
||||
{
|
||||
topBlock = Blocks.air.getState();
|
||||
}
|
||||
if(alt1)
|
||||
{
|
||||
fillerBlock = this.alt2;
|
||||
}
|
||||
if(alt2)
|
||||
{
|
||||
topBlock = this.alt1;
|
||||
}
|
||||
if(alt2)
|
||||
{
|
||||
fillerBlock = this.alt1;
|
||||
}
|
||||
}
|
||||
if(py < seaLevel && topBlock.getBlock() == Blocks.air)
|
||||
{
|
||||
topBlock = this.liquid;
|
||||
}
|
||||
rockHeight = excl;
|
||||
if(py >= seaLevel - 1)
|
||||
{
|
||||
primer.set(px, py, pz, topBlock);
|
||||
} else
|
||||
{
|
||||
primer.set(px, py, pz, fillerBlock);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(rockHeight > 0)
|
||||
{
|
||||
rockHeight--;
|
||||
primer.set(px, py, pz, fillerBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
131
java/src/game/worldgen/ReplacerAltSurface.java
Executable file
131
java/src/game/worldgen/ReplacerAltSurface.java
Executable file
|
@ -0,0 +1,131 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.block.Block;
|
||||
import game.material.Material;
|
||||
import game.rng.OctaveGen;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class ReplacerAltSurface implements BlockReplacer
|
||||
{
|
||||
private final OctaveGen altNoiseGen;
|
||||
private final OctaveGen exclNoiseGen;
|
||||
|
||||
private final double[] alt2Noise = new double[256];
|
||||
private final double[] alt1Noise = new double[256];
|
||||
private final double[] exclNoise = new double[256];
|
||||
|
||||
private final State filler;
|
||||
private final State alt1;
|
||||
private final State alt2;
|
||||
private final State liquid;
|
||||
private final Block fillerBlock;
|
||||
|
||||
// public ReplacerAltSurface(Dimension dim, Random rand) {
|
||||
// this(rand, dim.getFiller(), dim.getAltFiller1(), dim.getAltFiller2(), dim.getLiquid());
|
||||
// }
|
||||
|
||||
public ReplacerAltSurface(Random rand, State filler, State alt1, State alt2, State liquid)
|
||||
{
|
||||
this.altNoiseGen = new OctaveGen(rand, 4);
|
||||
this.exclNoiseGen = new OctaveGen(rand, 4);
|
||||
this.filler = filler;
|
||||
this.alt1 = alt1;
|
||||
this.alt2 = alt2;
|
||||
this.liquid = liquid;
|
||||
this.fillerBlock = filler.getBlock();
|
||||
}
|
||||
|
||||
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes)
|
||||
{
|
||||
int i = world.getSeaLevel() + 1;
|
||||
double d0 = 0.03125D;
|
||||
this.altNoiseGen.generate(this.alt2Noise, x * 16, z * 16, 0, 16, 16, 1, d0, d0, 1.0D);
|
||||
this.altNoiseGen.generate(this.alt1Noise, x * 16, 109, z * 16, 16, 1, 16, d0, 1.0D, d0);
|
||||
this.exclNoiseGen.generate(this.exclNoise, x * 16, z * 16, 0, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D);
|
||||
|
||||
for (int j = 0; j < 16; ++j)
|
||||
{
|
||||
for (int k = 0; k < 16; ++k)
|
||||
{
|
||||
boolean flag = this.alt2Noise[j + k * 16] + rand.doublev() * 0.2D > 0.0D;
|
||||
boolean flag1 = this.alt1Noise[j + k * 16] + rand.doublev() * 0.2D > 0.0D;
|
||||
int l = (int)(this.exclNoise[j + k * 16] / 3.0D + 3.0D + rand.doublev() * 0.25D);
|
||||
int i1 = -1;
|
||||
State iblockstate = this.filler;
|
||||
State iblockstate1 = this.filler;
|
||||
|
||||
for (int j1 = primer.height - 1; j1 >= 0; --j1)
|
||||
{
|
||||
// if (j1 < (primer.height - 1) - rand.zrange(5) || this.ceiling == null)
|
||||
// {
|
||||
State iblockstate2 = primer.get(k, j1, j);
|
||||
|
||||
if (iblockstate2.getBlock() != null && iblockstate2.getBlock().getMaterial() != Material.air)
|
||||
{
|
||||
if (iblockstate2.getBlock() == this.fillerBlock)
|
||||
{
|
||||
if (i1 == -1)
|
||||
{
|
||||
if (l <= 0)
|
||||
{
|
||||
iblockstate = null;
|
||||
iblockstate1 = this.filler;
|
||||
}
|
||||
else if (j1 >= i - 4 && j1 <= i + 1)
|
||||
{
|
||||
iblockstate = this.filler;
|
||||
iblockstate1 = this.filler;
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
iblockstate = this.alt1;
|
||||
iblockstate1 = this.filler;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
iblockstate = this.alt2;
|
||||
iblockstate1 = this.alt2;
|
||||
}
|
||||
}
|
||||
|
||||
if (j1 < i && (iblockstate == null || iblockstate.getBlock().getMaterial() == Material.air))
|
||||
{
|
||||
iblockstate = this.liquid;
|
||||
}
|
||||
|
||||
i1 = l;
|
||||
|
||||
if (j1 >= i - 1)
|
||||
{
|
||||
primer.set(k, j1, j, iblockstate);
|
||||
}
|
||||
else
|
||||
{
|
||||
primer.set(k, j1, j, iblockstate1);
|
||||
}
|
||||
}
|
||||
else if (i1 > 0)
|
||||
{
|
||||
--i1;
|
||||
primer.set(k, j1, j, iblockstate1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i1 = -1;
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// primer.set(k, j1, j, this.ceiling);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
32
java/src/game/worldgen/ReplacerBiome.java
Executable file
32
java/src/game/worldgen/ReplacerBiome.java
Executable file
|
@ -0,0 +1,32 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.rng.PerlinGen;
|
||||
import game.rng.Random;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class ReplacerBiome implements BlockReplacer
|
||||
{
|
||||
private final PerlinGen stoneNoiseGen;
|
||||
private final double[] stoneNoise = new double[256];
|
||||
|
||||
public ReplacerBiome(Random rand)
|
||||
{
|
||||
this.stoneNoiseGen = new PerlinGen(rand, 4);
|
||||
}
|
||||
|
||||
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes)
|
||||
{
|
||||
double d0 = 0.03125D;
|
||||
this.stoneNoiseGen.generate(this.stoneNoise, (double)(x * 16), (double)(z * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D);
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
for (int j = 0; j < 16; ++j)
|
||||
{
|
||||
Biome biome = biomes[j + i * 16];
|
||||
biome.genTerrainBlocks(world, rand, primer, x * 16 + i, z * 16 + j, this.stoneNoise[j + i * 16]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
java/src/game/worldgen/ReplacerTopLayer.java
Executable file
75
java/src/game/worldgen/ReplacerTopLayer.java
Executable file
|
@ -0,0 +1,75 @@
|
|||
package game.worldgen;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class ReplacerTopLayer implements BlockReplacer
|
||||
{
|
||||
private final State filler;
|
||||
private final Block replace;
|
||||
|
||||
// public ReplacerTopLayer(Dimension dim) {
|
||||
// this(dim.getSurface(), dim.getFiller().getBlock());
|
||||
// }
|
||||
|
||||
public ReplacerTopLayer(State filler, Block replace) {
|
||||
this.filler = filler;
|
||||
this.replace = replace;
|
||||
}
|
||||
|
||||
public void replaceBlocks(WorldServer world, int x, int z, ChunkPrimer primer, Random rand, Biome[] biomes)
|
||||
{
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
for (int j = 0; j < 16; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
int l = -1;
|
||||
State iblockstate = this.filler;
|
||||
State iblockstate1 = this.filler;
|
||||
|
||||
for (int i1 = primer.height - 1; i1 >= 0; --i1)
|
||||
{
|
||||
State iblockstate2 = primer.get(i, i1, j);
|
||||
|
||||
if (iblockstate2.getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
l = -1;
|
||||
}
|
||||
else if (iblockstate2.getBlock() == this.replace)
|
||||
{
|
||||
if (l == -1)
|
||||
{
|
||||
if (k <= 0)
|
||||
{
|
||||
iblockstate = Blocks.air.getState();
|
||||
iblockstate1 = this.filler;
|
||||
}
|
||||
|
||||
l = k;
|
||||
|
||||
if (i1 >= 0)
|
||||
{
|
||||
primer.set(i, i1, j, iblockstate);
|
||||
}
|
||||
else
|
||||
{
|
||||
primer.set(i, i1, j, iblockstate1);
|
||||
}
|
||||
}
|
||||
else if (l > 0)
|
||||
{
|
||||
--l;
|
||||
primer.set(i, i1, j, iblockstate1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
java/src/game/worldgen/caves/MapGenBase.java
Executable file
44
java/src/game/worldgen/caves/MapGenBase.java
Executable file
|
@ -0,0 +1,44 @@
|
|||
package game.worldgen.caves;
|
||||
|
||||
import game.rng.Random;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.ChunkPrimer;
|
||||
|
||||
public class MapGenBase
|
||||
{
|
||||
/** The number of Chunks to gen-check in any given direction. */
|
||||
protected int range = 8;
|
||||
|
||||
/** The RNG used by the MapGen classes. */
|
||||
protected Random rand = new Random();
|
||||
|
||||
/** This world object. */
|
||||
protected WorldServer worldObj;
|
||||
|
||||
public void generate(WorldServer worldIn, int x, int z, ChunkPrimer chunkPrimerIn)
|
||||
{
|
||||
int i = this.range;
|
||||
this.worldObj = worldIn;
|
||||
this.rand.setSeed(worldIn.getSeed());
|
||||
long j = this.rand.longv();
|
||||
long k = this.rand.longv();
|
||||
|
||||
for (int l = x - i; l <= x + i; ++l)
|
||||
{
|
||||
for (int i1 = z - i; i1 <= z + i; ++i1)
|
||||
{
|
||||
long j1 = (long)l * j;
|
||||
long k1 = (long)i1 * k;
|
||||
this.rand.setSeed(j1 ^ k1 ^ worldIn.getSeed());
|
||||
this.recursiveGenerate(worldIn, l, i1, x, z, chunkPrimerIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively called by generate()
|
||||
*/
|
||||
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
|
||||
{
|
||||
}
|
||||
}
|
233
java/src/game/worldgen/caves/MapGenBigCaves.java
Executable file
233
java/src/game/worldgen/caves/MapGenBigCaves.java
Executable file
|
@ -0,0 +1,233 @@
|
|||
package game.worldgen.caves;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.ChunkPrimer;
|
||||
|
||||
public class MapGenBigCaves extends MapGenBase
|
||||
{
|
||||
private final Block replace;
|
||||
private final Block top;
|
||||
private final Block surface;
|
||||
|
||||
public MapGenBigCaves(Block replace, Block top, Block surface) {
|
||||
this.replace = replace;
|
||||
this.top = top;
|
||||
this.surface = surface;
|
||||
}
|
||||
|
||||
protected void func_180705_a(long p_180705_1_, int p_180705_3_, int p_180705_4_, ChunkPrimer p_180705_5_, double p_180705_6_, double p_180705_8_, double p_180705_10_)
|
||||
{
|
||||
this.func_180704_a(p_180705_1_, p_180705_3_, p_180705_4_, p_180705_5_, p_180705_6_, p_180705_8_, p_180705_10_, 1.0F + this.rand.floatv() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
|
||||
}
|
||||
|
||||
protected void func_180704_a(long p_180704_1_, int p_180704_3_, int p_180704_4_, ChunkPrimer p_180704_5_, double p_180704_6_, double p_180704_8_, double p_180704_10_, float p_180704_12_, float p_180704_13_, float p_180704_14_, int p_180704_15_, int p_180704_16_, double p_180704_17_)
|
||||
{
|
||||
double d0 = (double)(p_180704_3_ * 16 + 8);
|
||||
double d1 = (double)(p_180704_4_ * 16 + 8);
|
||||
float f = 0.0F;
|
||||
float f1 = 0.0F;
|
||||
Random random = new Random(p_180704_1_);
|
||||
|
||||
if (p_180704_16_ <= 0)
|
||||
{
|
||||
int i = this.range * 16 - 16;
|
||||
p_180704_16_ = i - random.zrange(i / 4);
|
||||
}
|
||||
|
||||
boolean flag1 = false;
|
||||
|
||||
if (p_180704_15_ == -1)
|
||||
{
|
||||
p_180704_15_ = p_180704_16_ / 2;
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
int j = random.zrange(p_180704_16_ / 2) + p_180704_16_ / 4;
|
||||
|
||||
for (boolean flag = random.zrange(6) == 0; p_180704_15_ < p_180704_16_; ++p_180704_15_)
|
||||
{
|
||||
double d2 = 1.5D + (double)(ExtMath.sin((float)p_180704_15_ * (float)Math.PI / (float)p_180704_16_) * p_180704_12_ * 1.0F);
|
||||
double d3 = d2 * p_180704_17_;
|
||||
float f2 = ExtMath.cos(p_180704_14_);
|
||||
float f3 = ExtMath.sin(p_180704_14_);
|
||||
p_180704_6_ += (double)(ExtMath.cos(p_180704_13_) * f2);
|
||||
p_180704_8_ += (double)f3;
|
||||
p_180704_10_ += (double)(ExtMath.sin(p_180704_13_) * f2);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
p_180704_14_ = p_180704_14_ * 0.92F;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_180704_14_ = p_180704_14_ * 0.7F;
|
||||
}
|
||||
|
||||
p_180704_14_ = p_180704_14_ + f1 * 0.1F;
|
||||
p_180704_13_ += f * 0.1F;
|
||||
f1 = f1 * 0.9F;
|
||||
f = f * 0.75F;
|
||||
f1 = f1 + (random.floatv() - random.floatv()) * random.floatv() * 2.0F;
|
||||
f = f + (random.floatv() - random.floatv()) * random.floatv() * 4.0F;
|
||||
|
||||
if (!flag1 && p_180704_15_ == j && p_180704_12_ > 1.0F)
|
||||
{
|
||||
this.func_180704_a(random.longv(), p_180704_3_, p_180704_4_, p_180704_5_, p_180704_6_, p_180704_8_, p_180704_10_, random.floatv() * 0.5F + 0.5F, p_180704_13_ - ((float)Math.PI / 2F), p_180704_14_ / 3.0F, p_180704_15_, p_180704_16_, 1.0D);
|
||||
this.func_180704_a(random.longv(), p_180704_3_, p_180704_4_, p_180704_5_, p_180704_6_, p_180704_8_, p_180704_10_, random.floatv() * 0.5F + 0.5F, p_180704_13_ + ((float)Math.PI / 2F), p_180704_14_ / 3.0F, p_180704_15_, p_180704_16_, 1.0D);
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag1 || random.zrange(4) != 0)
|
||||
{
|
||||
double d4 = p_180704_6_ - d0;
|
||||
double d5 = p_180704_10_ - d1;
|
||||
double d6 = (double)(p_180704_16_ - p_180704_15_);
|
||||
double d7 = (double)(p_180704_12_ + 2.0F + 16.0F);
|
||||
|
||||
if (d4 * d4 + d5 * d5 - d6 * d6 > d7 * d7)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_180704_6_ >= d0 - 16.0D - d2 * 2.0D && p_180704_10_ >= d1 - 16.0D - d2 * 2.0D && p_180704_6_ <= d0 + 16.0D + d2 * 2.0D && p_180704_10_ <= d1 + 16.0D + d2 * 2.0D)
|
||||
{
|
||||
int j2 = ExtMath.floord(p_180704_6_ - d2) - p_180704_3_ * 16 - 1;
|
||||
int k = ExtMath.floord(p_180704_6_ + d2) - p_180704_3_ * 16 + 1;
|
||||
int k2 = ExtMath.floord(p_180704_8_ - d3) - 1;
|
||||
int l = ExtMath.floord(p_180704_8_ + d3) + 1;
|
||||
int l2 = ExtMath.floord(p_180704_10_ - d2) - p_180704_4_ * 16 - 1;
|
||||
int i1 = ExtMath.floord(p_180704_10_ + d2) - p_180704_4_ * 16 + 1;
|
||||
|
||||
if (j2 < 0)
|
||||
{
|
||||
j2 = 0;
|
||||
}
|
||||
|
||||
if (k > 16)
|
||||
{
|
||||
k = 16;
|
||||
}
|
||||
|
||||
if (k2 < 1)
|
||||
{
|
||||
k2 = 1;
|
||||
}
|
||||
|
||||
if (l > 120)
|
||||
{
|
||||
l = 120;
|
||||
}
|
||||
|
||||
if (l2 < 0)
|
||||
{
|
||||
l2 = 0;
|
||||
}
|
||||
|
||||
if (i1 > 16)
|
||||
{
|
||||
i1 = 16;
|
||||
}
|
||||
|
||||
boolean flag2 = false;
|
||||
|
||||
for (int j1 = j2; !flag2 && j1 < k; ++j1)
|
||||
{
|
||||
for (int k1 = l2; !flag2 && k1 < i1; ++k1)
|
||||
{
|
||||
for (int l1 = l + 1; !flag2 && l1 >= k2 - 1; --l1)
|
||||
{
|
||||
if (l1 >= 0 && l1 < 128)
|
||||
{
|
||||
State iblockstate = p_180704_5_.get(j1, l1, k1);
|
||||
|
||||
if (iblockstate.getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
|
||||
if (l1 != k2 - 1 && j1 != j2 && j1 != k - 1 && k1 != l2 && k1 != i1 - 1)
|
||||
{
|
||||
l1 = k2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
for (int i3 = j2; i3 < k; ++i3)
|
||||
{
|
||||
double d10 = ((double)(i3 + p_180704_3_ * 16) + 0.5D - p_180704_6_) / d2;
|
||||
|
||||
for (int j3 = l2; j3 < i1; ++j3)
|
||||
{
|
||||
double d8 = ((double)(j3 + p_180704_4_ * 16) + 0.5D - p_180704_10_) / d2;
|
||||
|
||||
for (int i2 = l; i2 > k2; --i2)
|
||||
{
|
||||
double d9 = ((double)(i2 - 1) + 0.5D - p_180704_8_) / d3;
|
||||
|
||||
if (d9 > -0.7D && d10 * d10 + d9 * d9 + d8 * d8 < 1.0D)
|
||||
{
|
||||
State iblockstate1 = p_180704_5_.get(i3, i2, j3);
|
||||
|
||||
if (iblockstate1.getBlock() == this.replace || iblockstate1.getBlock() == this.top || iblockstate1.getBlock() == this.surface)
|
||||
{
|
||||
p_180704_5_.set(i3, i2, j3, Blocks.air.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively called by generate()
|
||||
*/
|
||||
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
|
||||
{
|
||||
int i = this.rand.zrange(this.rand.zrange(this.rand.zrange(10) + 1) + 1);
|
||||
|
||||
if (this.rand.zrange(5) != 0)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double d0 = (double)(chunkX * 16 + this.rand.zrange(16));
|
||||
double d1 = (double)this.rand.zrange(128);
|
||||
double d2 = (double)(chunkZ * 16 + this.rand.zrange(16));
|
||||
int k = 1;
|
||||
|
||||
if (this.rand.zrange(4) == 0)
|
||||
{
|
||||
this.func_180705_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2);
|
||||
k += this.rand.zrange(4);
|
||||
}
|
||||
|
||||
for (int l = 0; l < k; ++l)
|
||||
{
|
||||
float f = this.rand.floatv() * (float)Math.PI * 2.0F;
|
||||
float f1 = (this.rand.floatv() - 0.5F) * 2.0F / 8.0F;
|
||||
float f2 = this.rand.floatv() * 2.0F + this.rand.floatv();
|
||||
this.func_180704_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2, f2 * 2.0F, f, f1, 0, 0, 0.5D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
285
java/src/game/worldgen/caves/MapGenCaves.java
Executable file
285
java/src/game/worldgen/caves/MapGenCaves.java
Executable file
|
@ -0,0 +1,285 @@
|
|||
package game.worldgen.caves;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.block.BlockColored;
|
||||
import game.block.BlockSand;
|
||||
import game.color.DyeColor;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.ChunkPrimer;
|
||||
|
||||
public class MapGenCaves extends MapGenBase
|
||||
{
|
||||
private final State filler;
|
||||
private final Block replace;
|
||||
private final Block top;
|
||||
private final Block surface;
|
||||
private final Block alt;
|
||||
|
||||
public MapGenCaves(State filler, Block replace, Block top, Block surface, Block alt) {
|
||||
this.filler = filler;
|
||||
this.replace = replace;
|
||||
this.top = top;
|
||||
this.surface = surface;
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
protected void func_180703_a(long p_180703_1_, int p_180703_3_, int p_180703_4_, ChunkPrimer p_180703_5_, double p_180703_6_, double p_180703_8_, double p_180703_10_)
|
||||
{
|
||||
this.func_180702_a(p_180703_1_, p_180703_3_, p_180703_4_, p_180703_5_, p_180703_6_, p_180703_8_, p_180703_10_, 1.0F + this.rand.floatv() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
|
||||
}
|
||||
|
||||
protected void func_180702_a(long p_180702_1_, int p_180702_3_, int p_180702_4_, ChunkPrimer p_180702_5_, double p_180702_6_, double p_180702_8_, double p_180702_10_, float p_180702_12_, float p_180702_13_, float p_180702_14_, int p_180702_15_, int p_180702_16_, double p_180702_17_)
|
||||
{
|
||||
double d0 = (double)(p_180702_3_ * 16 + 8);
|
||||
double d1 = (double)(p_180702_4_ * 16 + 8);
|
||||
float f = 0.0F;
|
||||
float f1 = 0.0F;
|
||||
Random random = new Random(p_180702_1_);
|
||||
|
||||
if (p_180702_16_ <= 0)
|
||||
{
|
||||
int i = this.range * 16 - 16;
|
||||
p_180702_16_ = i - random.zrange(i / 4);
|
||||
}
|
||||
|
||||
boolean flag2 = false;
|
||||
|
||||
if (p_180702_15_ == -1)
|
||||
{
|
||||
p_180702_15_ = p_180702_16_ / 2;
|
||||
flag2 = true;
|
||||
}
|
||||
|
||||
int j = random.zrange(p_180702_16_ / 2) + p_180702_16_ / 4;
|
||||
|
||||
for (boolean flag = random.zrange(6) == 0; p_180702_15_ < p_180702_16_; ++p_180702_15_)
|
||||
{
|
||||
double d2 = 1.5D + (double)(ExtMath.sin((float)p_180702_15_ * (float)Math.PI / (float)p_180702_16_) * p_180702_12_ * 1.0F);
|
||||
double d3 = d2 * p_180702_17_;
|
||||
float f2 = ExtMath.cos(p_180702_14_);
|
||||
float f3 = ExtMath.sin(p_180702_14_);
|
||||
p_180702_6_ += (double)(ExtMath.cos(p_180702_13_) * f2);
|
||||
p_180702_8_ += (double)f3;
|
||||
p_180702_10_ += (double)(ExtMath.sin(p_180702_13_) * f2);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
p_180702_14_ = p_180702_14_ * 0.92F;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_180702_14_ = p_180702_14_ * 0.7F;
|
||||
}
|
||||
|
||||
p_180702_14_ = p_180702_14_ + f1 * 0.1F;
|
||||
p_180702_13_ += f * 0.1F;
|
||||
f1 = f1 * 0.9F;
|
||||
f = f * 0.75F;
|
||||
f1 = f1 + (random.floatv() - random.floatv()) * random.floatv() * 2.0F;
|
||||
f = f + (random.floatv() - random.floatv()) * random.floatv() * 4.0F;
|
||||
|
||||
if (!flag2 && p_180702_15_ == j && p_180702_12_ > 1.0F && p_180702_16_ > 0)
|
||||
{
|
||||
this.func_180702_a(random.longv(), p_180702_3_, p_180702_4_, p_180702_5_, p_180702_6_, p_180702_8_, p_180702_10_, random.floatv() * 0.5F + 0.5F, p_180702_13_ - ((float)Math.PI / 2F), p_180702_14_ / 3.0F, p_180702_15_, p_180702_16_, 1.0D);
|
||||
this.func_180702_a(random.longv(), p_180702_3_, p_180702_4_, p_180702_5_, p_180702_6_, p_180702_8_, p_180702_10_, random.floatv() * 0.5F + 0.5F, p_180702_13_ + ((float)Math.PI / 2F), p_180702_14_ / 3.0F, p_180702_15_, p_180702_16_, 1.0D);
|
||||
return;
|
||||
}
|
||||
|
||||
if (flag2 || random.zrange(4) != 0)
|
||||
{
|
||||
double d4 = p_180702_6_ - d0;
|
||||
double d5 = p_180702_10_ - d1;
|
||||
double d6 = (double)(p_180702_16_ - p_180702_15_);
|
||||
double d7 = (double)(p_180702_12_ + 2.0F + 16.0F);
|
||||
|
||||
if (d4 * d4 + d5 * d5 - d6 * d6 > d7 * d7)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_180702_6_ >= d0 - 16.0D - d2 * 2.0D && p_180702_10_ >= d1 - 16.0D - d2 * 2.0D && p_180702_6_ <= d0 + 16.0D + d2 * 2.0D && p_180702_10_ <= d1 + 16.0D + d2 * 2.0D)
|
||||
{
|
||||
int k2 = ExtMath.floord(p_180702_6_ - d2) - p_180702_3_ * 16 - 1;
|
||||
int k = ExtMath.floord(p_180702_6_ + d2) - p_180702_3_ * 16 + 1;
|
||||
int l2 = ExtMath.floord(p_180702_8_ - d3) - 1;
|
||||
int l = ExtMath.floord(p_180702_8_ + d3) + 1;
|
||||
int i3 = ExtMath.floord(p_180702_10_ - d2) - p_180702_4_ * 16 - 1;
|
||||
int i1 = ExtMath.floord(p_180702_10_ + d2) - p_180702_4_ * 16 + 1;
|
||||
|
||||
if (k2 < 0)
|
||||
{
|
||||
k2 = 0;
|
||||
}
|
||||
|
||||
if (k > 16)
|
||||
{
|
||||
k = 16;
|
||||
}
|
||||
|
||||
if (l2 < 1)
|
||||
{
|
||||
l2 = 1;
|
||||
}
|
||||
|
||||
if (l > 248)
|
||||
{
|
||||
l = 248;
|
||||
}
|
||||
|
||||
if (i3 < 0)
|
||||
{
|
||||
i3 = 0;
|
||||
}
|
||||
|
||||
if (i1 > 16)
|
||||
{
|
||||
i1 = 16;
|
||||
}
|
||||
|
||||
boolean flag3 = false;
|
||||
|
||||
for (int j1 = k2; !flag3 && j1 < k; ++j1)
|
||||
{
|
||||
for (int k1 = i3; !flag3 && k1 < i1; ++k1)
|
||||
{
|
||||
for (int l1 = l + 1; !flag3 && l1 >= l2 - 1; --l1)
|
||||
{
|
||||
if (l1 >= 0 && l1 < p_180702_5_.height)
|
||||
{
|
||||
State iblockstate = p_180702_5_.get(j1, l1, k1);
|
||||
|
||||
if (iblockstate.getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
flag3 = true;
|
||||
}
|
||||
|
||||
if (l1 != l2 - 1 && j1 != k2 && j1 != k - 1 && k1 != i3 && k1 != i1 - 1)
|
||||
{
|
||||
l1 = l2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag3)
|
||||
{
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int j3 = k2; j3 < k; ++j3)
|
||||
{
|
||||
double d10 = ((double)(j3 + p_180702_3_ * 16) + 0.5D - p_180702_6_) / d2;
|
||||
|
||||
for (int i2 = i3; i2 < i1; ++i2)
|
||||
{
|
||||
double d8 = ((double)(i2 + p_180702_4_ * 16) + 0.5D - p_180702_10_) / d2;
|
||||
boolean flag1 = false;
|
||||
|
||||
if (d10 * d10 + d8 * d8 < 1.0D)
|
||||
{
|
||||
for (int j2 = l; j2 > l2; --j2)
|
||||
{
|
||||
double d9 = ((double)(j2 - 1) + 0.5D - p_180702_8_) / d3;
|
||||
|
||||
if (d9 > -0.7D && d10 * d10 + d9 * d9 + d8 * d8 < 1.0D)
|
||||
{
|
||||
State iblockstate1 = p_180702_5_.get(j3, j2, i2);
|
||||
State iblockstate2 = // (State)Objects.firstNonNull(
|
||||
p_180702_5_.get(j3, j2 + 1, i2); //,
|
||||
if(iblockstate2 == null)
|
||||
iblockstate2 = Blocks.air.getState();
|
||||
|
||||
if (iblockstate1.getBlock() == this.surface || iblockstate1.getBlock() == Blocks.mycelium)
|
||||
{
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
if (this.func_175793_a(iblockstate1, iblockstate2))
|
||||
{
|
||||
if (j2 - 1 < 10)
|
||||
{
|
||||
p_180702_5_.set(j3, j2, i2, this.filler);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_180702_5_.set(j3, j2, i2, Blocks.air.getState());
|
||||
|
||||
if (iblockstate2.getBlock() == Blocks.sand)
|
||||
{
|
||||
p_180702_5_.set(j3, j2 + 1, i2, iblockstate2.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE) : Blocks.sandstone.getState()); //TODO: check!
|
||||
}
|
||||
|
||||
if (flag1 && p_180702_5_.get(j3, j2 - 1, i2).getBlock() == this.top)
|
||||
{
|
||||
blockpos$mutableblockpos.set(j3 + p_180702_3_ * 16, 0, i2 + p_180702_4_ * 16);
|
||||
p_180702_5_.set(j3, j2 - 1, i2, this.worldObj.getBiomeGenForCoords(blockpos$mutableblockpos).topBlock.getBlock().getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean func_175793_a(State p_175793_1_, State p_175793_2_)
|
||||
{
|
||||
return p_175793_1_.getBlock() == this.replace ? true : (p_175793_1_.getBlock() == this.top ? true : (p_175793_1_.getBlock() == this.surface ? true : (p_175793_1_.getBlock() == Blocks.hardened_clay ? true : (p_175793_1_.getBlock() == Blocks.stained_hardened_clay ? true : (p_175793_1_.getBlock() == Blocks.sandstone ? true : /* (p_175793_1_.getBlock() == Blocks.red_sandstone ? true : */ (p_175793_1_.getBlock() == Blocks.mycelium ? true : (p_175793_1_.getBlock() == Blocks.snow_layer ? true : (p_175793_1_.getBlock() == Blocks.sand || p_175793_1_.getBlock() == this.alt) && !p_175793_2_.getBlock().getMaterial().isColdLiquid()))))))); // );
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively called by generate()
|
||||
*/
|
||||
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
|
||||
{
|
||||
int i = this.rand.zrange(this.rand.zrange(this.rand.zrange(15) + 1) + 1);
|
||||
|
||||
if (this.rand.zrange(7) != 0)
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double d0 = (double)(chunkX * 16 + this.rand.zrange(16));
|
||||
double d1 = (double)this.rand.zrange(this.rand.zrange(120) + 8);
|
||||
double d2 = (double)(chunkZ * 16 + this.rand.zrange(16));
|
||||
int k = 1;
|
||||
|
||||
if (this.rand.zrange(4) == 0)
|
||||
{
|
||||
this.func_180703_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2);
|
||||
k += this.rand.zrange(4);
|
||||
}
|
||||
|
||||
for (int l = 0; l < k; ++l)
|
||||
{
|
||||
float f = this.rand.floatv() * (float)Math.PI * 2.0F;
|
||||
float f1 = (this.rand.floatv() - 0.5F) * 2.0F / 8.0F;
|
||||
float f2 = this.rand.floatv() * 2.0F + this.rand.floatv();
|
||||
|
||||
if (this.rand.zrange(10) == 0)
|
||||
{
|
||||
f2 *= this.rand.floatv() * this.rand.floatv() * 3.0F + 1.0F;
|
||||
}
|
||||
|
||||
this.func_180702_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 1.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
240
java/src/game/worldgen/caves/MapGenRavine.java
Executable file
240
java/src/game/worldgen/caves/MapGenRavine.java
Executable file
|
@ -0,0 +1,240 @@
|
|||
package game.worldgen.caves;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.ChunkPrimer;
|
||||
|
||||
public class MapGenRavine extends MapGenBase
|
||||
{
|
||||
private final State filler;
|
||||
private final Block replace;
|
||||
private final Block top;
|
||||
private final Block surface;
|
||||
|
||||
private float[] field_75046_d = new float[1024];
|
||||
|
||||
public MapGenRavine(State filler, Block replace, Block top, Block surface) {
|
||||
this.filler = filler;
|
||||
this.replace = replace;
|
||||
this.top = top;
|
||||
this.surface = surface;
|
||||
}
|
||||
|
||||
protected void func_180707_a(long p_180707_1_, int p_180707_3_, int p_180707_4_, ChunkPrimer p_180707_5_, double p_180707_6_, double p_180707_8_, double p_180707_10_, float p_180707_12_, float p_180707_13_, float p_180707_14_, int p_180707_15_, int p_180707_16_, double p_180707_17_)
|
||||
{
|
||||
Random random = new Random(p_180707_1_);
|
||||
double d0 = (double)(p_180707_3_ * 16 + 8);
|
||||
double d1 = (double)(p_180707_4_ * 16 + 8);
|
||||
float f = 0.0F;
|
||||
float f1 = 0.0F;
|
||||
|
||||
if (p_180707_16_ <= 0)
|
||||
{
|
||||
int i = this.range * 16 - 16;
|
||||
p_180707_16_ = i - random.zrange(i / 4);
|
||||
}
|
||||
|
||||
boolean flag1 = false;
|
||||
|
||||
if (p_180707_15_ == -1)
|
||||
{
|
||||
p_180707_15_ = p_180707_16_ / 2;
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
float f2 = 1.0F;
|
||||
|
||||
for (int j = 0; j < 256; ++j)
|
||||
{
|
||||
if (j == 0 || random.zrange(3) == 0)
|
||||
{
|
||||
f2 = 1.0F + random.floatv() * random.floatv() * 1.0F;
|
||||
}
|
||||
|
||||
this.field_75046_d[j] = f2 * f2;
|
||||
}
|
||||
|
||||
for (; p_180707_15_ < p_180707_16_; ++p_180707_15_)
|
||||
{
|
||||
double d9 = 1.5D + (double)(ExtMath.sin((float)p_180707_15_ * (float)Math.PI / (float)p_180707_16_) * p_180707_12_ * 1.0F);
|
||||
double d2 = d9 * p_180707_17_;
|
||||
d9 = d9 * ((double)random.floatv() * 0.25D + 0.75D);
|
||||
d2 = d2 * ((double)random.floatv() * 0.25D + 0.75D);
|
||||
float f3 = ExtMath.cos(p_180707_14_);
|
||||
float f4 = ExtMath.sin(p_180707_14_);
|
||||
p_180707_6_ += (double)(ExtMath.cos(p_180707_13_) * f3);
|
||||
p_180707_8_ += (double)f4;
|
||||
p_180707_10_ += (double)(ExtMath.sin(p_180707_13_) * f3);
|
||||
p_180707_14_ = p_180707_14_ * 0.7F;
|
||||
p_180707_14_ = p_180707_14_ + f1 * 0.05F;
|
||||
p_180707_13_ += f * 0.05F;
|
||||
f1 = f1 * 0.8F;
|
||||
f = f * 0.5F;
|
||||
f1 = f1 + (random.floatv() - random.floatv()) * random.floatv() * 2.0F;
|
||||
f = f + (random.floatv() - random.floatv()) * random.floatv() * 4.0F;
|
||||
|
||||
if (flag1 || random.zrange(4) != 0)
|
||||
{
|
||||
double d3 = p_180707_6_ - d0;
|
||||
double d4 = p_180707_10_ - d1;
|
||||
double d5 = (double)(p_180707_16_ - p_180707_15_);
|
||||
double d6 = (double)(p_180707_12_ + 2.0F + 16.0F);
|
||||
|
||||
if (d3 * d3 + d4 * d4 - d5 * d5 > d6 * d6)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_180707_6_ >= d0 - 16.0D - d9 * 2.0D && p_180707_10_ >= d1 - 16.0D - d9 * 2.0D && p_180707_6_ <= d0 + 16.0D + d9 * 2.0D && p_180707_10_ <= d1 + 16.0D + d9 * 2.0D)
|
||||
{
|
||||
int k2 = ExtMath.floord(p_180707_6_ - d9) - p_180707_3_ * 16 - 1;
|
||||
int k = ExtMath.floord(p_180707_6_ + d9) - p_180707_3_ * 16 + 1;
|
||||
int l2 = ExtMath.floord(p_180707_8_ - d2) - 1;
|
||||
int l = ExtMath.floord(p_180707_8_ + d2) + 1;
|
||||
int i3 = ExtMath.floord(p_180707_10_ - d9) - p_180707_4_ * 16 - 1;
|
||||
int i1 = ExtMath.floord(p_180707_10_ + d9) - p_180707_4_ * 16 + 1;
|
||||
|
||||
if (k2 < 0)
|
||||
{
|
||||
k2 = 0;
|
||||
}
|
||||
|
||||
if (k > 16)
|
||||
{
|
||||
k = 16;
|
||||
}
|
||||
|
||||
if (l2 < 1)
|
||||
{
|
||||
l2 = 1;
|
||||
}
|
||||
|
||||
if (l > 248)
|
||||
{
|
||||
l = 248;
|
||||
}
|
||||
|
||||
if (i3 < 0)
|
||||
{
|
||||
i3 = 0;
|
||||
}
|
||||
|
||||
if (i1 > 16)
|
||||
{
|
||||
i1 = 16;
|
||||
}
|
||||
|
||||
boolean flag2 = false;
|
||||
|
||||
for (int j1 = k2; !flag2 && j1 < k; ++j1)
|
||||
{
|
||||
for (int k1 = i3; !flag2 && k1 < i1; ++k1)
|
||||
{
|
||||
for (int l1 = l + 1; !flag2 && l1 >= l2 - 1; --l1)
|
||||
{
|
||||
if (l1 >= 0 && l1 < p_180707_5_.height)
|
||||
{
|
||||
State iblockstate = p_180707_5_.get(j1, l1, k1);
|
||||
|
||||
if (iblockstate.getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
|
||||
if (l1 != l2 - 1 && j1 != k2 && j1 != k - 1 && k1 != i3 && k1 != i1 - 1)
|
||||
{
|
||||
l1 = l2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int j3 = k2; j3 < k; ++j3)
|
||||
{
|
||||
double d10 = ((double)(j3 + p_180707_3_ * 16) + 0.5D - p_180707_6_) / d9;
|
||||
|
||||
for (int i2 = i3; i2 < i1; ++i2)
|
||||
{
|
||||
double d7 = ((double)(i2 + p_180707_4_ * 16) + 0.5D - p_180707_10_) / d9;
|
||||
boolean flag = false;
|
||||
|
||||
if (d10 * d10 + d7 * d7 < 1.0D)
|
||||
{
|
||||
for (int j2 = l; j2 > l2; --j2)
|
||||
{
|
||||
double d8 = ((double)(j2 - 1) + 0.5D - p_180707_8_) / d2;
|
||||
|
||||
if ((d10 * d10 + d7 * d7) * (double)this.field_75046_d[j2 - 1] + d8 * d8 / 6.0D < 1.0D)
|
||||
{
|
||||
State iblockstate1 = p_180707_5_.get(j3, j2, i2);
|
||||
|
||||
if (iblockstate1.getBlock() == this.surface)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (iblockstate1.getBlock() == this.replace || iblockstate1.getBlock() == this.top || iblockstate1.getBlock() == this.surface)
|
||||
{
|
||||
if (j2 - 1 < 10)
|
||||
{
|
||||
p_180707_5_.set(j3, j2, i2, this.filler);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_180707_5_.set(j3, j2, i2, Blocks.air.getState());
|
||||
|
||||
if (flag && p_180707_5_.get(j3, j2 - 1, i2).getBlock() == this.top)
|
||||
{
|
||||
blockpos$mutableblockpos.set(j3 + p_180707_3_ * 16, 0, i2 + p_180707_4_ * 16);
|
||||
p_180707_5_.set(j3, j2 - 1, i2, this.worldObj.getBiomeGenForCoords(blockpos$mutableblockpos).topBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively called by generate()
|
||||
*/
|
||||
protected void recursiveGenerate(WorldServer worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
|
||||
{
|
||||
if (this.rand.zrange(50) == 0)
|
||||
{
|
||||
double d0 = (double)(chunkX * 16 + this.rand.zrange(16));
|
||||
double d1 = (double)(this.rand.zrange(this.rand.zrange(40) + 8) + 20);
|
||||
double d2 = (double)(chunkZ * 16 + this.rand.zrange(16));
|
||||
int i = 1;
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
float f = this.rand.floatv() * (float)Math.PI * 2.0F;
|
||||
float f1 = (this.rand.floatv() - 0.5F) * 2.0F / 8.0F;
|
||||
float f2 = (this.rand.floatv() * 2.0F + this.rand.floatv()) * 2.0F;
|
||||
this.func_180707_a(this.rand.longv(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2, f2, f, f1, 0, 0, 3.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
62
java/src/game/worldgen/feature/WorldGenAbandonedChest.java
Executable file
62
java/src/game/worldgen/feature/WorldGenAbandonedChest.java
Executable file
|
@ -0,0 +1,62 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.item.RngLoot;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
import game.tileentity.TileEntity;
|
||||
import game.tileentity.TileEntityChest;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
import game.worldgen.LootConstants;
|
||||
|
||||
public class WorldGenAbandonedChest extends FeatureGenerator
|
||||
{
|
||||
private final WeightedList<RngLoot> items;
|
||||
private final int amount;
|
||||
|
||||
// BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(x, 0, z)).up();
|
||||
|
||||
public WorldGenAbandonedChest(WeightedList<RngLoot> items, int amount)
|
||||
{
|
||||
this.items = items;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public WorldGenAbandonedChest() {
|
||||
this(LootConstants.ABANDONED_ITEMS, 10);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
Block block;
|
||||
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 1)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
if (position.getY() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
position = position.up();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(4) - rand.zrange(4), rand.zrange(3) - rand.zrange(3), rand.zrange(4) - rand.zrange(4));
|
||||
if (worldIn.isAirBlock(blockpos) && worldIn.isBlockSolid(blockpos.down()))
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.chest.getState(), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
if(tileentity instanceof TileEntityChest)
|
||||
RngLoot.generateChestContents(rand, this.items, (TileEntityChest)tileentity, this.amount);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
70
java/src/game/worldgen/feature/WorldGenAsteroid.java
Executable file
70
java/src/game/worldgen/feature/WorldGenAsteroid.java
Executable file
|
@ -0,0 +1,70 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenAsteroid extends FeatureGenerator {
|
||||
private final State[] blocks;
|
||||
|
||||
public WorldGenAsteroid(State ... blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer world, Random rand, BlockPos pos) {
|
||||
for(pos = pos.add(-8, 0, -8); pos.getY() > 9 && !world.isAirBlock(pos); pos = pos.down()) {
|
||||
;
|
||||
}
|
||||
if(pos.getY() <= 8)
|
||||
return false;
|
||||
pos = pos.down(8);
|
||||
boolean[] set = new boolean[4096];
|
||||
int iter = rand.range(1, 15);
|
||||
for(int n = 0; n < iter; ++n) {
|
||||
double d0 = rand.doublev() * 6.0D + 3.0D;
|
||||
double d1 = rand.doublev() * 6.0D + 3.0D;
|
||||
double d2 = rand.doublev() * 6.0D + 3.0D;
|
||||
double d3 = rand.doublev() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D;
|
||||
double d4 = rand.doublev() * (16.0D - d1 - 2.0D) + 1.0D + d1 / 2.0D;
|
||||
double d5 = rand.doublev() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D;
|
||||
for(int x = 1; x < 15; ++x) {
|
||||
for(int z = 1; z < 15; ++z) {
|
||||
for(int y = 1; y < 15; ++y) {
|
||||
double dx = ((double)x - d3) / (d0 / 2.0D);
|
||||
double dy = ((double)y - d4) / (d1 / 2.0D);
|
||||
double dz = ((double)z - d5) / (d2 / 2.0D);
|
||||
double dist = dx * dx + dy * dy + dz * dz;
|
||||
if(dist < 1.0D) {
|
||||
set[(x * 16 + z) * 16 + y] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int x = 0; x < 16; ++x) {
|
||||
for(int z = 0; z < 16; ++z) {
|
||||
for(int y = 0; y < 16; ++y) {
|
||||
boolean flag = !set[(x * 16 + z) * 16 + y]
|
||||
&& (x < 15 && set[((x + 1) * 16 + z) * 16 + y] || x > 0 && set[((x - 1) * 16 + z) * 16 + y]
|
||||
|| z < 15 && set[(x * 16 + z + 1) * 16 + y] || z > 0 && set[(x * 16 + (z - 1)) * 16 + y]
|
||||
|| y < 7 && set[(x * 16 + z) * 16 + y + 1] || y > 0 && set[(x * 16 + z) * 16 + (y - 1)]);
|
||||
if(flag && !world.isAirBlock(pos.add(x, y, z))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int x = 0; x < 16; ++x) {
|
||||
for(int z = 0; z < 16; ++z) {
|
||||
for(int y = 0; y < 16; ++y) {
|
||||
if(set[(x * 16 + z) * 16 + y]) {
|
||||
world.setState(pos.add(x, y, z), rand.pick(this.blocks), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
73
java/src/game/worldgen/feature/WorldGenBlockBlob.java
Executable file
73
java/src/game/worldgen/feature/WorldGenBlockBlob.java
Executable file
|
@ -0,0 +1,73 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenBlockBlob extends FeatureGenerator
|
||||
{
|
||||
private final Block field_150545_a;
|
||||
private final int field_150544_b;
|
||||
|
||||
public WorldGenBlockBlob(Block p_i45450_1_, int p_i45450_2_)
|
||||
{
|
||||
// super(false);
|
||||
this.field_150545_a = p_i45450_1_;
|
||||
this.field_150544_b = p_i45450_2_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
label0:
|
||||
{
|
||||
if (position.getY() > 3)
|
||||
{
|
||||
if (worldIn.isAirBlock(position.down()))
|
||||
{
|
||||
break label0;
|
||||
}
|
||||
|
||||
Block block = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if (block != Blocks.grass && block != Blocks.dirt && block != Blocks.stone)
|
||||
{
|
||||
break label0;
|
||||
}
|
||||
}
|
||||
|
||||
if (position.getY() <= 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int i1 = this.field_150544_b;
|
||||
|
||||
for (int i = 0; i1 >= 0 && i < 3; ++i)
|
||||
{
|
||||
int j = i1 + rand.zrange(2);
|
||||
int k = i1 + rand.zrange(2);
|
||||
int l = i1 + rand.zrange(2);
|
||||
float f = (float)(j + k + l) * 0.333F + 0.5F;
|
||||
|
||||
for (BlockPos blockpos : BlockPos.getAllInBox(position.add(-j, -k, -l), position.add(j, k, l)))
|
||||
{
|
||||
if (blockpos.distanceSq(position) <= (double)(f * f))
|
||||
{
|
||||
worldIn.setState(blockpos, this.field_150545_a.getState(), 4);
|
||||
}
|
||||
}
|
||||
|
||||
position = position.add(-(i1 + 1) + rand.zrange(2 + i1 * 2), 0 - rand.zrange(2), -(i1 + 1) + rand.zrange(2 + i1 * 2));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
position = position.down();
|
||||
}
|
||||
}
|
||||
}
|
59
java/src/game/worldgen/feature/WorldGenClay.java
Executable file
59
java/src/game/worldgen/feature/WorldGenClay.java
Executable file
|
@ -0,0 +1,59 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenClay extends FeatureGenerator
|
||||
{
|
||||
protected Block clayBlock = Blocks.clay;
|
||||
|
||||
/** The number of blocks to generate. */
|
||||
protected int numberOfBlocks;
|
||||
|
||||
public WorldGenClay(int blocks)
|
||||
{
|
||||
this.numberOfBlocks = blocks;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
if (!worldIn.getState(position).getBlock().getMaterial().isColdLiquid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = rand.zrange(this.numberOfBlocks - 2) + 2;
|
||||
int j = 1;
|
||||
|
||||
for (int k = position.getX() - i; k <= position.getX() + i; ++k)
|
||||
{
|
||||
for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
|
||||
{
|
||||
int i1 = k - position.getX();
|
||||
int j1 = l - position.getZ();
|
||||
|
||||
if (i1 * i1 + j1 * j1 <= i * i)
|
||||
{
|
||||
for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(k, k1, l);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block == Blocks.dirt || block == Blocks.clay)
|
||||
{
|
||||
worldIn.setState(blockpos, this.clayBlock.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
54
java/src/game/worldgen/feature/WorldGenClayExt.java
Executable file
54
java/src/game/worldgen/feature/WorldGenClayExt.java
Executable file
|
@ -0,0 +1,54 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenClayExt extends WorldGenClay {
|
||||
public WorldGenClayExt(int blocks) {
|
||||
super(blocks);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position) {
|
||||
if(!worldIn.getState(position).getBlock().getMaterial().isColdLiquid()) {
|
||||
return false;
|
||||
}
|
||||
float f = rand.floatv() * 3.141593F;
|
||||
double d = (float)position.getX() + (ExtMath.sin(f) * (float)numberOfBlocks) / 8F;
|
||||
double d1 = (float)position.getX() - (ExtMath.sin(f) * (float)numberOfBlocks) / 8F;
|
||||
double d2 = (float)position.getZ() + (ExtMath.cos(f) * (float)numberOfBlocks) / 8F;
|
||||
double d3 = (float)position.getZ() - (ExtMath.cos(f) * (float)numberOfBlocks) / 8F;
|
||||
double d4 = position.getY() + rand.zrange(3) + 2;
|
||||
double d5 = position.getY() + rand.zrange(3) + 2;
|
||||
for(int l = 0; l <= numberOfBlocks; l++) {
|
||||
double d6 = d + ((d1 - d) * (double)l) / (double)numberOfBlocks;
|
||||
double d7 = d4 + ((d5 - d4) * (double)l) / (double)numberOfBlocks;
|
||||
double d8 = d2 + ((d3 - d2) * (double)l) / (double)numberOfBlocks;
|
||||
double d9 = (rand.doublev() * (double)numberOfBlocks) / 16D;
|
||||
double d10 = (double)(ExtMath.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
|
||||
double d11 = (double)(ExtMath.sin(((float)l * 3.141593F) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
|
||||
for(int i1 = (int)(d6 - d10 / 2D); i1 <= (int)(d6 + d10 / 2D); i1++) {
|
||||
for(int j1 = (int)(d7 - d11 / 2D); j1 <= (int)(d7 + d11 / 2D); j1++) {
|
||||
for(int k1 = (int)(d8 - d10 / 2D); k1 <= (int)(d8 + d10 / 2D); k1++) {
|
||||
double d12 = (((double)i1 + 0.5D) - d6) / (d10 / 2D);
|
||||
double d13 = (((double)j1 + 0.5D) - d7) / (d11 / 2D);
|
||||
double d14 = (((double)k1 + 0.5D) - d8) / (d10 / 2D);
|
||||
if(d12 * d12 + d13 * d13 + d14 * d14 >= 1.0D) {
|
||||
continue;
|
||||
}
|
||||
BlockPos blockpos = new BlockPos(i1, j1, k1);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if(block == Blocks.sand) {
|
||||
worldIn.setState(blockpos, this.clayBlock.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
106
java/src/game/worldgen/feature/WorldGenDesertWells.java
Executable file
106
java/src/game/worldgen/feature/WorldGenDesertWells.java
Executable file
|
@ -0,0 +1,106 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.Predicates;
|
||||
import game.block.BlockSand;
|
||||
import game.block.BlockSlab;
|
||||
import game.init.Blocks;
|
||||
import game.pattern.BlockStateHelper;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenDesertWells extends FeatureGenerator
|
||||
{
|
||||
private static final BlockStateHelper field_175913_a = BlockStateHelper.forBlock(Blocks.sand).where(BlockSand.VARIANT, Predicates.equalTo(BlockSand.EnumType.SAND));
|
||||
private final State field_175911_b = Blocks.sandstone_slab.getState().withProperty(BlockSlab.FACING, Facing.DOWN);
|
||||
private final State field_175912_c = Blocks.sandstone.getState();
|
||||
private final State field_175910_d = Blocks.flowing_water.getState();
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
while (worldIn.isAirBlock(position) && position.getY() > 2)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
if (!field_175913_a.test(worldIn.getState(position)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = -2; i <= 2; ++i)
|
||||
{
|
||||
for (int j = -2; j <= 2; ++j)
|
||||
{
|
||||
if (worldIn.isAirBlock(position.add(i, -1, j)) && worldIn.isAirBlock(position.add(i, -2, j)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = -1; l <= 0; ++l)
|
||||
{
|
||||
for (int l1 = -2; l1 <= 2; ++l1)
|
||||
{
|
||||
for (int k = -2; k <= 2; ++k)
|
||||
{
|
||||
worldIn.setState(position.add(l1, l, k), this.field_175912_c, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
worldIn.setState(position, this.field_175910_d, 2);
|
||||
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
|
||||
{
|
||||
worldIn.setState(position.offset(enumfacing), this.field_175910_d, 2);
|
||||
}
|
||||
|
||||
for (int i1 = -2; i1 <= 2; ++i1)
|
||||
{
|
||||
for (int i2 = -2; i2 <= 2; ++i2)
|
||||
{
|
||||
if (i1 == -2 || i1 == 2 || i2 == -2 || i2 == 2)
|
||||
{
|
||||
worldIn.setState(position.add(i1, 1, i2), this.field_175912_c, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
worldIn.setState(position.add(2, 1, 0), this.field_175911_b, 2);
|
||||
worldIn.setState(position.add(-2, 1, 0), this.field_175911_b, 2);
|
||||
worldIn.setState(position.add(0, 1, 2), this.field_175911_b, 2);
|
||||
worldIn.setState(position.add(0, 1, -2), this.field_175911_b, 2);
|
||||
|
||||
for (int j1 = -1; j1 <= 1; ++j1)
|
||||
{
|
||||
for (int j2 = -1; j2 <= 1; ++j2)
|
||||
{
|
||||
if (j1 == 0 && j2 == 0)
|
||||
{
|
||||
worldIn.setState(position.add(j1, 4, j2), this.field_175912_c, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldIn.setState(position.add(j1, 4, j2), this.field_175911_b, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int k1 = 1; k1 <= 3; ++k1)
|
||||
{
|
||||
worldIn.setState(position.add(-1, k1, -1), this.field_175912_c, 2);
|
||||
worldIn.setState(position.add(-1, k1, 1), this.field_175912_c, 2);
|
||||
worldIn.setState(position.add(1, k1, -1), this.field_175912_c, 2);
|
||||
worldIn.setState(position.add(1, k1, 1), this.field_175912_c, 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
25
java/src/game/worldgen/feature/WorldGenFire.java
Executable file
25
java/src/game/worldgen/feature/WorldGenFire.java
Executable file
|
@ -0,0 +1,25 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenFire extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.hellrock)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.fire.getState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
58
java/src/game/worldgen/feature/WorldGenGlowStone.java
Executable file
58
java/src/game/worldgen/feature/WorldGenGlowStone.java
Executable file
|
@ -0,0 +1,58 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenGlowStone extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
if (!worldIn.isAirBlock(position))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (worldIn.getState(position.up()).getBlock() != Blocks.hellrock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
worldIn.setState(position, Blocks.glowstone.getState(), 2);
|
||||
|
||||
for (int i = 0; i < 1500; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), -rand.zrange(12), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.getState(blockpos).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
int j = 0;
|
||||
|
||||
for (Facing enumfacing : Facing.values())
|
||||
{
|
||||
if (worldIn.getState(blockpos.offset(enumfacing)).getBlock() == Blocks.glowstone)
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (j > 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j == 1)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.glowstone.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
97
java/src/game/worldgen/feature/WorldGenHellLava.java
Executable file
97
java/src/game/worldgen/feature/WorldGenHellLava.java
Executable file
|
@ -0,0 +1,97 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenHellLava extends FeatureGenerator
|
||||
{
|
||||
private final Block field_150553_a;
|
||||
private final boolean field_94524_b;
|
||||
|
||||
public WorldGenHellLava(Block p_i45453_1_, boolean p_i45453_2_)
|
||||
{
|
||||
this.field_150553_a = p_i45453_1_;
|
||||
this.field_94524_b = p_i45453_2_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
if (worldIn.getState(position.up()).getBlock() != Blocks.hellrock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (worldIn.getState(position).getBlock().getMaterial() != Material.air && worldIn.getState(position).getBlock() != Blocks.hellrock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (worldIn.getState(position.west()).getBlock() == Blocks.hellrock)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (worldIn.getState(position.east()).getBlock() == Blocks.hellrock)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (worldIn.getState(position.north()).getBlock() == Blocks.hellrock)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (worldIn.getState(position.south()).getBlock() == Blocks.hellrock)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (worldIn.getState(position.down()).getBlock() == Blocks.hellrock)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
|
||||
if (worldIn.isAirBlock(position.west()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (worldIn.isAirBlock(position.east()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (worldIn.isAirBlock(position.north()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (worldIn.isAirBlock(position.south()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (worldIn.isAirBlock(position.down()))
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (!this.field_94524_b && i == 4 && j == 1 || i == 5)
|
||||
{
|
||||
worldIn.setState(position, this.field_150553_a.getState(), 2);
|
||||
worldIn.forceBlockUpdateTick(this.field_150553_a, position, rand);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
62
java/src/game/worldgen/feature/WorldGenIcePath.java
Executable file
62
java/src/game/worldgen/feature/WorldGenIcePath.java
Executable file
|
@ -0,0 +1,62 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenIcePath extends FeatureGenerator
|
||||
{
|
||||
private Block block = Blocks.packed_ice;
|
||||
private int basePathWidth;
|
||||
|
||||
public WorldGenIcePath(int p_i45454_1_)
|
||||
{
|
||||
this.basePathWidth = p_i45454_1_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
while (worldIn.isAirBlock(position) && position.getY() > 2)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
if (worldIn.getState(position).getBlock() != Blocks.snow)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = rand.zrange(this.basePathWidth - 2) + 2;
|
||||
int j = 1;
|
||||
|
||||
for (int k = position.getX() - i; k <= position.getX() + i; ++k)
|
||||
{
|
||||
for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
|
||||
{
|
||||
int i1 = k - position.getX();
|
||||
int j1 = l - position.getZ();
|
||||
|
||||
if (i1 * i1 + j1 * j1 <= i * i)
|
||||
{
|
||||
for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(k, k1, l);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
|
||||
{
|
||||
worldIn.setState(blockpos, this.block.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
120
java/src/game/worldgen/feature/WorldGenIceSpike.java
Executable file
120
java/src/game/worldgen/feature/WorldGenIceSpike.java
Executable file
|
@ -0,0 +1,120 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenIceSpike extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
while (worldIn.isAirBlock(position) && position.getY() > 2)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
if (worldIn.getState(position).getBlock() != Blocks.snow)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
position = position.up(rand.zrange(4));
|
||||
int i = rand.zrange(4) + 7;
|
||||
int j = i / 4 + rand.zrange(2);
|
||||
|
||||
if (j > 1 && rand.zrange(60) == 0)
|
||||
{
|
||||
position = position.up(10 + rand.zrange(30));
|
||||
}
|
||||
|
||||
for (int k = 0; k < i; ++k)
|
||||
{
|
||||
float f = (1.0F - (float)k / (float)i) * (float)j;
|
||||
int l = ExtMath.ceilf(f);
|
||||
|
||||
for (int i1 = -l; i1 <= l; ++i1)
|
||||
{
|
||||
float f1 = (float)ExtMath.absi(i1) - 0.25F;
|
||||
|
||||
for (int j1 = -l; j1 <= l; ++j1)
|
||||
{
|
||||
float f2 = (float)ExtMath.absi(j1) - 0.25F;
|
||||
|
||||
if ((i1 == 0 && j1 == 0 || f1 * f1 + f2 * f2 <= f * f) && (i1 != -l && i1 != l && j1 != -l && j1 != l || rand.floatv() <= 0.75F))
|
||||
{
|
||||
Block block = worldIn.getState(position.add(i1, k, j1)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(i1, k, j1), Blocks.packed_ice.getState());
|
||||
}
|
||||
|
||||
if (k != 0 && l > 1)
|
||||
{
|
||||
block = worldIn.getState(position.add(i1, -k, j1)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(i1, -k, j1), Blocks.packed_ice.getState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int k1 = j - 1;
|
||||
|
||||
if (k1 < 0)
|
||||
{
|
||||
k1 = 0;
|
||||
}
|
||||
else if (k1 > 1)
|
||||
{
|
||||
k1 = 1;
|
||||
}
|
||||
|
||||
for (int l1 = -k1; l1 <= k1; ++l1)
|
||||
{
|
||||
for (int i2 = -k1; i2 <= k1; ++i2)
|
||||
{
|
||||
BlockPos blockpos = position.add(l1, -1, i2);
|
||||
int j2 = 50;
|
||||
|
||||
if (Math.abs(l1) == 1 && Math.abs(i2) == 1)
|
||||
{
|
||||
j2 = rand.zrange(5);
|
||||
}
|
||||
|
||||
while (blockpos.getY() > 50)
|
||||
{
|
||||
Block block1 = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block1.getMaterial() != Material.air && block1 != Blocks.dirt && block1 != Blocks.snow && block1 != Blocks.ice && block1 != Blocks.packed_ice)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, Blocks.packed_ice.getState());
|
||||
blockpos = blockpos.down();
|
||||
--j2;
|
||||
|
||||
if (j2 <= 0)
|
||||
{
|
||||
blockpos = blockpos.down(rand.zrange(5) + 1);
|
||||
j2 = rand.zrange(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
60
java/src/game/worldgen/feature/WorldGenSand.java
Executable file
60
java/src/game/worldgen/feature/WorldGenSand.java
Executable file
|
@ -0,0 +1,60 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenSand extends FeatureGenerator
|
||||
{
|
||||
private Block block;
|
||||
|
||||
/** The maximum radius used when generating a patch of blocks. */
|
||||
private int radius;
|
||||
|
||||
public WorldGenSand(Block p_i45462_1_, int p_i45462_2_)
|
||||
{
|
||||
this.block = p_i45462_1_;
|
||||
this.radius = p_i45462_2_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
if (!worldIn.getState(position).getBlock().getMaterial().isColdLiquid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = rand.zrange(this.radius - 2) + 2;
|
||||
int j = 2;
|
||||
|
||||
for (int k = position.getX() - i; k <= position.getX() + i; ++k)
|
||||
{
|
||||
for (int l = position.getZ() - i; l <= position.getZ() + i; ++l)
|
||||
{
|
||||
int i1 = k - position.getX();
|
||||
int j1 = l - position.getZ();
|
||||
|
||||
if (i1 * i1 + j1 * j1 <= i * i)
|
||||
{
|
||||
for (int k1 = position.getY() - j; k1 <= position.getY() + j; ++k1)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(k, k1, l);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block == Blocks.dirt || block == Blocks.grass)
|
||||
{
|
||||
worldIn.setState(blockpos, this.block.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
84
java/src/game/worldgen/feature/WorldGenSpikes.java
Executable file
84
java/src/game/worldgen/feature/WorldGenSpikes.java
Executable file
|
@ -0,0 +1,84 @@
|
|||
package game.worldgen.feature;
|
||||
|
||||
import game.block.Block;
|
||||
import game.entity.Entity;
|
||||
import game.entity.item.EntityCrystal;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenSpikes extends FeatureGenerator
|
||||
{
|
||||
private final Block base;
|
||||
private final int maxHeight;
|
||||
private final int minRadius;
|
||||
private final int maxRadius;
|
||||
private final State block;
|
||||
private final boolean crystals;
|
||||
|
||||
public WorldGenSpikes(Block base, int maxHeight, int minRadius, int maxRadius, State placed, boolean crystals)
|
||||
{
|
||||
this.base = base;
|
||||
this.maxHeight = maxHeight;
|
||||
this.minRadius = minRadius;
|
||||
this.maxRadius = maxRadius;
|
||||
this.block = placed;
|
||||
this.crystals = crystals;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
if (worldIn.isAirBlock(position) && worldIn.getState(position.down()).getBlock() == this.base)
|
||||
{
|
||||
int i = rand.zrange(this.maxHeight - 6) + 6;
|
||||
int j = rand.range(this.minRadius, this.maxRadius);
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int k = position.getX() - j; k <= position.getX() + j; ++k)
|
||||
{
|
||||
for (int l = position.getZ() - j; l <= position.getZ() + j; ++l)
|
||||
{
|
||||
int i1 = k - position.getX();
|
||||
int j1 = l - position.getZ();
|
||||
|
||||
if (i1 * i1 + j1 * j1 <= j * j + 1 && worldIn.getState(blockpos$mutableblockpos.set(k, position.getY() - 1, l)).getBlock() != this.base)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int l1 = position.getY(); l1 < position.getY() + i && l1 < 512; ++l1)
|
||||
{
|
||||
for (int i2 = position.getX() - j; i2 <= position.getX() + j; ++i2)
|
||||
{
|
||||
for (int j2 = position.getZ() - j; j2 <= position.getZ() + j; ++j2)
|
||||
{
|
||||
int k2 = i2 - position.getX();
|
||||
int k1 = j2 - position.getZ();
|
||||
|
||||
if (k2 * k2 + k1 * k1 <= j * j + 1)
|
||||
{
|
||||
worldIn.setState(new BlockPos(i2, l1, j2), this.block, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.crystals) {
|
||||
Entity entity = new EntityCrystal(worldIn);
|
||||
entity.setLocationAndAngles((double)((float)position.getX() + 0.5F), (double)(position.getY() + i), (double)((float)position.getZ() + 0.5F), rand.floatv() * 360.0F, 0.0F);
|
||||
worldIn.spawnEntityInWorld(entity);
|
||||
// if(worldIn.dimension.getDimensionId() == 1)
|
||||
// worldIn.setBlockState(position.up(i), Blocks.obsidian.getDefaultState(), 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
35
java/src/game/worldgen/foliage/FeatureDoublePlant.java
Executable file
35
java/src/game/worldgen/foliage/FeatureDoublePlant.java
Executable file
|
@ -0,0 +1,35 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockDoublePlant;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class FeatureDoublePlant
|
||||
{
|
||||
private BlockDoublePlant.EnumPlantType type;
|
||||
|
||||
public void setPlantType(BlockDoublePlant.EnumPlantType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
boolean flag = false;
|
||||
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 254) && Blocks.double_plant.canPlaceBlockAt(worldIn, blockpos))
|
||||
{
|
||||
Blocks.double_plant.placeAt(worldIn, blockpos, this.type, 2);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
}
|
223
java/src/game/worldgen/foliage/WorldGenBigMushroom.java
Executable file
223
java/src/game/worldgen/foliage/WorldGenBigMushroom.java
Executable file
|
@ -0,0 +1,223 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockHugeMushroom;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenBigMushroom extends FeatureGenerator
|
||||
{
|
||||
/** The mushroom type. 0 for brown, 1 for red. */
|
||||
private Block mushroomType;
|
||||
|
||||
public WorldGenBigMushroom(Block p_i46449_1_)
|
||||
{
|
||||
super(true);
|
||||
this.mushroomType = p_i46449_1_;
|
||||
}
|
||||
|
||||
public WorldGenBigMushroom()
|
||||
{
|
||||
super(false);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
// if (this.mushroomType == null)
|
||||
// {
|
||||
this.mushroomType = rand.chance() ? Blocks.brown_mushroom_block : Blocks.red_mushroom_block;
|
||||
// }
|
||||
|
||||
int i = rand.zrange(3) + 4;
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 < 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 3;
|
||||
|
||||
if (j <= position.getY() + 3)
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
Block block = worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock();
|
||||
|
||||
if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if (block1 != Blocks.dirt && block1 != Blocks.grass && block1 != Blocks.mycelium)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int k2 = position.getY() + i;
|
||||
|
||||
if (this.mushroomType == Blocks.red_mushroom_block)
|
||||
{
|
||||
k2 = position.getY() + i - 3;
|
||||
}
|
||||
|
||||
for (int l2 = k2; l2 <= position.getY() + i; ++l2)
|
||||
{
|
||||
int j3 = 1;
|
||||
|
||||
if (l2 < position.getY() + i)
|
||||
{
|
||||
++j3;
|
||||
}
|
||||
|
||||
if (this.mushroomType == Blocks.brown_mushroom_block)
|
||||
{
|
||||
j3 = 3;
|
||||
}
|
||||
|
||||
int k3 = position.getX() - j3;
|
||||
int l3 = position.getX() + j3;
|
||||
int j1 = position.getZ() - j3;
|
||||
int k1 = position.getZ() + j3;
|
||||
|
||||
for (int l1 = k3; l1 <= l3; ++l1)
|
||||
{
|
||||
for (int i2 = j1; i2 <= k1; ++i2)
|
||||
{
|
||||
int j2 = 5;
|
||||
|
||||
if (l1 == k3)
|
||||
{
|
||||
--j2;
|
||||
}
|
||||
else if (l1 == l3)
|
||||
{
|
||||
++j2;
|
||||
}
|
||||
|
||||
if (i2 == j1)
|
||||
{
|
||||
j2 -= 3;
|
||||
}
|
||||
else if (i2 == k1)
|
||||
{
|
||||
j2 += 3;
|
||||
}
|
||||
|
||||
BlockHugeMushroom.EnumType blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.byMetadata(j2);
|
||||
|
||||
if (this.mushroomType == Blocks.brown_mushroom_block || l2 < position.getY() + i)
|
||||
{
|
||||
if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() - (j3 - 1) && i2 == j1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == k3 && i2 == position.getZ() - (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() + (j3 - 1) && i2 == j1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
|
||||
}
|
||||
|
||||
if (l1 == l3 && i2 == position.getZ() - (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.NORTH_EAST;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() - (j3 - 1) && i2 == k1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == k3 && i2 == position.getZ() + (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_WEST;
|
||||
}
|
||||
|
||||
if (l1 == position.getX() + (j3 - 1) && i2 == k1)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
|
||||
}
|
||||
|
||||
if (l1 == l3 && i2 == position.getZ() + (j3 - 1))
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.SOUTH_EAST;
|
||||
}
|
||||
}
|
||||
|
||||
if (blockhugemushroom$enumtype == BlockHugeMushroom.EnumType.CENTER && l2 < position.getY() + i)
|
||||
{
|
||||
blockhugemushroom$enumtype = BlockHugeMushroom.EnumType.ALL_INSIDE;
|
||||
}
|
||||
|
||||
if (position.getY() >= position.getY() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(l1, l2, i2);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.mushroomType.getState().withProperty(BlockHugeMushroom.VARIANT, blockhugemushroom$enumtype));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i3 = 0; i3 < i; ++i3)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(i3)).getBlock();
|
||||
|
||||
if (!block2.isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(i3), this.mushroomType.getState().withProperty(BlockHugeMushroom.VARIANT, BlockHugeMushroom.EnumType.STEM));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
33
java/src/game/worldgen/foliage/WorldGenCactus.java
Executable file
33
java/src/game/worldgen/foliage/WorldGenCactus.java
Executable file
|
@ -0,0 +1,33 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenCactus extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos))
|
||||
{
|
||||
int j = 1 + rand.zrange(rand.zrange(3) + 1);
|
||||
|
||||
for (int k = 0; k < j; ++k)
|
||||
{
|
||||
if (Blocks.cactus.canBlockStay(worldIn, blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos.up(k), Blocks.cactus.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
34
java/src/game/worldgen/foliage/WorldGenDeadBush.java
Executable file
34
java/src/game/worldgen/foliage/WorldGenDeadBush.java
Executable file
|
@ -0,0 +1,34 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenDeadBush extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
Block block;
|
||||
|
||||
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && Blocks.deadbush.canBlockStay(worldIn, blockpos, Blocks.deadbush.getState()))
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.deadbush.getState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
40
java/src/game/worldgen/foliage/WorldGenFlowers.java
Executable file
40
java/src/game/worldgen/foliage/WorldGenFlowers.java
Executable file
|
@ -0,0 +1,40 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockFlower;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenFlowers extends FeatureGenerator
|
||||
{
|
||||
private BlockFlower flower;
|
||||
private State field_175915_b;
|
||||
|
||||
public WorldGenFlowers(BlockFlower p_i45632_1_, BlockFlower.EnumFlowerType p_i45632_2_)
|
||||
{
|
||||
this.setGeneratedBlock(p_i45632_1_, p_i45632_2_);
|
||||
}
|
||||
|
||||
public void setGeneratedBlock(BlockFlower p_175914_1_, BlockFlower.EnumFlowerType p_175914_2_)
|
||||
{
|
||||
this.flower = p_175914_1_;
|
||||
this.field_175915_b = p_175914_1_.getState().withProperty(p_175914_1_.getTypeProperty(), p_175914_2_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.flower.canBlockStay(worldIn, blockpos, this.field_175915_b))
|
||||
{
|
||||
worldIn.setState(blockpos, this.field_175915_b, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
25
java/src/game/worldgen/foliage/WorldGenMelon.java
Executable file
25
java/src/game/worldgen/foliage/WorldGenMelon.java
Executable file
|
@ -0,0 +1,25 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenMelon extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (Blocks.melon_block.canPlaceBlockAt(worldIn, blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.melon_block.getState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
32
java/src/game/worldgen/foliage/WorldGenMushroom.java
Executable file
32
java/src/game/worldgen/foliage/WorldGenMushroom.java
Executable file
|
@ -0,0 +1,32 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockBush;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenMushroom extends FeatureGenerator
|
||||
{
|
||||
private BlockBush field_175908_a;
|
||||
|
||||
public WorldGenMushroom(BlockBush p_i45633_1_)
|
||||
{
|
||||
this.field_175908_a = p_i45633_1_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.field_175908_a.canBlockStay(worldIn, blockpos, this.field_175908_a.getState()))
|
||||
{
|
||||
worldIn.setState(blockpos, this.field_175908_a.getState(), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
27
java/src/game/worldgen/foliage/WorldGenPumpkin.java
Executable file
27
java/src/game/worldgen/foliage/WorldGenPumpkin.java
Executable file
|
@ -0,0 +1,27 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockPumpkin;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenPumpkin extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 64; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && worldIn.getState(blockpos.down()).getBlock() == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(worldIn, blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.pumpkin.getState().withProperty(BlockPumpkin.FACING, Facing.Plane.HORIZONTAL.random(rand)), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
39
java/src/game/worldgen/foliage/WorldGenReed.java
Executable file
39
java/src/game/worldgen/foliage/WorldGenReed.java
Executable file
|
@ -0,0 +1,39 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenReed extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(4) - rand.zrange(4), 0, rand.zrange(4) - rand.zrange(4));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos))
|
||||
{
|
||||
BlockPos blockpos1 = blockpos.down();
|
||||
|
||||
if (worldIn.getState(blockpos1.west()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.east()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.north()).getBlock().getMaterial() == Material.water || worldIn.getState(blockpos1.south()).getBlock().getMaterial() == Material.water)
|
||||
{
|
||||
int j = 2 + rand.zrange(rand.zrange(3) + 1);
|
||||
|
||||
for (int k = 0; k < j; ++k)
|
||||
{
|
||||
if (Blocks.reeds.canBlockStay(worldIn, blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos.up(k), Blocks.reeds.getState(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
70
java/src/game/worldgen/foliage/WorldGenShrub.java
Executable file
70
java/src/game/worldgen/foliage/WorldGenShrub.java
Executable file
|
@ -0,0 +1,70 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.tree.WorldGenBaseTree;
|
||||
|
||||
public class WorldGenShrub extends WorldGenBaseTree
|
||||
{
|
||||
private final State leavesMetadata;
|
||||
private final State woodMetadata;
|
||||
|
||||
public WorldGenShrub(State log, State leaves)
|
||||
{
|
||||
super(false);
|
||||
this.woodMetadata = log;
|
||||
this.leavesMetadata = leaves.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
Block block;
|
||||
|
||||
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
Block block1 = worldIn.getState(position).getBlock();
|
||||
|
||||
if (block1 == Blocks.dirt || block1 == Blocks.grass)
|
||||
{
|
||||
position = position.up();
|
||||
this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);
|
||||
|
||||
for (int i = position.getY(); i <= position.getY() + 2; ++i)
|
||||
{
|
||||
int j = i - position.getY();
|
||||
int k = 2 - j;
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k; ++l)
|
||||
{
|
||||
int i1 = l - position.getX();
|
||||
|
||||
for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
|
||||
{
|
||||
int k1 = j1 - position.getZ();
|
||||
|
||||
if (Math.abs(i1) != k || Math.abs(k1) != k || rand.zrange(2) != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(l, i, j1);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
43
java/src/game/worldgen/foliage/WorldGenTallGrass.java
Executable file
43
java/src/game/worldgen/foliage/WorldGenTallGrass.java
Executable file
|
@ -0,0 +1,43 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockTallGrass;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenTallGrass extends FeatureGenerator
|
||||
{
|
||||
private final State tallGrassState;
|
||||
|
||||
public WorldGenTallGrass(BlockTallGrass.EnumType p_i45629_1_)
|
||||
{
|
||||
this.tallGrassState = Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, p_i45629_1_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
Block block;
|
||||
|
||||
while (((block = worldIn.getState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
|
||||
{
|
||||
position = position.down();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 128; ++i)
|
||||
{
|
||||
BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8));
|
||||
|
||||
if (worldIn.isAirBlock(blockpos) && Blocks.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState))
|
||||
{
|
||||
worldIn.setState(blockpos, this.tallGrassState, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
38
java/src/game/worldgen/foliage/WorldGenVines.java
Executable file
38
java/src/game/worldgen/foliage/WorldGenVines.java
Executable file
|
@ -0,0 +1,38 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenVines extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (; position.getY() < 128; position = position.up())
|
||||
{
|
||||
if (worldIn.isAirBlock(position))
|
||||
{
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL.facings())
|
||||
{
|
||||
if (Blocks.vine.canPlaceBlockOnSide(worldIn, position, enumfacing))
|
||||
{
|
||||
State iblockstate = Blocks.vine.getState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == Facing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == Facing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == Facing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == Facing.WEST));
|
||||
worldIn.setState(position, iblockstate, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
position = position.add(rand.zrange(4) - rand.zrange(4), 0, rand.zrange(4) - rand.zrange(4));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
29
java/src/game/worldgen/foliage/WorldGenWaterlily.java
Executable file
29
java/src/game/worldgen/foliage/WorldGenWaterlily.java
Executable file
|
@ -0,0 +1,29 @@
|
|||
package game.worldgen.foliage;
|
||||
|
||||
import game.block.BlockDirectional;
|
||||
import game.init.Blocks;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.FeatureGenerator;
|
||||
|
||||
public class WorldGenWaterlily extends FeatureGenerator
|
||||
{
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
int j = position.getX() + rand.zrange(8) - rand.zrange(8);
|
||||
int k = position.getY() + rand.zrange(4) - rand.zrange(4);
|
||||
int l = position.getZ() + rand.zrange(8) - rand.zrange(8);
|
||||
|
||||
if (worldIn.isAirBlock(new BlockPos(j, k, l)) && Blocks.waterlily.canPlaceBlockAt(worldIn, new BlockPos(j, k, l)))
|
||||
{
|
||||
worldIn.setState(new BlockPos(j, k, l), Blocks.waterlily.getState().withProperty(BlockDirectional.FACING, Facing.randHorizontal(rand)), 2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
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();
|
||||
}
|
||||
}
|
54
java/src/game/worldgen/structure/MapGenBridge.java
Executable file
54
java/src/game/worldgen/structure/MapGenBridge.java
Executable file
|
@ -0,0 +1,54 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.rng.Random;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class MapGenBridge extends MapGenStructure
|
||||
{
|
||||
public String getStructureName()
|
||||
{
|
||||
return "Fortress";
|
||||
}
|
||||
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
|
||||
{
|
||||
int i = chunkX >> 4;
|
||||
int j = chunkZ >> 4;
|
||||
this.rand.setSeed((long)(i ^ j << 4) ^ this.worldObj.getSeed());
|
||||
this.rand.intv();
|
||||
return this.rand.zrange(3) != 0 ? false : (chunkX != (i << 4) + 4 + this.rand.zrange(8) ? false : chunkZ == (j << 4) + 4 + this.rand.zrange(8));
|
||||
}
|
||||
|
||||
protected StructureStart getStructureStart(int chunkX, int chunkZ)
|
||||
{
|
||||
return new MapGenBridge.Start(this.worldObj, this.rand, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public static class Start extends StructureStart
|
||||
{
|
||||
public Start()
|
||||
{
|
||||
}
|
||||
|
||||
public Start(WorldServer worldIn, Random p_i2040_2_, int p_i2040_3_, int p_i2040_4_)
|
||||
{
|
||||
super(p_i2040_3_, p_i2040_4_);
|
||||
StructureBridge.Start start = new StructureBridge.Start(p_i2040_2_, (p_i2040_3_ << 4) + 2, (p_i2040_4_ << 4) + 2);
|
||||
this.components.add(start);
|
||||
start.buildComponent(start, this.components, p_i2040_2_);
|
||||
List<StructureComponent> list = start.field_74967_d;
|
||||
|
||||
while (!list.isEmpty())
|
||||
{
|
||||
int i = p_i2040_2_.zrange(list.size());
|
||||
StructureComponent structurecomponent = (StructureComponent)list.remove(i);
|
||||
structurecomponent.buildComponent(start, this.components, p_i2040_2_);
|
||||
}
|
||||
|
||||
this.updateBoundingBox();
|
||||
this.setRandomHeight(worldIn, p_i2040_2_, 48, 70);
|
||||
}
|
||||
}
|
||||
}
|
36
java/src/game/worldgen/structure/MapGenMineshaft.java
Executable file
36
java/src/game/worldgen/structure/MapGenMineshaft.java
Executable file
|
@ -0,0 +1,36 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
public class MapGenMineshaft extends MapGenStructure
|
||||
{
|
||||
private double chance = 0.004D;
|
||||
|
||||
// public MapGenMineshaft()
|
||||
// {
|
||||
// }
|
||||
|
||||
public String getStructureName()
|
||||
{
|
||||
return "Mineshaft";
|
||||
}
|
||||
|
||||
// public MapGenMineshaft(Map<String, String> p_i2034_1_)
|
||||
// {
|
||||
// for (Entry<String, String> entry : p_i2034_1_.entrySet())
|
||||
// {
|
||||
// if (((String)entry.getKey()).equals("chance"))
|
||||
// {
|
||||
// this.field_82673_e = MathHelper.parseDoubleWithDefault((String)entry.getValue(), this.field_82673_e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
|
||||
{
|
||||
return this.rand.doublev() < this.chance && this.rand.zrange(80) < Math.max(Math.abs(chunkX), Math.abs(chunkZ));
|
||||
}
|
||||
|
||||
protected StructureStart getStructureStart(int chunkX, int chunkZ)
|
||||
{
|
||||
return new StructureMineshaftStart(this.worldObj, this.rand, chunkX, chunkZ);
|
||||
}
|
||||
}
|
119
java/src/game/worldgen/structure/MapGenScatteredFeature.java
Executable file
119
java/src/game/worldgen/structure/MapGenScatteredFeature.java
Executable file
|
@ -0,0 +1,119 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class MapGenScatteredFeature extends MapGenStructure
|
||||
{
|
||||
private static final List<Biome> biomelist = Arrays.<Biome>asList(new Biome[] {Biome.desert, Biome.desertHills, Biome.jungle, Biome.jungleHills, Biome.swampland});
|
||||
private static final int MAX_DISTANCE = 32;
|
||||
private static final int MIN_DISTANCE = 8;
|
||||
|
||||
public String getStructureName()
|
||||
{
|
||||
return "Temple";
|
||||
}
|
||||
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
|
||||
{
|
||||
int i = chunkX;
|
||||
int j = chunkZ;
|
||||
|
||||
if (chunkX < 0)
|
||||
{
|
||||
chunkX -= MapGenScatteredFeature.MAX_DISTANCE - 1;
|
||||
}
|
||||
|
||||
if (chunkZ < 0)
|
||||
{
|
||||
chunkZ -= MapGenScatteredFeature.MAX_DISTANCE - 1;
|
||||
}
|
||||
|
||||
int k = chunkX / MapGenScatteredFeature.MAX_DISTANCE;
|
||||
int l = chunkZ / MapGenScatteredFeature.MAX_DISTANCE;
|
||||
Random random = this.worldObj.getRng(k, l, 14357617);
|
||||
k = k * MapGenScatteredFeature.MAX_DISTANCE;
|
||||
l = l * MapGenScatteredFeature.MAX_DISTANCE;
|
||||
k = k + random.zrange(MapGenScatteredFeature.MAX_DISTANCE - MapGenScatteredFeature.MIN_DISTANCE);
|
||||
l = l + random.zrange(MapGenScatteredFeature.MAX_DISTANCE - MapGenScatteredFeature.MIN_DISTANCE);
|
||||
|
||||
if (i == k && j == l)
|
||||
{
|
||||
Biome biomegenbase = this.worldObj.getBiomeGenerator().getBiomeGenerator(new BlockPos(i * 16 + 8, 0, j * 16 + 8), null);
|
||||
|
||||
if (biomegenbase == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Biome biomegenbase1 : biomelist)
|
||||
{
|
||||
if (biomegenbase == biomegenbase1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected StructureStart getStructureStart(int chunkX, int chunkZ)
|
||||
{
|
||||
return new MapGenScatteredFeature.Start(this.worldObj, this.rand, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public boolean hasMageHut(BlockPos pos)
|
||||
{
|
||||
StructureStart structurestart = this.func_175797_c(pos);
|
||||
|
||||
if (structurestart != null && structurestart instanceof MapGenScatteredFeature.Start && !structurestart.components.isEmpty())
|
||||
{
|
||||
StructureComponent structurecomponent = (StructureComponent)structurestart.components.getFirst();
|
||||
return structurecomponent instanceof StructureScattered.SwampHut;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Start extends StructureStart
|
||||
{
|
||||
public Start()
|
||||
{
|
||||
}
|
||||
|
||||
public Start(WorldServer worldIn, Random p_i2060_2_, int p_i2060_3_, int p_i2060_4_)
|
||||
{
|
||||
super(p_i2060_3_, p_i2060_4_);
|
||||
Biome biomegenbase = worldIn.getBiomeGenForCoords(new BlockPos(p_i2060_3_ * 16 + 8, 0, p_i2060_4_ * 16 + 8));
|
||||
|
||||
if (biomegenbase != Biome.jungle && biomegenbase != Biome.jungleHills)
|
||||
{
|
||||
if (biomegenbase == Biome.swampland)
|
||||
{
|
||||
StructureScattered.SwampHut componentscatteredfeaturepieces$swamphut = new StructureScattered.SwampHut(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
|
||||
this.components.add(componentscatteredfeaturepieces$swamphut);
|
||||
}
|
||||
else if (biomegenbase == Biome.desert || biomegenbase == Biome.desertHills)
|
||||
{
|
||||
StructureScattered.DesertPyramid componentscatteredfeaturepieces$desertpyramid = new StructureScattered.DesertPyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
|
||||
this.components.add(componentscatteredfeaturepieces$desertpyramid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StructureScattered.JunglePyramid componentscatteredfeaturepieces$junglepyramid = new StructureScattered.JunglePyramid(p_i2060_2_, p_i2060_3_ * 16, p_i2060_4_ * 16);
|
||||
this.components.add(componentscatteredfeaturepieces$junglepyramid);
|
||||
}
|
||||
|
||||
this.updateBoundingBox();
|
||||
}
|
||||
}
|
||||
}
|
167
java/src/game/worldgen/structure/MapGenStronghold.java
Executable file
167
java/src/game/worldgen/structure/MapGenStronghold.java
Executable file
|
@ -0,0 +1,167 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.rng.Random;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class MapGenStronghold extends MapGenStructure
|
||||
{
|
||||
private double chance = 0.001D;
|
||||
// private Set<Biome> biomeList;
|
||||
//
|
||||
// /**
|
||||
// * is spawned false and set true once the defined BiomeGenBases were compared with the present ones
|
||||
// */
|
||||
// private boolean ranBiomeCheck;
|
||||
// private ChunkPos[] structureCoords;
|
||||
// private double field_82671_h;
|
||||
// private int field_82672_i;
|
||||
|
||||
// public MapGenStronghold()
|
||||
// {
|
||||
// this.structureCoords = new ChunkPos[3];
|
||||
// this.field_82671_h = 32.0D;
|
||||
// this.field_82672_i = 3;
|
||||
// this.biomeList = Sets.<Biome>newHashSet();
|
||||
//
|
||||
// for (Biome biomegenbase : Biome.getBiomeGenArray())
|
||||
// {
|
||||
// if (biomegenbase != null && biomegenbase.minHeight > 0.0F)
|
||||
// {
|
||||
// this.biomeList.add(biomegenbase);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// public MapGenStronghold(Map<String, String> p_i2068_1_)
|
||||
// {
|
||||
// this();
|
||||
//
|
||||
// for (Entry<String, String> entry : p_i2068_1_.entrySet())
|
||||
// {
|
||||
// if (((String)entry.getKey()).equals("distance"))
|
||||
// {
|
||||
// this.field_82671_h = MathHelper.parseDoubleWithDefaultAndMax((String)entry.getValue(), this.field_82671_h, 1.0D);
|
||||
// }
|
||||
// else if (((String)entry.getKey()).equals("count"))
|
||||
// {
|
||||
// this.structureCoords = new ChunkPos[MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.structureCoords.length, 1)];
|
||||
// }
|
||||
// else if (((String)entry.getKey()).equals("spread"))
|
||||
// {
|
||||
// this.field_82672_i = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.field_82672_i, 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public String getStructureName()
|
||||
{
|
||||
return "Stronghold";
|
||||
}
|
||||
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
|
||||
{
|
||||
return this.rand.doublev() < this.chance && this.rand.zrange(80) < Math.max(Math.abs(chunkX), Math.abs(chunkZ));
|
||||
}
|
||||
|
||||
// protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
|
||||
// {
|
||||
// if (!this.ranBiomeCheck)
|
||||
// {
|
||||
// Random random = new Random();
|
||||
// random.setSeed(this.worldObj.getSeed());
|
||||
// double d0 = random.doublev() * Math.PI * 2.0D;
|
||||
// int i = 1;
|
||||
//
|
||||
// for (int j = 0; j < this.structureCoords.length; ++j)
|
||||
// {
|
||||
// double d1 = (1.25D * (double)i + random.doublev()) * this.field_82671_h * (double)i;
|
||||
// int k = (int)Math.round(Math.cos(d0) * d1);
|
||||
// int l = (int)Math.round(Math.sin(d0) * d1);
|
||||
// BlockPos blockpos = this.worldObj.getBiomeGenerator().findBiomePosition((k << 4) + 8, (l << 4) + 8, 112, this.biomeList, random);
|
||||
//
|
||||
// if (blockpos != null)
|
||||
// {
|
||||
// k = blockpos.getX() >> 4;
|
||||
// l = blockpos.getZ() >> 4;
|
||||
// }
|
||||
//
|
||||
// this.structureCoords[j] = new ChunkPos(k, l);
|
||||
// d0 += (Math.PI * 2D) * (double)i / (double)this.field_82672_i;
|
||||
//
|
||||
// if (j == this.field_82672_i)
|
||||
// {
|
||||
// i += 2 + random.zrange(5);
|
||||
// this.field_82672_i += 1 + random.zrange(2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// this.ranBiomeCheck = true;
|
||||
// }
|
||||
//
|
||||
// for (ChunkPos chunkcoordintpair : this.structureCoords)
|
||||
// {
|
||||
// if (chunkX == chunkcoordintpair.x && chunkZ == chunkcoordintpair.z)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// protected List<BlockPos> getCoordList()
|
||||
// {
|
||||
// List<BlockPos> list = Lists.<BlockPos>newArrayList();
|
||||
//
|
||||
// for (ChunkPos chunkcoordintpair : this.structureCoords)
|
||||
// {
|
||||
// if (chunkcoordintpair != null)
|
||||
// {
|
||||
// list.add(new BlockPos((chunkcoordintpair.x << 4) + 8, 64, (chunkcoordintpair.z << 4) + 8));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return list;
|
||||
// }
|
||||
|
||||
protected StructureStart getStructureStart(int chunkX, int chunkZ)
|
||||
{
|
||||
MapGenStronghold.Start mapgenstronghold$start;
|
||||
|
||||
for (mapgenstronghold$start = new MapGenStronghold.Start(this.worldObj, this.rand, chunkX, chunkZ); mapgenstronghold$start.getComponents().isEmpty() || ((StructureStronghold.Stairs2)mapgenstronghold$start.getComponents().get(0)).strongholdPortalRoom == null; mapgenstronghold$start = new MapGenStronghold.Start(this.worldObj, this.rand, chunkX, chunkZ))
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
return mapgenstronghold$start;
|
||||
}
|
||||
|
||||
public static class Start extends StructureStart
|
||||
{
|
||||
public Start()
|
||||
{
|
||||
}
|
||||
|
||||
public Start(WorldServer worldIn, Random p_i2067_2_, int p_i2067_3_, int p_i2067_4_)
|
||||
{
|
||||
super(p_i2067_3_, p_i2067_4_);
|
||||
StructureStronghold.prepareStructurePieces();
|
||||
StructureStronghold.Stairs2 structurestrongholdpieces$stairs2 = new StructureStronghold.Stairs2(0, p_i2067_2_, (p_i2067_3_ << 4) + 2, (p_i2067_4_ << 4) + 2);
|
||||
this.components.add(structurestrongholdpieces$stairs2);
|
||||
structurestrongholdpieces$stairs2.buildComponent(structurestrongholdpieces$stairs2, this.components, p_i2067_2_);
|
||||
List<StructureComponent> list = structurestrongholdpieces$stairs2.field_75026_c;
|
||||
|
||||
while (!list.isEmpty())
|
||||
{
|
||||
int i = p_i2067_2_.zrange(list.size());
|
||||
StructureComponent structurecomponent = (StructureComponent)list.remove(i);
|
||||
structurecomponent.buildComponent(structurestrongholdpieces$stairs2, this.components, p_i2067_2_);
|
||||
}
|
||||
|
||||
this.updateBoundingBox();
|
||||
this.markAvailableHeight(worldIn, p_i2067_2_, 10);
|
||||
}
|
||||
}
|
||||
}
|
242
java/src/game/worldgen/structure/MapGenStructure.java
Executable file
242
java/src/game/worldgen/structure/MapGenStructure.java
Executable file
|
@ -0,0 +1,242 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import game.collect.Maps;
|
||||
import game.nbt.NBTBase;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.ChunkPos;
|
||||
import game.world.LongHashMap;
|
||||
import game.world.World;
|
||||
import game.world.WorldServer;
|
||||
import game.world.WorldServer.WorldSavedData;
|
||||
import game.worldgen.ChunkPrimer;
|
||||
import game.worldgen.caves.MapGenBase;
|
||||
|
||||
public abstract class MapGenStructure extends MapGenBase
|
||||
{
|
||||
private WorldSavedData structureData;
|
||||
protected Map<Long, StructureStart> structureMap = Maps.<Long, StructureStart>newHashMap();
|
||||
|
||||
public abstract String getStructureName();
|
||||
|
||||
/**
|
||||
* Recursively called by generate()
|
||||
*/
|
||||
protected final void recursiveGenerate(WorldServer worldIn, final int chunkX, final int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
|
||||
{
|
||||
int i = (chunkX << 4) + 8;
|
||||
int j = (chunkZ << 4) + 8;
|
||||
if(i < -World.MAX_SIZE + 2048 || j < -World.MAX_SIZE + 2048 || i >= World.MAX_SIZE - 2048 || j >= World.MAX_SIZE - 2048)
|
||||
return;
|
||||
this.initializeStructureData(worldIn);
|
||||
|
||||
if (!this.structureMap.containsKey(Long.valueOf(LongHashMap.packInt(chunkX, chunkZ))))
|
||||
{
|
||||
this.rand.intv();
|
||||
|
||||
if (this.canSpawnStructureAtCoords(chunkX, chunkZ))
|
||||
{
|
||||
StructureStart structurestart = this.getStructureStart(chunkX, chunkZ);
|
||||
this.structureMap.put(Long.valueOf(LongHashMap.packInt(chunkX, chunkZ)), structurestart);
|
||||
this.setStructureStart(chunkX, chunkZ, structurestart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean generateStructure(WorldServer worldIn, Random randomIn, ChunkPos chunkCoord)
|
||||
{
|
||||
int i = (chunkCoord.x << 4) + 8;
|
||||
int j = (chunkCoord.z << 4) + 8;
|
||||
if(i < -World.MAX_SIZE + 2048 || j < -World.MAX_SIZE + 2048 || i >= World.MAX_SIZE - 2048 || j >= World.MAX_SIZE - 2048)
|
||||
return false;
|
||||
this.initializeStructureData(worldIn);
|
||||
boolean flag = false;
|
||||
|
||||
for (StructureStart structurestart : this.structureMap.values())
|
||||
{
|
||||
if (structurestart.isSizeableStructure() && structurestart.func_175788_a(chunkCoord) && structurestart.getBoundingBox().intersectsWith(i, j, i + 15, j + 15))
|
||||
{
|
||||
structurestart.generateStructure(worldIn, randomIn, new StructureBoundingBox(i, j, i + 15, j + 15));
|
||||
structurestart.func_175787_b(chunkCoord);
|
||||
flag = true;
|
||||
this.setStructureStart(structurestart.getChunkPosX(), structurestart.getChunkPosZ(), structurestart);
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public boolean isPresent(BlockPos pos)
|
||||
{
|
||||
this.initializeStructureData(this.worldObj);
|
||||
return this.func_175797_c(pos) != null;
|
||||
}
|
||||
|
||||
protected StructureStart func_175797_c(BlockPos pos)
|
||||
{
|
||||
label24:
|
||||
|
||||
for (StructureStart structurestart : this.structureMap.values())
|
||||
{
|
||||
if (structurestart.isSizeableStructure() && structurestart.getBoundingBox().isVecInside(pos))
|
||||
{
|
||||
Iterator<StructureComponent> iterator = structurestart.getComponents().iterator();
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
continue label24;
|
||||
}
|
||||
|
||||
StructureComponent structurecomponent = (StructureComponent)iterator.next();
|
||||
|
||||
if (structurecomponent.getBoundingBox().isVecInside(pos))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return structurestart;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isPositionInStructure(WorldServer worldIn, BlockPos pos)
|
||||
{
|
||||
this.initializeStructureData(worldIn);
|
||||
|
||||
for (StructureStart structurestart : this.structureMap.values())
|
||||
{
|
||||
if (structurestart.isSizeableStructure() && structurestart.getBoundingBox().isVecInside(pos))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// public BlockPos getClosestStrongholdPos(WorldServer worldIn, BlockPos pos)
|
||||
// {
|
||||
// this.worldObj = worldIn;
|
||||
// this.initializeStructureData(worldIn);
|
||||
// this.rand.setSeed(worldIn.getSeed());
|
||||
// long i = this.rand.longv();
|
||||
// long j = this.rand.longv();
|
||||
// long k = (long)(pos.getX() >> 4) * i;
|
||||
// long l = (long)(pos.getZ() >> 4) * j;
|
||||
// this.rand.setSeed(k ^ l ^ worldIn.getSeed());
|
||||
// this.recursiveGenerate(worldIn, pos.getX() >> 4, pos.getZ() >> 4, 0, 0, (ChunkPrimer)null);
|
||||
// double d0 = Double.MAX_VALUE;
|
||||
// BlockPos blockpos = null;
|
||||
//
|
||||
// for (StructureStart structurestart : this.structureMap.values())
|
||||
// {
|
||||
// if (structurestart.isSizeableStructure())
|
||||
// {
|
||||
// StructureComponent structurecomponent = (StructureComponent)structurestart.getComponents().get(0);
|
||||
// BlockPos blockpos1 = structurecomponent.getBoundingBoxCenter();
|
||||
// double d1 = blockpos1.distanceSq(pos);
|
||||
//
|
||||
// if (d1 < d0)
|
||||
// {
|
||||
// d0 = d1;
|
||||
// blockpos = blockpos1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (blockpos != null)
|
||||
// {
|
||||
// return blockpos;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// List<BlockPos> list = this.getCoordList();
|
||||
//
|
||||
// if (list != null)
|
||||
// {
|
||||
// BlockPos blockpos2 = null;
|
||||
//
|
||||
// for (BlockPos blockpos3 : list)
|
||||
// {
|
||||
// double d2 = blockpos3.distanceSq(pos);
|
||||
//
|
||||
// if (d2 < d0)
|
||||
// {
|
||||
// d0 = d2;
|
||||
// blockpos2 = blockpos3;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return blockpos2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// protected List<BlockPos> getCoordList()
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
private void initializeStructureData(WorldServer worldIn)
|
||||
{
|
||||
if (this.structureData == null)
|
||||
{
|
||||
this.structureData = worldIn.loadItemData(this.getStructureName());
|
||||
|
||||
if (this.structureData == null)
|
||||
{
|
||||
this.structureData = new WorldSavedData(this.getStructureName(), new NBTTagCompound());
|
||||
worldIn.setItemData(this.getStructureName(), this.structureData);
|
||||
}
|
||||
else
|
||||
{
|
||||
NBTTagCompound tag = this.structureData.tag;
|
||||
|
||||
for (String s : tag.getKeySet())
|
||||
{
|
||||
NBTBase nbtbase = tag.getTag(s);
|
||||
|
||||
if (nbtbase.getId() == 10)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbtbase;
|
||||
|
||||
if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ"))
|
||||
{
|
||||
int i = nbttagcompound1.getInteger("ChunkX");
|
||||
int j = nbttagcompound1.getInteger("ChunkZ");
|
||||
StructureStart structurestart = MapGenStructureIO.getStructureStart(nbttagcompound1, worldIn);
|
||||
|
||||
if (structurestart != null)
|
||||
{
|
||||
this.structureMap.put(Long.valueOf(LongHashMap.packInt(i, j)), structurestart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setStructureStart(int chunkX, int chunkZ, StructureStart start)
|
||||
{
|
||||
this.structureData.tag.setTag("[" + chunkX + "," + chunkZ + "]", start.writeStructureComponentsToNBT(chunkX, chunkZ));
|
||||
this.structureData.dirty = true;
|
||||
}
|
||||
|
||||
protected abstract boolean canSpawnStructureAtCoords(int chunkX, int chunkZ);
|
||||
|
||||
protected abstract StructureStart getStructureStart(int chunkX, int chunkZ);
|
||||
}
|
114
java/src/game/worldgen/structure/MapGenStructureIO.java
Executable file
114
java/src/game/worldgen/structure/MapGenStructureIO.java
Executable file
|
@ -0,0 +1,114 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import game.Log;
|
||||
import game.collect.Maps;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class MapGenStructureIO
|
||||
{
|
||||
private static Map < String, Class <? extends StructureStart >> startNameToClassMap = Maps. < String, Class <? extends StructureStart >> newHashMap();
|
||||
private static Map < Class <? extends StructureStart > , String > startClassToNameMap = Maps. < Class <? extends StructureStart > , String > newHashMap();
|
||||
private static Map < String, Class <? extends StructureComponent >> componentNameToClassMap = Maps. < String, Class <? extends StructureComponent >> newHashMap();
|
||||
private static Map < Class <? extends StructureComponent > , String > componentClassToNameMap = Maps. < Class <? extends StructureComponent > , String > newHashMap();
|
||||
|
||||
private static void registerStructure(Class <? extends StructureStart > startClass, String structureName)
|
||||
{
|
||||
startNameToClassMap.put(structureName, startClass);
|
||||
startClassToNameMap.put(startClass, structureName);
|
||||
}
|
||||
|
||||
static void registerStructureComponent(Class <? extends StructureComponent > componentClass, String componentName)
|
||||
{
|
||||
componentNameToClassMap.put(componentName, componentClass);
|
||||
componentClassToNameMap.put(componentClass, componentName);
|
||||
}
|
||||
|
||||
public static String getStructureStartName(StructureStart start)
|
||||
{
|
||||
return (String)startClassToNameMap.get(start.getClass());
|
||||
}
|
||||
|
||||
public static String getStructureComponentName(StructureComponent component)
|
||||
{
|
||||
return (String)componentClassToNameMap.get(component.getClass());
|
||||
}
|
||||
|
||||
public static StructureStart getStructureStart(NBTTagCompound tagCompound, WorldServer worldIn)
|
||||
{
|
||||
StructureStart structurestart = null;
|
||||
|
||||
try
|
||||
{
|
||||
Class <? extends StructureStart > oclass = (Class)startNameToClassMap.get(tagCompound.getString("id"));
|
||||
|
||||
if (oclass != null)
|
||||
{
|
||||
structurestart = (StructureStart)oclass.newInstance();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.JNI.warn("Fehler bei Strukturanfang mit ID " + tagCompound.getString("id"));
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if (structurestart != null)
|
||||
{
|
||||
structurestart.readStructureComponentsFromNBT(worldIn, tagCompound);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.JNI.warn("Überspringe Struktur mit ID " + tagCompound.getString("id"));
|
||||
}
|
||||
|
||||
return structurestart;
|
||||
}
|
||||
|
||||
public static StructureComponent getStructureComponent(NBTTagCompound tagCompound, WorldServer worldIn)
|
||||
{
|
||||
StructureComponent structurecomponent = null;
|
||||
|
||||
try
|
||||
{
|
||||
Class <? extends StructureComponent > oclass = (Class)componentNameToClassMap.get(tagCompound.getString("id"));
|
||||
|
||||
if (oclass != null)
|
||||
{
|
||||
structurecomponent = (StructureComponent)oclass.newInstance();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.JNI.warn("Fehler bei Strukturteil mit ID " + tagCompound.getString("id"));
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if (structurecomponent != null)
|
||||
{
|
||||
structurecomponent.readStructureBaseNBT(worldIn, tagCompound);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.JNI.warn("Überspringe Strukturteil mit ID " + tagCompound.getString("id"));
|
||||
}
|
||||
|
||||
return structurecomponent;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
registerStructure(StructureMineshaftStart.class, "Mineshaft");
|
||||
registerStructure(MapGenVillage.Start.class, "Village");
|
||||
registerStructure(MapGenBridge.Start.class, "Fortress");
|
||||
registerStructure(MapGenStronghold.Start.class, "Stronghold");
|
||||
registerStructure(MapGenScatteredFeature.Start.class, "Temple");
|
||||
StructureMineshaft.registerStructurePieces();
|
||||
StructureVillage.registerVillagePieces();
|
||||
StructureBridge.registerFortressPieces();
|
||||
StructureStronghold.registerStrongholdPieces();
|
||||
StructureScattered.registerScatteredFeaturePieces();
|
||||
}
|
||||
}
|
155
java/src/game/worldgen/structure/MapGenVillage.java
Executable file
155
java/src/game/worldgen/structure/MapGenVillage.java
Executable file
|
@ -0,0 +1,155 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import game.biome.Biome;
|
||||
import game.collect.Sets;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.rng.Random;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class MapGenVillage extends MapGenStructure
|
||||
{
|
||||
public static final Set<Biome> villageSpawnBiomes = Sets.<Biome>newHashSet(Biome.plains, Biome.desert, Biome.savanna);
|
||||
|
||||
/** World terrain type, 0 for normal, 1 for flat map */
|
||||
private int terrainType;
|
||||
private int distance;
|
||||
private int field_82666_h;
|
||||
|
||||
public MapGenVillage()
|
||||
{
|
||||
this.distance = 32;
|
||||
this.field_82666_h = 8;
|
||||
}
|
||||
|
||||
// public MapGenVillage(Map<String, String> p_i2093_1_)
|
||||
// {
|
||||
// this();
|
||||
//
|
||||
// for (Entry<String, String> entry : p_i2093_1_.entrySet())
|
||||
// {
|
||||
// if (((String)entry.getKey()).equals("size"))
|
||||
// {
|
||||
// this.terrainType = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.terrainType, 0);
|
||||
// }
|
||||
// else if (((String)entry.getKey()).equals("distance"))
|
||||
// {
|
||||
// this.distance = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.distance, this.field_82666_h + 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public String getStructureName()
|
||||
{
|
||||
return "Village";
|
||||
}
|
||||
|
||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ)
|
||||
{
|
||||
int i = chunkX;
|
||||
int j = chunkZ;
|
||||
|
||||
if (chunkX < 0)
|
||||
{
|
||||
chunkX -= this.distance - 1;
|
||||
}
|
||||
|
||||
if (chunkZ < 0)
|
||||
{
|
||||
chunkZ -= this.distance - 1;
|
||||
}
|
||||
|
||||
int k = chunkX / this.distance;
|
||||
int l = chunkZ / this.distance;
|
||||
Random random = this.worldObj.getRng(k, l, 10387312);
|
||||
k = k * this.distance;
|
||||
l = l * this.distance;
|
||||
k = k + random.zrange(this.distance - this.field_82666_h);
|
||||
l = l + random.zrange(this.distance - this.field_82666_h);
|
||||
|
||||
if (i == k && j == l)
|
||||
{
|
||||
boolean flag = this.worldObj.getBiomeGenerator().areBiomesViable(i * 16 + 8, j * 16 + 8, 0, villageSpawnBiomes);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected StructureStart getStructureStart(int chunkX, int chunkZ)
|
||||
{
|
||||
return new MapGenVillage.Start(this.worldObj, this.rand, chunkX, chunkZ, this.terrainType);
|
||||
}
|
||||
|
||||
public static class Start extends StructureStart
|
||||
{
|
||||
private boolean hasMoreThanTwoComponents;
|
||||
|
||||
public Start()
|
||||
{
|
||||
}
|
||||
|
||||
public Start(WorldServer worldIn, Random rand, int x, int z, int size)
|
||||
{
|
||||
super(x, z);
|
||||
List<StructureVillage.PieceWeight> list = StructureVillage.getStructureVillageWeightedPieceList(rand, size);
|
||||
StructureVillage.Start structurevillagepieces$start = new StructureVillage.Start(worldIn.getBiomeGenerator(), 0, rand, (x << 4) + 2, (z << 4) + 2, list, size);
|
||||
this.components.add(structurevillagepieces$start);
|
||||
structurevillagepieces$start.buildComponent(structurevillagepieces$start, this.components, rand);
|
||||
List<StructureComponent> list1 = structurevillagepieces$start.field_74930_j;
|
||||
List<StructureComponent> list2 = structurevillagepieces$start.field_74932_i;
|
||||
|
||||
while (!list1.isEmpty() || !list2.isEmpty())
|
||||
{
|
||||
if (list1.isEmpty())
|
||||
{
|
||||
int i = rand.zrange(list2.size());
|
||||
StructureComponent structurecomponent = (StructureComponent)list2.remove(i);
|
||||
structurecomponent.buildComponent(structurevillagepieces$start, this.components, rand);
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = rand.zrange(list1.size());
|
||||
StructureComponent structurecomponent2 = (StructureComponent)list1.remove(j);
|
||||
structurecomponent2.buildComponent(structurevillagepieces$start, this.components, rand);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateBoundingBox();
|
||||
int k = 0;
|
||||
|
||||
for (StructureComponent structurecomponent1 : this.components)
|
||||
{
|
||||
if (!(structurecomponent1 instanceof StructureVillage.Road))
|
||||
{
|
||||
++k;
|
||||
}
|
||||
}
|
||||
|
||||
this.hasMoreThanTwoComponents = k > 2;
|
||||
}
|
||||
|
||||
public boolean isSizeableStructure()
|
||||
{
|
||||
return this.hasMoreThanTwoComponents;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeToNBT(tagCompound);
|
||||
tagCompound.setBoolean("Valid", this.hasMoreThanTwoComponents);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readFromNBT(tagCompound);
|
||||
this.hasMoreThanTwoComponents = tagCompound.getBoolean("Valid");
|
||||
}
|
||||
}
|
||||
}
|
216
java/src/game/worldgen/structure/StructureBoundingBox.java
Executable file
216
java/src/game/worldgen/structure/StructureBoundingBox.java
Executable file
|
@ -0,0 +1,216 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import game.nbt.NBTTagIntArray;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.Vec3i;
|
||||
|
||||
public class StructureBoundingBox
|
||||
{
|
||||
/** The first x coordinate of a bounding box. */
|
||||
public int minX;
|
||||
|
||||
/** The first y coordinate of a bounding box. */
|
||||
public int minY;
|
||||
|
||||
/** The first z coordinate of a bounding box. */
|
||||
public int minZ;
|
||||
|
||||
/** The second x coordinate of a bounding box. */
|
||||
public int maxX;
|
||||
|
||||
/** The second y coordinate of a bounding box. */
|
||||
public int maxY;
|
||||
|
||||
/** The second z coordinate of a bounding box. */
|
||||
public int maxZ;
|
||||
|
||||
public StructureBoundingBox()
|
||||
{
|
||||
}
|
||||
|
||||
public StructureBoundingBox(int[] coords)
|
||||
{
|
||||
if (coords.length == 6)
|
||||
{
|
||||
this.minX = coords[0];
|
||||
this.minY = coords[1];
|
||||
this.minZ = coords[2];
|
||||
this.maxX = coords[3];
|
||||
this.maxY = coords[4];
|
||||
this.maxZ = coords[5];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a new StructureBoundingBox with MAX values
|
||||
*/
|
||||
public static StructureBoundingBox getNewBoundingBox()
|
||||
{
|
||||
return new StructureBoundingBox(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a bounding box with the specified dimensions and rotate it. Used to project a possible new component
|
||||
* Bounding Box - to check if it would cut anything already spawned
|
||||
*/
|
||||
public static StructureBoundingBox getComponentToAddBoundingBox(int p_175897_0_, int p_175897_1_, int p_175897_2_, int p_175897_3_, int p_175897_4_, int p_175897_5_, int p_175897_6_, int p_175897_7_, int p_175897_8_, Facing p_175897_9_)
|
||||
{
|
||||
switch (p_175897_9_)
|
||||
{
|
||||
case NORTH:
|
||||
return new StructureBoundingBox(p_175897_0_ + p_175897_3_, p_175897_1_ + p_175897_4_, p_175897_2_ - p_175897_8_ + 1 + p_175897_5_, p_175897_0_ + p_175897_6_ - 1 + p_175897_3_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_5_);
|
||||
|
||||
case SOUTH:
|
||||
return new StructureBoundingBox(p_175897_0_ + p_175897_3_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_5_, p_175897_0_ + p_175897_6_ - 1 + p_175897_3_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_8_ - 1 + p_175897_5_);
|
||||
|
||||
case WEST:
|
||||
return new StructureBoundingBox(p_175897_0_ - p_175897_8_ + 1 + p_175897_5_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_3_, p_175897_0_ + p_175897_5_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_6_ - 1 + p_175897_3_);
|
||||
|
||||
case EAST:
|
||||
return new StructureBoundingBox(p_175897_0_ + p_175897_5_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_3_, p_175897_0_ + p_175897_8_ - 1 + p_175897_5_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_6_ - 1 + p_175897_3_);
|
||||
|
||||
default:
|
||||
return new StructureBoundingBox(p_175897_0_ + p_175897_3_, p_175897_1_ + p_175897_4_, p_175897_2_ + p_175897_5_, p_175897_0_ + p_175897_6_ - 1 + p_175897_3_, p_175897_1_ + p_175897_7_ - 1 + p_175897_4_, p_175897_2_ + p_175897_8_ - 1 + p_175897_5_);
|
||||
}
|
||||
}
|
||||
|
||||
public static StructureBoundingBox func_175899_a(int p_175899_0_, int p_175899_1_, int p_175899_2_, int p_175899_3_, int p_175899_4_, int p_175899_5_)
|
||||
{
|
||||
return new StructureBoundingBox(Math.min(p_175899_0_, p_175899_3_), Math.min(p_175899_1_, p_175899_4_), Math.min(p_175899_2_, p_175899_5_), Math.max(p_175899_0_, p_175899_3_), Math.max(p_175899_1_, p_175899_4_), Math.max(p_175899_2_, p_175899_5_));
|
||||
}
|
||||
|
||||
public StructureBoundingBox(StructureBoundingBox structurebb)
|
||||
{
|
||||
this.minX = structurebb.minX;
|
||||
this.minY = structurebb.minY;
|
||||
this.minZ = structurebb.minZ;
|
||||
this.maxX = structurebb.maxX;
|
||||
this.maxY = structurebb.maxY;
|
||||
this.maxZ = structurebb.maxZ;
|
||||
}
|
||||
|
||||
public StructureBoundingBox(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax)
|
||||
{
|
||||
this.minX = xMin;
|
||||
this.minY = yMin;
|
||||
this.minZ = zMin;
|
||||
this.maxX = xMax;
|
||||
this.maxY = yMax;
|
||||
this.maxZ = zMax;
|
||||
}
|
||||
|
||||
public StructureBoundingBox(Vec3i vec1, Vec3i vec2)
|
||||
{
|
||||
this.minX = Math.min(vec1.getX(), vec2.getX());
|
||||
this.minY = Math.min(vec1.getY(), vec2.getY());
|
||||
this.minZ = Math.min(vec1.getZ(), vec2.getZ());
|
||||
this.maxX = Math.max(vec1.getX(), vec2.getX());
|
||||
this.maxY = Math.max(vec1.getY(), vec2.getY());
|
||||
this.maxZ = Math.max(vec1.getZ(), vec2.getZ());
|
||||
}
|
||||
|
||||
public StructureBoundingBox(int xMin, int zMin, int xMax, int zMax)
|
||||
{
|
||||
this.minX = xMin;
|
||||
this.minZ = zMin;
|
||||
this.maxX = xMax;
|
||||
this.maxZ = zMax;
|
||||
this.minY = 1;
|
||||
this.maxY = 512;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover if bounding box can fit within the current bounding box object.
|
||||
*/
|
||||
public boolean intersectsWith(StructureBoundingBox structurebb)
|
||||
{
|
||||
return this.maxX >= structurebb.minX && this.minX <= structurebb.maxX && this.maxZ >= structurebb.minZ && this.minZ <= structurebb.maxZ && this.maxY >= structurebb.minY && this.minY <= structurebb.maxY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover if a coordinate is inside the bounding box area.
|
||||
*/
|
||||
public boolean intersectsWith(int minXIn, int minZIn, int maxXIn, int maxZIn)
|
||||
{
|
||||
return this.maxX >= minXIn && this.minX <= maxXIn && this.maxZ >= minZIn && this.minZ <= maxZIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands a bounding box's dimensions to include the supplied bounding box.
|
||||
*/
|
||||
public void expandTo(StructureBoundingBox sbb)
|
||||
{
|
||||
this.minX = Math.min(this.minX, sbb.minX);
|
||||
this.minY = Math.min(this.minY, sbb.minY);
|
||||
this.minZ = Math.min(this.minZ, sbb.minZ);
|
||||
this.maxX = Math.max(this.maxX, sbb.maxX);
|
||||
this.maxY = Math.max(this.maxY, sbb.maxY);
|
||||
this.maxZ = Math.max(this.maxZ, sbb.maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offsets the current bounding box by the specified coordinates. Args: x, y, z
|
||||
*/
|
||||
public void offset(int x, int y, int z)
|
||||
{
|
||||
this.minX += x;
|
||||
this.minY += y;
|
||||
this.minZ += z;
|
||||
this.maxX += x;
|
||||
this.maxY += y;
|
||||
this.maxZ += z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if given Vec3i is inside of StructureBoundingBox
|
||||
*/
|
||||
public boolean isVecInside(Vec3i vec)
|
||||
{
|
||||
return vec.getX() >= this.minX && vec.getX() <= this.maxX && vec.getZ() >= this.minZ && vec.getZ() <= this.maxZ && vec.getY() >= this.minY && vec.getY() <= this.maxY;
|
||||
}
|
||||
|
||||
public Vec3i func_175896_b()
|
||||
{
|
||||
return new Vec3i(this.maxX - this.minX, this.maxY - this.minY, this.maxZ - this.minZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dimension of the bounding box in the x direction.
|
||||
*/
|
||||
public int getXSize()
|
||||
{
|
||||
return this.maxX - this.minX + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dimension of the bounding box in the y direction.
|
||||
*/
|
||||
public int getYSize()
|
||||
{
|
||||
return this.maxY - this.minY + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dimension of the bounding box in the z direction.
|
||||
*/
|
||||
public int getZSize()
|
||||
{
|
||||
return this.maxZ - this.minZ + 1;
|
||||
}
|
||||
|
||||
public Vec3i getCenter()
|
||||
{
|
||||
return new BlockPos(this.minX + (this.maxX - this.minX + 1) / 2, this.minY + (this.maxY - this.minY + 1) / 2, this.minZ + (this.maxZ - this.minZ + 1) / 2);
|
||||
}
|
||||
|
||||
// public String toString()
|
||||
// {
|
||||
// return Objects.toStringHelper(this).add("x0", this.minX).add("y0", this.minY).add("z0", this.minZ).add("x1", this.maxX).add("y1", this.maxY).add("z1", this.maxZ).toString();
|
||||
// }
|
||||
|
||||
public NBTTagIntArray toNBTTagIntArray()
|
||||
{
|
||||
return new NBTTagIntArray(new int[] {this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ});
|
||||
}
|
||||
}
|
1395
java/src/game/worldgen/structure/StructureBridge.java
Executable file
1395
java/src/game/worldgen/structure/StructureBridge.java
Executable file
File diff suppressed because it is too large
Load diff
855
java/src/game/worldgen/structure/StructureComponent.java
Executable file
855
java/src/game/worldgen/structure/StructureComponent.java
Executable file
|
@ -0,0 +1,855 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockDirectional;
|
||||
import game.block.BlockDoor;
|
||||
import game.init.Blocks;
|
||||
import game.item.ItemDoor;
|
||||
import game.item.RngLoot;
|
||||
import game.material.Material;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
import game.tileentity.TileEntity;
|
||||
import game.tileentity.TileEntityChest;
|
||||
import game.tileentity.TileEntityDispenser;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public abstract class StructureComponent
|
||||
{
|
||||
protected StructureBoundingBox boundingBox;
|
||||
|
||||
/** switches the Coordinate System base off the Bounding Box */
|
||||
protected Facing coordBaseMode;
|
||||
|
||||
/** The type ID of this component. */
|
||||
protected int componentType;
|
||||
|
||||
public StructureComponent()
|
||||
{
|
||||
}
|
||||
|
||||
protected StructureComponent(int type)
|
||||
{
|
||||
this.componentType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes structure base data (id, boundingbox, {@link
|
||||
* game.worldgen.structure.StructureComponent#coordBaseMode coordBase} and {@link
|
||||
* game.worldgen.structure.StructureComponent#componentType componentType}) to new NBTTagCompound and
|
||||
* returns it.
|
||||
*/
|
||||
public NBTTagCompound createStructureBaseNBT()
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("id", MapGenStructureIO.getStructureComponentName(this));
|
||||
nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray());
|
||||
nbttagcompound.setInteger("O", this.coordBaseMode == null ? -1 : this.coordBaseMode.getHorizontalIndex());
|
||||
nbttagcompound.setInteger("GD", this.componentType);
|
||||
this.writeStructureToNBT(nbttagcompound);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Helper method to write subclass data to NBT
|
||||
*/
|
||||
protected abstract void writeStructureToNBT(NBTTagCompound tagCompound);
|
||||
|
||||
/**
|
||||
* Reads and sets structure base data (boundingbox, {@link
|
||||
* game.worldgen.structure.StructureComponent#coordBaseMode coordBase} and {@link
|
||||
* game.worldgen.structure.StructureComponent#componentType componentType})
|
||||
*/
|
||||
public void readStructureBaseNBT(WorldServer worldIn, NBTTagCompound tagCompound)
|
||||
{
|
||||
if (tagCompound.hasKey("BB"))
|
||||
{
|
||||
this.boundingBox = new StructureBoundingBox(tagCompound.getIntArray("BB"));
|
||||
}
|
||||
|
||||
int i = tagCompound.getInteger("O");
|
||||
this.coordBaseMode = i == -1 ? null : Facing.getHorizontal(i);
|
||||
this.componentType = tagCompound.getInteger("GD");
|
||||
this.readStructureFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
/**
|
||||
* (abstract) Helper method to read subclass data from NBT
|
||||
*/
|
||||
protected abstract void readStructureFromNBT(NBTTagCompound tagCompound);
|
||||
|
||||
/**
|
||||
* Initiates construction of the Structure Component picked, at the current Location of StructGen
|
||||
*/
|
||||
public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
|
||||
* the end, it adds Fences...
|
||||
*/
|
||||
public abstract boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn);
|
||||
|
||||
public StructureBoundingBox getBoundingBox()
|
||||
{
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component type ID of this component.
|
||||
*/
|
||||
public int getComponentType()
|
||||
{
|
||||
return this.componentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover if bounding box can fit within the current bounding box object.
|
||||
*/
|
||||
public static StructureComponent findIntersecting(List<StructureComponent> listIn, StructureBoundingBox boundingboxIn)
|
||||
{
|
||||
for (StructureComponent structurecomponent : listIn)
|
||||
{
|
||||
if (structurecomponent.getBoundingBox() != null && structurecomponent.getBoundingBox().intersectsWith(boundingboxIn))
|
||||
{
|
||||
return structurecomponent;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BlockPos getBoundingBoxCenter()
|
||||
{
|
||||
return new BlockPos(this.boundingBox.getCenter());
|
||||
}
|
||||
|
||||
/**
|
||||
* checks the entire StructureBoundingBox for Liquids
|
||||
*/
|
||||
protected boolean isLiquidInStructureBoundingBox(WorldServer worldIn, StructureBoundingBox boundingboxIn)
|
||||
{
|
||||
int i = Math.max(this.boundingBox.minX - 1, boundingboxIn.minX);
|
||||
int j = Math.max(this.boundingBox.minY - 1, boundingboxIn.minY);
|
||||
int k = Math.max(this.boundingBox.minZ - 1, boundingboxIn.minZ);
|
||||
int l = Math.min(this.boundingBox.maxX + 1, boundingboxIn.maxX);
|
||||
int i1 = Math.min(this.boundingBox.maxY + 1, boundingboxIn.maxY);
|
||||
int j1 = Math.min(this.boundingBox.maxZ + 1, boundingboxIn.maxZ);
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int k1 = i; k1 <= l; ++k1)
|
||||
{
|
||||
for (int l1 = k; l1 <= j1; ++l1)
|
||||
{
|
||||
if (worldIn.getState(blockpos$mutableblockpos.set(k1, j, l1)).getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (worldIn.getState(blockpos$mutableblockpos.set(k1, i1, l1)).getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i2 = i; i2 <= l; ++i2)
|
||||
{
|
||||
for (int k2 = j; k2 <= i1; ++k2)
|
||||
{
|
||||
if (worldIn.getState(blockpos$mutableblockpos.set(i2, k2, k)).getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (worldIn.getState(blockpos$mutableblockpos.set(i2, k2, j1)).getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j2 = k; j2 <= j1; ++j2)
|
||||
{
|
||||
for (int l2 = j; l2 <= i1; ++l2)
|
||||
{
|
||||
if (worldIn.getState(blockpos$mutableblockpos.set(i, l2, j2)).getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (worldIn.getState(blockpos$mutableblockpos.set(l, l2, j2)).getBlock().getMaterial().isLiquid())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected int getXWithOffset(int x, int z)
|
||||
{
|
||||
if (this.coordBaseMode == null)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this.coordBaseMode)
|
||||
{
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
return this.boundingBox.minX + x;
|
||||
|
||||
case WEST:
|
||||
return this.boundingBox.maxX - z;
|
||||
|
||||
case EAST:
|
||||
return this.boundingBox.minX + z;
|
||||
|
||||
default:
|
||||
return x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int getYWithOffset(int y)
|
||||
{
|
||||
return this.coordBaseMode == null ? y : y + this.boundingBox.minY;
|
||||
}
|
||||
|
||||
protected int getZWithOffset(int x, int z)
|
||||
{
|
||||
if (this.coordBaseMode == null)
|
||||
{
|
||||
return z;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this.coordBaseMode)
|
||||
{
|
||||
case NORTH:
|
||||
return this.boundingBox.maxZ - z;
|
||||
|
||||
case SOUTH:
|
||||
return this.boundingBox.minZ + z;
|
||||
|
||||
case WEST:
|
||||
case EAST:
|
||||
return this.boundingBox.minZ + x;
|
||||
|
||||
default:
|
||||
return z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction-shifted metadata for blocks that require orientation, e.g. doors, stairs, ladders.
|
||||
*/
|
||||
protected int getMetadataWithOffset(Block blockIn, int meta)
|
||||
{
|
||||
if (blockIn == Blocks.rail)
|
||||
{
|
||||
if (this.coordBaseMode == Facing.WEST || this.coordBaseMode == Facing.EAST)
|
||||
{
|
||||
if (meta == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (blockIn instanceof BlockDoor)
|
||||
{
|
||||
if (this.coordBaseMode == Facing.SOUTH)
|
||||
{
|
||||
if (meta == 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (meta == 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.coordBaseMode == Facing.WEST)
|
||||
{
|
||||
return meta + 1 & 3;
|
||||
}
|
||||
|
||||
if (this.coordBaseMode == Facing.EAST)
|
||||
{
|
||||
return meta + 3 & 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (blockIn != Blocks.cobblestone_stairs && blockIn != Blocks.oak_stairs && blockIn != Blocks.blood_brick_stairs && blockIn != Blocks.stonebrick_stairs && blockIn != Blocks.sandstone_stairs)
|
||||
{
|
||||
if (blockIn == Blocks.ladder)
|
||||
{
|
||||
if (this.coordBaseMode == Facing.SOUTH)
|
||||
{
|
||||
if (meta == Facing.NORTH.getIndex())
|
||||
{
|
||||
return Facing.SOUTH.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.SOUTH.getIndex())
|
||||
{
|
||||
return Facing.NORTH.getIndex();
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.WEST)
|
||||
{
|
||||
if (meta == Facing.NORTH.getIndex())
|
||||
{
|
||||
return Facing.WEST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.SOUTH.getIndex())
|
||||
{
|
||||
return Facing.EAST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.WEST.getIndex())
|
||||
{
|
||||
return Facing.NORTH.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.EAST.getIndex())
|
||||
{
|
||||
return Facing.SOUTH.getIndex();
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.EAST)
|
||||
{
|
||||
if (meta == Facing.NORTH.getIndex())
|
||||
{
|
||||
return Facing.EAST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.SOUTH.getIndex())
|
||||
{
|
||||
return Facing.WEST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.WEST.getIndex())
|
||||
{
|
||||
return Facing.NORTH.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.EAST.getIndex())
|
||||
{
|
||||
return Facing.SOUTH.getIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (blockIn == Blocks.stone_button)
|
||||
{
|
||||
if (this.coordBaseMode == Facing.SOUTH)
|
||||
{
|
||||
if (meta == 3)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (meta == 4)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.WEST)
|
||||
{
|
||||
if (meta == 3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (meta == 4)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (meta == 2)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (meta == 1)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.EAST)
|
||||
{
|
||||
if (meta == 3)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (meta == 4)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (meta == 2)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (meta == 1)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (blockIn != Blocks.tripwire_hook && !(blockIn instanceof BlockDirectional))
|
||||
{
|
||||
if (blockIn == Blocks.piston || blockIn == Blocks.sticky_piston || blockIn == Blocks.lever || blockIn == Blocks.dispenser)
|
||||
{
|
||||
if (this.coordBaseMode == Facing.SOUTH)
|
||||
{
|
||||
if (meta == Facing.NORTH.getIndex() || meta == Facing.SOUTH.getIndex())
|
||||
{
|
||||
return Facing.getFront(meta).getOpposite().getIndex();
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.WEST)
|
||||
{
|
||||
if (meta == Facing.NORTH.getIndex())
|
||||
{
|
||||
return Facing.WEST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.SOUTH.getIndex())
|
||||
{
|
||||
return Facing.EAST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.WEST.getIndex())
|
||||
{
|
||||
return Facing.NORTH.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.EAST.getIndex())
|
||||
{
|
||||
return Facing.SOUTH.getIndex();
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.EAST)
|
||||
{
|
||||
if (meta == Facing.NORTH.getIndex())
|
||||
{
|
||||
return Facing.EAST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.SOUTH.getIndex())
|
||||
{
|
||||
return Facing.WEST.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.WEST.getIndex())
|
||||
{
|
||||
return Facing.NORTH.getIndex();
|
||||
}
|
||||
|
||||
if (meta == Facing.EAST.getIndex())
|
||||
{
|
||||
return Facing.SOUTH.getIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Facing enumfacing = Facing.getHorizontal(meta);
|
||||
|
||||
if (this.coordBaseMode == Facing.SOUTH)
|
||||
{
|
||||
if (enumfacing == Facing.SOUTH || enumfacing == Facing.NORTH)
|
||||
{
|
||||
return enumfacing.getOpposite().getHorizontalIndex();
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.WEST)
|
||||
{
|
||||
if (enumfacing == Facing.NORTH)
|
||||
{
|
||||
return Facing.WEST.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (enumfacing == Facing.SOUTH)
|
||||
{
|
||||
return Facing.EAST.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (enumfacing == Facing.WEST)
|
||||
{
|
||||
return Facing.NORTH.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (enumfacing == Facing.EAST)
|
||||
{
|
||||
return Facing.SOUTH.getHorizontalIndex();
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.EAST)
|
||||
{
|
||||
if (enumfacing == Facing.NORTH)
|
||||
{
|
||||
return Facing.EAST.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (enumfacing == Facing.SOUTH)
|
||||
{
|
||||
return Facing.WEST.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (enumfacing == Facing.WEST)
|
||||
{
|
||||
return Facing.NORTH.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (enumfacing == Facing.EAST)
|
||||
{
|
||||
return Facing.SOUTH.getHorizontalIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.SOUTH)
|
||||
{
|
||||
if (meta == 2)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (meta == 3)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.WEST)
|
||||
{
|
||||
if (meta == 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (meta == 1)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (meta == 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (meta == 3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (this.coordBaseMode == Facing.EAST)
|
||||
{
|
||||
if (meta == 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (meta == 1)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (meta == 2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (meta == 3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
protected void setBlockState(WorldServer worldIn, State blockstateIn, int x, int y, int z, StructureBoundingBox boundingboxIn)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
|
||||
if (boundingboxIn.isVecInside(blockpos))
|
||||
{
|
||||
worldIn.setState(blockpos, blockstateIn, 2);
|
||||
}
|
||||
}
|
||||
|
||||
protected State getBlockStateFromPos(WorldServer worldIn, int x, int y, int z, StructureBoundingBox boundingboxIn)
|
||||
{
|
||||
int i = this.getXWithOffset(x, z);
|
||||
int j = this.getYWithOffset(y);
|
||||
int k = this.getZWithOffset(x, z);
|
||||
BlockPos blockpos = new BlockPos(i, j, k);
|
||||
return !boundingboxIn.isVecInside(blockpos) ? Blocks.air.getState() : worldIn.getState(blockpos);
|
||||
}
|
||||
|
||||
/**
|
||||
* arguments: (World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
|
||||
* maxZ)
|
||||
*/
|
||||
protected void fillWithAir(WorldServer worldIn, StructureBoundingBox structurebb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
|
||||
{
|
||||
for (int i = minY; i <= maxY; ++i)
|
||||
{
|
||||
for (int j = minX; j <= maxX; ++j)
|
||||
{
|
||||
for (int k = minZ; k <= maxZ; ++k)
|
||||
{
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), j, i, k, structurebb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the given area with the selected blocks
|
||||
*/
|
||||
protected void fillWithBlocks(WorldServer worldIn, StructureBoundingBox boundingboxIn, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, State boundaryBlockState, State insideBlockState, boolean existingOnly)
|
||||
{
|
||||
for (int i = yMin; i <= yMax; ++i)
|
||||
{
|
||||
for (int j = xMin; j <= xMax; ++j)
|
||||
{
|
||||
for (int k = zMin; k <= zMax; ++k)
|
||||
{
|
||||
if (!existingOnly || this.getBlockStateFromPos(worldIn, j, i, k, boundingboxIn).getBlock().getMaterial() != Material.air)
|
||||
{
|
||||
if (i != yMin && i != yMax && j != xMin && j != xMax && k != zMin && k != zMax)
|
||||
{
|
||||
this.setBlockState(worldIn, insideBlockState, j, i, k, boundingboxIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockState(worldIn, boundaryBlockState, j, i, k, boundingboxIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* arguments: World worldObj, StructureBoundingBox structBB, int minX, int minY, int minZ, int maxX, int maxY, int
|
||||
* maxZ, boolean alwaysreplace, Random rand, StructurePieceBlockSelector blockselector
|
||||
*/
|
||||
protected void fillWithRandomizedBlocks(WorldServer worldIn, StructureBoundingBox boundingboxIn, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, boolean alwaysReplace, Random rand, StructureComponent.BlockSelector blockselector)
|
||||
{
|
||||
for (int i = minY; i <= maxY; ++i)
|
||||
{
|
||||
for (int j = minX; j <= maxX; ++j)
|
||||
{
|
||||
for (int k = minZ; k <= maxZ; ++k)
|
||||
{
|
||||
if (!alwaysReplace || this.getBlockStateFromPos(worldIn, j, i, k, boundingboxIn).getBlock().getMaterial() != Material.air)
|
||||
{
|
||||
blockselector.selectBlocks(rand, j, i, k, i == minY || i == maxY || j == minX || j == maxX || k == minZ || k == maxZ);
|
||||
this.setBlockState(worldIn, blockselector.getBlockState(), j, i, k, boundingboxIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void func_175805_a(WorldServer worldIn, StructureBoundingBox boundingboxIn, Random rand, float chance, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, State blockstate1, State blockstate2, boolean p_175805_13_)
|
||||
{
|
||||
for (int i = minY; i <= maxY; ++i)
|
||||
{
|
||||
for (int j = minX; j <= maxX; ++j)
|
||||
{
|
||||
for (int k = minZ; k <= maxZ; ++k)
|
||||
{
|
||||
if (rand.floatv() <= chance && (!p_175805_13_ || this.getBlockStateFromPos(worldIn, j, i, k, boundingboxIn).getBlock().getMaterial() != Material.air))
|
||||
{
|
||||
if (i != minY && i != maxY && j != minX && j != maxX && k != minZ && k != maxZ)
|
||||
{
|
||||
this.setBlockState(worldIn, blockstate2, j, i, k, boundingboxIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockState(worldIn, blockstate1, j, i, k, boundingboxIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void randomlyPlaceBlock(WorldServer worldIn, StructureBoundingBox boundingboxIn, Random rand, float chance, int x, int y, int z, State blockstateIn)
|
||||
{
|
||||
if (rand.floatv() < chance)
|
||||
{
|
||||
this.setBlockState(worldIn, blockstateIn, x, y, z, boundingboxIn);
|
||||
}
|
||||
}
|
||||
|
||||
protected void randomlyRareFillWithBlocks(WorldServer worldIn, StructureBoundingBox boundingboxIn, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, State blockstateIn, boolean p_180777_10_)
|
||||
{
|
||||
float f = (float)(maxX - minX + 1);
|
||||
float f1 = (float)(maxY - minY + 1);
|
||||
float f2 = (float)(maxZ - minZ + 1);
|
||||
float f3 = (float)minX + f / 2.0F;
|
||||
float f4 = (float)minZ + f2 / 2.0F;
|
||||
|
||||
for (int i = minY; i <= maxY; ++i)
|
||||
{
|
||||
float f5 = (float)(i - minY) / f1;
|
||||
|
||||
for (int j = minX; j <= maxX; ++j)
|
||||
{
|
||||
float f6 = ((float)j - f3) / (f * 0.5F);
|
||||
|
||||
for (int k = minZ; k <= maxZ; ++k)
|
||||
{
|
||||
float f7 = ((float)k - f4) / (f2 * 0.5F);
|
||||
|
||||
if (!p_180777_10_ || this.getBlockStateFromPos(worldIn, j, i, k, boundingboxIn).getBlock().getMaterial() != Material.air)
|
||||
{
|
||||
float f8 = f6 * f6 + f5 * f5 + f7 * f7;
|
||||
|
||||
if (f8 <= 1.05F)
|
||||
{
|
||||
this.setBlockState(worldIn, blockstateIn, j, i, k, boundingboxIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all continuous blocks from selected position upwards. Stops at hitting air.
|
||||
*/
|
||||
protected void clearCurrentPositionBlocksUpwards(WorldServer worldIn, int x, int y, int z, StructureBoundingBox structurebb)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
|
||||
if (structurebb.isVecInside(blockpos))
|
||||
{
|
||||
while (!worldIn.isAirBlock(blockpos) && blockpos.getY() < 511)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.air.getState(), 2);
|
||||
blockpos = blockpos.up();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces air and liquid from given position downwards. Stops when hitting anything else than air or liquid
|
||||
*/
|
||||
protected void replaceAirAndLiquidDownwards(WorldServer worldIn, State blockstateIn, int x, int y, int z, StructureBoundingBox boundingboxIn)
|
||||
{
|
||||
int i = this.getXWithOffset(x, z);
|
||||
int j = this.getYWithOffset(y);
|
||||
int k = this.getZWithOffset(x, z);
|
||||
|
||||
if (boundingboxIn.isVecInside(new BlockPos(i, j, k)))
|
||||
{
|
||||
while ((worldIn.isAirBlock(new BlockPos(i, j, k)) || worldIn.getState(new BlockPos(i, j, k)).getBlock().getMaterial().isLiquid()) && j > 1)
|
||||
{
|
||||
worldIn.setState(new BlockPos(i, j, k), blockstateIn, 2);
|
||||
--j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean generateChestContents(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, WeightedList<RngLoot> listIn, int max)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
|
||||
if (boundingBoxIn.isVecInside(blockpos) && worldIn.getState(blockpos).getBlock() != Blocks.chest)
|
||||
{
|
||||
State iblockstate = Blocks.chest.getState();
|
||||
worldIn.setState(blockpos, Blocks.chest.correctFacing(worldIn, blockpos, iblockstate), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof TileEntityChest)
|
||||
{
|
||||
RngLoot.generateChestContents(rand, listIn, (TileEntityChest)tileentity, max);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean generateDispenserContents(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, int meta, WeightedList<RngLoot> listIn, int max)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
|
||||
if (boundingBoxIn.isVecInside(blockpos) && worldIn.getState(blockpos).getBlock() != Blocks.dispenser)
|
||||
{
|
||||
worldIn.setState(blockpos, Blocks.dispenser.getStateFromMeta(this.getMetadataWithOffset(Blocks.dispenser, meta)), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof TileEntityDispenser)
|
||||
{
|
||||
RngLoot.generateDispenserContents(rand, listIn, (TileEntityDispenser)tileentity, max);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Places door on given position
|
||||
*/
|
||||
protected void placeDoorCurrentPosition(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, Facing facing)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
|
||||
if (boundingBoxIn.isVecInside(blockpos))
|
||||
{
|
||||
ItemDoor.placeDoor(worldIn, blockpos, facing.rotateYCCW(), Blocks.oak_door, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void func_181138_a(int p_181138_1_, int p_181138_2_, int p_181138_3_)
|
||||
{
|
||||
this.boundingBox.offset(p_181138_1_, p_181138_2_, p_181138_3_);
|
||||
}
|
||||
|
||||
public abstract static class BlockSelector
|
||||
{
|
||||
protected State blockstate = Blocks.air.getState();
|
||||
|
||||
public abstract void selectBlocks(Random rand, int x, int y, int z, boolean p_75062_5_);
|
||||
|
||||
public State getBlockState()
|
||||
{
|
||||
return this.blockstate;
|
||||
}
|
||||
}
|
||||
}
|
833
java/src/game/worldgen/structure/StructureMineshaft.java
Executable file
833
java/src/game/worldgen/structure/StructureMineshaft.java
Executable file
|
@ -0,0 +1,833 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import game.entity.item.EntityChestCart;
|
||||
import game.init.Blocks;
|
||||
import game.init.Items;
|
||||
import game.item.RngLoot;
|
||||
import game.material.Material;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.nbt.NBTTagList;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
import game.tileentity.TileEntity;
|
||||
import game.tileentity.TileEntityMobSpawner;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.LootConstants;
|
||||
|
||||
|
||||
public class StructureMineshaft
|
||||
{
|
||||
public static void registerStructurePieces()
|
||||
{
|
||||
MapGenStructureIO.registerStructureComponent(StructureMineshaft.Corridor.class, "MSCorridor");
|
||||
MapGenStructureIO.registerStructureComponent(StructureMineshaft.Cross.class, "MSCrossing");
|
||||
MapGenStructureIO.registerStructureComponent(StructureMineshaft.Room.class, "MSRoom");
|
||||
MapGenStructureIO.registerStructureComponent(StructureMineshaft.Stairs.class, "MSStairs");
|
||||
}
|
||||
|
||||
private static StructureComponent func_175892_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, Facing facing, int type)
|
||||
{
|
||||
int i = rand.zrange(100);
|
||||
|
||||
if (i >= 80)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox = StructureMineshaft.Cross.func_175813_a(listIn, rand, x, y, z, facing);
|
||||
|
||||
if (structureboundingbox != null)
|
||||
{
|
||||
return new StructureMineshaft.Cross(type, rand, structureboundingbox, facing);
|
||||
}
|
||||
}
|
||||
else if (i >= 70)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox1 = StructureMineshaft.Stairs.func_175812_a(listIn, rand, x, y, z, facing);
|
||||
|
||||
if (structureboundingbox1 != null)
|
||||
{
|
||||
return new StructureMineshaft.Stairs(type, rand, structureboundingbox1, facing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StructureBoundingBox structureboundingbox2 = StructureMineshaft.Corridor.func_175814_a(listIn, rand, x, y, z, facing);
|
||||
|
||||
if (structureboundingbox2 != null)
|
||||
{
|
||||
return new StructureMineshaft.Corridor(type, rand, structureboundingbox2, facing);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static StructureComponent func_175890_b(StructureComponent componentIn, List<StructureComponent> listIn, Random rand, int x, int y, int z, Facing facing, int type)
|
||||
{
|
||||
if (type > 8)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (Math.abs(x - componentIn.getBoundingBox().minX) <= 80 && Math.abs(z - componentIn.getBoundingBox().minZ) <= 80)
|
||||
{
|
||||
StructureComponent structurecomponent = func_175892_a(listIn, rand, x, y, z, facing, type + 1);
|
||||
|
||||
if (structurecomponent != null)
|
||||
{
|
||||
listIn.add(structurecomponent);
|
||||
structurecomponent.buildComponent(componentIn, listIn, rand);
|
||||
}
|
||||
|
||||
return structurecomponent;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Corridor extends StructureComponent
|
||||
{
|
||||
private boolean hasRails;
|
||||
private boolean hasSpiders;
|
||||
private boolean spawnerPlaced;
|
||||
private int sectionCount;
|
||||
|
||||
public Corridor()
|
||||
{
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
tagCompound.setBoolean("hr", this.hasRails);
|
||||
tagCompound.setBoolean("sc", this.hasSpiders);
|
||||
tagCompound.setBoolean("hps", this.spawnerPlaced);
|
||||
tagCompound.setInteger("Num", this.sectionCount);
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
this.hasRails = tagCompound.getBoolean("hr");
|
||||
this.hasSpiders = tagCompound.getBoolean("sc");
|
||||
this.spawnerPlaced = tagCompound.getBoolean("hps");
|
||||
this.sectionCount = tagCompound.getInteger("Num");
|
||||
}
|
||||
|
||||
public Corridor(int type, Random rand, StructureBoundingBox structurebb, Facing facing)
|
||||
{
|
||||
super(type);
|
||||
this.coordBaseMode = facing;
|
||||
this.boundingBox = structurebb;
|
||||
this.hasRails = rand.zrange(3) == 0;
|
||||
this.hasSpiders = !this.hasRails && rand.zrange(23) == 0;
|
||||
|
||||
if (this.coordBaseMode != Facing.NORTH && this.coordBaseMode != Facing.SOUTH)
|
||||
{
|
||||
this.sectionCount = structurebb.getXSize() / 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sectionCount = structurebb.getZSize() / 5;
|
||||
}
|
||||
}
|
||||
|
||||
public static StructureBoundingBox func_175814_a(List<StructureComponent> p_175814_0_, Random rand, int x, int y, int z, Facing facing)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y, z, x, y + 2, z);
|
||||
int i;
|
||||
|
||||
for (i = rand.zrange(3) + 2; i > 0; --i)
|
||||
{
|
||||
int j = i * 5;
|
||||
|
||||
switch (facing)
|
||||
{
|
||||
case NORTH:
|
||||
structureboundingbox.maxX = x + 2;
|
||||
structureboundingbox.minZ = z - (j - 1);
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
structureboundingbox.maxX = x + 2;
|
||||
structureboundingbox.maxZ = z + (j - 1);
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
structureboundingbox.minX = x - (j - 1);
|
||||
structureboundingbox.maxZ = z + 2;
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
structureboundingbox.maxX = x + (j - 1);
|
||||
structureboundingbox.maxZ = z + 2;
|
||||
}
|
||||
|
||||
if (StructureComponent.findIntersecting(p_175814_0_, structureboundingbox) == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i > 0 ? structureboundingbox : null;
|
||||
}
|
||||
|
||||
public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
|
||||
{
|
||||
int i = this.getComponentType();
|
||||
int j = rand.zrange(4);
|
||||
|
||||
if (this.coordBaseMode != null)
|
||||
{
|
||||
switch (this.coordBaseMode)
|
||||
{
|
||||
case NORTH:
|
||||
if (j <= 1)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.minZ - 1, this.coordBaseMode, i);
|
||||
}
|
||||
else if (j == 2)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.minZ, Facing.WEST, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.minZ, Facing.EAST, i);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
if (j <= 1)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.maxZ + 1, this.coordBaseMode, i);
|
||||
}
|
||||
else if (j == 2)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.maxZ - 3, Facing.WEST, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.maxZ - 3, Facing.EAST, i);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
if (j <= 1)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.minZ, this.coordBaseMode, i);
|
||||
}
|
||||
else if (j == 2)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
if (j <= 1)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.minZ, this.coordBaseMode, i);
|
||||
}
|
||||
else if (j == 2)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + rand.zrange(3), this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i < 8)
|
||||
{
|
||||
if (this.coordBaseMode != Facing.NORTH && this.coordBaseMode != Facing.SOUTH)
|
||||
{
|
||||
for (int i1 = this.boundingBox.minX + 3; i1 + 3 <= this.boundingBox.maxX; i1 += 5)
|
||||
{
|
||||
int j1 = rand.zrange(5);
|
||||
|
||||
if (j1 == 0)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, i1, this.boundingBox.minY, this.boundingBox.minZ - 1, Facing.NORTH, i + 1);
|
||||
}
|
||||
else if (j1 == 1)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, i1, this.boundingBox.minY, this.boundingBox.maxZ + 1, Facing.SOUTH, i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int k = this.boundingBox.minZ + 3; k + 3 <= this.boundingBox.maxZ; k += 5)
|
||||
{
|
||||
int l = rand.zrange(5);
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, k, Facing.WEST, i + 1);
|
||||
}
|
||||
else if (l == 1)
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, k, Facing.EAST, i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean generateChestContents(WorldServer worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, WeightedList<RngLoot> listIn, int max)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
|
||||
|
||||
if (boundingBoxIn.isVecInside(blockpos) && worldIn.getState(blockpos).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
int i = rand.chance() ? 1 : 0;
|
||||
worldIn.setState(blockpos, Blocks.rail.getStateFromMeta(this.getMetadataWithOffset(Blocks.rail, i)), 2);
|
||||
EntityChestCart entityminecartchest = new EntityChestCart(worldIn, (double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F));
|
||||
RngLoot.generateChestContents(rand, listIn, entityminecartchest, max);
|
||||
worldIn.spawnEntityInWorld(entityminecartchest);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
|
||||
{
|
||||
if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
int j = 2;
|
||||
int k = 0;
|
||||
int l = 2;
|
||||
int i1 = this.sectionCount * 5 - 1;
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 2, 1, i1, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.func_175805_a(worldIn, structureBoundingBoxIn, randomIn, 0.8F, 0, 2, 0, 2, 2, i1, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
|
||||
if (this.hasSpiders)
|
||||
{
|
||||
this.func_175805_a(worldIn, structureBoundingBoxIn, randomIn, 0.6F, 0, 0, 0, 2, 1, i1, Blocks.web.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
|
||||
for (int j1 = 0; j1 < this.sectionCount; ++j1)
|
||||
{
|
||||
int k1 = 2 + j1 * 5;
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, k1, 0, 1, k1, Blocks.oak_fence.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 0, k1, 2, 1, k1, Blocks.oak_fence.getState(), Blocks.air.getState(), false);
|
||||
|
||||
if (randomIn.zrange(4) == 0)
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 2, k1, 0, 2, k1, Blocks.oak_planks.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 2, k1, 2, 2, k1, Blocks.oak_planks.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 2, k1, 2, 2, k1, Blocks.oak_planks.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 0, 2, k1 - 1, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 2, 2, k1 - 1, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 0, 2, k1 + 1, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.1F, 2, 2, k1 + 1, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 0, 2, k1 - 2, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 2, 2, k1 - 2, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 0, 2, k1 + 2, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 2, 2, k1 + 2, Blocks.web.getState());
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 - 1, Blocks.torch.getStateFromMeta(Facing.UP.getIndex()));
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.05F, 1, 2, k1 + 1, Blocks.torch.getStateFromMeta(Facing.UP.getIndex()));
|
||||
|
||||
if (randomIn.zrange(100) == 0)
|
||||
{
|
||||
this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 2, 0, k1 - 1, RngLoot.addToList(LootConstants.MINESHAFT_CHEST, Items.enchanted_book.getRandom(randomIn)), 3 + randomIn.zrange(4));
|
||||
}
|
||||
|
||||
if (randomIn.zrange(100) == 0)
|
||||
{
|
||||
this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 0, 0, k1 + 1, RngLoot.addToList(LootConstants.MINESHAFT_CHEST, Items.enchanted_book.getRandom(randomIn)), 3 + randomIn.zrange(4));
|
||||
}
|
||||
|
||||
if (this.hasSpiders && !this.spawnerPlaced)
|
||||
{
|
||||
int l1 = this.getYWithOffset(0);
|
||||
int i2 = k1 - 1 + randomIn.zrange(3);
|
||||
int j2 = this.getXWithOffset(1, i2);
|
||||
i2 = this.getZWithOffset(1, i2);
|
||||
BlockPos blockpos = new BlockPos(j2, l1, i2);
|
||||
|
||||
if (structureBoundingBoxIn.isVecInside(blockpos))
|
||||
{
|
||||
this.spawnerPlaced = true;
|
||||
worldIn.setState(blockpos, Blocks.mob_spawner.getState(), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof TileEntityMobSpawner)
|
||||
{
|
||||
((TileEntityMobSpawner)tileentity).setEntityName("Arachnoid");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int k2 = 0; k2 <= 2; ++k2)
|
||||
{
|
||||
for (int i3 = 0; i3 <= i1; ++i3)
|
||||
{
|
||||
int j3 = -1;
|
||||
State iblockstate1 = this.getBlockStateFromPos(worldIn, k2, j3, i3, structureBoundingBoxIn);
|
||||
|
||||
if (iblockstate1.getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
int k3 = -1;
|
||||
this.setBlockState(worldIn, Blocks.oak_planks.getState(), k2, k3, i3, structureBoundingBoxIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.hasRails)
|
||||
{
|
||||
for (int l2 = 0; l2 <= i1; ++l2)
|
||||
{
|
||||
State iblockstate = this.getBlockStateFromPos(worldIn, 1, -1, l2, structureBoundingBoxIn);
|
||||
|
||||
if (iblockstate.getBlock().getMaterial() != Material.air && iblockstate.getBlock().isFullBlock())
|
||||
{
|
||||
this.randomlyPlaceBlock(worldIn, structureBoundingBoxIn, randomIn, 0.7F, 1, 0, l2, Blocks.rail.getStateFromMeta(this.getMetadataWithOffset(Blocks.rail, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cross extends StructureComponent
|
||||
{
|
||||
private Facing corridorDirection;
|
||||
private boolean isMultipleFloors;
|
||||
|
||||
public Cross()
|
||||
{
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
tagCompound.setBoolean("tf", this.isMultipleFloors);
|
||||
tagCompound.setInteger("D", this.corridorDirection.getHorizontalIndex());
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
this.isMultipleFloors = tagCompound.getBoolean("tf");
|
||||
this.corridorDirection = Facing.getHorizontal(tagCompound.getInteger("D"));
|
||||
}
|
||||
|
||||
public Cross(int type, Random rand, StructureBoundingBox structurebb, Facing facing)
|
||||
{
|
||||
super(type);
|
||||
this.corridorDirection = facing;
|
||||
this.boundingBox = structurebb;
|
||||
this.isMultipleFloors = structurebb.getYSize() > 3;
|
||||
}
|
||||
|
||||
public static StructureBoundingBox func_175813_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, Facing facing)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y, z, x, y + 2, z);
|
||||
|
||||
if (rand.zrange(4) == 0)
|
||||
{
|
||||
structureboundingbox.maxY += 4;
|
||||
}
|
||||
|
||||
switch (facing)
|
||||
{
|
||||
case NORTH:
|
||||
structureboundingbox.minX = x - 1;
|
||||
structureboundingbox.maxX = x + 3;
|
||||
structureboundingbox.minZ = z - 4;
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
structureboundingbox.minX = x - 1;
|
||||
structureboundingbox.maxX = x + 3;
|
||||
structureboundingbox.maxZ = z + 4;
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
structureboundingbox.minX = x - 4;
|
||||
structureboundingbox.minZ = z - 1;
|
||||
structureboundingbox.maxZ = z + 3;
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
structureboundingbox.maxX = x + 4;
|
||||
structureboundingbox.minZ = z - 1;
|
||||
structureboundingbox.maxZ = z + 3;
|
||||
}
|
||||
|
||||
return StructureComponent.findIntersecting(listIn, structureboundingbox) != null ? null : structureboundingbox;
|
||||
}
|
||||
|
||||
public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
|
||||
{
|
||||
int i = this.getComponentType();
|
||||
|
||||
switch (this.corridorDirection)
|
||||
{
|
||||
case NORTH:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, Facing.WEST, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, Facing.EAST, i);
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, Facing.WEST, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, Facing.EAST, i);
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, Facing.WEST, i);
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, Facing.EAST, i);
|
||||
}
|
||||
|
||||
if (this.isMultipleFloors)
|
||||
{
|
||||
if (rand.chance())
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
}
|
||||
|
||||
if (rand.chance())
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ + 1, Facing.WEST, i);
|
||||
}
|
||||
|
||||
if (rand.chance())
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ + 1, Facing.EAST, i);
|
||||
}
|
||||
|
||||
if (rand.chance())
|
||||
{
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
|
||||
{
|
||||
if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.isMultipleFloors)
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ - 1, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.maxY - 2, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.maxY - 2, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY + 3, this.boundingBox.minZ + 1, this.boundingBox.maxX - 1, this.boundingBox.minY + 3, this.boundingBox.maxZ - 1, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.minX + 1, this.boundingBox.maxY, this.boundingBox.minZ + 1, Blocks.oak_planks.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.minX + 1, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.oak_planks.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.minZ + 1, Blocks.oak_planks.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.oak_planks.getState(), Blocks.air.getState(), false);
|
||||
|
||||
for (int i = this.boundingBox.minX; i <= this.boundingBox.maxX; ++i)
|
||||
{
|
||||
for (int j = this.boundingBox.minZ; j <= this.boundingBox.maxZ; ++j)
|
||||
{
|
||||
if (this.getBlockStateFromPos(worldIn, i, this.boundingBox.minY - 1, j, structureBoundingBoxIn).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.setBlockState(worldIn, Blocks.oak_planks.getState(), i, this.boundingBox.minY - 1, j, structureBoundingBoxIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Room extends StructureComponent
|
||||
{
|
||||
private List<StructureBoundingBox> roomsLinkedToTheRoom = new LinkedList<StructureBoundingBox>();
|
||||
|
||||
public Room()
|
||||
{
|
||||
}
|
||||
|
||||
public Room(int type, Random rand, int x, int z)
|
||||
{
|
||||
super(type);
|
||||
this.boundingBox = new StructureBoundingBox(x, 50, z, x + 7 + rand.zrange(6), 54 + rand.zrange(6), z + 7 + rand.zrange(6));
|
||||
}
|
||||
|
||||
public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
|
||||
{
|
||||
int i = this.getComponentType();
|
||||
int j = this.boundingBox.getYSize() - 3 - 1;
|
||||
|
||||
if (j <= 0)
|
||||
{
|
||||
j = 1;
|
||||
}
|
||||
|
||||
int k;
|
||||
|
||||
for (k = 0; k < this.boundingBox.getXSize(); k = k + 4)
|
||||
{
|
||||
k = k + rand.zrange(this.boundingBox.getXSize());
|
||||
|
||||
if (k + 3 > this.boundingBox.getXSize())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
StructureComponent structurecomponent = StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + k, this.boundingBox.minY + rand.zrange(j) + 1, this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
|
||||
if (structurecomponent != null)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox = structurecomponent.getBoundingBox();
|
||||
this.roomsLinkedToTheRoom.add(new StructureBoundingBox(structureboundingbox.minX, structureboundingbox.minY, this.boundingBox.minZ, structureboundingbox.maxX, structureboundingbox.maxY, this.boundingBox.minZ + 1));
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < this.boundingBox.getXSize(); k = k + 4)
|
||||
{
|
||||
k = k + rand.zrange(this.boundingBox.getXSize());
|
||||
|
||||
if (k + 3 > this.boundingBox.getXSize())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
StructureComponent structurecomponent1 = StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX + k, this.boundingBox.minY + rand.zrange(j) + 1, this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
|
||||
if (structurecomponent1 != null)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox1 = structurecomponent1.getBoundingBox();
|
||||
this.roomsLinkedToTheRoom.add(new StructureBoundingBox(structureboundingbox1.minX, structureboundingbox1.minY, this.boundingBox.maxZ - 1, structureboundingbox1.maxX, structureboundingbox1.maxY, this.boundingBox.maxZ));
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < this.boundingBox.getZSize(); k = k + 4)
|
||||
{
|
||||
k = k + rand.zrange(this.boundingBox.getZSize());
|
||||
|
||||
if (k + 3 > this.boundingBox.getZSize())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
StructureComponent structurecomponent2 = StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY + rand.zrange(j) + 1, this.boundingBox.minZ + k, Facing.WEST, i);
|
||||
|
||||
if (structurecomponent2 != null)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox2 = structurecomponent2.getBoundingBox();
|
||||
this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.minX, structureboundingbox2.minY, structureboundingbox2.minZ, this.boundingBox.minX + 1, structureboundingbox2.maxY, structureboundingbox2.maxZ));
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < this.boundingBox.getZSize(); k = k + 4)
|
||||
{
|
||||
k = k + rand.zrange(this.boundingBox.getZSize());
|
||||
|
||||
if (k + 3 > this.boundingBox.getZSize())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
StructureComponent structurecomponent3 = StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY + rand.zrange(j) + 1, this.boundingBox.minZ + k, Facing.EAST, i);
|
||||
|
||||
if (structurecomponent3 != null)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox3 = structurecomponent3.getBoundingBox();
|
||||
this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.maxX - 1, structureboundingbox3.minY, structureboundingbox3.minZ, this.boundingBox.maxX, structureboundingbox3.maxY, structureboundingbox3.maxZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
|
||||
{
|
||||
if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.minY, this.boundingBox.maxZ, Blocks.dirt.getState(), Blocks.air.getState(), true);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY + 1, this.boundingBox.minZ, this.boundingBox.maxX, Math.min(this.boundingBox.minY + 3, this.boundingBox.maxY), this.boundingBox.maxZ, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
|
||||
for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom)
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, structureboundingbox.minX, structureboundingbox.maxY - 2, structureboundingbox.minZ, structureboundingbox.maxX, structureboundingbox.maxY, structureboundingbox.maxZ, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
|
||||
this.randomlyRareFillWithBlocks(worldIn, structureBoundingBoxIn, this.boundingBox.minX, this.boundingBox.minY + 4, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air.getState(), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void func_181138_a(int p_181138_1_, int p_181138_2_, int p_181138_3_)
|
||||
{
|
||||
super.func_181138_a(p_181138_1_, p_181138_2_, p_181138_3_);
|
||||
|
||||
for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom)
|
||||
{
|
||||
structureboundingbox.offset(p_181138_1_, p_181138_2_, p_181138_3_);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (StructureBoundingBox structureboundingbox : this.roomsLinkedToTheRoom)
|
||||
{
|
||||
nbttaglist.appendTag(structureboundingbox.toNBTTagIntArray());
|
||||
}
|
||||
|
||||
tagCompound.setTag("Entrances", nbttaglist);
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
NBTTagList nbttaglist = tagCompound.getTagList("Entrances", 11);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
this.roomsLinkedToTheRoom.add(new StructureBoundingBox(nbttaglist.getIntArrayAt(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Stairs extends StructureComponent
|
||||
{
|
||||
public Stairs()
|
||||
{
|
||||
}
|
||||
|
||||
public Stairs(int type, Random rand, StructureBoundingBox structurebb, Facing facing)
|
||||
{
|
||||
super(type);
|
||||
this.coordBaseMode = facing;
|
||||
this.boundingBox = structurebb;
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
}
|
||||
|
||||
public static StructureBoundingBox func_175812_a(List<StructureComponent> listIn, Random rand, int x, int y, int z, Facing facing)
|
||||
{
|
||||
StructureBoundingBox structureboundingbox = new StructureBoundingBox(x, y - 5, z, x, y + 2, z);
|
||||
|
||||
switch (facing)
|
||||
{
|
||||
case NORTH:
|
||||
structureboundingbox.maxX = x + 2;
|
||||
structureboundingbox.minZ = z - 8;
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
structureboundingbox.maxX = x + 2;
|
||||
structureboundingbox.maxZ = z + 8;
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
structureboundingbox.minX = x - 8;
|
||||
structureboundingbox.maxZ = z + 2;
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
structureboundingbox.maxX = x + 8;
|
||||
structureboundingbox.maxZ = z + 2;
|
||||
}
|
||||
|
||||
return StructureComponent.findIntersecting(listIn, structureboundingbox) != null ? null : structureboundingbox;
|
||||
}
|
||||
|
||||
public void buildComponent(StructureComponent componentIn, List<StructureComponent> listIn, Random rand)
|
||||
{
|
||||
int i = this.getComponentType();
|
||||
|
||||
if (this.coordBaseMode != null)
|
||||
{
|
||||
switch (this.coordBaseMode)
|
||||
{
|
||||
case NORTH:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, Facing.NORTH, i);
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.maxZ + 1, Facing.SOUTH, i);
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, Facing.WEST, i);
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
StructureMineshaft.func_175890_b(componentIn, listIn, rand, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, Facing.EAST, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
|
||||
{
|
||||
if (this.isLiquidInStructureBoundingBox(worldIn, structureBoundingBoxIn))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5, 0, 2, 7, 1, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 7, 2, 2, 8, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5 - i - (i < 4 ? 1 : 0), 2 + i, 2, 7 - i, 2 + i, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
java/src/game/worldgen/structure/StructureMineshaftStart.java
Executable file
21
java/src/game/worldgen/structure/StructureMineshaftStart.java
Executable file
|
@ -0,0 +1,21 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import game.rng.Random;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class StructureMineshaftStart extends StructureStart
|
||||
{
|
||||
public StructureMineshaftStart()
|
||||
{
|
||||
}
|
||||
|
||||
public StructureMineshaftStart(WorldServer worldIn, Random rand, int chunkX, int chunkZ)
|
||||
{
|
||||
super(chunkX, chunkZ);
|
||||
StructureMineshaft.Room structuremineshaftpieces$room = new StructureMineshaft.Room(0, rand, (chunkX << 4) + 2, (chunkZ << 4) + 2);
|
||||
this.components.add(structuremineshaftpieces$room);
|
||||
structuremineshaftpieces$room.buildComponent(structuremineshaftpieces$room, this.components, rand);
|
||||
this.updateBoundingBox();
|
||||
this.markAvailableHeight(worldIn, rand, 10);
|
||||
}
|
||||
}
|
694
java/src/game/worldgen/structure/StructureScattered.java
Executable file
694
java/src/game/worldgen/structure/StructureScattered.java
Executable file
|
@ -0,0 +1,694 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import game.block.BlockFlower;
|
||||
import game.block.BlockFlowerPot;
|
||||
import game.block.BlockLever;
|
||||
import game.block.BlockSandStone;
|
||||
import game.block.BlockStoneBrick;
|
||||
import game.block.BlockTripWire;
|
||||
import game.block.BlockTripWireHook;
|
||||
import game.color.DyeColor;
|
||||
import game.entity.npc.EntityMage;
|
||||
import game.init.Blocks;
|
||||
import game.init.Config;
|
||||
import game.init.Items;
|
||||
import game.item.RngLoot;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.WorldServer;
|
||||
import game.worldgen.LootConstants;
|
||||
|
||||
public class StructureScattered
|
||||
{
|
||||
public static void registerScatteredFeaturePieces()
|
||||
{
|
||||
MapGenStructureIO.registerStructureComponent(StructureScattered.DesertPyramid.class, "TeDP");
|
||||
MapGenStructureIO.registerStructureComponent(StructureScattered.JunglePyramid.class, "TeJP");
|
||||
MapGenStructureIO.registerStructureComponent(StructureScattered.SwampHut.class, "TeSH");
|
||||
}
|
||||
|
||||
public static class DesertPyramid extends StructureScattered.Feature
|
||||
{
|
||||
private boolean[] hasPlacedChest = new boolean[4];
|
||||
public DesertPyramid()
|
||||
{
|
||||
}
|
||||
|
||||
public DesertPyramid(Random p_i2062_1_, int p_i2062_2_, int p_i2062_3_)
|
||||
{
|
||||
super(p_i2062_1_, p_i2062_2_, 64, p_i2062_3_, 21, 15, 21);
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeStructureToNBT(tagCompound);
|
||||
tagCompound.setBoolean("hasPlacedChest0", this.hasPlacedChest[0]);
|
||||
tagCompound.setBoolean("hasPlacedChest1", this.hasPlacedChest[1]);
|
||||
tagCompound.setBoolean("hasPlacedChest2", this.hasPlacedChest[2]);
|
||||
tagCompound.setBoolean("hasPlacedChest3", this.hasPlacedChest[3]);
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readStructureFromNBT(tagCompound);
|
||||
this.hasPlacedChest[0] = tagCompound.getBoolean("hasPlacedChest0");
|
||||
this.hasPlacedChest[1] = tagCompound.getBoolean("hasPlacedChest1");
|
||||
this.hasPlacedChest[2] = tagCompound.getBoolean("hasPlacedChest2");
|
||||
this.hasPlacedChest[3] = tagCompound.getBoolean("hasPlacedChest3");
|
||||
}
|
||||
|
||||
public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, -4, 0, this.scatteredFeatureSizeX - 1, 0, this.scatteredFeatureSizeZ - 1, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
|
||||
for (int i = 1; i <= 9; ++i)
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, i, i, i, this.scatteredFeatureSizeX - 1 - i, i, this.scatteredFeatureSizeZ - 1 - i, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, i + 1, i, i + 1, this.scatteredFeatureSizeX - 2 - i, i, this.scatteredFeatureSizeZ - 2 - i, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
}
|
||||
|
||||
for (int j2 = 0; j2 < this.scatteredFeatureSizeX; ++j2)
|
||||
{
|
||||
for (int j = 0; j < this.scatteredFeatureSizeZ; ++j)
|
||||
{
|
||||
int k = -5;
|
||||
this.replaceAirAndLiquidDownwards(worldIn, Blocks.sandstone.getState(), j2, k, j, structureBoundingBoxIn);
|
||||
}
|
||||
}
|
||||
|
||||
int k2 = this.getMetadataWithOffset(Blocks.sandstone_stairs, 3);
|
||||
int l2 = this.getMetadataWithOffset(Blocks.sandstone_stairs, 2);
|
||||
int i3 = this.getMetadataWithOffset(Blocks.sandstone_stairs, 0);
|
||||
int l = this.getMetadataWithOffset(Blocks.sandstone_stairs, 1);
|
||||
int i1 = ~DyeColor.ORANGE.getDyeDamage() & 15;
|
||||
int j1 = ~DyeColor.BLUE.getDyeDamage() & 15;
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 4, 9, 4, Blocks.sandstone.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 10, 1, 3, 10, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), 2, 10, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l2), 2, 10, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(i3), 0, 10, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l), 4, 10, 2, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 5, 0, 0, this.scatteredFeatureSizeX - 1, 9, 4, Blocks.sandstone.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 4, 10, 1, this.scatteredFeatureSizeX - 2, 10, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), this.scatteredFeatureSizeX - 3, 10, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l2), this.scatteredFeatureSizeX - 3, 10, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(i3), this.scatteredFeatureSizeX - 5, 10, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l), this.scatteredFeatureSizeX - 1, 10, 2, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, 0, 0, 12, 4, 4, Blocks.sandstone.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 9, 1, 0, 11, 3, 4, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 9, 1, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 9, 2, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 9, 3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 10, 3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 11, 3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 11, 2, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 11, 1, 1, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 1, 1, 8, 3, 3, Blocks.sandstone.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 1, 2, 8, 2, 2, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 12, 1, 1, 16, 3, 3, Blocks.sandstone.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 12, 1, 2, 16, 2, 2, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 4, 5, this.scatteredFeatureSizeX - 6, 4, this.scatteredFeatureSizeZ - 6, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 9, 4, 9, 11, 4, 11, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, 1, 8, 8, 3, 8, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 12, 1, 8, 12, 3, 8, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, 1, 12, 8, 3, 12, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 12, 1, 12, 12, 3, 12, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 5, 4, 4, 11, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 5, 1, 5, this.scatteredFeatureSizeX - 2, 4, 11, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 7, 9, 6, 7, 11, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 7, 7, 9, this.scatteredFeatureSizeX - 7, 7, 11, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 5, 9, 5, 7, 11, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 6, 5, 9, this.scatteredFeatureSizeX - 6, 7, 11, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 5, 5, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 5, 6, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 6, 6, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), this.scatteredFeatureSizeX - 6, 5, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), this.scatteredFeatureSizeX - 6, 6, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), this.scatteredFeatureSizeX - 7, 6, 10, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 4, 4, 2, 6, 4, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 3, 4, 4, this.scatteredFeatureSizeX - 3, 6, 4, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), 2, 4, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), 2, 3, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), this.scatteredFeatureSizeX - 3, 4, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(k2), this.scatteredFeatureSizeX - 3, 3, 4, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 3, 2, 2, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 3, 1, 3, this.scatteredFeatureSizeX - 2, 2, 3, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getState(), 1, 1, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getState(), this.scatteredFeatureSizeX - 2, 1, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_slab.getState(), 1, 2, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_slab.getState(), this.scatteredFeatureSizeX - 2, 2, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(l), 2, 1, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone_stairs.getStateFromMeta(i3), this.scatteredFeatureSizeX - 3, 1, 2, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 3, 5, 4, 3, 18, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 5, 3, 5, this.scatteredFeatureSizeX - 5, 3, 17, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 3, 1, 5, 4, 2, 16, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, this.scatteredFeatureSizeX - 6, 1, 5, this.scatteredFeatureSizeX - 5, 2, 16, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
|
||||
for (int k1 = 5; k1 <= 17; k1 += 2)
|
||||
{
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 4, 1, k1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), 4, 2, k1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), this.scatteredFeatureSizeX - 5, 1, k1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), this.scatteredFeatureSizeX - 5, 2, k1, structureBoundingBoxIn);
|
||||
}
|
||||
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 10, 0, 7, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 10, 0, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 9, 0, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 11, 0, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 8, 0, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 12, 0, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 7, 0, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 13, 0, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 9, 0, 11, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 11, 0, 11, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 10, 0, 12, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 10, 0, 13, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(j1), 10, 0, 10, structureBoundingBoxIn);
|
||||
|
||||
for (int j3 = 0; j3 <= this.scatteredFeatureSizeX - 1; j3 += this.scatteredFeatureSizeX - 1)
|
||||
{
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 2, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 2, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 2, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 3, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 3, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 4, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), j3, 4, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 4, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 5, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 5, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 5, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 6, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), j3, 6, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 6, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 7, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 7, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), j3, 7, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 8, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 8, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), j3, 8, 3, structureBoundingBoxIn);
|
||||
}
|
||||
|
||||
for (int k3 = 2; k3 <= this.scatteredFeatureSizeX - 3; k3 += this.scatteredFeatureSizeX - 3 - 2)
|
||||
{
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 - 1, 2, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3, 2, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 + 1, 2, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 - 1, 3, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3, 3, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 + 1, 3, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3 - 1, 4, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), k3, 4, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3 + 1, 4, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 - 1, 5, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3, 5, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 + 1, 5, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3 - 1, 6, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), k3, 6, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3 + 1, 6, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3 - 1, 7, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3, 7, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), k3 + 1, 7, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 - 1, 8, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3, 8, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), k3 + 1, 8, 0, structureBoundingBoxIn);
|
||||
}
|
||||
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, 4, 0, 12, 6, 0, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 8, 6, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 12, 6, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 9, 5, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), 10, 5, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stained_hardened_clay.getStateFromMeta(i1), 11, 5, 0, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, -14, 8, 12, -11, 12, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, -10, 8, 12, -10, 12, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, -9, 8, 12, -9, 12, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 8, -8, 8, 12, -1, 12, Blocks.sandstone.getState(), Blocks.sandstone.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 9, -11, 9, 11, -1, 11, Blocks.air.getState(), Blocks.air.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.stone_pressure_plate.getState(), 10, -11, 10, structureBoundingBoxIn);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 9, -13, 9, 11, -13, 11, Blocks.tnt.getState(), Blocks.air.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 8, -11, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 8, -10, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), 7, -10, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 7, -11, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 12, -11, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 12, -10, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), 13, -10, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 13, -11, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 10, -11, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 10, -10, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), 10, -10, 7, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 10, -11, 7, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 10, -11, 12, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 10, -10, 12, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.CHISELED.getMetadata()), 10, -10, 13, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sandstone.getStateFromMeta(BlockSandStone.EnumType.SMOOTH.getMetadata()), 10, -11, 13, structureBoundingBoxIn);
|
||||
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
|
||||
{
|
||||
if (!this.hasPlacedChest[enumfacing.getHorizontalIndex()])
|
||||
{
|
||||
int l1 = enumfacing.getFrontOffsetX() * 2;
|
||||
int i2 = enumfacing.getFrontOffsetZ() * 2;
|
||||
this.hasPlacedChest[enumfacing.getHorizontalIndex()] = this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 10 + l1, -11, 10 + i2, RngLoot.addToList(LootConstants.DESERT_PYRAMID, Items.enchanted_book.getRandom(randomIn)), 2 + randomIn.zrange(5));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class Feature extends StructureComponent
|
||||
{
|
||||
protected int scatteredFeatureSizeX;
|
||||
protected int scatteredFeatureSizeY;
|
||||
protected int scatteredFeatureSizeZ;
|
||||
protected int field_74936_d = -1;
|
||||
|
||||
public Feature()
|
||||
{
|
||||
}
|
||||
|
||||
protected Feature(Random p_i2065_1_, int p_i2065_2_, int p_i2065_3_, int p_i2065_4_, int p_i2065_5_, int p_i2065_6_, int p_i2065_7_)
|
||||
{
|
||||
super(0);
|
||||
this.scatteredFeatureSizeX = p_i2065_5_;
|
||||
this.scatteredFeatureSizeY = p_i2065_6_;
|
||||
this.scatteredFeatureSizeZ = p_i2065_7_;
|
||||
this.coordBaseMode = Facing.Plane.HORIZONTAL.random(p_i2065_1_);
|
||||
|
||||
switch (this.coordBaseMode)
|
||||
{
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
this.boundingBox = new StructureBoundingBox(p_i2065_2_, p_i2065_3_, p_i2065_4_, p_i2065_2_ + p_i2065_5_ - 1, p_i2065_3_ + p_i2065_6_ - 1, p_i2065_4_ + p_i2065_7_ - 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.boundingBox = new StructureBoundingBox(p_i2065_2_, p_i2065_3_, p_i2065_4_, p_i2065_2_ + p_i2065_7_ - 1, p_i2065_3_ + p_i2065_6_ - 1, p_i2065_4_ + p_i2065_5_ - 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
tagCompound.setInteger("Width", this.scatteredFeatureSizeX);
|
||||
tagCompound.setInteger("Height", this.scatteredFeatureSizeY);
|
||||
tagCompound.setInteger("Depth", this.scatteredFeatureSizeZ);
|
||||
tagCompound.setInteger("HPos", this.field_74936_d);
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
this.scatteredFeatureSizeX = tagCompound.getInteger("Width");
|
||||
this.scatteredFeatureSizeY = tagCompound.getInteger("Height");
|
||||
this.scatteredFeatureSizeZ = tagCompound.getInteger("Depth");
|
||||
this.field_74936_d = tagCompound.getInteger("HPos");
|
||||
}
|
||||
|
||||
protected boolean func_74935_a(WorldServer worldIn, StructureBoundingBox p_74935_2_, int p_74935_3_)
|
||||
{
|
||||
if (this.field_74936_d >= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int k = this.boundingBox.minZ; k <= this.boundingBox.maxZ; ++k)
|
||||
{
|
||||
for (int l = this.boundingBox.minX; l <= this.boundingBox.maxX; ++l)
|
||||
{
|
||||
blockpos$mutableblockpos.set(l, 64, k);
|
||||
|
||||
if (p_74935_2_.isVecInside(blockpos$mutableblockpos))
|
||||
{
|
||||
i += Math.max(worldIn.getTopSolidOrLiquidBlock(blockpos$mutableblockpos).getY(), worldIn.getSeaLevel());
|
||||
++j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_74936_d = i / j;
|
||||
this.boundingBox.offset(0, this.field_74936_d - this.boundingBox.minY + p_74935_3_, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class JunglePyramid extends StructureScattered.Feature
|
||||
{
|
||||
private boolean placedMainChest;
|
||||
private boolean placedHiddenChest;
|
||||
private boolean placedTrap1;
|
||||
private boolean placedTrap2;
|
||||
private static StructureScattered.JunglePyramid.Stones junglePyramidsRandomScatteredStones = new StructureScattered.JunglePyramid.Stones();
|
||||
|
||||
public JunglePyramid()
|
||||
{
|
||||
}
|
||||
|
||||
public JunglePyramid(Random p_i2064_1_, int p_i2064_2_, int p_i2064_3_)
|
||||
{
|
||||
super(p_i2064_1_, p_i2064_2_, 64, p_i2064_3_, 12, 10, 15);
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeStructureToNBT(tagCompound);
|
||||
tagCompound.setBoolean("placedMainChest", this.placedMainChest);
|
||||
tagCompound.setBoolean("placedHiddenChest", this.placedHiddenChest);
|
||||
tagCompound.setBoolean("placedTrap1", this.placedTrap1);
|
||||
tagCompound.setBoolean("placedTrap2", this.placedTrap2);
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readStructureFromNBT(tagCompound);
|
||||
this.placedMainChest = tagCompound.getBoolean("placedMainChest");
|
||||
this.placedHiddenChest = tagCompound.getBoolean("placedHiddenChest");
|
||||
this.placedTrap1 = tagCompound.getBoolean("placedTrap1");
|
||||
this.placedTrap2 = tagCompound.getBoolean("placedTrap2");
|
||||
}
|
||||
|
||||
public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
|
||||
{
|
||||
if (!this.func_74935_a(worldIn, structureBoundingBoxIn, 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 3);
|
||||
int j = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 2);
|
||||
int k = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 0);
|
||||
int l = this.getMetadataWithOffset(Blocks.cobblestone_stairs, 1);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 0, -4, 0, this.scatteredFeatureSizeX - 1, 0, this.scatteredFeatureSizeZ - 1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 1, 2, 9, 2, 2, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 1, 12, 9, 2, 12, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 1, 3, 2, 2, 11, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 9, 1, 3, 9, 2, 11, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 1, 3, 1, 10, 6, 1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 1, 3, 13, 10, 6, 13, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 1, 3, 2, 1, 6, 12, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 10, 3, 2, 10, 6, 12, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 3, 2, 9, 3, 12, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 6, 2, 9, 6, 12, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 3, 7, 3, 8, 7, 11, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 8, 4, 7, 8, 10, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 3, 1, 3, 8, 2, 11);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 4, 3, 6, 7, 3, 9);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 2, 4, 2, 9, 5, 12);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 4, 6, 5, 7, 6, 9);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 5, 7, 6, 6, 7, 8);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 5, 1, 2, 6, 2, 2);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 5, 2, 12, 6, 2, 12);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 5, 5, 1, 6, 5, 1);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 5, 5, 13, 6, 5, 13);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 1, 5, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 10, 5, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 1, 5, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 10, 5, 9, structureBoundingBoxIn);
|
||||
|
||||
for (int i1 = 0; i1 <= 14; i1 += 14)
|
||||
{
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 4, i1, 2, 5, i1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 4, i1, 4, 5, i1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, 4, i1, 7, 5, i1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 9, 4, i1, 9, 5, i1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
}
|
||||
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 5, 6, 0, 6, 6, 0, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
|
||||
for (int k1 = 0; k1 <= 11; k1 += 11)
|
||||
{
|
||||
for (int j1 = 2; j1 <= 12; j1 += 2)
|
||||
{
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, k1, 4, j1, k1, 5, j1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
}
|
||||
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, k1, 6, 5, k1, 6, 5, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, k1, 6, 9, k1, 6, 9, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
}
|
||||
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 7, 2, 2, 9, 2, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 9, 7, 2, 9, 9, 2, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, 7, 12, 2, 9, 12, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 9, 7, 12, 9, 9, 12, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 9, 4, 4, 9, 4, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, 9, 4, 7, 9, 4, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 9, 10, 4, 9, 10, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, 9, 10, 7, 9, 10, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 5, 9, 7, 6, 9, 7, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 5, 9, 6, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 6, 9, 6, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 5, 9, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 6, 9, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 0, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 5, 0, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 6, 0, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 0, 0, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 1, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 2, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 4, 3, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 1, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 2, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(i), 7, 3, 10, structureBoundingBoxIn);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 1, 9, 4, 1, 9, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, 1, 9, 7, 1, 9, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 4, 1, 10, 7, 2, 10, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 5, 4, 5, 6, 4, 5, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(k), 4, 4, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(l), 7, 4, 5, structureBoundingBoxIn);
|
||||
|
||||
for (int l1 = 0; l1 < 4; ++l1)
|
||||
{
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 5, 0 - l1, 6 + l1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cobblestone_stairs.getStateFromMeta(j), 6, 0 - l1, 6 + l1, structureBoundingBoxIn);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 5, 0 - l1, 7 + l1, 6, 0 - l1, 9 + l1);
|
||||
}
|
||||
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 1, -3, 12, 10, -1, 13);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 1, -3, 1, 3, -1, 13);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 1, -3, 1, 9, -1, 5);
|
||||
|
||||
for (int i2 = 1; i2 <= 13; i2 += 2)
|
||||
{
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 1, -3, i2, 1, -2, i2, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
}
|
||||
|
||||
for (int j2 = 2; j2 <= 12; j2 += 2)
|
||||
{
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 1, -1, j2, 3, -1, j2, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
}
|
||||
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 2, -2, 1, 5, -2, 1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 7, -2, 1, 9, -2, 1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 6, -3, 1, 6, -3, 1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 6, -1, 1, 6, -1, 1, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.EAST.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 1, -3, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.WEST.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 4, -3, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 2, -3, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 3, -3, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 7, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 6, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 5, -3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 4, -3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 3, -3, 1, structureBoundingBoxIn);
|
||||
|
||||
if (!this.placedTrap1)
|
||||
{
|
||||
this.placedTrap1 = this.generateDispenserContents(worldIn, structureBoundingBoxIn, randomIn, 3, -2, 1, Facing.NORTH.getIndex(), LootConstants.JUNGLE_TRAP, 2);
|
||||
}
|
||||
|
||||
this.setBlockState(worldIn, Blocks.vine.getStateFromMeta(15), 3, -2, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.NORTH.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 7, -3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.tripwire_hook.getStateFromMeta(this.getMetadataWithOffset(Blocks.tripwire_hook, Facing.SOUTH.getHorizontalIndex())).withProperty(BlockTripWireHook.ATTACHED, Boolean.valueOf(true)), 7, -3, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 7, -3, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 7, -3, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.string.getState().withProperty(BlockTripWire.ATTACHED, Boolean.valueOf(true)), 7, -3, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 8, -3, 6, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 9, -3, 6, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 9, -3, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 9, -3, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 9, -2, 4, structureBoundingBoxIn);
|
||||
|
||||
if (!this.placedTrap2)
|
||||
{
|
||||
this.placedTrap2 = this.generateDispenserContents(worldIn, structureBoundingBoxIn, randomIn, 9, -2, 3, Facing.WEST.getIndex(), LootConstants.JUNGLE_TRAP, 2);
|
||||
}
|
||||
|
||||
this.setBlockState(worldIn, Blocks.vine.getStateFromMeta(15), 8, -1, 3, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.vine.getStateFromMeta(15), 8, -2, 3, structureBoundingBoxIn);
|
||||
|
||||
if (!this.placedMainChest)
|
||||
{
|
||||
this.placedMainChest = this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 8, -3, 3, RngLoot.addToList(LootConstants.JUNGLE_MAIN, Items.enchanted_book.getRandom(randomIn)), 2 + randomIn.zrange(5));
|
||||
}
|
||||
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 9, -3, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 8, -3, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 4, -3, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 5, -2, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 5, -1, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 6, -3, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 7, -2, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 7, -1, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 8, -3, 5, structureBoundingBoxIn);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 9, -1, 1, 9, -1, 5, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithAir(worldIn, structureBoundingBoxIn, 8, -3, 8, 10, -1, 10);
|
||||
this.setBlockState(worldIn, Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.CHISELED_META), 8, -2, 11, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.CHISELED_META), 9, -2, 11, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.CHISELED_META), 10, -2, 11, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 8, -2, 12, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 9, -2, 12, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 10, -2, 12, structureBoundingBoxIn);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 8, -3, 8, 8, -3, 10, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 10, -3, 8, 10, -3, 10, false, randomIn, junglePyramidsRandomScatteredStones);
|
||||
this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 10, -2, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 8, -2, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 8, -2, 10, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.redstone.getState(), 10, -1, 9, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sticky_piston.getStateFromMeta(Facing.UP.getIndex()), 9, -2, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sticky_piston.getStateFromMeta(this.getMetadataWithOffset(Blocks.sticky_piston, Facing.WEST.getIndex())), 10, -2, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.sticky_piston.getStateFromMeta(this.getMetadataWithOffset(Blocks.sticky_piston, Facing.WEST.getIndex())), 10, -1, 8, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.repeater.getStateFromMeta(this.getMetadataWithOffset(Blocks.repeater, Facing.NORTH.getHorizontalIndex())), 10, -2, 10, structureBoundingBoxIn);
|
||||
|
||||
if (!this.placedHiddenChest)
|
||||
{
|
||||
this.placedHiddenChest = this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 9, -3, 10, RngLoot.addToList(LootConstants.JUNGLE_MAIN, Items.enchanted_book.getRandom(randomIn)), 2 + randomIn.zrange(5));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static class Stones extends StructureComponent.BlockSelector
|
||||
{
|
||||
private Stones()
|
||||
{
|
||||
}
|
||||
|
||||
public void selectBlocks(Random rand, int x, int y, int z, boolean p_75062_5_)
|
||||
{
|
||||
if (rand.floatv() < 0.4F)
|
||||
{
|
||||
this.blockstate = Blocks.cobblestone.getState();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.blockstate = Blocks.mossy_cobblestone.getState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SwampHut extends StructureScattered.Feature
|
||||
{
|
||||
private boolean hasMage;
|
||||
|
||||
public SwampHut()
|
||||
{
|
||||
}
|
||||
|
||||
public SwampHut(Random p_i2066_1_, int p_i2066_2_, int p_i2066_3_)
|
||||
{
|
||||
super(p_i2066_1_, p_i2066_2_, 64, p_i2066_3_, 7, 7, 9);
|
||||
}
|
||||
|
||||
protected void writeStructureToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.writeStructureToNBT(tagCompound);
|
||||
tagCompound.setBoolean("Mage", this.hasMage);
|
||||
}
|
||||
|
||||
protected void readStructureFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
super.readStructureFromNBT(tagCompound);
|
||||
this.hasMage = tagCompound.getBoolean("Mage");
|
||||
}
|
||||
|
||||
public boolean addComponentParts(WorldServer worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn)
|
||||
{
|
||||
if (!this.func_74935_a(worldIn, structureBoundingBoxIn, 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 5, 1, 7, Blocks.spruce_planks.getState(), Blocks.spruce_planks.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 4, 2, 5, 4, 7, Blocks.spruce_planks.getState(), Blocks.spruce_planks.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 1, 0, 4, 1, 0, Blocks.spruce_planks.getState(), Blocks.spruce_planks.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 2, 2, 3, 3, 2, Blocks.spruce_planks.getState(), Blocks.spruce_planks.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 2, 3, 1, 3, 6, Blocks.spruce_planks.getState(), Blocks.spruce_planks.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 2, 3, 5, 3, 6, Blocks.spruce_planks.getState(), Blocks.spruce_planks.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 2, 7, 4, 3, 7, Blocks.spruce_planks.getState(), Blocks.spruce_planks.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 2, 1, 3, 2, Blocks.oak_log.getState(), Blocks.oak_log.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 0, 2, 5, 3, 2, Blocks.oak_log.getState(), Blocks.oak_log.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 0, 7, 1, 3, 7, Blocks.oak_log.getState(), Blocks.oak_log.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 5, 0, 7, 5, 3, 7, Blocks.oak_log.getState(), Blocks.oak_log.getState(), false);
|
||||
this.setBlockState(worldIn, Blocks.oak_fence.getState(), 2, 3, 2, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.oak_fence.getState(), 3, 3, 7, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 1, 3, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 5, 3, 4, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.air.getState(), 5, 3, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.flower_pot.getState().withProperty(BlockFlowerPot.CONTENTS, 2 + BlockFlower.EnumFlowerType.BLACK_LOTUS.getMeta()), 1, 3, 5, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.crafting_table.getState(), 3, 2, 6, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.cauldron.getState(), 4, 2, 6, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.oak_fence.getState(), 1, 2, 1, structureBoundingBoxIn);
|
||||
this.setBlockState(worldIn, Blocks.oak_fence.getState(), 5, 2, 1, structureBoundingBoxIn);
|
||||
int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3);
|
||||
int j = this.getMetadataWithOffset(Blocks.oak_stairs, 1);
|
||||
int k = this.getMetadataWithOffset(Blocks.oak_stairs, 0);
|
||||
int l = this.getMetadataWithOffset(Blocks.oak_stairs, 2);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 1, 6, 4, 1, Blocks.spruce_stairs.getStateFromMeta(i), Blocks.spruce_stairs.getStateFromMeta(i), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 2, 0, 4, 7, Blocks.spruce_stairs.getStateFromMeta(k), Blocks.spruce_stairs.getStateFromMeta(k), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 4, 2, 6, 4, 7, Blocks.spruce_stairs.getStateFromMeta(j), Blocks.spruce_stairs.getStateFromMeta(j), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 8, 6, 4, 8, Blocks.spruce_stairs.getStateFromMeta(l), Blocks.spruce_stairs.getStateFromMeta(l), false);
|
||||
|
||||
for (int i1 = 2; i1 <= 7; i1 += 5)
|
||||
{
|
||||
for (int j1 = 1; j1 <= 5; j1 += 4)
|
||||
{
|
||||
this.replaceAirAndLiquidDownwards(worldIn, Blocks.oak_log.getState(), j1, -1, i1, structureBoundingBoxIn);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.hasMage && Config.mobs && Config.spawnHutMage)
|
||||
{
|
||||
int l1 = this.getXWithOffset(2, 5);
|
||||
int i2 = this.getYWithOffset(2);
|
||||
int k1 = this.getZWithOffset(2, 5);
|
||||
|
||||
if (structureBoundingBoxIn.isVecInside(new BlockPos(l1, i2, k1)))
|
||||
{
|
||||
this.hasMage = true;
|
||||
EntityMage mage = new EntityMage(worldIn);
|
||||
mage.setLocationAndAngles((double)l1 + 0.5D, (double)i2, (double)k1 + 0.5D, 0.0F, 0.0F);
|
||||
mage.onInitialSpawn(null);
|
||||
worldIn.spawnEntityInWorld(mage);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
188
java/src/game/worldgen/structure/StructureStart.java
Executable file
188
java/src/game/worldgen/structure/StructureStart.java
Executable file
|
@ -0,0 +1,188 @@
|
|||
package game.worldgen.structure;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.nbt.NBTTagList;
|
||||
import game.rng.Random;
|
||||
import game.world.ChunkPos;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public abstract class StructureStart
|
||||
{
|
||||
protected LinkedList<StructureComponent> components = new LinkedList();
|
||||
protected StructureBoundingBox boundingBox;
|
||||
private int chunkPosX;
|
||||
private int chunkPosZ;
|
||||
|
||||
public StructureStart()
|
||||
{
|
||||
}
|
||||
|
||||
public StructureStart(int chunkX, int chunkZ)
|
||||
{
|
||||
this.chunkPosX = chunkX;
|
||||
this.chunkPosZ = chunkZ;
|
||||
}
|
||||
|
||||
public StructureBoundingBox getBoundingBox()
|
||||
{
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
public LinkedList<StructureComponent> getComponents()
|
||||
{
|
||||
return this.components;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps iterating Structure Pieces and spawning them until the checks tell it to stop
|
||||
*/
|
||||
public void generateStructure(WorldServer worldIn, Random rand, StructureBoundingBox structurebb)
|
||||
{
|
||||
Iterator<StructureComponent> iterator = this.components.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
StructureComponent structurecomponent = (StructureComponent)iterator.next();
|
||||
|
||||
if (structurecomponent.getBoundingBox().intersectsWith(structurebb) && !structurecomponent.addComponentParts(worldIn, rand, structurebb))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates total bounding box based on components' bounding boxes and saves it to boundingBox
|
||||
*/
|
||||
protected void updateBoundingBox()
|
||||
{
|
||||
this.boundingBox = StructureBoundingBox.getNewBoundingBox();
|
||||
|
||||
for (StructureComponent structurecomponent : this.components)
|
||||
{
|
||||
this.boundingBox.expandTo(structurecomponent.getBoundingBox());
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeStructureComponentsToNBT(int chunkX, int chunkZ)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("id", MapGenStructureIO.getStructureStartName(this));
|
||||
nbttagcompound.setInteger("ChunkX", chunkX);
|
||||
nbttagcompound.setInteger("ChunkZ", chunkZ);
|
||||
nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray());
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (StructureComponent structurecomponent : this.components)
|
||||
{
|
||||
nbttaglist.appendTag(structurecomponent.createStructureBaseNBT());
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Children", nbttaglist);
|
||||
this.writeToNBT(nbttagcompound);
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
}
|
||||
|
||||
public void readStructureComponentsFromNBT(WorldServer worldIn, NBTTagCompound tagCompound)
|
||||
{
|
||||
this.chunkPosX = tagCompound.getInteger("ChunkX");
|
||||
this.chunkPosZ = tagCompound.getInteger("ChunkZ");
|
||||
|
||||
if (tagCompound.hasKey("BB"))
|
||||
{
|
||||
this.boundingBox = new StructureBoundingBox(tagCompound.getIntArray("BB"));
|
||||
}
|
||||
|
||||
NBTTagList nbttaglist = tagCompound.getTagList("Children", 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
this.components.add(MapGenStructureIO.getStructureComponent(nbttaglist.getCompoundTagAt(i), worldIn));
|
||||
}
|
||||
|
||||
this.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* offsets the structure Bounding Boxes up to a certain height, typically 63 - 10
|
||||
*/
|
||||
protected void markAvailableHeight(WorldServer worldIn, Random rand, int p_75067_3_)
|
||||
{
|
||||
int i = worldIn.getSeaLevel() - p_75067_3_;
|
||||
int j = this.boundingBox.getYSize() + 1;
|
||||
|
||||
if (j < i)
|
||||
{
|
||||
j += rand.zrange(i - j);
|
||||
}
|
||||
|
||||
int k = j - this.boundingBox.maxY;
|
||||
this.boundingBox.offset(0, k, 0);
|
||||
|
||||
for (StructureComponent structurecomponent : this.components)
|
||||
{
|
||||
structurecomponent.func_181138_a(0, k, 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRandomHeight(WorldServer worldIn, Random rand, int p_75070_3_, int p_75070_4_)
|
||||
{
|
||||
int i = p_75070_4_ - p_75070_3_ + 1 - this.boundingBox.getYSize();
|
||||
int j = 1;
|
||||
|
||||
if (i > 1)
|
||||
{
|
||||
j = p_75070_3_ + rand.zrange(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
j = p_75070_3_;
|
||||
}
|
||||
|
||||
int k = j - this.boundingBox.minY;
|
||||
this.boundingBox.offset(0, k, 0);
|
||||
|
||||
for (StructureComponent structurecomponent : this.components)
|
||||
{
|
||||
structurecomponent.func_181138_a(0, k, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* currently only defined for Villages, returns true if Village has more than 2 non-road components
|
||||
*/
|
||||
public boolean isSizeableStructure()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean func_175788_a(ChunkPos pair)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void func_175787_b(ChunkPos pair)
|
||||
{
|
||||
}
|
||||
|
||||
public int getChunkPosX()
|
||||
{
|
||||
return this.chunkPosX;
|
||||
}
|
||||
|
||||
public int getChunkPosZ()
|
||||
{
|
||||
return this.chunkPosZ;
|
||||
}
|
||||
}
|
1660
java/src/game/worldgen/structure/StructureStronghold.java
Executable file
1660
java/src/game/worldgen/structure/StructureStronghold.java
Executable file
File diff suppressed because it is too large
Load diff
1983
java/src/game/worldgen/structure/StructureVillage.java
Executable file
1983
java/src/game/worldgen/structure/StructureVillage.java
Executable file
File diff suppressed because it is too large
Load diff
257
java/src/game/worldgen/tree/WorldGenBaseTree.java
Executable file
257
java/src/game/worldgen/tree/WorldGenBaseTree.java
Executable file
|
@ -0,0 +1,257 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockCocoa;
|
||||
import game.block.BlockLeaves;
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.properties.PropertyBool;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenBaseTree extends WorldGenTree
|
||||
{
|
||||
private static final State defLog = Blocks.oak_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK);
|
||||
private static final State defLeaves = Blocks.oak_leaves.getState(); // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK);
|
||||
|
||||
private final int minTreeHeight;
|
||||
private final boolean vinesGrow;
|
||||
private final State metaWood;
|
||||
private final State metaLeaves;
|
||||
|
||||
public WorldGenBaseTree(boolean notify)
|
||||
{
|
||||
this(notify, 4, defLog, defLeaves, false);
|
||||
}
|
||||
|
||||
public WorldGenBaseTree(boolean notify, State log, State leaves)
|
||||
{
|
||||
this(notify, 4, log, leaves, false);
|
||||
}
|
||||
|
||||
public WorldGenBaseTree(boolean notify, int minHeight, State log, State leaves, boolean vines)
|
||||
{
|
||||
super(notify);
|
||||
this.minTreeHeight = minHeight;
|
||||
this.metaWood = log;
|
||||
this.metaLeaves = leaves.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
this.vinesGrow = vines;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + this.minTreeHeight;
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block1 == Blocks.grass || block1 == Blocks.dirt || block1 == Blocks.farmland || block1 == Blocks.tian_soil) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
int k2 = 3;
|
||||
int l2 = 0;
|
||||
|
||||
for (int i3 = position.getY() - k2 + i; i3 <= position.getY() + i; ++i3)
|
||||
{
|
||||
int i4 = i3 - (position.getY() + i);
|
||||
int j1 = l2 + 1 - i4 / 2;
|
||||
|
||||
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1)
|
||||
{
|
||||
int l1 = k1 - position.getX();
|
||||
|
||||
for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2)
|
||||
{
|
||||
int j2 = i2 - position.getZ();
|
||||
|
||||
if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.zrange(2) != 0 && i4 != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(k1, i3, i2);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves || block.getMaterial() == Material.vine)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j3 = 0; j3 < i; ++j3)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(j3)).getBlock();
|
||||
|
||||
if (block2.getMaterial() == Material.air || block2.getMaterial() == Material.leaves || block2.getMaterial() == Material.vine)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
|
||||
|
||||
if (this.vinesGrow && j3 > 0)
|
||||
{
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(-1, j3, 0)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(-1, j3, 0), BlockVine.EAST);
|
||||
}
|
||||
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(1, j3, 0)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(1, j3, 0), BlockVine.WEST);
|
||||
}
|
||||
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(0, j3, -1)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(0, j3, -1), BlockVine.SOUTH);
|
||||
}
|
||||
|
||||
if (rand.zrange(3) > 0 && worldIn.isAirBlock(position.add(0, j3, 1)))
|
||||
{
|
||||
this.func_181651_a(worldIn, position.add(0, j3, 1), BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.vinesGrow)
|
||||
{
|
||||
for (int k3 = position.getY() - 3 + i; k3 <= position.getY() + i; ++k3)
|
||||
{
|
||||
int j4 = k3 - (position.getY() + i);
|
||||
int k4 = 2 - j4 / 2;
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l4 = position.getX() - k4; l4 <= position.getX() + k4; ++l4)
|
||||
{
|
||||
for (int i5 = position.getZ() - k4; i5 <= position.getZ() + k4; ++i5)
|
||||
{
|
||||
blockpos$mutableblockpos1.set(l4, k3, i5);
|
||||
|
||||
if (worldIn.getState(blockpos$mutableblockpos1).getBlock().getMaterial() == Material.leaves)
|
||||
{
|
||||
BlockPos blockpos2 = blockpos$mutableblockpos1.west();
|
||||
BlockPos blockpos3 = blockpos$mutableblockpos1.east();
|
||||
BlockPos blockpos4 = blockpos$mutableblockpos1.north();
|
||||
BlockPos blockpos1 = blockpos$mutableblockpos1.south();
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos2).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos2, BlockVine.EAST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos3).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos3, BlockVine.WEST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos4).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos4, BlockVine.SOUTH);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos1).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181650_b(worldIn, blockpos1, BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.zrange(5) == 0 && i > 5)
|
||||
{
|
||||
for (int l3 = 0; l3 < 2; ++l3)
|
||||
{
|
||||
for (Facing enumfacing : Facing.Plane.HORIZONTAL)
|
||||
{
|
||||
if (rand.zrange(4 - l3) == 0)
|
||||
{
|
||||
Facing enumfacing1 = enumfacing.getOpposite();
|
||||
this.func_181652_a(worldIn, rand.zrange(3), position.add(enumfacing1.getFrontOffsetX(), i - 5 + l3, enumfacing1.getFrontOffsetZ()), enumfacing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181652_a(WorldServer p_181652_1_, int p_181652_2_, BlockPos p_181652_3_, Facing p_181652_4_)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181652_1_, p_181652_3_, Blocks.cocoa.getState().withProperty(BlockCocoa.AGE, p_181652_2_).withProperty(BlockCocoa.FACING, p_181652_4_));
|
||||
}
|
||||
|
||||
private void func_181651_a(WorldServer p_181651_1_, BlockPos p_181651_2_, PropertyBool p_181651_3_)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181651_1_, p_181651_2_, Blocks.vine.getState().withProperty(p_181651_3_, Boolean.valueOf(true)));
|
||||
}
|
||||
|
||||
private void func_181650_b(WorldServer p_181650_1_, BlockPos p_181650_2_, PropertyBool p_181650_3_)
|
||||
{
|
||||
this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_);
|
||||
int i = 4;
|
||||
|
||||
for (p_181650_2_ = p_181650_2_.down(); p_181650_1_.getState(p_181650_2_).getBlock().getMaterial() == Material.air && i > 0; --i)
|
||||
{
|
||||
this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_);
|
||||
p_181650_2_ = p_181650_2_.down();
|
||||
}
|
||||
}
|
||||
}
|
397
java/src/game/worldgen/tree/WorldGenBigTree.java
Executable file
397
java/src/game/worldgen/tree/WorldGenBigTree.java
Executable file
|
@ -0,0 +1,397 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.block.BlockLog;
|
||||
import game.collect.Lists;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenBigTree extends WorldGenTree
|
||||
{
|
||||
private final State leavesBase;
|
||||
private final State logBase;
|
||||
|
||||
private Random rand;
|
||||
private WorldServer world;
|
||||
private BlockPos basePos = BlockPos.ORIGIN;
|
||||
private int heightLimit;
|
||||
private int height;
|
||||
double heightAttenuation = 0.618D;
|
||||
double branchSlope = 0.381D;
|
||||
double scaleWidth = 1.0D;
|
||||
double leafDensity = 1.0D;
|
||||
private int trunkSize = 1;
|
||||
private int heightLimitLower = 5;
|
||||
private int heightLimitLimit = 16;
|
||||
private int leafDistanceLimit = 4;
|
||||
List<WorldGenBigTree.FoliageCoordinates> field_175948_j;
|
||||
|
||||
public WorldGenBigTree(boolean notify, State logBase, State leavesBase)
|
||||
{
|
||||
super(notify);
|
||||
this.leavesBase = leavesBase;
|
||||
this.logBase = logBase;
|
||||
}
|
||||
|
||||
public WorldGenBigTree(boolean notify)
|
||||
{
|
||||
this(notify, Blocks.oak_log.getState(), Blocks.oak_leaves.getState());
|
||||
}
|
||||
|
||||
public WorldGenBigTree setHeightLimit(int lower, int limit) {
|
||||
this.heightLimitLower = lower;
|
||||
this.heightLimitLimit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WorldGenBigTree setDistanceLimit(int limit) {
|
||||
this.leafDistanceLimit = limit;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a list of leaf nodes for the tree, to be populated by generateLeaves.
|
||||
*/
|
||||
void generateLeafNodeList()
|
||||
{
|
||||
this.height = (int)((double)this.heightLimit * this.heightAttenuation);
|
||||
|
||||
if (this.height >= this.heightLimit)
|
||||
{
|
||||
this.height = this.heightLimit - 1;
|
||||
}
|
||||
|
||||
int i = (int)(1.382D + Math.pow(this.leafDensity * (double)this.heightLimit / 13.0D, 2.0D));
|
||||
|
||||
if (i < 1)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
|
||||
int j = this.basePos.getY() + this.height;
|
||||
int k = this.heightLimit - this.leafDistanceLimit;
|
||||
this.field_175948_j = Lists.<WorldGenBigTree.FoliageCoordinates>newArrayList();
|
||||
this.field_175948_j.add(new WorldGenBigTree.FoliageCoordinates(this.basePos.up(k), j));
|
||||
|
||||
for (; k >= 0; --k)
|
||||
{
|
||||
float f = this.layerSize(k);
|
||||
|
||||
if (f >= 0.0F)
|
||||
{
|
||||
for (int l = 0; l < i; ++l)
|
||||
{
|
||||
double d0 = this.scaleWidth * (double)f * ((double)this.rand.floatv() + 0.328D);
|
||||
double d1 = (double)(this.rand.floatv() * 2.0F) * Math.PI;
|
||||
double d2 = d0 * Math.sin(d1) + 0.5D;
|
||||
double d3 = d0 * Math.cos(d1) + 0.5D;
|
||||
BlockPos blockpos = this.basePos.add(d2, (double)(k - 1), d3);
|
||||
BlockPos blockpos1 = blockpos.up(this.leafDistanceLimit);
|
||||
|
||||
if (this.checkBlockLine(blockpos, blockpos1) == -1)
|
||||
{
|
||||
int i1 = this.basePos.getX() - blockpos.getX();
|
||||
int j1 = this.basePos.getZ() - blockpos.getZ();
|
||||
double d4 = (double)blockpos.getY() - Math.sqrt((double)(i1 * i1 + j1 * j1)) * this.branchSlope;
|
||||
int k1 = d4 > (double)j ? j : (int)d4;
|
||||
BlockPos blockpos2 = new BlockPos(this.basePos.getX(), k1, this.basePos.getZ());
|
||||
|
||||
if (this.checkBlockLine(blockpos2, blockpos) == -1)
|
||||
{
|
||||
this.field_175948_j.add(new WorldGenBigTree.FoliageCoordinates(blockpos, blockpos2.getY()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_181631_a(BlockPos p_181631_1_, float p_181631_2_, State p_181631_3_)
|
||||
{
|
||||
int i = (int)((double)p_181631_2_ + 0.618D);
|
||||
|
||||
for (int j = -i; j <= i; ++j)
|
||||
{
|
||||
for (int k = -i; k <= i; ++k)
|
||||
{
|
||||
if (Math.pow((double)Math.abs(j) + 0.5D, 2.0D) + Math.pow((double)Math.abs(k) + 0.5D, 2.0D) <= (double)(p_181631_2_ * p_181631_2_))
|
||||
{
|
||||
BlockPos blockpos = p_181631_1_.add(j, 0, k);
|
||||
Material material = this.world.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(this.world, blockpos, p_181631_3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rough size of a layer of the tree.
|
||||
*/
|
||||
float layerSize(int p_76490_1_)
|
||||
{
|
||||
if ((float)p_76490_1_ < (float)this.heightLimit * 0.3F)
|
||||
{
|
||||
return -1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)this.heightLimit / 2.0F;
|
||||
float f1 = f - (float)p_76490_1_;
|
||||
float f2 = ExtMath.sqrtf(f * f - f1 * f1);
|
||||
|
||||
if (f1 == 0.0F)
|
||||
{
|
||||
f2 = f;
|
||||
}
|
||||
else if (Math.abs(f1) >= f)
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
return f2 * 0.5F;
|
||||
}
|
||||
}
|
||||
|
||||
float leafSize(int p_76495_1_)
|
||||
{
|
||||
return p_76495_1_ >= 0 && p_76495_1_ < this.leafDistanceLimit ? (p_76495_1_ != 0 && p_76495_1_ != this.leafDistanceLimit - 1 ? 3.0F : 2.0F) : -1.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the leaves surrounding an individual entry in the leafNodes list.
|
||||
*/
|
||||
void generateLeafNode(BlockPos pos)
|
||||
{
|
||||
for (int i = 0; i < this.leafDistanceLimit; ++i)
|
||||
{
|
||||
this.func_181631_a(pos.up(i), this.leafSize(i), this.leavesBase.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false))
|
||||
.withProperty(BlockLeaves.TYPE, this.world.getLeavesGen(pos.up(i))));
|
||||
}
|
||||
}
|
||||
|
||||
void func_175937_a(BlockPos p_175937_1_, BlockPos p_175937_2_)
|
||||
{
|
||||
BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ());
|
||||
int i = this.getGreatestDistance(blockpos);
|
||||
float f = (float)blockpos.getX() / (float)i;
|
||||
float f1 = (float)blockpos.getY() / (float)i;
|
||||
float f2 = (float)blockpos.getZ() / (float)i;
|
||||
|
||||
for (int j = 0; j <= i; ++j)
|
||||
{
|
||||
BlockPos blockpos1 = p_175937_1_.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));
|
||||
BlockLog.EnumAxis blocklog$enumaxis = this.func_175938_b(p_175937_1_, blockpos1);
|
||||
this.setBlockAndNotifyAdequately(this.world, blockpos1, this.logBase.withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute greatest distance in the BlockPos object.
|
||||
*/
|
||||
private int getGreatestDistance(BlockPos posIn)
|
||||
{
|
||||
int i = ExtMath.absi(posIn.getX());
|
||||
int j = ExtMath.absi(posIn.getY());
|
||||
int k = ExtMath.absi(posIn.getZ());
|
||||
return k > i && k > j ? k : (j > i ? j : i);
|
||||
}
|
||||
|
||||
private BlockLog.EnumAxis func_175938_b(BlockPos p_175938_1_, BlockPos p_175938_2_)
|
||||
{
|
||||
BlockLog.EnumAxis blocklog$enumaxis = BlockLog.EnumAxis.Y;
|
||||
int i = Math.abs(p_175938_2_.getX() - p_175938_1_.getX());
|
||||
int j = Math.abs(p_175938_2_.getZ() - p_175938_1_.getZ());
|
||||
int k = Math.max(i, j);
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
if (i == k)
|
||||
{
|
||||
blocklog$enumaxis = BlockLog.EnumAxis.X;
|
||||
}
|
||||
else if (j == k)
|
||||
{
|
||||
blocklog$enumaxis = BlockLog.EnumAxis.Z;
|
||||
}
|
||||
}
|
||||
|
||||
return blocklog$enumaxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the leaf portion of the tree as specified by the leafNodes list.
|
||||
*/
|
||||
void generateLeaves()
|
||||
{
|
||||
for (WorldGenBigTree.FoliageCoordinates worldgenbigtree$foliagecoordinates : this.field_175948_j)
|
||||
{
|
||||
this.generateLeafNode(worldgenbigtree$foliagecoordinates);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether or not a leaf node requires additional wood to be added to preserve integrity.
|
||||
*/
|
||||
boolean leafNodeNeedsBase(int p_76493_1_)
|
||||
{
|
||||
return (double)p_76493_1_ >= (double)this.heightLimit * 0.2D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the trunk for the big tree that is being generated. Able to generate double-sized trunks by changing a
|
||||
* field that is always 1 to 2.
|
||||
*/
|
||||
void generateTrunk()
|
||||
{
|
||||
BlockPos blockpos = this.basePos;
|
||||
BlockPos blockpos1 = this.basePos.up(this.height);
|
||||
this.func_175937_a(blockpos, blockpos1);
|
||||
|
||||
if (this.trunkSize == 2)
|
||||
{
|
||||
this.func_175937_a(blockpos.east(), blockpos1.east());
|
||||
this.func_175937_a(blockpos.east().south(), blockpos1.east().south());
|
||||
this.func_175937_a(blockpos.south(), blockpos1.south());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates additional wood blocks to fill out the bases of different leaf nodes that would otherwise degrade.
|
||||
*/
|
||||
void generateLeafNodeBases()
|
||||
{
|
||||
for (WorldGenBigTree.FoliageCoordinates worldgenbigtree$foliagecoordinates : this.field_175948_j)
|
||||
{
|
||||
int i = worldgenbigtree$foliagecoordinates.func_177999_q();
|
||||
BlockPos blockpos = new BlockPos(this.basePos.getX(), i, this.basePos.getZ());
|
||||
|
||||
if (!blockpos.equals(worldgenbigtree$foliagecoordinates) && this.leafNodeNeedsBase(i - this.basePos.getY()))
|
||||
{
|
||||
this.func_175937_a(blockpos, worldgenbigtree$foliagecoordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a line of blocks in the world from the first coordinate to triplet to the second, returning the distance
|
||||
* (in blocks) before a non-air, non-leaf block is encountered and/or the end is encountered.
|
||||
*/
|
||||
int checkBlockLine(BlockPos posOne, BlockPos posTwo)
|
||||
{
|
||||
BlockPos blockpos = posTwo.add(-posOne.getX(), -posOne.getY(), -posOne.getZ());
|
||||
int i = this.getGreatestDistance(blockpos);
|
||||
float f = (float)blockpos.getX() / (float)i;
|
||||
float f1 = (float)blockpos.getY() / (float)i;
|
||||
float f2 = (float)blockpos.getZ() / (float)i;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j <= i; ++j)
|
||||
{
|
||||
BlockPos blockpos1 = posOne.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));
|
||||
|
||||
if (!this.canBeReplaced(this.world.getState(blockpos1).getBlock()))
|
||||
{
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void prepare()
|
||||
{
|
||||
if(this.heightLimitLimit <= 16)
|
||||
this.leafDistanceLimit = 5;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
this.world = worldIn;
|
||||
this.basePos = position;
|
||||
this.rand = new Random(rand.longv());
|
||||
|
||||
if (this.heightLimit == 0)
|
||||
{
|
||||
this.heightLimit = this.rand.range(this.heightLimitLower, this.heightLimitLimit);
|
||||
}
|
||||
|
||||
if (!this.validTreeLocation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.generateLeafNodeList();
|
||||
this.generateLeaves();
|
||||
this.generateTrunk();
|
||||
this.generateLeafNodeBases();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether or not the current location for the tree, spanning basePos to to the height
|
||||
* limit, is valid.
|
||||
*/
|
||||
private boolean validTreeLocation()
|
||||
{
|
||||
Block block = this.world.getState(this.basePos.down()).getBlock();
|
||||
|
||||
if (block != Blocks.dirt && block != Blocks.grass && block != Blocks.farmland && block != Blocks.tian_soil)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = this.checkBlockLine(this.basePos, this.basePos.up(this.heightLimit - 1));
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (i < 6)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.heightLimit = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class FoliageCoordinates extends BlockPos
|
||||
{
|
||||
private final int field_178000_b;
|
||||
|
||||
public FoliageCoordinates(BlockPos p_i45635_1_, int p_i45635_2_)
|
||||
{
|
||||
super(p_i45635_1_.getX(), p_i45635_1_.getY(), p_i45635_1_.getZ());
|
||||
this.field_178000_b = p_i45635_2_;
|
||||
}
|
||||
|
||||
public int func_177999_q()
|
||||
{
|
||||
return this.field_178000_b;
|
||||
}
|
||||
}
|
||||
}
|
136
java/src/game/worldgen/tree/WorldGenBirch.java
Executable file
136
java/src/game/worldgen/tree/WorldGenBirch.java
Executable file
|
@ -0,0 +1,136 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenBirch extends WorldGenTree
|
||||
{
|
||||
private static final State logBlock = Blocks.birch_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.BIRCH);
|
||||
private static final State leavesBlock = Blocks.birch_leaves.getState()
|
||||
// .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.BIRCH)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
private boolean useExtraRandomHeight;
|
||||
|
||||
public WorldGenBirch(boolean notify, boolean extra)
|
||||
{
|
||||
super(notify);
|
||||
this.useExtraRandomHeight = extra;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + 5;
|
||||
|
||||
if (this.useExtraRandomHeight)
|
||||
{
|
||||
i += rand.zrange(7);
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block1 == Blocks.grass || block1 == Blocks.dirt || block1 == Blocks.farmland) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
|
||||
for (int i2 = position.getY() - 3 + i; i2 <= position.getY() + i; ++i2)
|
||||
{
|
||||
int k2 = i2 - (position.getY() + i);
|
||||
int l2 = 1 - k2 / 2;
|
||||
|
||||
for (int i3 = position.getX() - l2; i3 <= position.getX() + l2; ++i3)
|
||||
{
|
||||
int j1 = i3 - position.getX();
|
||||
|
||||
for (int k1 = position.getZ() - l2; k1 <= position.getZ() + l2; ++k1)
|
||||
{
|
||||
int l1 = k1 - position.getZ();
|
||||
|
||||
if (Math.abs(j1) != l2 || Math.abs(l1) != l2 || rand.zrange(2) != 0 && k2 != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(i3, i2, k1);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, leavesBlock.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j2 = 0; j2 < i; ++j2)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(j2)).getBlock();
|
||||
|
||||
if (block2.getMaterial() == Material.air || block2.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(j2), logBlock);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
218
java/src/game/worldgen/tree/WorldGenDarkOak.java
Executable file
218
java/src/game/worldgen/tree/WorldGenDarkOak.java
Executable file
|
@ -0,0 +1,218 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenDarkOak extends WorldGenTree
|
||||
{
|
||||
private static final State logBlock = Blocks.dark_oak_log.getState(); // .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.DARK_OAK);
|
||||
private static final State leavesBlock = Blocks.dark_oak_leaves.getState()
|
||||
// .withProperty(BlockNewLeaf.VARIANT, BlockPlanks.EnumType.DARK_OAK)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenDarkOak(boolean notify)
|
||||
{
|
||||
super(notify);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + rand.zrange(2) + 6;
|
||||
int j = position.getX();
|
||||
int k = position.getY();
|
||||
int l = position.getZ();
|
||||
|
||||
if (k >= 1 && k + i + 1 < 512)
|
||||
{
|
||||
BlockPos blockpos = position.down();
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block != Blocks.grass && block != Blocks.dirt)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!this.func_181638_a(worldIn, position, i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBaseBlock(worldIn, blockpos);
|
||||
this.setBaseBlock(worldIn, blockpos.east());
|
||||
this.setBaseBlock(worldIn, blockpos.south());
|
||||
this.setBaseBlock(worldIn, blockpos.south().east());
|
||||
Facing enumfacing = Facing.Plane.HORIZONTAL.random(rand);
|
||||
int i1 = i - rand.zrange(4);
|
||||
int j1 = 2 - rand.zrange(3);
|
||||
int k1 = j;
|
||||
int l1 = l;
|
||||
int i2 = k + i - 1;
|
||||
|
||||
for (int j2 = 0; j2 < i; ++j2)
|
||||
{
|
||||
if (j2 >= i1 && j1 > 0)
|
||||
{
|
||||
k1 += enumfacing.getFrontOffsetX();
|
||||
l1 += enumfacing.getFrontOffsetZ();
|
||||
--j1;
|
||||
}
|
||||
|
||||
int k2 = k + j2;
|
||||
BlockPos blockpos1 = new BlockPos(k1, k2, l1);
|
||||
Material material = worldIn.getState(blockpos1).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.func_181639_b(worldIn, blockpos1);
|
||||
this.func_181639_b(worldIn, blockpos1.east());
|
||||
this.func_181639_b(worldIn, blockpos1.south());
|
||||
this.func_181639_b(worldIn, blockpos1.east().south());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i3 = -2; i3 <= 0; ++i3)
|
||||
{
|
||||
for (int l3 = -2; l3 <= 0; ++l3)
|
||||
{
|
||||
int k4 = -1;
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, 1 + l1 - l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, 1 + l1 - l3);
|
||||
|
||||
if ((i3 > -2 || l3 > -1) && (i3 != -1 || l3 != -2))
|
||||
{
|
||||
k4 = 1;
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, l1 + l3);
|
||||
this.func_150526_a(worldIn, k1 + i3, i2 + k4, 1 + l1 - l3);
|
||||
this.func_150526_a(worldIn, 1 + k1 - i3, i2 + k4, 1 + l1 - l3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.chance())
|
||||
{
|
||||
this.func_150526_a(worldIn, k1, i2 + 2, l1);
|
||||
this.func_150526_a(worldIn, k1 + 1, i2 + 2, l1);
|
||||
this.func_150526_a(worldIn, k1 + 1, i2 + 2, l1 + 1);
|
||||
this.func_150526_a(worldIn, k1, i2 + 2, l1 + 1);
|
||||
}
|
||||
|
||||
for (int j3 = -3; j3 <= 4; ++j3)
|
||||
{
|
||||
for (int i4 = -3; i4 <= 4; ++i4)
|
||||
{
|
||||
if ((j3 != -3 || i4 != -3) && (j3 != -3 || i4 != 4) && (j3 != 4 || i4 != -3) && (j3 != 4 || i4 != 4) && (Math.abs(j3) < 3 || Math.abs(i4) < 3))
|
||||
{
|
||||
this.func_150526_a(worldIn, k1 + j3, i2, l1 + i4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int k3 = -1; k3 <= 2; ++k3)
|
||||
{
|
||||
for (int j4 = -1; j4 <= 2; ++j4)
|
||||
{
|
||||
if ((k3 < 0 || k3 > 1 || j4 < 0 || j4 > 1) && rand.zrange(3) <= 0)
|
||||
{
|
||||
int l4 = rand.zrange(3) + 2;
|
||||
|
||||
for (int i5 = 0; i5 < l4; ++i5)
|
||||
{
|
||||
this.func_181639_b(worldIn, new BlockPos(j + k3, i2 - i5 - 1, l + j4));
|
||||
}
|
||||
|
||||
for (int j5 = -1; j5 <= 1; ++j5)
|
||||
{
|
||||
for (int l2 = -1; l2 <= 1; ++l2)
|
||||
{
|
||||
this.func_150526_a(worldIn, k1 + k3 + j5, i2, l1 + j4 + l2);
|
||||
}
|
||||
}
|
||||
|
||||
for (int k5 = -2; k5 <= 2; ++k5)
|
||||
{
|
||||
for (int l5 = -2; l5 <= 2; ++l5)
|
||||
{
|
||||
if (Math.abs(k5) != 2 || Math.abs(l5) != 2)
|
||||
{
|
||||
this.func_150526_a(worldIn, k1 + k3 + k5, i2 - 1, l1 + j4 + l5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean func_181638_a(WorldServer p_181638_1_, BlockPos p_181638_2_, int p_181638_3_)
|
||||
{
|
||||
int i = p_181638_2_.getX();
|
||||
int j = p_181638_2_.getY();
|
||||
int k = p_181638_2_.getZ();
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = 0; l <= p_181638_3_ + 1; ++l)
|
||||
{
|
||||
int i1 = 1;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
i1 = 0;
|
||||
}
|
||||
|
||||
if (l >= p_181638_3_ - 1)
|
||||
{
|
||||
i1 = 2;
|
||||
}
|
||||
|
||||
for (int j1 = -i1; j1 <= i1; ++j1)
|
||||
{
|
||||
for (int k1 = -i1; k1 <= i1; ++k1)
|
||||
{
|
||||
if (!this.canBeReplaced(p_181638_1_.getState(blockpos$mutableblockpos.set(i + j1, j + l, k + k1)).getBlock()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void func_181639_b(WorldServer p_181639_1_, BlockPos p_181639_2_)
|
||||
{
|
||||
if (this.canBeReplaced(p_181639_1_.getState(p_181639_2_).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181639_1_, p_181639_2_, logBlock);
|
||||
}
|
||||
}
|
||||
|
||||
private void func_150526_a(WorldServer worldIn, int p_150526_2_, int p_150526_3_, int p_150526_4_)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(p_150526_2_, p_150526_3_, p_150526_4_);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, leavesBlock.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
154
java/src/game/worldgen/tree/WorldGenHugeTree.java
Executable file
154
java/src/game/worldgen/tree/WorldGenHugeTree.java
Executable file
|
@ -0,0 +1,154 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public abstract class WorldGenHugeTree extends WorldGenTree
|
||||
{
|
||||
/** The base height of the tree */
|
||||
protected final int baseHeight;
|
||||
|
||||
/** Sets the metadata for the wood blocks used */
|
||||
protected final State woodMetadata;
|
||||
|
||||
/** Sets the metadata for the leaves used in huge trees */
|
||||
protected final State leavesMetadata;
|
||||
protected int extraRandomHeight;
|
||||
|
||||
public WorldGenHugeTree(boolean notify, int base, int extra, State log, State leaves)
|
||||
{
|
||||
super(notify);
|
||||
this.baseHeight = base;
|
||||
this.extraRandomHeight = extra;
|
||||
this.woodMetadata = log;
|
||||
this.leavesMetadata = leaves.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
protected int func_150533_a(Random p_150533_1_)
|
||||
{
|
||||
int i = p_150533_1_.zrange(3) + this.baseHeight;
|
||||
|
||||
if (this.extraRandomHeight > 1)
|
||||
{
|
||||
i += p_150533_1_.zrange(this.extraRandomHeight);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private boolean func_175926_c(WorldServer worldIn, BlockPos p_175926_2_, int p_175926_3_)
|
||||
{
|
||||
boolean flag = true;
|
||||
|
||||
if (p_175926_2_.getY() >= 1 && p_175926_2_.getY() + p_175926_3_ + 1 <= 512)
|
||||
{
|
||||
for (int i = 0; i <= 1 + p_175926_3_; ++i)
|
||||
{
|
||||
int j = 2;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
j = 1;
|
||||
}
|
||||
else if (i >= 1 + p_175926_3_ - 2)
|
||||
{
|
||||
j = 2;
|
||||
}
|
||||
|
||||
for (int k = -j; k <= j && flag; ++k)
|
||||
{
|
||||
for (int l = -j; l <= j && flag; ++l)
|
||||
{
|
||||
if (p_175926_2_.getY() + i < 0 || p_175926_2_.getY() + i >= 512 || !this.canBeReplaced(worldIn.getState(p_175926_2_.add(k, i, l)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean func_175927_a(BlockPos p_175927_1_, WorldServer worldIn)
|
||||
{
|
||||
BlockPos blockpos = p_175927_1_.down();
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if ((block == Blocks.grass || block == Blocks.dirt) && p_175927_1_.getY() >= 2)
|
||||
{
|
||||
this.setBaseBlock(worldIn, blockpos);
|
||||
this.setBaseBlock(worldIn, blockpos.east());
|
||||
this.setBaseBlock(worldIn, blockpos.south());
|
||||
this.setBaseBlock(worldIn, blockpos.south().east());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean func_175929_a(WorldServer worldIn, Random p_175929_2_, BlockPos p_175929_3_, int p_175929_4_)
|
||||
{
|
||||
return this.func_175926_c(worldIn, p_175929_3_, p_175929_4_) && this.func_175927_a(p_175929_3_, worldIn);
|
||||
}
|
||||
|
||||
protected void func_175925_a(WorldServer worldIn, BlockPos p_175925_2_, int p_175925_3_)
|
||||
{
|
||||
int i = p_175925_3_ * p_175925_3_;
|
||||
|
||||
for (int j = -p_175925_3_; j <= p_175925_3_ + 1; ++j)
|
||||
{
|
||||
for (int k = -p_175925_3_; k <= p_175925_3_ + 1; ++k)
|
||||
{
|
||||
int l = j - 1;
|
||||
int i1 = k - 1;
|
||||
|
||||
if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
|
||||
{
|
||||
BlockPos blockpos = p_175925_2_.add(j, 0, k);
|
||||
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void func_175928_b(WorldServer worldIn, BlockPos p_175928_2_, int p_175928_3_)
|
||||
{
|
||||
int i = p_175928_3_ * p_175928_3_;
|
||||
|
||||
for (int j = -p_175928_3_; j <= p_175928_3_; ++j)
|
||||
{
|
||||
for (int k = -p_175928_3_; k <= p_175928_3_; ++k)
|
||||
{
|
||||
if (j * j + k * k <= i)
|
||||
{
|
||||
BlockPos blockpos = p_175928_2_.add(j, 0, k);
|
||||
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
java/src/game/worldgen/tree/WorldGenJungle.java
Executable file
133
java/src/game/worldgen/tree/WorldGenJungle.java
Executable file
|
@ -0,0 +1,133 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.properties.PropertyBool;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenJungle extends WorldGenHugeTree
|
||||
{
|
||||
public WorldGenJungle(boolean p_i46448_1_, int p_i46448_2_, int p_i46448_3_, State p_i46448_4_, State p_i46448_5_)
|
||||
{
|
||||
super(p_i46448_1_, p_i46448_2_, p_i46448_3_, p_i46448_4_, p_i46448_5_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = this.func_150533_a(rand);
|
||||
|
||||
if (!this.func_175929_a(worldIn, rand, position, i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_175930_c(worldIn, position.up(i), 2);
|
||||
|
||||
for (int j = position.getY() + i - 2 - rand.zrange(4); j > position.getY() + i / 2; j -= 2 + rand.zrange(4))
|
||||
{
|
||||
float f = rand.floatv() * (float)Math.PI * 2.0F;
|
||||
int k = position.getX() + (int)(0.5F + ExtMath.cos(f) * 4.0F);
|
||||
int l = position.getZ() + (int)(0.5F + ExtMath.sin(f) * 4.0F);
|
||||
|
||||
for (int i1 = 0; i1 < 5; ++i1)
|
||||
{
|
||||
k = position.getX() + (int)(1.5F + ExtMath.cos(f) * (float)i1);
|
||||
l = position.getZ() + (int)(1.5F + ExtMath.sin(f) * (float)i1);
|
||||
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(k, j - 3 + i1 / 2, l), this.woodMetadata);
|
||||
}
|
||||
|
||||
int j2 = 1 + rand.zrange(2);
|
||||
int j1 = j;
|
||||
|
||||
for (int k1 = j - j2; k1 <= j1; ++k1)
|
||||
{
|
||||
int l1 = k1 - j1;
|
||||
this.func_175928_b(worldIn, new BlockPos(k, k1, l), 1 - l1);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i2 = 0; i2 < i; ++i2)
|
||||
{
|
||||
BlockPos blockpos = position.up(i2);
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos.west(), BlockVine.EAST);
|
||||
this.func_181632_a(worldIn, rand, blockpos.north(), BlockVine.SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
if (i2 < i - 1)
|
||||
{
|
||||
BlockPos blockpos1 = blockpos.east();
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos1).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos1, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos1.east(), BlockVine.WEST);
|
||||
this.func_181632_a(worldIn, rand, blockpos1.north(), BlockVine.SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos blockpos2 = blockpos.south().east();
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos2).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos2, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos2.east(), BlockVine.WEST);
|
||||
this.func_181632_a(worldIn, rand, blockpos2.south(), BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos blockpos3 = blockpos.south();
|
||||
|
||||
if (this.canBeReplaced(worldIn.getState(blockpos3).getBlock()))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos3, this.woodMetadata);
|
||||
|
||||
if (i2 > 0)
|
||||
{
|
||||
this.func_181632_a(worldIn, rand, blockpos3.west(), BlockVine.EAST);
|
||||
this.func_181632_a(worldIn, rand, blockpos3.south(), BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181632_a(WorldServer p_181632_1_, Random p_181632_2_, BlockPos p_181632_3_, PropertyBool p_181632_4_)
|
||||
{
|
||||
if (p_181632_2_.zrange(3) > 0 && p_181632_1_.isAirBlock(p_181632_3_))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181632_1_, p_181632_3_, Blocks.vine.getState().withProperty(p_181632_4_, Boolean.valueOf(true)));
|
||||
}
|
||||
}
|
||||
|
||||
private void func_175930_c(WorldServer worldIn, BlockPos p_175930_2_, int p_175930_3_)
|
||||
{
|
||||
int i = 2;
|
||||
|
||||
for (int j = -i; j <= 0; ++j)
|
||||
{
|
||||
this.func_175925_a(worldIn, p_175930_2_.up(j), p_175930_3_ + 1 - j);
|
||||
}
|
||||
}
|
||||
}
|
143
java/src/game/worldgen/tree/WorldGenPine.java
Executable file
143
java/src/game/worldgen/tree/WorldGenPine.java
Executable file
|
@ -0,0 +1,143 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.block.BlockDirt;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenPine extends WorldGenHugeTree
|
||||
{
|
||||
private static final State field_181633_e = Blocks.spruce_log.getState(); // .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
||||
private static final State field_181634_f = Blocks.spruce_leaves.getState(); // .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE); // .withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
|
||||
private static final State field_181635_g = Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL);
|
||||
private boolean useBaseHeight;
|
||||
|
||||
public WorldGenPine(boolean p_i45457_1_, boolean p_i45457_2_)
|
||||
{
|
||||
super(p_i45457_1_, 13, 15, field_181633_e, field_181634_f);
|
||||
this.useBaseHeight = p_i45457_2_;
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = this.func_150533_a(rand);
|
||||
|
||||
if (!this.func_175929_a(worldIn, rand, position, i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_150541_c(worldIn, position.getX(), position.getZ(), position.getY() + i, 0, rand);
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
Block block = worldIn.getState(position.up(j)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(j), this.woodMetadata);
|
||||
}
|
||||
|
||||
if (j < i - 1)
|
||||
{
|
||||
block = worldIn.getState(position.add(1, j, 0)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 0), this.woodMetadata);
|
||||
}
|
||||
|
||||
block = worldIn.getState(position.add(1, j, 1)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 1), this.woodMetadata);
|
||||
}
|
||||
|
||||
block = worldIn.getState(position.add(0, j, 1)).getBlock();
|
||||
|
||||
if (block.getMaterial() == Material.air || block.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.add(0, j, 1), this.woodMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_150541_c(WorldServer worldIn, int p_150541_2_, int p_150541_3_, int p_150541_4_, int p_150541_5_, Random p_150541_6_)
|
||||
{
|
||||
int i = p_150541_6_.zrange(5) + (this.useBaseHeight ? this.baseHeight : 3);
|
||||
int j = 0;
|
||||
|
||||
for (int k = p_150541_4_ - i; k <= p_150541_4_; ++k)
|
||||
{
|
||||
int l = p_150541_4_ - k;
|
||||
int i1 = p_150541_5_ + ExtMath.floorf((float)l / (float)i * 3.5F);
|
||||
this.func_175925_a(worldIn, new BlockPos(p_150541_2_, k, p_150541_3_), i1 + (l > 0 && i1 == j && (k & 1) == 0 ? 1 : 0));
|
||||
j = i1;
|
||||
}
|
||||
}
|
||||
|
||||
public void finish(WorldServer worldIn, Random p_180711_2_, BlockPos p_180711_3_)
|
||||
{
|
||||
this.func_175933_b(worldIn, p_180711_3_.west().north());
|
||||
this.func_175933_b(worldIn, p_180711_3_.east(2).north());
|
||||
this.func_175933_b(worldIn, p_180711_3_.west().south(2));
|
||||
this.func_175933_b(worldIn, p_180711_3_.east(2).south(2));
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
int j = p_180711_2_.zrange(64);
|
||||
int k = j % 8;
|
||||
int l = j / 8;
|
||||
|
||||
if (k == 0 || k == 7 || l == 0 || l == 7)
|
||||
{
|
||||
this.func_175933_b(worldIn, p_180711_3_.add(-3 + k, 0, -3 + l));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_175933_b(WorldServer worldIn, BlockPos p_175933_2_)
|
||||
{
|
||||
for (int i = -2; i <= 2; ++i)
|
||||
{
|
||||
for (int j = -2; j <= 2; ++j)
|
||||
{
|
||||
if (Math.abs(i) != 2 || Math.abs(j) != 2)
|
||||
{
|
||||
this.func_175934_c(worldIn, p_175933_2_.add(i, 0, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void func_175934_c(WorldServer worldIn, BlockPos p_175934_2_)
|
||||
{
|
||||
for (int i = 2; i >= -3; --i)
|
||||
{
|
||||
BlockPos blockpos = p_175934_2_.up(i);
|
||||
Block block = worldIn.getState(blockpos).getBlock();
|
||||
|
||||
if (block == Blocks.grass || block == Blocks.dirt)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181635_g);
|
||||
break;
|
||||
}
|
||||
|
||||
if (block.getMaterial() != Material.air && i < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
219
java/src/game/worldgen/tree/WorldGenSavanna.java
Executable file
219
java/src/game/worldgen/tree/WorldGenSavanna.java
Executable file
|
@ -0,0 +1,219 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenSavanna extends WorldGenTree
|
||||
{
|
||||
private static final State field_181643_a = Blocks.acacia_log.getState();
|
||||
// .withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.ACACIA);
|
||||
private static final State field_181644_b = Blocks.acacia_leaves.getState()
|
||||
// .withProperty(BlockNewLeaf.VARIANT, BlockPlanks.EnumType.ACACIA)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenSavanna(boolean p_i45463_1_)
|
||||
{
|
||||
super(p_i45463_1_);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(3) + rand.zrange(3) + 5;
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block == Blocks.grass || block == Blocks.dirt) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
Facing enumfacing = Facing.Plane.HORIZONTAL.random(rand);
|
||||
int k2 = i - rand.zrange(4) - 1;
|
||||
int l2 = 3 - rand.zrange(3);
|
||||
int i3 = position.getX();
|
||||
int j1 = position.getZ();
|
||||
int k1 = 0;
|
||||
|
||||
for (int l1 = 0; l1 < i; ++l1)
|
||||
{
|
||||
int i2 = position.getY() + l1;
|
||||
|
||||
if (l1 >= k2 && l2 > 0)
|
||||
{
|
||||
i3 += enumfacing.getFrontOffsetX();
|
||||
j1 += enumfacing.getFrontOffsetZ();
|
||||
--l2;
|
||||
}
|
||||
|
||||
BlockPos blockpos = new BlockPos(i3, i2, j1);
|
||||
Material material = worldIn.getState(blockpos).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.func_181642_b(worldIn, blockpos);
|
||||
k1 = i2;
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos blockpos2 = new BlockPos(i3, k1, j1);
|
||||
|
||||
for (int j3 = -3; j3 <= 3; ++j3)
|
||||
{
|
||||
for (int i4 = -3; i4 <= 3; ++i4)
|
||||
{
|
||||
if (Math.abs(j3) != 3 || Math.abs(i4) != 3)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos2.add(j3, 0, i4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockpos2 = blockpos2.up();
|
||||
|
||||
for (int k3 = -1; k3 <= 1; ++k3)
|
||||
{
|
||||
for (int j4 = -1; j4 <= 1; ++j4)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos2.add(k3, 0, j4));
|
||||
}
|
||||
}
|
||||
|
||||
this.func_175924_b(worldIn, blockpos2.east(2));
|
||||
this.func_175924_b(worldIn, blockpos2.west(2));
|
||||
this.func_175924_b(worldIn, blockpos2.south(2));
|
||||
this.func_175924_b(worldIn, blockpos2.north(2));
|
||||
i3 = position.getX();
|
||||
j1 = position.getZ();
|
||||
Facing enumfacing1 = Facing.Plane.HORIZONTAL.random(rand);
|
||||
|
||||
if (enumfacing1 != enumfacing)
|
||||
{
|
||||
int l3 = k2 - rand.zrange(2) - 1;
|
||||
int k4 = 1 + rand.zrange(3);
|
||||
k1 = 0;
|
||||
|
||||
for (int l4 = l3; l4 < i && k4 > 0; --k4)
|
||||
{
|
||||
if (l4 >= 1)
|
||||
{
|
||||
int j2 = position.getY() + l4;
|
||||
i3 += enumfacing1.getFrontOffsetX();
|
||||
j1 += enumfacing1.getFrontOffsetZ();
|
||||
BlockPos blockpos1 = new BlockPos(i3, j2, j1);
|
||||
Material material1 = worldIn.getState(blockpos1).getBlock().getMaterial();
|
||||
|
||||
if (material1 == Material.air || material1 == Material.leaves)
|
||||
{
|
||||
this.func_181642_b(worldIn, blockpos1);
|
||||
k1 = j2;
|
||||
}
|
||||
}
|
||||
|
||||
++l4;
|
||||
}
|
||||
|
||||
if (k1 > 0)
|
||||
{
|
||||
BlockPos blockpos3 = new BlockPos(i3, k1, j1);
|
||||
|
||||
for (int i5 = -2; i5 <= 2; ++i5)
|
||||
{
|
||||
for (int k5 = -2; k5 <= 2; ++k5)
|
||||
{
|
||||
if (Math.abs(i5) != 2 || Math.abs(k5) != 2)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos3.add(i5, 0, k5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockpos3 = blockpos3.up();
|
||||
|
||||
for (int j5 = -1; j5 <= 1; ++j5)
|
||||
{
|
||||
for (int l5 = -1; l5 <= 1; ++l5)
|
||||
{
|
||||
this.func_175924_b(worldIn, blockpos3.add(j5, 0, l5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181642_b(WorldServer p_181642_1_, BlockPos p_181642_2_)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181642_1_, p_181642_2_, field_181643_a);
|
||||
}
|
||||
|
||||
private void func_175924_b(WorldServer worldIn, BlockPos p_175924_2_)
|
||||
{
|
||||
Material material = worldIn.getState(p_175924_2_).getBlock().getMaterial();
|
||||
|
||||
if (material == Material.air || material == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, p_175924_2_, field_181644_b.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(p_175924_2_)));
|
||||
}
|
||||
}
|
||||
}
|
201
java/src/game/worldgen/tree/WorldGenSwamp.java
Executable file
201
java/src/game/worldgen/tree/WorldGenSwamp.java
Executable file
|
@ -0,0 +1,201 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.block.BlockVine;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.properties.PropertyBool;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenSwamp extends WorldGenTree
|
||||
{
|
||||
private static final State field_181648_a = Blocks.oak_log.getState();
|
||||
// .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK);
|
||||
private static final State field_181649_b = Blocks.oak_leaves.getState()
|
||||
// .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenSwamp()
|
||||
{
|
||||
super(false);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = rand.zrange(4) + 5; worldIn.getState(position.down()).getBlock().getMaterial() == Material.water; position = position.down())
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int j = position.getY(); j <= position.getY() + 1 + i; ++j)
|
||||
{
|
||||
int k = 1;
|
||||
|
||||
if (j == position.getY())
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
|
||||
if (j >= position.getY() + 1 + i - 2)
|
||||
{
|
||||
k = 3;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l)
|
||||
{
|
||||
for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1)
|
||||
{
|
||||
if (j >= 0 && j < 512)
|
||||
{
|
||||
Block block = worldIn.getState(blockpos$mutableblockpos.set(l, j, i1)).getBlock();
|
||||
|
||||
if (block.getMaterial() != Material.air && block.getMaterial() != Material.leaves)
|
||||
{
|
||||
if (block != Blocks.water && block != Blocks.flowing_water)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else if (j > position.getY())
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block1 = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block1 == Blocks.grass || block1 == Blocks.dirt) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
|
||||
for (int l1 = position.getY() - 3 + i; l1 <= position.getY() + i; ++l1)
|
||||
{
|
||||
int k2 = l1 - (position.getY() + i);
|
||||
int i3 = 2 - k2 / 2;
|
||||
|
||||
for (int k3 = position.getX() - i3; k3 <= position.getX() + i3; ++k3)
|
||||
{
|
||||
int l3 = k3 - position.getX();
|
||||
|
||||
for (int j1 = position.getZ() - i3; j1 <= position.getZ() + i3; ++j1)
|
||||
{
|
||||
int k1 = j1 - position.getZ();
|
||||
|
||||
if (Math.abs(l3) != i3 || Math.abs(k1) != i3 || rand.zrange(2) != 0 && k2 != 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(k3, l1, j1);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181649_b.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i2 = 0; i2 < i; ++i2)
|
||||
{
|
||||
Block block2 = worldIn.getState(position.up(i2)).getBlock();
|
||||
|
||||
if (block2.getMaterial() == Material.air || block2.getMaterial() == Material.leaves || block2 == Blocks.flowing_water || block2 == Blocks.water)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(i2), field_181648_a);
|
||||
}
|
||||
}
|
||||
|
||||
for (int j2 = position.getY() - 3 + i; j2 <= position.getY() + i; ++j2)
|
||||
{
|
||||
int l2 = j2 - (position.getY() + i);
|
||||
int j3 = 2 - l2 / 2;
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int i4 = position.getX() - j3; i4 <= position.getX() + j3; ++i4)
|
||||
{
|
||||
for (int j4 = position.getZ() - j3; j4 <= position.getZ() + j3; ++j4)
|
||||
{
|
||||
blockpos$mutableblockpos1.set(i4, j2, j4);
|
||||
|
||||
if (worldIn.getState(blockpos$mutableblockpos1).getBlock().getMaterial() == Material.leaves)
|
||||
{
|
||||
BlockPos blockpos3 = blockpos$mutableblockpos1.west();
|
||||
BlockPos blockpos4 = blockpos$mutableblockpos1.east();
|
||||
BlockPos blockpos1 = blockpos$mutableblockpos1.north();
|
||||
BlockPos blockpos2 = blockpos$mutableblockpos1.south();
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos3).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos3, BlockVine.EAST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos4).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos4, BlockVine.WEST);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos1).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos1, BlockVine.SOUTH);
|
||||
}
|
||||
|
||||
if (rand.zrange(4) == 0 && worldIn.getState(blockpos2).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
this.func_181647_a(worldIn, blockpos2, BlockVine.NORTH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void func_181647_a(WorldServer p_181647_1_, BlockPos p_181647_2_, PropertyBool p_181647_3_)
|
||||
{
|
||||
State iblockstate = Blocks.vine.getState().withProperty(p_181647_3_, Boolean.valueOf(true));
|
||||
this.setBlockAndNotifyAdequately(p_181647_1_, p_181647_2_, iblockstate);
|
||||
int i = 4;
|
||||
|
||||
for (p_181647_2_ = p_181647_2_.down(); p_181647_1_.getState(p_181647_2_).getBlock().getMaterial() == Material.air && i > 0; --i)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(p_181647_1_, p_181647_2_, iblockstate);
|
||||
p_181647_2_ = p_181647_2_.down();
|
||||
}
|
||||
}
|
||||
}
|
137
java/src/game/worldgen/tree/WorldGenTaiga1.java
Executable file
137
java/src/game/worldgen/tree/WorldGenTaiga1.java
Executable file
|
@ -0,0 +1,137 @@
|
|||
package game.worldgen.tree;
|
||||
|
||||
import game.block.Block;
|
||||
import game.block.BlockLeaves;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.rng.Random;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class WorldGenTaiga1 extends WorldGenTree
|
||||
{
|
||||
private static final State field_181636_a = Blocks.spruce_log.getState();
|
||||
// .withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE);
|
||||
private static final State field_181637_b = Blocks.spruce_leaves.getState()
|
||||
// .withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE)
|
||||
.withProperty(BlockLeaves.DECAY, Boolean.valueOf(false));
|
||||
|
||||
public WorldGenTaiga1()
|
||||
{
|
||||
super(false);
|
||||
}
|
||||
|
||||
public boolean generate(WorldServer worldIn, Random rand, BlockPos position)
|
||||
{
|
||||
int i = rand.zrange(5) + 7;
|
||||
int j = i - rand.zrange(2) - 3;
|
||||
int k = i - j;
|
||||
int l = 1 + rand.zrange(k + 1);
|
||||
boolean flag = true;
|
||||
|
||||
if (position.getY() >= 1 && position.getY() + i + 1 <= 512)
|
||||
{
|
||||
for (int i1 = position.getY(); i1 <= position.getY() + 1 + i && flag; ++i1)
|
||||
{
|
||||
int j1 = 1;
|
||||
|
||||
if (i1 - position.getY() < j)
|
||||
{
|
||||
j1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
j1 = l;
|
||||
}
|
||||
|
||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
||||
|
||||
for (int k1 = position.getX() - j1; k1 <= position.getX() + j1 && flag; ++k1)
|
||||
{
|
||||
for (int l1 = position.getZ() - j1; l1 <= position.getZ() + j1 && flag; ++l1)
|
||||
{
|
||||
if (i1 >= 0 && i1 < 512)
|
||||
{
|
||||
if (!this.canBeReplaced(worldIn.getState(blockpos$mutableblockpos.set(k1, i1, l1)).getBlock()))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block block = worldIn.getState(position.down()).getBlock();
|
||||
|
||||
if ((block == Blocks.grass || block == Blocks.dirt) && position.getY() < 512 - i - 1)
|
||||
{
|
||||
this.setBaseBlock(worldIn, position.down());
|
||||
int k2 = 0;
|
||||
|
||||
for (int l2 = position.getY() + i; l2 >= position.getY() + j; --l2)
|
||||
{
|
||||
for (int j3 = position.getX() - k2; j3 <= position.getX() + k2; ++j3)
|
||||
{
|
||||
int k3 = j3 - position.getX();
|
||||
|
||||
for (int i2 = position.getZ() - k2; i2 <= position.getZ() + k2; ++i2)
|
||||
{
|
||||
int j2 = i2 - position.getZ();
|
||||
|
||||
if (Math.abs(k3) != k2 || Math.abs(j2) != k2 || k2 <= 0)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(j3, l2, i2);
|
||||
|
||||
if (!worldIn.getState(blockpos).getBlock().isFullBlock())
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181637_b.withProperty(BlockLeaves.TYPE, worldIn.getLeavesGen(blockpos)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k2 >= 1 && l2 == position.getY() + j + 1)
|
||||
{
|
||||
--k2;
|
||||
}
|
||||
else if (k2 < l)
|
||||
{
|
||||
++k2;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i3 = 0; i3 < i - 1; ++i3)
|
||||
{
|
||||
Block block1 = worldIn.getState(position.up(i3)).getBlock();
|
||||
|
||||
if (block1.getMaterial() == Material.air || block1.getMaterial() == Material.leaves)
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(worldIn, position.up(i3), field_181636_a);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue