- 1,057
- 50
- 234
Добрый день всем знающим и не знающим.
Проблема такая:
Minecraft 1.7.10
Есть 2 биома, в котором прописаны 3 слоя блоков:
У них общий BiomeGenBaseEnceladus:
Stone слой сделан через свой BiomeGenBase:
Измерение генерится через переделанный ChunkProvider:
[merge_posts_bbcode]Добавлено: 12.02.2016 03:03:08[/merge_posts_bbcode]
Проблема следующая:
Второй биом генерируется с другими блоками (со слоем Stone из первого) и лишь со слоем Stone...
Как фиксить?
Проблема такая:
Minecraft 1.7.10
Есть 2 биома, в котором прописаны 3 слоя блоков:
Код:
public class BiomeGenEnceladus extends BiomeGenBaseEnceladus
{
public BiomeGenEnceladus(int var1)
{
super(var1);
this.enableRain = false;
this.enableSnow = false;
this.topBlock = GSBlocks.EnceladusIce;
this.topMeta = 0;
this.fillerBlock = Blocks.packed_ice;
this.fillerMeta = 0;
this.stoneBlock = GSBlocks.EnceladusGrunt;
this.stoneMeta = 0;
this.spawnableCaveCreatureList.clear();
this.spawnableCreatureList.clear();
this.spawnableMonsterList.clear();
this.spawnableWaterCreatureList.clear();
if (!ConfigManagerCore.disableBiomeTypeRegistrations)
{
BiomeDictionary.registerBiomeType(this, BiomeDictionary.Type.COLD, BiomeDictionary.Type.DRY, BiomeDictionary.Type.DEAD, BiomeDictionary.Type.SPOOKY);
}
}
}
------------------------------------------------------------------------------------------
public class BiomeGenEnceladusWater extends BiomeGenBaseEnceladus
{
public BiomeGenEnceladusWater(int var1)
{
super(var1);
this.enableRain = false;
this.enableSnow = false;
this.topBlock = GSBlocks.EnceladusIce;
this.topMeta = 0;
this.fillerBlock = Blocks.packed_ice;
this.fillerMeta = 0;
this.stoneBlock = Blocks.water;
this.stoneMeta = 0;
this.spawnableCaveCreatureList.clear();
this.spawnableCreatureList.clear();
this.spawnableMonsterList.clear();
this.spawnableWaterCreatureList.clear();
if (!ConfigManagerCore.disableBiomeTypeRegistrations)
{
BiomeDictionary.registerBiomeType(this, BiomeDictionary.Type.COLD, BiomeDictionary.Type.DRY, BiomeDictionary.Type.DEAD, BiomeDictionary.Type.SPOOKY);
}
}
}
Код:
public class BiomeGenBaseEnceladus extends GSBiomeGenBase
{
public static BiomeGenBase Enceladus = new BiomeGenEnceladus(GSConfigBiomes.IDEnceladusBiome).setBiomeName("Enceladus").setHeight(new Height(0.1F, 0.2F));
public static BiomeGenBase EnceladusWater = new BiomeGenEnceladusWater(GSConfigBiomes.IDEnceladusBiome + 33).setBiomeName("EnceladusWater").setHeight(new Height(0.01F, 0.02F));
public BiomeGenBaseEnceladus(int id)
{
super(id);
this.enableRain = true;
this.enableSnow = true;
this.topBlock = Blocks.grass;
this.fillerBlock = Blocks.dirt;
this.stoneBlock = Blocks.stone;
}
@Override
public BiomeDecorator createBiomeDecorator()
{
return new BiomeDecoratorEnceladus();
}
protected BiomeDecoratorEnceladus getBiomeDecorator()
{
return (BiomeDecoratorEnceladus)this.theBiomeDecorator;
}
}
Код:
public abstract class GSBiomeGenBase extends BiomeGenBase
{
protected Block stoneBlock;
protected byte topMeta;
protected byte fillerMeta;
protected byte stoneMeta;
public GSBiomeGenBase(int id)
{
super(id);
this.spawnableMonsterList.clear();
this.spawnableWaterCreatureList.clear();
this.spawnableCreatureList.clear();
this.spawnableCaveCreatureList.clear();
this.rainfall = 0F;
this.setColor(-16744448);
}
@Override
public GSBiomeGenBase setColor(int var1)
{
return (GSBiomeGenBase) super.setColor(var1);
}
@Override
public float getSpawningChance()
{
return 0.1F;
}
@Override
public void genTerrainBlocks(World world, Random rand, Block[] block, byte[] meta, int x, int z, double stoneNoise)
{
this.genSpaceBiomeTerrain(world, rand, block, meta, x, z, stoneNoise);
}
public void genSpaceBiomeTerrain(World world, Random rand, Block[] block, byte[] meta, int x, int z, double stoneNoise)
{
Block topBlock = this.topBlock;
byte topMeta = this.topMeta;
Block fillerBlock = this.fillerBlock;
byte fillerMeta = this.fillerMeta;
int currentFillerDepth = -1;
int maxFillerDepth = (int)(stoneNoise / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
int maskX = x & 15;
int maskZ = z & 15;
int worldHeight = block.length / 256;
int height = 63;
int seaLevel = 63;
for (int y = 255; y >= 0; y--)
{
int index = (maskZ * 16 + maskX) * worldHeight + y;
if (y <= 0 + rand.nextInt(5))
{
block[index] = Blocks.bedrock;
}
else
{
Block currentBlock = block[index];
if (currentBlock != null && currentBlock.getMaterial() != Material.air)
{
if (currentBlock == Blocks.stone)
{
if (this.stoneBlock != null)
{
block[index] = this.stoneBlock;
meta[index] = this.stoneMeta;
}
if (currentFillerDepth == -1)
{
if (maxFillerDepth <= 0)
{
topBlock = null;
topMeta = 0;
fillerBlock = Blocks.dirt;
fillerMeta = 0;
}
else if (y >= seaLevel - 5 && y <= seaLevel)
{
topBlock = this.topBlock;
topMeta = this.topMeta;
fillerBlock = this.fillerBlock;
fillerMeta = 0;
}
if (y < seaLevel - 1 && (topBlock == null || topBlock.getMaterial() == Material.air))
{
if (this.getFloatTemperature(x, y, z) < 0.15F)
{
topBlock = Blocks.ice;
topMeta = 0;
}
else
{
topBlock = Blocks.water;
topMeta = 0;
}
}
currentFillerDepth = maxFillerDepth;
if (y >= seaLevel - 2)
{
block[index] = topBlock;
meta[index] = topMeta;
}
/*else if (y < seaLevel - 8 - maxFillerDepth)
{
topBlock = null;
fillerBlock = Blocks.dirt;
fillerMeta = 0;
block[index] = Blocks.gravel;
}*/
else
{
block[index] = fillerBlock;
meta[index] = fillerMeta;
}
}
else if (currentFillerDepth > 0)
{
currentFillerDepth--;
block[index] = fillerBlock;
meta[index] = fillerMeta;
if (currentFillerDepth == 0 && fillerBlock == Blocks.sand)
{
currentFillerDepth = rand.nextInt(4) + Math.max(0, y - (seaLevel - 1));
fillerBlock = Blocks.sandstone;
fillerMeta = 0;
}
}
}
}
}
}
}
/**
* @return Base height modifier
*/
public int getHeight(int height) {
return height;
}
}
Код:
public abstract class ChunkProviderSpaceCraters extends ChunkProviderGenerate
{
protected final Random rand;
private BiomeCache myBiomeCache;
private final Gradient noiseGen1;
private final Gradient noiseGen2;
private final Gradient noiseGen3;
private final Gradient noiseGen4;
private final Gradient noiseGen5;
private final Gradient noiseGen6;
private final Gradient noiseGen7;
protected double[] stoneNoise;
protected final World worldObj;
protected BiomeGenBase[] biomesForGeneration = this.getBiomesForGeneration();
private final double TERRAIN_HEIGHT_MOD = this.getHeightModifier();
private final double SMALL_FEATURE_HEIGHT_MOD = this.getSmallFeatureHeightModifier();
private final double MOUNTAIN_HEIGHT_MOD = this.getMountainHeightModifier();
private final double VALLEY_HEIGHT_MOD = this.getValleyHeightModifier();
private final int CRATER_PROB = this.getCraterProbability();
// DO NOT CHANGE
private final int MID_HEIGHT = this.getSeaLevel();
private static final int CHUNK_SIZE_X = 16;
private static final int CHUNK_SIZE_Y = 256;
private static final int CHUNK_SIZE_Z = 16;
private static final double MAIN_FEATURE_FILTER_MOD = 4;
private static final double LARGE_FEATURE_FILTER_MOD = 8;
private static final double SMALL_FEATURE_FILTER_MOD = 8;
private List<MapGenBaseMeta> worldGenerators;
protected NoiseGeneratorPerlin field_147430_m;
public ChunkProviderSpaceCraters(World par1World, long seed, boolean mapFeaturesEnabled)
{
super(par1World, seed, mapFeaturesEnabled);
this.worldObj = par1World;
this.rand = new Random(seed);
this.noiseGen1 = new Gradient(this.rand.nextLong(), 4, 0.25F);
this.noiseGen2 = new Gradient(this.rand.nextLong(), 4, 0.25F);
this.noiseGen3 = new Gradient(this.rand.nextLong(), 4, 0.25F);
this.noiseGen4 = new Gradient(this.rand.nextLong(), 2, 0.25F);
this.noiseGen5 = new Gradient(this.rand.nextLong(), 1, 0.25F);
this.noiseGen6 = new Gradient(this.rand.nextLong(), 1, 0.25F);
this.noiseGen7 = new Gradient(this.rand.nextLong(), 1, 0.25F);
this.stoneNoise = new double[256];
this.field_147430_m = new NoiseGeneratorPerlin(this.rand, 4);
}
public void generateTerrain(int chunkX, int chunkZ, Block[] idArray, byte[] metaArray)
{
this.noiseGen1.setFrequency(0.015F);
this.noiseGen2.setFrequency(0.01F);
this.noiseGen3.setFrequency(0.01F);
this.noiseGen4.setFrequency(0.01F);
this.noiseGen5.setFrequency(0.01F);
this.noiseGen6.setFrequency(0.001F);
this.noiseGen7.setFrequency(0.005F);
for (int x = 0; x < ChunkProviderSpaceCraters.CHUNK_SIZE_X; x++)
{
for (int z = 0; z < ChunkProviderSpaceCraters.CHUNK_SIZE_Z; z++)
{
final double baseHeight = this.noiseGen1.getNoise(chunkX * 16 + x, chunkZ * 16 + z) * this.TERRAIN_HEIGHT_MOD;
final double smallHillHeight = this.noiseGen2.getNoise(chunkX * 16 + x, chunkZ * 16 + z) * this.SMALL_FEATURE_HEIGHT_MOD;
double mountainHeight = Math.abs(this.noiseGen3.getNoise(chunkX * 16 + x, chunkZ * 16 + z));
double valleyHeight = Math.abs(this.noiseGen4.getNoise(chunkX * 16 + x, chunkZ * 16 + z));
final double featureFilter = this.noiseGen5.getNoise(chunkX * 16 + x, chunkZ * 16 + z) * ChunkProviderSpaceCraters.MAIN_FEATURE_FILTER_MOD;
final double largeFilter = this.noiseGen6.getNoise(chunkX * 16 + x, chunkZ * 16 + z) * ChunkProviderSpaceCraters.LARGE_FEATURE_FILTER_MOD;
final double smallFilter = this.noiseGen7.getNoise(chunkX * 16 + x, chunkZ * 16 + z) * ChunkProviderSpaceCraters.SMALL_FEATURE_FILTER_MOD - 0.5;
mountainHeight = this.lerp(smallHillHeight, mountainHeight * this.MOUNTAIN_HEIGHT_MOD, this.fade(this.clamp(mountainHeight * 2, 0, 1)));
valleyHeight = this.lerp(smallHillHeight, valleyHeight * this.VALLEY_HEIGHT_MOD - this.VALLEY_HEIGHT_MOD + 9, this.fade(this.clamp((valleyHeight + 2) * 4, 0, 1)));
double yDev = this.lerp(valleyHeight, mountainHeight, this.fade(largeFilter));
yDev = this.lerp(smallHillHeight, yDev, smallFilter);
yDev = this.lerp(baseHeight, yDev, featureFilter);
GSBiomeGenBase biomegenbase = (GSBiomeGenBase) this.worldObj.getBiomeGenForCoords(x, z);
for (int y = 0; y < ChunkProviderSpaceCraters.CHUNK_SIZE_Y; y++)
{
if (y < this.MID_HEIGHT + yDev)
{
//idArray[this.getIndex(x, y, z)] = this.getStoneBlock().getBlock();
//metaArray[this.getIndex(x, y, z)] = this.getStoneBlock().getMetadata();
idArray[this.getIndex(x, y, z)] = biomegenbase.stoneBlock;
metaArray[this.getIndex(x, y, z)] = biomegenbase.stoneMeta;
}
}
}
}
}
protected double lerp(double d1, double d2, double t)
{
if (t < 0.0)
{
return d1;
}
else if (t > 1.0)
{
return d2;
}
else
{
return d1 + (d2 - d1) * t;
}
}
protected double fade(double n)
{
return n * n * n * (n * (n * 6 - 15) + 10);
}
protected double clamp(double x, double min, double max)
{
if (x < min)
{
return min;
}
if (x > max)
{
return max;
}
return x;
}
@Override
public void replaceBlocksForBiome(int par1, int par2, Block[] arrayOfIDs, byte[] arrayOfMeta, BiomeGenBase[] par4ArrayOfBiomeGenBase)
{
final int var5 = 20;
final float var6 = 0.03125F;
this.noiseGen4.setFrequency(var6 * 2);
for (int var8 = 0; var8 < 16; ++var8)
{
for (int var9 = 0; var9 < 16; ++var9)
{
GSBiomeGenBase biomegenbase = (GSBiomeGenBase) par4ArrayOfBiomeGenBase[var8 + var9 * 16];
final int var12 = (int) (this.noiseGen4.getNoise(par1 * 16 + var8, par2 * 16 + var9) / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);
int var13 = -1;
Block var14 = biomegenbase.topBlock;
byte var14m = biomegenbase.topMeta;
Block var15 = biomegenbase.fillerBlock;
byte var15m = biomegenbase.fillerMeta;
for (int var16 = ChunkProviderSpaceCraters.CHUNK_SIZE_Y - 1; var16 >= 0; --var16)
{
final int index = this.getIndex(var8, var16, var9);
if (var16 <= 0 + this.rand.nextInt(5))
{
arrayOfIDs[index] = Blocks.bedrock;
}
else
{
final Block var18 = arrayOfIDs[index];
if (Blocks.air == var18)
{
var13 = -1;
}
else if (var18 == biomegenbase.stoneBlock)
{
arrayOfMeta[index] = biomegenbase.stoneMeta;
if (var13 == -1)
{
if (var12 <= 0)
{
var14 = Blocks.air;
var14m = 0;
var15 = biomegenbase.stoneBlock;
var15m = biomegenbase.stoneMeta;
}
else if (var16 >= var5 - -16 && var16 <= var5 + 1)
{
var14 = biomegenbase.topBlock;
var14m = biomegenbase.topMeta;
var14 = biomegenbase.fillerBlock;
var14m = biomegenbase.fillerMeta;
}
var13 = var12;
if (var16 >= var5 - 1)
{
arrayOfIDs[index] = var14;
arrayOfMeta[index] = var14m;
}
else
{
arrayOfIDs[index] = var15;
arrayOfMeta[index] = var15m;
}
}
else if (var13 > 0)
{
--var13;
arrayOfIDs[index] = var15;
arrayOfMeta[index] = var15m;
}
}
}
}
}
}
}
@Override
public Chunk provideChunk(int x, int z)
{
this.rand.setSeed(x * 341873128712L + z * 132897987541L);
Block[] blockStorage = new Block[256 * 256];
byte[] metaStorage = new byte[256 * 256];
this.generateTerrain(x, z, blockStorage, metaStorage);
this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);
this.replaceBlocksForBiome(x, z, blockStorage, metaStorage, this.biomesForGeneration);
this.onChunkProvide(x, z, blockStorage, metaStorage);
Chunk chunk = new Chunk(this.worldObj, blockStorage, metaStorage, x, z);
byte[] chunkBiomes = chunk.getBiomeArray();
if (this.worldGenerators == null)
{
this.worldGenerators = this.getWorldGenerators();
}
for (MapGenBaseMeta generator : this.worldGenerators)
{
generator.generate(this, this.worldObj, x, z, blockStorage, metaStorage);
}
for (int i = 0; i < chunkBiomes.length; i++)
{
chunkBiomes[i] = (byte)this.biomesForGeneration[i].biomeID;
}
chunk.generateSkylightMap();
return chunk;
}
public void createCraters(int chunkX, int chunkZ, Block[] chunkArray, byte[] metaArray)
{
this.noiseGen5.setFrequency(0.015F);
for (int cx = chunkX - 2; cx <= chunkX + 2; cx++)
{
for (int cz = chunkZ - 2; cz <= chunkZ + 2; cz++)
{
for (int x = 0; x < ChunkProviderSpaceCraters.CHUNK_SIZE_X; x++)
{
for (int z = 0; z < ChunkProviderSpaceCraters.CHUNK_SIZE_Z; z++)
{
if (Math.abs(this.randFromPoint(cx * 16 + x, (cz * 16 + z) * 1000)) < this.noiseGen5.getNoise(cx * 16 + x, cz * 16 + z) / this.CRATER_PROB)
{
final Random random = new Random(cx * 16 + x + (cz * 16 + z) * 5000);
final EnumCraterSize cSize = EnumCraterSize.sizeArray[random.nextInt(EnumCraterSize.sizeArray.length)];
final int size = random.nextInt(cSize.MAX_SIZE - cSize.MIN_SIZE) + cSize.MIN_SIZE + 15;
this.makeCrater(cx * 16 + x, cz * 16 + z, chunkX * 16, chunkZ * 16, size, chunkArray, metaArray);
}
}
}
}
}
}
public void makeCrater(int craterX, int craterZ, int chunkX, int chunkZ, int size, Block[] chunkArray, byte[] metaArray)
{
for (int x = 0; x < ChunkProviderSpaceCraters.CHUNK_SIZE_X; x++)
{
for (int z = 0; z < ChunkProviderSpaceCraters.CHUNK_SIZE_Z; z++)
{
double xDev = craterX - (chunkX + x);
double zDev = craterZ - (chunkZ + z);
if (xDev * xDev + zDev * zDev < size * size)
{
xDev /= size;
zDev /= size;
final double sqrtY = xDev * xDev + zDev * zDev;
double yDev = sqrtY * sqrtY * 6;
yDev = 5 - yDev;
int helper = 0;
for (int y = 127; y > 0; y--)
{
if (Blocks.air != chunkArray[this.getIndex(x, y, z)] && helper <= yDev)
{
chunkArray[this.getIndex(x, y, z)] = Blocks.air;
metaArray[this.getIndex(x, y, z)] = 0;
helper++;
}
if (helper > yDev)
{
break;
}
}
}
}
}
}
private int getIndex(int x, int y, int z)
{
return (x * 16 + z) * 256 + y;
}
private double randFromPoint(int x, int z)
{
int n;
n = x + z * 57;
n = n << 13 ^ n;
return 1.0 - (n * (n * n * 15731 + 789221) + 1376312589 & 0x7fffffff) / 1073741824.0;
}
@Override
public boolean chunkExists(int par1, int par2)
{
return true;
}
public void decoratePlanet(World par1World, Random par2Random, int par3, int par4)
{
this.getBiomeGenerator().decorate(par1World, par2Random, par3, par4);
}
@Override
public void populate(IChunkProvider par1IChunkProvider, int par2, int par3)
{
BlockFalling.fallInstantly = true;
int var4 = par2 * 16;
int var5 = par3 * 16;
BiomeGenBase biomeGen = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);
this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);
this.rand.setSeed(this.worldObj.getSeed());
final long var7 = this.rand.nextLong() / 2L * 2L + 1L;
final long var9 = this.rand.nextLong() / 2L * 2L + 1L;
this.rand.setSeed(par2 * var7 + par3 * var9 ^ this.worldObj.getSeed());
this.decoratePlanet(this.worldObj, this.rand, var4, var5);
biomeGen.decorate(this.worldObj, this.rand, var4, var5);
this.onPopulate(par1IChunkProvider, par2, par3);
BlockFalling.fallInstantly = false;
}
@Override
public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate)
{
return true;
}
@Override
public boolean canSave()
{
return true;
}
@Override
public Chunk loadChunk(int x, int z)
{
return this.provideChunk(x, z);
}
@Override
public String makeString()
{
return "RandomLevelSource";
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int i, int j, int k)
{
if (par1EnumCreatureType == EnumCreatureType.monster)
{
final List monsters = new ArrayList();
for (SpawnListEntry monster : this.getMonsters())
{
monsters.add(monster);
}
return monsters;
}
else if (par1EnumCreatureType == EnumCreatureType.creature)
{
final List creatures = new ArrayList();
for (SpawnListEntry creature : this.getCreatures())
{
creatures.add(creature);
}
return creatures;
}
else if (par1EnumCreatureType == EnumCreatureType.waterCreature)
{
final List watercreatures = new ArrayList();
for (SpawnListEntry watercreature : this.getWaterCreatures())
{
watercreatures.add(watercreature);
}
return watercreatures;
}
else
{
return null;
}
}
/**
* Do not return null
*
* @return The biome generator for this world, handles ore, flower, etc
* generation. See GCBiomeDecoratorBase.
*/
protected abstract BiomeDecoratorSpace getBiomeGenerator();
/**
* Do not return null, have at least one biome for generation
*
* @return Biome instance for generation
*/
protected abstract BiomeGenBase[] getBiomesForGeneration();
/**
* @return The average terrain level. Default is 64.
*/
protected abstract int getSeaLevel();
/**
* List of all world generators to use. Caves, ravines, structures, etc.
* <p/>
* Return an empty list for no world generators. Do not return null.
*
* @return
*/
protected abstract List<MapGenBaseMeta> getWorldGenerators();
/**
* @return List of spawn list entries for monsters
*/
protected abstract SpawnListEntry[] getMonsters();
/**
* @return List of spawn list entries for creatures
*/
protected abstract SpawnListEntry[] getCreatures();
/**
* @return List of spawn list entries for water creatures
*/
protected abstract SpawnListEntry[] getWaterCreatures();
/**
* @return Base height modifier
*/
public abstract double getHeightModifier();
/**
* @return Height modifier for small hills
*/
public abstract double getSmallFeatureHeightModifier();
/**
* @return Height modifier for mountains
*/
public abstract double getMountainHeightModifier();
/**
* @return Height modifier for valleys
*/
public abstract double getValleyHeightModifier();
/**
* @return Probability that craters will be generated
*/
public abstract int getCraterProbability();
public abstract void onChunkProvide(int cX, int cZ, Block[] blocks, byte[] metadata);
public abstract void onPopulate(IChunkProvider provider, int cX, int cZ);
/**
* The stone block to be generated. Doesn't have to be stone of course.
*
* @return BlockMetaPair instance containing ID and metadata for stone
* block.
*/
protected abstract BlockMetaPair getStoneBlock();
}
Проблема следующая:
Второй биом генерируется с другими блоками (со слоем Stone из первого) и лишь со слоем Stone...
Как фиксить?