Good day, radfast.
Trying to make craters on Mercury, made here so ChunkProviderMercury:
But Craters not.
Trying to make craters on Mercury, made here so ChunkProviderMercury:
Code:
package blessentumble.planets.mercury.dimension;
import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE;
import java.util.List;
import java.util.Random;
import micdoodle8.mods.galacticraft.api.prefab.core.BlockMetaPair;
import micdoodle8.mods.galacticraft.api.prefab.world.gen.BiomeDecoratorSpace;
import micdoodle8.mods.galacticraft.api.prefab.world.gen.ChunkProviderSpace;
import micdoodle8.mods.galacticraft.api.prefab.world.gen.MapGenBaseMeta;
import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper;
import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton;
import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedZombie;
import micdoodle8.mods.galacticraft.core.perlin.NoiseModule;
import micdoodle8.mods.galacticraft.core.perlin.generator.Gradient;
import micdoodle8.mods.galacticraft.core.world.gen.EnumCraterSize;
import micdoodle8.mods.galacticraft.core.world.gen.MapGenCavesMoon;
import micdoodle8.mods.galacticraft.core.world.gen.dungeon.MapGenDungeon;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.MapGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.terraingen.TerrainGen;
import blessentumble.core.blocks.BlocksAddon;
import blessentumble.moons.io.entities.EntityEvolvedFireCreeper;
import blessentumble.planets.mercury.world.gen.BiomeDecoratorMercury;
import blessentumble.planets.venus.entity.EntityEvolvedFireSpider;
import com.google.common.collect.Lists;
public class ChunkProviderMercury extends ChunkProviderSpace {
private static final int CRATER_PROB = 300;
// DO NOT CHANGE
private static final int MID_HEIGHT = 68;
private static final int CHUNK_SIZE_X = 16;
private static final int CHUNK_SIZE_Y = 128;
private static final int CHUNK_SIZE_Z = 16;
private final NoiseModule noiseGen1;
private final NoiseModule noiseGen2;
private final NoiseModule noiseGen3;
private final NoiseModule noiseGen4;
@Override
protected List getWorldGenerators()
{
List<MapGenBaseMeta> generators = Lists.newArrayList();
generators.add(new MapGenCavesMoon());
return generators;
}
public ChunkProviderMercury(World par1World, long seed, boolean mapFeaturesEnabled)
{
super(par1World, seed, mapFeaturesEnabled);
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(), 1, 0.25F);
this.noiseGen4 = new Gradient(this.rand.nextLong(), 1, 0.25F);
}
public void generateTerrain(int chunkX, int chunkZ, Block[] idArray, byte[] metaArray)
{
this.noiseGen1.setFrequency(0.0125F);
this.noiseGen2.setFrequency(0.015F);
this.noiseGen3.setFrequency(0.01F);
this.noiseGen4.setFrequency(0.02F);
for (int x = 0; x < ChunkProviderMercury.CHUNK_SIZE_X; x++)
{
for (int z = 0; z < ChunkProviderMercury.CHUNK_SIZE_Z; z++)
{
final double d = this.noiseGen1.getNoise(x + chunkX * 16, z + chunkZ * 16) * 8;
final double d2 = this.noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16) * 24;
double d3 = this.noiseGen3.getNoise(x + chunkX * 16, z + chunkZ * 16) - 0.1;
d3 *= 4;
double yDev = 0;
if (d3 < 0.0D)
{
yDev = d;
}
else if (d3 > 1.0D)
{
yDev = d2;
}
else
{
yDev = d + (d2 - d) * d3;
}
for (int y = 0; y < ChunkProviderMercury.CHUNK_SIZE_Y; y++)
{
if (y < ChunkProviderMercury.MID_HEIGHT + yDev)
{
idArray[this.getIndex(x, y, z)] = BlocksAddon.MercuryGrunt;
metaArray[this.getIndex(x, y, z)] = 0;
}
}
}
}
}
@Override
protected BiomeDecoratorSpace getBiomeGenerator() {
// TODO Auto-generated method stub
return new BiomeDecoratorMercury();
}
//This should be a custom biome for your mod, but I'm opting to go desert instead out of quickness
//and the fact that biomes are outside the scope of this tutorial
@Override
protected BiomeGenBase[] getBiomesForGeneration() {
return new BiomeGenBase[]{BiomeGenBase.extremeHillsPlus};
}
@Override
public int getCraterProbability() {
return 300;
}
@Override
protected SpawnListEntry[] getCreatures() {
return new SpawnListEntry[]{};
}
@Override
protected BlockMetaPair getStoneBlock() {
// TODO Auto-generated method stub
return new BlockMetaPair(BlocksAddon.MercuryGrunt, (byte) 4);
}
@Override
protected BlockMetaPair getDirtBlock() {
// TODO Auto-generated method stub
return new BlockMetaPair(BlocksAddon.MercurySubGrunt, (byte) 3);
}
@Override
protected BlockMetaPair getGrassBlock() {
// TODO Auto-generated method stub
return new BlockMetaPair(BlocksAddon.MercuryGrunt, (byte) 1);
}
@Override
public double getHeightModifier() {
// TODO Auto-generated method stub
return 10;
}
@Override
protected SpawnListEntry[] getMonsters() {
SpawnListEntry skele = new SpawnListEntry(EntityEvolvedSkeleton.class, 100, 4, 4);
SpawnListEntry creeper = new SpawnListEntry(EntityEvolvedFireCreeper.class, 100, 4, 4);
SpawnListEntry spider = new SpawnListEntry(EntityEvolvedFireSpider.class, 100, 4, 4);
return new SpawnListEntry[]{skele, creeper, spider};
}
@Override
public double getMountainHeightModifier() {
return 0;
}
@Override
protected int getSeaLevel() {
return 60;
}
@Override
public double getSmallFeatureHeightModifier() {
return 5;
}
@Override
public double getValleyHeightModifier() {
return 0;
}
@Override
public void onPopulate(IChunkProvider arg0, int arg1, int arg2){
//this.dungeonGenerator.handleTileEntities(this.rand);
}
@Override
public boolean chunkExists(int x, int y){
return false;
}
public void createCraters(int chunkX, int chunkZ, Block[] chunkArray, byte[] metaArray)
{
for (int cx = chunkX - 2; cx <= chunkX + 2; cx++)
{
for (int cz = chunkZ - 2; cz <= chunkZ + 2; cz++)
{
for (int x = 0; x < ChunkProviderMercury.CHUNK_SIZE_X; x++)
{
for (int z = 0; z < ChunkProviderMercury.CHUNK_SIZE_Z; z++)
{
if (Math.abs(this.randFromPoint(cx * 16 + x, (cz * 16 + z) * 1000)) < this.noiseGen4.getNoise(x * ChunkProviderMercury.CHUNK_SIZE_X + x, cz * ChunkProviderMercury.CHUNK_SIZE_Z + z) / ChunkProviderMercury.this.getCraterProbability())
{
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;
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 < ChunkProviderMercury.CHUNK_SIZE_X; x++)
{
for (int z = 0; z < ChunkProviderMercury.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 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;
}
private int getIndex(int x, int y, int z)
{
return (x * 16 + z) * 256 + y;
}
@Override
public void onChunkProvide(int cX, int cZ, Block[] blocks, byte[] metadata) {
//this.dungeonGenerator.generateUsingArrays(this.worldObj, this.worldObj.getSeed(), cX * 16, 30, cZ * 16, cX, cZ, blocks, metadata);
this.generateTerrain(cX, cZ, blocks, metadata);
this.createCraters(cX, cZ, blocks, metadata);
}
}
But Craters not.