use of net.minecraft.world.gen.ChunkProviderSettings in project Realistic-Terrain-Generation by Team-RTG.
the class BiomeDecoratorRTG method decorateOres.
/*
* This method should only be called by ChunkProviderRTG#generateOres.
*/
public void decorateOres(World worldIn, Random random, int worldX, int worldZ) {
//Logger.debug("Started generating ores in %s (%d %d)", this.biome.getBiomeName(), worldX, worldZ);
BiomeDecorator biomeDecorator = biome.theBiomeDecorator;
if (biomeDecorator.chunkProviderSettings == null) {
String generatorOptions = worldIn.getWorldInfo().getGeneratorOptions();
generatorOptions = (generatorOptions != null) ? generatorOptions : "";
biomeDecorator.chunkProviderSettings = ChunkProviderSettings.Factory.jsonToFactory(generatorOptions).build();
}
// This local variable has to be declared/initialised AFTER the chunk provider settings have been built.
ChunkProviderSettings chunkProviderSettings = biomeDecorator.chunkProviderSettings;
pos = new BlockPos(worldX, 0, worldZ);
biomeDecorator.dirtGen = new WorldGenMinable(Blocks.DIRT.getDefaultState(), chunkProviderSettings.dirtSize);
biomeDecorator.gravelGen = new WorldGenMinable(Blocks.GRAVEL.getDefaultState(), chunkProviderSettings.gravelSize);
biomeDecorator.graniteGen = new WorldGenMinable(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE), chunkProviderSettings.graniteSize);
biomeDecorator.dioriteGen = new WorldGenMinable(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE), chunkProviderSettings.dioriteSize);
biomeDecorator.andesiteGen = new WorldGenMinable(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE), chunkProviderSettings.andesiteSize);
biomeDecorator.coalGen = new WorldGenMinable(Blocks.COAL_ORE.getDefaultState(), chunkProviderSettings.coalSize);
biomeDecorator.ironGen = new WorldGenMinable(Blocks.IRON_ORE.getDefaultState(), chunkProviderSettings.ironSize);
biomeDecorator.goldGen = new WorldGenMinable(Blocks.GOLD_ORE.getDefaultState(), chunkProviderSettings.goldSize);
biomeDecorator.redstoneGen = new WorldGenMinable(Blocks.REDSTONE_ORE.getDefaultState(), chunkProviderSettings.redstoneSize);
biomeDecorator.diamondGen = new WorldGenMinable(Blocks.DIAMOND_ORE.getDefaultState(), chunkProviderSettings.diamondSize);
biomeDecorator.lapisGen = new WorldGenMinable(Blocks.LAPIS_ORE.getDefaultState(), chunkProviderSettings.lapisSize);
MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(worldIn, random, pos));
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.dirtGen, pos, OreGenEvent.GenerateMinable.EventType.DIRT)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.dirtCount, biomeDecorator.dirtGen, chunkProviderSettings.dirtMinHeight, chunkProviderSettings.dirtMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.gravelGen, pos, OreGenEvent.GenerateMinable.EventType.GRAVEL)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.gravelCount, biomeDecorator.gravelGen, chunkProviderSettings.gravelMinHeight, chunkProviderSettings.gravelMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.dioriteGen, pos, OreGenEvent.GenerateMinable.EventType.DIORITE)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.dioriteCount, biomeDecorator.dioriteGen, chunkProviderSettings.dioriteMinHeight, chunkProviderSettings.dioriteMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.graniteGen, pos, OreGenEvent.GenerateMinable.EventType.GRANITE)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.graniteCount, biomeDecorator.graniteGen, chunkProviderSettings.graniteMinHeight, chunkProviderSettings.graniteMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.andesiteGen, pos, OreGenEvent.GenerateMinable.EventType.ANDESITE)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.andesiteCount, biomeDecorator.andesiteGen, chunkProviderSettings.andesiteMinHeight, chunkProviderSettings.andesiteMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.coalGen, pos, OreGenEvent.GenerateMinable.EventType.COAL)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.coalCount, biomeDecorator.coalGen, chunkProviderSettings.coalMinHeight, chunkProviderSettings.coalMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.ironGen, pos, OreGenEvent.GenerateMinable.EventType.IRON)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.ironCount, biomeDecorator.ironGen, chunkProviderSettings.ironMinHeight, chunkProviderSettings.ironMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.goldGen, pos, OreGenEvent.GenerateMinable.EventType.GOLD)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.goldCount, biomeDecorator.goldGen, chunkProviderSettings.goldMinHeight, chunkProviderSettings.goldMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.redstoneGen, pos, OreGenEvent.GenerateMinable.EventType.REDSTONE)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.redstoneCount, biomeDecorator.redstoneGen, chunkProviderSettings.redstoneMinHeight, chunkProviderSettings.redstoneMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.diamondGen, pos, OreGenEvent.GenerateMinable.EventType.DIAMOND)) {
this.genStandardOre1(worldIn, random, chunkProviderSettings.diamondCount, biomeDecorator.diamondGen, chunkProviderSettings.diamondMinHeight, chunkProviderSettings.diamondMaxHeight);
}
if (TerrainGen.generateOre(worldIn, random, biomeDecorator.lapisGen, pos, OreGenEvent.GenerateMinable.EventType.LAPIS)) {
this.genStandardOre2(worldIn, random, chunkProviderSettings.lapisCount, biomeDecorator.lapisGen, chunkProviderSettings.lapisCenterHeight, chunkProviderSettings.lapisSpread);
}
if (rbb.generatesEmeralds()) {
this.genEmeraldOre(worldIn, random, pos);
}
if (rbb.generatesSilverfish()) {
this.genSilverfishOre(worldIn, random, pos);
}
if (rbb.getExtraGoldGenCount() > 0) {
this.genStandardOre1(worldIn, random, rbb.getExtraGoldGenCount(), biomeDecorator.goldGen, rbb.getExtraGoldGenMinHeight(), rbb.getExtraGoldGenMaxHeight());
}
MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(worldIn, random, pos));
//Logger.debug("Finished generating ores in %s (%d %d)", this.biome.getBiomeName(), worldX, worldZ);
}
use of net.minecraft.world.gen.ChunkProviderSettings in project RFToolsDimensions by McJty.
the class NormalTerrainGenerator method generateHeightmap.
protected void generateHeightmap(int chunkX4, int chunkY4, int chunkZ4) {
ChunkProviderSettings settings = provider.getSettings();
this.depthRegion = this.depthNoise.generateNoiseOctaves(this.depthRegion, chunkX4, chunkZ4, 5, 5, (double) settings.depthNoiseScaleX, (double) settings.depthNoiseScaleZ, (double) settings.depthNoiseScaleExponent);
float f = settings.coordinateScale;
float f1 = settings.heightScale;
this.mainNoiseRegion = this.mainPerlinNoise.generateNoiseOctaves(this.mainNoiseRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, (double) (f / settings.mainNoiseScaleX), (double) (f1 / settings.mainNoiseScaleY), (double) (f / settings.mainNoiseScaleZ));
this.minLimitRegion = this.minLimitPerlinNoise.generateNoiseOctaves(this.minLimitRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, (double) f, (double) f1, (double) f);
this.maxLimitRegion = this.maxLimitPerlinNoise.generateNoiseOctaves(this.maxLimitRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, (double) f, (double) f1, (double) f);
int i = 0;
int j = 0;
boolean domaze = false;
boolean elevated = false;
boolean donearlands = provider.dimensionInformation.getTerrainType() == TerrainType.TERRAIN_NEARLANDS;
if (donearlands) {
elevated = true;
}
if (provider.dimensionInformation.hasFeatureType(FeatureType.FEATURE_MAZE)) {
domaze = true;
long s2 = (((chunkX4 >> 2) + provider.seed + 13) * 314) + (chunkZ4 >> 2) * 17L;
Random rand = new Random(s2);
// Skip one.
rand.nextFloat();
elevated = ((chunkX4 >> 2) & 1) == 0;
if (rand.nextFloat() < .2f) {
elevated = !elevated;
}
}
if (donearlands) {
int cx = chunkX4 >> 2;
int cz = chunkZ4 >> 2;
if (Math.abs(cx) < 5 && Math.abs(cz) < 5) {
elevated = false;
}
}
if (provider.biomesForGeneration == null) {
Logging.log("Dimension " + world.provider.getDimension() + " has a problem! Ignoring for now.");
return;
}
for (int k = 0; k < 5; ++k) {
for (int l = 0; l < 5; ++l) {
float f2 = 0.0F;
float f3 = 0.0F;
float f4 = 0.0F;
Biome Biome = provider.biomesForGeneration[k + 2 + (l + 2) * 10];
for (int j1 = -2; j1 <= 2; ++j1) {
for (int k1 = -2; k1 <= 2; ++k1) {
Biome Biome1 = provider.biomesForGeneration[k + j1 + 2 + (l + k1 + 2) * 10];
float f5 = provider.getSettings().biomeDepthOffSet + Biome1.getBaseHeight() * provider.getSettings().biomeDepthWeight;
float f6 = provider.getSettings().biomeScaleOffset + Biome1.getHeightVariation() * provider.getSettings().biomeScaleWeight;
if (domaze || donearlands) {
if (f5 > 0.0F && elevated) {
if (provider.worldType == WorldType.AMPLIFIED) {
f5 = 2.0F + f5 * 1.5f;
f6 = 1.0F + f6 * 3.0f;
} else {
f5 = 2.0F + f5;
f6 = 0.5F + f6 * 1.5f;
}
} else {
if (provider.worldType == WorldType.AMPLIFIED && f5 > 0.0f) {
f5 = 0.5F + f5 * 1.5F;
f6 = 0.5F + f6 * 2.0F;
} else {
f6 = f6 * 0.5F;
}
}
} else {
if (provider.worldType == WorldType.AMPLIFIED && f5 > 0.0F) {
f5 = 1.0F + f5 * 2.0F;
f6 = 1.0F + f6 * 4.0F;
}
}
float f7 = biomeWeights[j1 + 2 + (k1 + 2) * 5] / (f5 + 2.0F);
if (Biome1.getBaseHeight() > Biome.getBaseHeight()) {
f7 /= 2.0F;
}
f2 += f6 * f7;
f3 += f5 * f7;
f4 += f7;
}
}
f2 /= f4;
f3 /= f4;
f2 = f2 * 0.9F + 0.1F;
f3 = (f3 * 4.0F - 1.0F) / 8.0F;
double d12 = this.depthRegion[j] / 8000.0D;
if (d12 < 0.0D) {
d12 = -d12 * 0.3D;
}
d12 = d12 * 3.0D - 2.0D;
if (d12 < 0.0D) {
d12 /= 2.0D;
if (d12 < -1.0D) {
d12 = -1.0D;
}
d12 /= 1.4D;
d12 /= 2.0D;
} else {
if (d12 > 1.0D) {
d12 = 1.0D;
}
d12 /= 8.0D;
}
++j;
double d13 = f3;
double d14 = f2;
d13 += d12 * 0.2D;
d13 = d13 * 8.5D / 8.0D;
double d5 = 8.5D + d13 * 4.0D;
for (int j2 = 0; j2 < 33; ++j2) {
double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14;
if (d6 < 0.0D) {
d6 *= 4.0D;
}
double d7 = this.minLimitRegion[i] / 512.0D;
double d8 = this.maxLimitRegion[i] / 512.0D;
double d9 = (this.mainNoiseRegion[i] / 10.0D + 1.0D) / 2.0D;
double d10 = MathTools.clamp(d7, d8, d9) - d6;
if (j2 > 29) {
double d11 = ((j2 - 29) / 3.0F);
d10 = d10 * (1.0D - d11) + -10.0D * d11;
}
this.heightMap[i] = d10;
++i;
}
}
}
}
use of net.minecraft.world.gen.ChunkProviderSettings in project RFToolsDimensions by McJty.
the class UpsideDownTerrainGenerator method generateHeightmap.
private void generateHeightmap(int chunkX4, int chunkY4, int chunkZ4) {
ChunkProviderSettings settings = provider.getSettings();
this.depthRegion = this.depthNoise.generateNoiseOctaves(this.depthRegion, chunkX4, chunkZ4, 5, 5, settings.depthNoiseScaleX, (double) settings.depthNoiseScaleZ, (double) settings.depthNoiseScaleExponent);
float f = settings.coordinateScale;
float f1 = settings.heightScale;
this.mainNoiseRegion = this.mainPerlinNoise.generateNoiseOctaves(this.mainNoiseRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, (double) (f / settings.mainNoiseScaleX), (double) (f1 / settings.mainNoiseScaleY), (double) (f / settings.mainNoiseScaleZ));
this.minLimitRegion = this.minLimitPerlinNoise.generateNoiseOctaves(this.minLimitRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, (double) f, (double) f1, (double) f);
this.maxLimitRegion = this.maxLimitPerlinNoise.generateNoiseOctaves(this.maxLimitRegion, chunkX4, chunkY4, chunkZ4, 5, 33, 5, (double) f, (double) f1, (double) f);
int i = 0;
int j = 0;
boolean domaze = false;
boolean elevated = false;
boolean donearlands = provider.dimensionInformation.getTerrainType() == TerrainType.TERRAIN_NEARLANDS;
if (donearlands) {
elevated = true;
}
if (provider.dimensionInformation.hasFeatureType(FeatureType.FEATURE_MAZE)) {
domaze = true;
long s2 = (((chunkX4 >> 2) + provider.seed + 13) * 314) + (chunkZ4 >> 2) * 17L;
Random rand = new Random(s2);
// Skip one.
rand.nextFloat();
elevated = ((chunkX4 >> 2) & 1) == 0;
if (rand.nextFloat() < .2f) {
elevated = !elevated;
}
}
if (donearlands) {
int cx = chunkX4 >> 2;
int cz = chunkZ4 >> 2;
if (Math.abs(cx) < 5 && Math.abs(cz) < 5) {
elevated = false;
}
}
if (provider.biomesForGeneration == null) {
Logging.log("Dimension " + world.provider.getDimension() + " has a problem! Ignoring for now.");
return;
}
for (int k = 0; k < 5; ++k) {
for (int l = 0; l < 5; ++l) {
float f2 = 0.0F;
float f3 = 0.0F;
float f4 = 0.0F;
Biome Biome = provider.biomesForGeneration[k + 2 + (l + 2) * 10];
for (int j1 = -2; j1 <= 2; ++j1) {
for (int k1 = -2; k1 <= 2; ++k1) {
Biome Biome1 = provider.biomesForGeneration[k + j1 + 2 + (l + k1 + 2) * 10];
float f5 = provider.getSettings().biomeDepthOffSet + Biome1.getBaseHeight() * provider.getSettings().biomeDepthWeight;
float f6 = provider.getSettings().biomeScaleOffset + Biome1.getHeightVariation() * provider.getSettings().biomeScaleWeight;
if (domaze || donearlands) {
if (f5 > 0.0F && elevated) {
if (provider.worldType == WorldType.AMPLIFIED) {
f5 = 2.0F + f5 * 1.5f;
f6 = 1.0F + f6 * 3.0f;
} else {
f5 = 2.0F + f5;
f6 = 0.5F + f6 * 1.5f;
}
} else {
if (provider.worldType == WorldType.AMPLIFIED && f5 > 0.0f) {
f5 = 0.5F + f5 * 1.5F;
f6 = 0.5F + f6 * 2.0F;
} else {
f6 = f6 * 0.5F;
}
}
} else {
if (provider.worldType == WorldType.AMPLIFIED && f5 > 0.0F) {
f5 = 1.0F + f5 * 2.0F;
f6 = 1.0F + f6 * 4.0F;
}
}
float f7 = biomeWeights[j1 + 2 + (k1 + 2) * 5] / (f5 + 2.0F);
if (Biome1.getBaseHeight() > Biome.getBaseHeight()) {
f7 /= 2.0F;
}
f2 += f6 * f7;
f3 += f5 * f7;
f4 += f7;
}
}
f2 /= f4;
f3 /= f4;
f2 = f2 * 0.9F + 0.1F;
f3 = (f3 * 4.0F - 1.0F) / 8.0F;
double d12 = this.depthRegion[j] / 8000.0D;
if (d12 < 0.0D) {
d12 = -d12 * 0.3D;
}
d12 = d12 * 3.0D - 2.0D;
if (d12 < 0.0D) {
d12 /= 2.0D;
if (d12 < -1.0D) {
d12 = -1.0D;
}
d12 /= 1.4D;
d12 /= 2.0D;
} else {
if (d12 > 1.0D) {
d12 = 1.0D;
}
d12 /= 8.0D;
}
++j;
double d13 = f3;
double d14 = f2;
d13 += d12 * 0.2D;
d13 = d13 * 8.5D / 8.0D;
double d5 = 8.5D + d13 * 4.0D;
for (int j2 = 0; j2 < 33; ++j2) {
double d6 = (j2 - d5) * 12.0D * 128.0D / 256.0D / d14;
if (d6 < 0.0D) {
d6 *= 4.0D;
}
double d7 = this.minLimitRegion[i] / 512.0D;
double d8 = this.maxLimitRegion[i] / 512.0D;
double d9 = (this.mainNoiseRegion[i] / 10.0D + 1.0D) / 2.0D;
double d10 = MathTools.clamp(d7, d8, d9) - d6;
if (j2 > 29) {
double d11 = ((j2 - 29) / 3.0F);
d10 = d10 * (1.0D - d11) + -10.0D * d11;
}
this.heightMap[i] = d10;
++i;
}
}
}
}
Aggregations