Jump to content

Caves, Just don't work?


CJCutrone9

Recommended Posts

Hello all, got my custom dimension to work, with custom trees, grass, dirt rock, ores, plants, etc. But not, I am walking around and I see a hole in the ground, I think, "Yes, finally a cave!" and when I fly down there I see.... The dirt has a hole in it, but the rock was not replaced in the cave generation leaving me with this:

 

2013-110.jpg

 

Anyone know what is going on with this? I find it slightly weird because when I originally started working on the dimension and used my custom rock, grass, dirt, it generated them perfectely (I even got one that was far batter than any I have seen in vanilla) and somewhere in the process of me adding in trees/plants/custom models/ores it got messed up and does that.

 

Here is all the code I think you guys might need:

 

WorldProvider

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.client.main.Main;

import net.minecraft.util.ChunkCoordinates;

import net.minecraft.util.MathHelper;

import net.minecraft.util.Vec3;

import net.minecraft.world.World;

import net.minecraft.world.WorldProvider;

import net.minecraft.world.biome.WorldChunkManagerHell;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraftforge.common.DimensionManager;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class LegendofZeldaWorldProvider extends WorldProvider

{

private float[] colorsSunriseSunset = new float[4];

public void registerWorldChunkManager()

{

this.worldChunkMgr = new WorldChunkManagerZelda(LegendofZelda.LoZBiome, 2.0F, 4.0F);

this.dimensionId = LegendofZelda.DimID;

this.hasNoSky = false;

}

public IChunkProvider createChunkGenerator()

{

return new LegendofZeldaChunkProvider(this.worldObj, this.worldObj.getSeed(), false);

}

public int getAverageGroundLevel()

{

return 0;

}

@SideOnly(Side.CLIENT)

public boolean doesXZShowFog(int par1, int par2)

{

return false;

}

public String getDimensionName()

{

return "The Legend of Zelda Dimension";

}

public boolean renderStars()

{

return true;

}

public float getStarBrightness(World world, float f)

{

return 12.0F;

}

public boolean renderClouds()

{

return true;

}

public boolean renderVoidFog()

{

return false;

}

public boolean renderEndSky()

{

return false;

}

public float setSunSize()

{

return 12.0F;

}

public float setMoonSize()

{

return 40.0F;

}

@SideOnly(Side.CLIENT)

public boolean isSkyColored()

{

return true;

}

public boolean canRespawnHere()

{

return true;

}

public boolean isSurfaceWorld()

{

return true;

}

@SideOnly(Side.CLIENT)

public float getCloudHeight()

{

return 128.0F;

}

@SideOnly(Side.CLIENT)

public String getSunTexture()

{

return "/Main:TwinSuns.png";

}

public boolean canCoordinateBeSpawn(int par1, int par2)

{

return false;

}

 

protected void generateLightBrightnessTable()

{

float f = 12.0F;

for (int i = 0; i <= 15; i++)

{

float f1 = 12.0F - i / 15.0F;

this.lightBrightnessTable = ((1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f);

}

}

@SideOnly(Side.CLIENT)

public String getWelcomeMessage()

{

if ((this instanceof LegendofZeldaWorldProvider))

{

return "Entering The Legend of Zelda Dimension";

}

return null;

}

@SideOnly(Side.CLIENT)

public float[] calcSunriseSunsetColors(float par1, float par2)

{

float f2 = 0.4F;

float f3 = MathHelper.cos(par1 * 3.141593F * 2.0F) - 0.0F;

float f4 = -0.0F;

if ((f3 >= f4 - f2) && (f3 <= f4 + f2))

{

float f5 = (f3 - f4) / f2 * 0.5F + 0.5F;

float f6 = 1.0F - (1.0F - MathHelper.sin(f5 * 3.141593F)) * 0.99F;

f6 *= f6;

this.colorsSunriseSunset[0] = (f5 * 0.3F + 0.7F);

this.colorsSunriseSunset[1] = (f5 * f5 * 0.7F + 0.2F);

this.colorsSunriseSunset[2] = (f5 * f5 * 0.0F + 0.2F);

this.colorsSunriseSunset[3] = f6;

return this.colorsSunriseSunset;

}

return null;

}

public float calculateCelestialAngle(long par1, float par3)

{

int j = (int)(par1 % 24000L);

float f1 = (j + par3) / 24000.0F - 0.25F;

if (f1 < 0.0F)

{

f1 += 1.0F;

}

if (f1 > 1.0F)

{

f1 -= 1.0F;

}

float f2 = f1;

f1 = 1.0F - (float)((Math.cos(f1 * 3.141592653589793D) + 1.0D) / 2.0D);

f1 = f2 + (f1 - f2) / 3.0F;

return f1;

}

@SideOnly(Side.CLIENT)

public Vec3 getFogColor(float par1, float par2)

{

int i = 10518688;

float f2 = MathHelper.cos(par1 * 3.141593F * 2.0F) * 2.0F + 0.5F;

if (f2 < 0.0F)

{

f2 = 0.0F;

}

if (f2 > 1.0F)

{

f2 = 1.0F;

}

float f3 = (i >> 16 & 0xFF) / 255.0F;

float f4 = (i >> 8 & 0xFF) / 255.0F;

float f5 = (i & 0xFF) / 255.0F;

f3 *= (f2 * 0.0F + 0.15F);

f4 *= (f2 * 0.0F + 0.15F);

f5 *= (f2 * 0.0F + 0.15F);

return this.worldObj.getWorldVec3Pool().getVecFromPool(f3, f4, f5);

}

public static WorldProvider getProviderForDimension(int par0)

{

    return DimensionManager.createProviderFor(par0);

}

public ChunkCoordinates getEntrancePortalLocation()

{

    return null;

}

}

 

 

 

 

Chunk Provider

 

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import java.util.List;

import java.util.Random;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.block.Block;

import net.minecraft.client.main.Main;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.util.IProgressUpdate;

import net.minecraft.util.MathHelper;

import net.minecraft.world.ChunkPosition;

import net.minecraft.world.SpawnerAnimals;

import net.minecraft.world.World;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraft.world.chunk.Chunk;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.gen.MapGenBase;

import net.minecraft.world.gen.MapGenCaves;

import net.minecraft.world.gen.MapGenRavine;

import net.minecraft.world.gen.NoiseGeneratorOctaves;

import net.minecraft.world.gen.feature.MapGenScatteredFeature;

import net.minecraft.world.gen.feature.WorldGenLakes;

import net.minecraft.world.gen.structure.MapGenMineshaft;

import net.minecraft.world.gen.structure.MapGenStronghold;

import net.minecraft.world.gen.structure.MapGenVillage;

 

public class LegendofZeldaChunkProvider implements IChunkProvider

{

private Random rand;

private NoiseGeneratorOctaves noiseGen1;

private NoiseGeneratorOctaves noiseGen2;

private NoiseGeneratorOctaves noiseGen3;

private NoiseGeneratorOctaves noiseGen4;

public NoiseGeneratorOctaves noiseGen5;

public NoiseGeneratorOctaves noiseGen6;

public NoiseGeneratorOctaves mobSpawnerNoise;

private World worldObj;

private final boolean mapFeaturesEnabled;

private double[] noiseArray;

private double[] stoneNoise = new double[256];

private MapGenBase caveGenerator = new MapGenCaves();

private MapGenStronghold strongholdGenerator = new MapGenStronghold();

private MapGenVillage villageGenerator = new MapGenVillage();

private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();

private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();

private MapGenBase ravineGenerator = new MapGenRavine();

private BiomeGenBase[] biomesForGeneration;

double[] noise3;

double[] noise1;

double[] noise2;

double[] noise5;

double[] noise6;

float[] parabolicField;

int[][] field_73219_j = new int[32][32];

public LegendofZeldaChunkProvider(World par1World, long par2, boolean par4) {

this.worldObj = par1World;

this.mapFeaturesEnabled = par4;

this.rand = new Random(par2);

this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16);

this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16);

this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8);

this.noiseGen4 = new NoiseGeneratorOctaves(this.rand, 4);

this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);

this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);

this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8);

}

/**

* Generates the shape of the terrain for the chunk though its all stone though the water is frozen if the

* temperature is low enough

*/

public void generateTerrain(int par1, int par2, byte[] par3ArrayOfByte)

{

byte b0 = 4;

byte b1 = 16;

byte b2 = 63;

int k = b0 + 1;

byte b3 = 17;

int l = b0 + 1;

this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, k + 5, l + 5);

this.noiseArray = this.initializeNoiseField(this.noiseArray, par1 * b0, 0, par2 * b0, k, b3, l);

for (int i1 = 0; i1 < b0; ++i1)

{

for (int j1 = 0; j1 < b0; ++j1)

{

for (int k1 = 0; k1 < b1; ++k1)

{

        double d0 = 0.125D;

        double d1 = this.noiseArray[((i1 + 0) * l + j1 + 0) * b3 + k1 + 0];

        double d2 = this.noiseArray[((i1 + 0) * l + j1 + 1) * b3 + k1 + 0];

        double d3 = this.noiseArray[((i1 + 1) * l + j1 + 0) * b3 + k1 + 0];

        double d4 = this.noiseArray[((i1 + 1) * l + j1 + 1) * b3 + k1 + 0];

        double d5 = (this.noiseArray[((i1 + 0) * l + j1 + 0) * b3 + k1 + 1] - d1) * d0;

        double d6 = (this.noiseArray[((i1 + 0) * l + j1 + 1) * b3 + k1 + 1] - d2) * d0;

        double d7 = (this.noiseArray[((i1 + 1) * l + j1 + 0) * b3 + k1 + 1] - d3) * d0;

        double d8 = (this.noiseArray[((i1 + 1) * l + j1 + 1) * b3 + k1 + 1] - d4) * d0;

        for (int l1 = 0; l1 < 8; ++l1)

        {

        double d9 = 0.25D;

        double d10 = d1;

        double d11 = d2;

        double d12 = (d3 - d1) * d9;

        double d13 = (d4 - d2) * d9;

        for (int i2 = 0; i2 < 4; ++i2)

        {

        int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1;

        short short1 = 128;

        j2 -= short1;

        double d14 = 0.25D;

        double d15 = (d11 - d10) * d14;

        double d16 = d10 - d15;

        for (int k2 = 0; k2 < 4; ++k2)

        {

        if ((d16 += d15) > 0.0D)

        {

                /** Main filler block fill's all the underground, replaces block stone **/

                par3ArrayOfByte[j2 += short1] = (byte)253;//

        }

        else if (k1 * 8 + l1 < b2)

        {

                par3ArrayOfByte[j2 += short1] = (byte)Block.waterStill.blockID;

        }

        else

        {

                par3ArrayOfByte[j2 += short1] = 0;

        }

        }

        d10 += d12;

        d11 += d13;

        }

        d1 += d5;

        d2 += d6;

        d3 += d7;

        d4 += d8;

        }

}

}

}

}

public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)

{

byte var5 = 63;

double var6 = 0.03125D;

this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D);

for (int var8 = 0; var8 < 16; var8++)

{

for (int var9 = 0; var9 < 16; var9++)

{

BiomeGenBase var10 = par4ArrayOfBiomeGenBase[(var9 + var8 * 16)];

float var11 = var10.getFloatTemperature();

int var12 = (int)(this.stoneNoise[(var8 + var9 * 16)] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);

int var13 = -1;

byte var14 = var10.topBlock;

byte var15 = var10.fillerBlock;

for (int var16 = 127; var16 >= 0; var16--)

{

        int var17 = (var9 * 16 + var8) * 128 + var16;

        if (var16 <= 0 + this.rand.nextInt(5))

        {

        par3ArrayOfByte[var17] = ((byte)Block.bedrock.blockID);

        }

        else

        {

        byte var18 = par3ArrayOfByte[var17];

        if (var18 == 0)

        {

        var13 = -1;

        }

        /** Main filler block fill's all the underground, replaces block stone **/

        else if (var18 != 253)

        {

        if (var13 == -1)

        {

        if (var12 == 0)

        {

                var14 = 0;

               

                /** change to custom dirt **/

                var15 = (byte)LegendofZelda.LoZDirt.blockID;//

        }

        else if ((var16 >= var5 - 4) && (var16 <= var5 + 1))

        {

                var14 = var10.topBlock;

                var15 = var10.fillerBlock;

        }

        if ((var16 < var5) && (var14 == 0))

        {

                if (var11 < 0.15F)

                {

                var14 = (byte)Block.ice.blockID;

                }

                else

                {

                var14 = (byte)Block.waterStill.blockID;

                }

        }

        var13 = var12;

        if (var16 >= var5 - 1)

        {

                par3ArrayOfByte[var17] = var14;

        }

        else

        {

                par3ArrayOfByte[var17] = var15;

        }

        }

        else if (var13 > 0)

        {

        var13--;

        par3ArrayOfByte[var17] = var15;

        if ((var13 == 0) && (var15 == Block.sand.blockID))

        {

                var13 = this.rand.nextInt(4);

                var15 = (byte)Block.sandStone.blockID;

        }

        }

        }

        }

}

}

}

}

public Chunk loadChunk(int par1, int par2)

{

return provideChunk(par1, par2);

}

public Chunk provideChunk(int par1, int par2)

{

this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L);

byte[] var3 = new byte[32768];

generateTerrain(par1, par2, var3);

this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);

replaceBlocksForBiome(par1, par2, var3, this.biomesForGeneration);

this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);

this.ravineGenerator.generate(this, this.worldObj, par1, par2, var3);

if (this.mapFeaturesEnabled)

{

this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, var3);

this.villageGenerator.generate(this, this.worldObj, par1, par2, var3);

this.strongholdGenerator.generate(this, this.worldObj, par1, par2, var3);

this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, var3);

}

Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);

byte[] var5 = var4.getBiomeArray();

for (int var6 = 0; var6 < var5.length; var6++)

{

var5[var6] = ((byte)this.biomesForGeneration[var6].biomeID);

}

var4.generateSkylightMap();

return var4;

}

private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7)

{

if (par1ArrayOfDouble == null)

{

par1ArrayOfDouble = new double[par5 * par6 * par7];

}

if (this.parabolicField == null)

{

this.parabolicField = new float[25];

for (int var8 = -2; var8 <= 2; var8++)

{

for (int var9 = -2; var9 <= 2; var9++)

{

        float var10 = 10.0F / MathHelper.sqrt_float(var8 * var8 + var9 * var9 + 0.2F);

        this.parabolicField[(var8 + 2 + (var9 + 2) * 5)] = var10;

}

}

}

double var44 = 684.41200000000003D;

double var45 = 684.41200000000003D;

this.noise5 = this.noiseGen5.generateNoiseOctaves(this.noise5, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D);

this.noise6 = this.noiseGen6.generateNoiseOctaves(this.noise6, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D);

this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, par2, par3, par4, par5, par6, par7, var44 / 80.0D, var45 / 160.0D, var44 / 80.0D);

this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44);

this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44);

boolean var43 = false;

boolean var42 = false;

int var12 = 0;

int var13 = 0;

for (int var14 = 0; var14 < par5; var14++)

{

for (int var15 = 0; var15 < par7; var15++)

{

float var16 = 0.0F;

float var17 = 0.0F;

float var18 = 0.0F;

byte var19 = 2;

BiomeGenBase var20 = this.biomesForGeneration[(var14 + 2 + (var15 + 2) * (par5 + 5))];

for (int var21 = -var19; var21 <= var19; var21++)

{

        for (int var22 = -var19; var22 <= var19; var22++)

        {

        BiomeGenBase var23 = this.biomesForGeneration[(var14 + var21 + 2 + (var15 + var22 + 2) * (par5 + 5))];

        float var24 = this.parabolicField[(var21 + 2 + (var22 + 2) * 5)] / (var23.minHeight + 2.0F);

        if (var23.minHeight > var20.minHeight)

        {

        var24 /= 2.0F;

        }

        var16 += var23.maxHeight * var24;

        var17 += var23.minHeight * var24;

        var18 += var24;

        }

}

var16 /= var18;

var17 /= var18;

var16 = var16 * 0.9F + 0.1F;

var17 = (var17 * 4.0F - 1.0F) / 8.0F;

double var47 = this.noise6[var13] / 8000.0D;

if (var47 < 0.0D)

{

        var47 = -var47 * 0.3D;

}

var47 = var47 * 3.0D - 2.0D;

if (var47 < 0.0D)

{

        var47 /= 2.0D;

        if (var47 < -1.0D)

        {

        var47 = -1.0D;

        }

        var47 /= 1.4D;

        var47 /= 2.0D;

}

else

{

        if (var47 > 1.0D)

        {

        var47 = 1.0D;

        }

        var47 /= 8.0D;

}

var13++;

for (int var46 = 0; var46 < par6; var46++)

{

        double var48 = var17;

        double var26 = var16;

        var48 += var47 * 0.2D;

        var48 = var48 * par6 / 16.0D;

        double var28 = par6 / 2.0D + var48 * 4.0D;

        double var30 = 0.0D;

        double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / var26;

        if (var32 < 0.0D)

        {

        var32 *= 4.0D;

        }

        double var34 = this.noise1[var12] / 512.0D;

        double var36 = this.noise2[var12] / 512.0D;

        double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D;

        if (var38 < 0.0D)

        {

        var30 = var34;

        }

        else if (var38 > 1.0D)

        {

        var30 = var36;

        }

        else

        {

        var30 = var34 + (var36 - var34) * var38;

        }

        var30 -= var32;

        if (var46 > par6 - 4)

        {

        double var40 = (var46 - (par6 - 4)) / 3.0F;

        var30 = var30 * (1.0D - var40) + -10.0D * var40;

        }

        par1ArrayOfDouble[var12] = var30;

        var12++;

}

}

}

return par1ArrayOfDouble;

}

public boolean chunkExists(int par1, int par2)

{

return true;

}

public void populate(IChunkProvider par1IChunkProvider, int par2, int par3)

{

net.minecraft.block.BlockSand.fallInstantly = true;

int var4 = par2 * 16;

int var5 = par3 * 16;

BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);

this.rand.setSeed(this.worldObj.getSeed());

long var7 = this.rand.nextLong() / 2L * 2L + 1L;

long var9 = this.rand.nextLong() / 2L * 2L + 1L;

this.rand.setSeed(par2 * var7 + par3 * var9 ^ this.worldObj.getSeed());

boolean var11 = false;

if (this.mapFeaturesEnabled)

{

this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

var11 = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

}

if ((!var11) && (this.rand.nextInt(4) == 0))

{

int var12 = var4 + this.rand.nextInt(16) + 8;

int var13 = this.rand.nextInt(128);

int var14 = var5 + this.rand.nextInt(16) + 8;

new WorldGenLakes(Block.waterStill.blockID).generate(this.worldObj, this.rand, var12, var13, var14);

}

var6.decorate(this.worldObj, this.rand, var4, var5);

SpawnerAnimals.performWorldGenSpawning(this.worldObj, var6, var4 + 8, var5 + 8, 16, 16, this.rand);

var4 += 8;

var5 += 8;

for (int var12 = 0; var12 < 16; var12++)

{

for (int var13 = 0; var13 < 16; var13++)

{

int var14 = this.worldObj.getPrecipitationHeight(var4 + var12, var5 + var13);

if (this.worldObj.isBlockFreezable(var12 + var4, var14 - 1, var13 + var5))

{

        this.worldObj.setBlock(var12 + var4, var14 - 1, var13 + var5, Block.ice.blockID);

}

if (this.worldObj.canSnowAt(var12 + var4, var14, var13 + var5))

{

        this.worldObj.setBlock(var12 + var4, var14, var13 + var5, Block.snow.blockID);

}

}

}

net.minecraft.block.BlockSand.fallInstantly = false;

}

public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate)

{

return true;

}

public boolean unload100OldestChunks()

{

return false;

}

public boolean canSave()

{

return true;

}

public String makeString()

{

return "RandomLevelSource";

}

public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4)

{

BiomeGenBase var5 = this.worldObj.getBiomeGenForCoords(par2, par4);

return var5 == null ? null : var5.getSpawnableList(par1EnumCreatureType);

}

public ChunkPosition findClosestStructure(World par1World, String par2Str, int par3, int par4, int par5)

{

return ("Stronghold".equals(par2Str)) && (this.strongholdGenerator != null) ? this.strongholdGenerator.getNearestInstance(par1World, par3, par4, par5) : null;

}

public int getLoadedChunkCount() {

return 0;

}

public boolean unloadQueuedChunks()

{

return false;

}

public void recreateStructures(int i, int j)

{

}

@Override

public void saveExtraData(){

 

}

}

 

 

 

 

Dimension Biome

 

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.FLOWERS;

 

import java.util.Random;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.entity.monster.EntityEnderman;

import net.minecraft.entity.passive.EntityWolf;

import net.minecraft.world.World;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraft.world.biome.SpawnListEntry;

import net.minecraft.world.gen.feature.WorldGenFlowers;

import net.minecraft.world.gen.feature.WorldGenTaiga1;

import net.minecraft.world.gen.feature.WorldGenTaiga2;

import net.minecraft.world.gen.feature.WorldGenerator;

import net.minecraftforge.event.terraingen.TerrainGen;

 

public class LegendofZeldaDimensionBiome extends BiomeGenBase{

 

 

private Object worldGeneratorTutorialBigTree;

 

public final Material blockMaterial;

public LegendofZeldaDimensionBiome(int par1){

super(par1);

this.blockMaterial = Material.water;

this.minHeight = 0.1F;

this.maxHeight = 0.6F;

this.spawnableMonsterList.clear();

this.spawnableCreatureList.clear();

this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 10, 4, 4));

this.topBlock = ((byte)252);

this.fillerBlock = ((byte)251);

this.setBiomeName("Legend of Zelda");

this.theBiomeDecorator.treesPerChunk = 5;

        this.theBiomeDecorator.grassPerChunk = 15;

     

}

 

public void decorate(World w, Random r, int x, int z)

    {

 

super.decorate(w, r, x, z);

WorldGenFlowers ZeldaTGrass = new WorldGenFlowers(LegendofZelda.ZeldaGrass.blockID);

boolean doGen = TerrainGen.decorate(w, r, x, z, FLOWERS);

        for (int j = 0; doGen && j < 2; ++j)

        {

            int k = x + r.nextInt(16) + 8;

            int l = r.nextInt(128);

            int i1 = z + r.nextInt(16) + 8;

            ZeldaTGrass.generate(w, r, k, l, i1);

 

 

        }

     

    }

public WorldGenerator getRandomWorldGenForTrees(Random par1Random)

    {

        return (WorldGenerator)(par1Random.nextInt(2) == 0 ? new LegendofZeldaTree() : new LegendofZeldaTree());

    }

}

 

 

 

Teleporter ( I honestly have no clue what this would do with the caves generating, but hey, why not even if it is useless someone might get to use it, Open source FTW! )

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;

import java.util.Random;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.block.Block;

import net.minecraft.client.main.Main;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.util.Direction;

import net.minecraft.util.LongHashMap;

import net.minecraft.util.MathHelper;

import net.minecraft.world.ChunkCoordIntPair;

import net.minecraft.world.PortalPosition;

import net.minecraft.world.Teleporter;

import net.minecraft.world.WorldServer;

 

public class LoZTeleporter extends Teleporter

{

private final WorldServer worldServerInstance;

/** A private Random() function in Teleporter */

private final Random random;

 

/**

        * A list of valid keys for the destinationCoordainteCache. These are based on the X & Z of the players initial

        * location.

        */

private final List destinationCoordinateKeys = new ArrayList();

public LoZTeleporter(WorldServer par1WorldServer)

{

        super(par1WorldServer);

        this.worldServerInstance = par1WorldServer;

        this.random = new Random(par1WorldServer.getSeed());

}

@Override

public boolean makePortal(Entity par1Entity)

{return false;}

 

@Override

public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8)

{return false;}

@Override

public void placeInPortal(Entity e, double par2, double par4, double par6, float par8)

{

 

 

 

System.out.println("Enter: The Legend of Zelda");

 

 

 

 

}

 

}

 

 

 

 

Custom WorldGenMinabl class

 

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import java.util.Random;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.block.Block;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.minecraft.world.gen.feature.WorldGenerator;

 

public class WorldGenMinableLoZ  extends WorldGenerator

{

    /** The block ID of the ore to be placed using this generator. */

    private int minableBlockId;

    private int minableBlockMeta = 0;

 

    /** The number of blocks to generate. */

    private int numberOfBlocks;

 

    /** The block ID of the block to be replaced with the ore (usually stone) */

    private int blockToReplace = LegendofZelda.LoZRock.blockID;

 

    public WorldGenMinableLoZ(int par1, int par2)

    {

        this(par1, par2, LegendofZelda.LoZRock.blockID);

    }

 

    public WorldGenMinableLoZ(int par1, int par2, int par3)

    {

        this.minableBlockId = par1;

        this.numberOfBlocks = par2;

        this.blockToReplace = par3;

    }

 

    public WorldGenMinableLoZ(int id, int meta, int number, int target)

    {

        this(id, number, target);

        this.minableBlockMeta = meta;

    }

 

    public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)

    {

        float f = par2Random.nextFloat() * (float)Math.PI;

        double d0 = (double)((float)(par3 + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);

        double d1 = (double)((float)(par3 + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);

        double d2 = (double)((float)(par5 + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);

        double d3 = (double)((float)(par5 + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);

        double d4 = (double)(par4 + par2Random.nextInt(3) - 2);

        double d5 = (double)(par4 + par2Random.nextInt(3) - 2);

 

        for (int l = 0; l <= this.numberOfBlocks; ++l)

        {

            double d6 = d0 + (d1 - d0) * (double)l / (double)this.numberOfBlocks;

            double d7 = d4 + (d5 - d4) * (double)l / (double)this.numberOfBlocks;

            double d8 = d2 + (d3 - d2) * (double)l / (double)this.numberOfBlocks;

            double d9 = par2Random.nextDouble() * (double)this.numberOfBlocks / 16.0D;

            double d10 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;

            double d11 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D;

            int i1 = MathHelper.floor_double(d6 - d10 / 2.0D);

            int j1 = MathHelper.floor_double(d7 - d11 / 2.0D);

            int k1 = MathHelper.floor_double(d8 - d10 / 2.0D);

            int l1 = MathHelper.floor_double(d6 + d10 / 2.0D);

            int i2 = MathHelper.floor_double(d7 + d11 / 2.0D);

            int j2 = MathHelper.floor_double(d8 + d10 / 2.0D);

 

            for (int k2 = i1; k2 <= l1; ++k2)

            {

                double d12 = ((double)k2 + 0.5D - d6) / (d10 / 2.0D);

 

                if (d12 * d12 < 1.0D)

                {

                    for (int l2 = j1; l2 <= i2; ++l2)

                    {

                        double d13 = ((double)l2 + 0.5D - d7) / (d11 / 2.0D);

 

                        if (d12 * d12 + d13 * d13 < 1.0D)

                        {

                            for (int i3 = k1; i3 <= j2; ++i3)

                            {

                                double d14 = ((double)i3 + 0.5D - d8) / (d10 / 2.0D);

 

                                Block block = Block.blocksList[par1World.getBlockId(k2, l2, i3)];

                                if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && (block != null && block.isGenMineableReplaceable(par1World, k2, l2, i3, this.blockToReplace)))

                                {

                                    par1World.setBlock(k2, l2, i3, this.minableBlockId, minableBlockMeta, 2);

                                }

                            }

                        }

                    }

                }

            }

        }

 

        return true;

    }

}

 

 

 

 

WorldGnererator

 

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import java.util.Random;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.block.Block;

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.gen.feature.WorldGenMinable;

import cpw.mods.fml.common.IWorldGenerator;

 

public class WorldGeneratorLoZ implements IWorldGenerator {

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world,

IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

switch(world.provider.dimensionId){

 

 

case -1:

generateNether(world, random, chunkX*16, chunkZ*16);

 

case 0:

generateOverworld(world, random, chunkX*16, chunkZ*16);

 

case 1:

generateEnd(world, random, chunkX*16, chunkZ*16);

 

case 4:

generateLoZ(world, random, chunkX*16, chunkZ*16);

}

 

}

 

private void generateNether(World w, Random r, int x, int z) {

 

 

}

 

private void generateOverworld(World w, Random r, int x, int z) {

 

 

}

 

private void generateEnd(World w, Random r, int x, int z) {

 

 

}

 

private void generateLoZ(World w, Random r, int x, int z) {

 

generateOre(LegendofZelda.LoZCopperOre, w, r, x, z, 16, 16, 8 + r.nextInt(6), 20, 20, 80);

 

}

 

private void generateOre(Block b, World w, Random r, int x, int z, int maxX, int maxZ, int maxVeinSize, int chanceToSpawn, int minY, int maxY){

 

for(int i = 0; i< chanceToSpawn; i++){

int posX = x + r.nextInt(maxX);

int posY = minY + r.nextInt(maxY - minY);

int posZ = z + r.nextInt(maxZ);

new WorldGenMinableLoZ(b.blockID, maxVeinSize).generate(w, r, posX, posY, posZ);

 

}

}

 

}

 

 

 

ChunkProvider

 

 

package net.CJCutrone.LegendofZelda.Dimension;

import java.util.Arrays;

import java.util.List;

import java.util.Random;

 

import net.minecraft.world.ChunkPosition;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraft.world.biome.WorldChunkManager;

 

 

public class WorldChunkManagerZelda extends WorldChunkManager

{

    /** this is the sole biome to utilize for this world */

    private BiomeGenBase biomeToUse;

    private float temp;

 

    /** The rainfall in the world */

    private float rainfall;

 

    public WorldChunkManagerZelda(BiomeGenBase par1BiomeGenBase, float par2, float par3)

    {

        this.biomeToUse = par1BiomeGenBase;

        this.temp = par2;

        this.rainfall = par3;

    }

 

    /**

    * Returns the BiomeGenBase related to the x, z position on the world.

    */

    public BiomeGenBase getBiomeGenAt(int par1, int par2)

    {

        return this.biomeToUse;

    }

 

    /**

    * Returns an array of biomes for the location input.

    */

    public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5)

    {

        if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5)

        {

            par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];

        }

 

        Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeToUse);

        return par1ArrayOfBiomeGenBase;

    }

 

    /**

    * Returns a list of temperatures to use for the specified blocks.  Args: listToReuse, x, y, width, length

    */

    public float[] getTemperatures(float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5)

    {

        if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5)

        {

            par1ArrayOfFloat = new float[par4 * par5];

        }

 

        Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, this.temp);

        return par1ArrayOfFloat;

    }

 

    /**

    * Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length.

    */

    public float[] getRainfall(float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5)

    {

        if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5)

        {

            par1ArrayOfFloat = new float[par4 * par5];

        }

 

        Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, this.rainfall);

        return par1ArrayOfFloat;

    }

 

    /**

    * Returns biomes to use for the blocks and loads the other data like temperature and humidity onto the

    * WorldChunkManager Args: oldBiomeList, x, z, width, depth

    */

    public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5)

    {

        if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5)

        {

            par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];

        }

 

        Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeToUse);

        return par1ArrayOfBiomeGenBase;

    }

 

    /**

    * Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false,

    * don't check biomeCache to avoid infinite loop in BiomeCacheBlock)

    */

    public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5, boolean par6)

    {

        return this.loadBlockGeneratorData(par1ArrayOfBiomeGenBase, par2, par3, par4, par5);

    }

 

    /**

    * Finds a valid position within a range, that is in one of the listed biomes. Searches {par1,par2} +-par3 blocks.

    * Strongly favors positive y positions.

    */

    public ChunkPosition findBiomePosition(int par1, int par2, int par3, List par4List, Random par5Random)

    {

        return par4List.contains(this.biomeToUse) ? new ChunkPosition(par1 - par3 + par5Random.nextInt(par3 * 2 + 1), 0, par2 - par3 + par5Random.nextInt(par3 * 2 + 1)) : null;

    }

 

    /**

    * checks given Chunk's Biomes against List of allowed ones

    */

    public boolean areBiomesViable(int par1, int par2, int par3, List par4List)

    {

        return par4List.contains(this.biomeToUse);

    }

}

 

 

 

Link to comment
Share on other sites

Cave code is set so it only generates cave in stone and the biomes top and filler blocks.  Copy the MapGenCaves file into a new file, look in the code for where it checks for stone etc and adjust it so check includes your custom blocks, then in your ChunkProvider change the MapGenCaves relevant code to your custom cave code.

Link to comment
Share on other sites

I would love to say that I love you... But it didn't work... :(

 

Here is my MapGenCaves and updated ChunkProvider:

 

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import java.util.Random;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.block.Block;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraft.world.gen.MapGenBase;

 

public class MapGenCavesLoZ extends MapGenBase

{

    /**

    * Generates a larger initial cave node than usual. Called 25% of the time.

    */

    protected void generateLargeCaveNode(long par1, int par3, int par4, byte[] par5ArrayOfByte, double par6, double par8, double par10)

    {

        this.generateCaveNode(par1, par3, par4, par5ArrayOfByte, par6, par8, par10, 1.0F + this.rand.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);

    }

 

    /**

    * Generates a node in the current cave system recursion tree.

    */

    protected void generateCaveNode(long par1, int par3, int par4, byte[] par5ArrayOfByte, double par6, double par8, double par10, float par12, float par13, float par14, int par15, int par16, double par17)

    {

        double d4 = (double)(par3 * 16 + 8);

        double d5 = (double)(par4 * 16 + 8);

        float f3 = 0.0F;

        float f4 = 0.0F;

        Random random = new Random(par1);

 

        if (par16 <= 0)

        {

            int j1 = this.range * 16 - 16;

            par16 = j1 - random.nextInt(j1 / 4);

        }

 

        boolean flag = false;

 

        if (par15 == -1)

        {

            par15 = par16 / 2;

            flag = true;

        }

 

        int k1 = random.nextInt(par16 / 2) + par16 / 4;

 

        for (boolean flag1 = random.nextInt(6) == 0; par15 < par16; ++par15)

        {

            double d6 = 1.5D + (double)(MathHelper.sin((float)par15 * (float)Math.PI / (float)par16) * par12 * 1.0F);

            double d7 = d6 * par17;

            float f5 = MathHelper.cos(par14);

            float f6 = MathHelper.sin(par14);

            par6 += (double)(MathHelper.cos(par13) * f5);

            par8 += (double)f6;

            par10 += (double)(MathHelper.sin(par13) * f5);

 

            if (flag1)

            {

                par14 *= 0.92F;

            }

            else

            {

                par14 *= 0.7F;

            }

 

            par14 += f4 * 0.1F;

            par13 += f3 * 0.1F;

            f4 *= 0.9F;

            f3 *= 0.75F;

            f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F;

            f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F;

 

            if (!flag && par15 == k1 && par12 > 1.0F && par16 > 0)

            {

                this.generateCaveNode(random.nextLong(), par3, par4, par5ArrayOfByte, par6, par8, par10, random.nextFloat() * 0.5F + 0.5F, par13 - ((float)Math.PI / 2F), par14 / 3.0F, par15, par16, 1.0D);

                this.generateCaveNode(random.nextLong(), par3, par4, par5ArrayOfByte, par6, par8, par10, random.nextFloat() * 0.5F + 0.5F, par13 + ((float)Math.PI / 2F), par14 / 3.0F, par15, par16, 1.0D);

                return;

            }

 

            if (flag || random.nextInt(4) != 0)

            {

                double d8 = par6 - d4;

                double d9 = par10 - d5;

                double d10 = (double)(par16 - par15);

                double d11 = (double)(par12 + 2.0F + 16.0F);

 

                if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11)

                {

                    return;

                }

 

                if (par6 >= d4 - 16.0D - d6 * 2.0D && par10 >= d5 - 16.0D - d6 * 2.0D && par6 <= d4 + 16.0D + d6 * 2.0D && par10 <= d5 + 16.0D + d6 * 2.0D)

                {

                    int l1 = MathHelper.floor_double(par6 - d6) - par3 * 16 - 1;

                    int i2 = MathHelper.floor_double(par6 + d6) - par3 * 16 + 1;

                    int j2 = MathHelper.floor_double(par8 - d7) - 1;

                    int k2 = MathHelper.floor_double(par8 + d7) + 1;

                    int l2 = MathHelper.floor_double(par10 - d6) - par4 * 16 - 1;

                    int i3 = MathHelper.floor_double(par10 + d6) - par4 * 16 + 1;

 

                    if (l1 < 0)

                    {

                        l1 = 0;

                    }

 

                    if (i2 > 16)

                    {

                        i2 = 16;

                    }

 

                    if (j2 < 1)

                    {

                        j2 = 1;

                    }

 

                    if (k2 > 120)

                    {

                        k2 = 120;

                    }

 

                    if (l2 < 0)

                    {

                        l2 = 0;

                    }

 

                    if (i3 > 16)

                    {

                        i3 = 16;

                    }

 

                    boolean flag2 = false;

                    int j3;

                    int k3;

 

                    for (j3 = l1; !flag2 && j3 < i2; ++j3)

                    {

                        for (int l3 = l2; !flag2 && l3 < i3; ++l3)

                        {

                            for (int i4 = k2 + 1; !flag2 && i4 >= j2 - 1; --i4)

                            {

                                k3 = (j3 * 16 + l3) * 128 + i4;

 

                                if (i4 >= 0 && i4 < 128)

                                {

                                    if (isOceanBlock(par5ArrayOfByte, k3, j3, i4, l3, par3, par4))

                                    {

                                        flag2 = true;

                                    }

 

                                    if (i4 != j2 - 1 && j3 != l1 && j3 != i2 - 1 && l3 != l2 && l3 != i3 - 1)

                                    {

                                        i4 = j2;

                                    }

                                }

                            }

                        }

                    }

 

                    if (!flag2)

                    {

                        for (j3 = l1; j3 < i2; ++j3)

                        {

                            double d12 = ((double)(j3 + par3 * 16) + 0.5D - par6) / d6;

 

                            for (k3 = l2; k3 < i3; ++k3)

                            {

                                double d13 = ((double)(k3 + par4 * 16) + 0.5D - par10) / d6;

                                int j4 = (j3 * 16 + k3) * 128 + k2;

                                boolean flag3 = false;

 

                                if (d12 * d12 + d13 * d13 < 1.0D)

                                {

                                    for (int k4 = k2 - 1; k4 >= j2; --k4)

                                    {

                                        double d14 = ((double)k4 + 0.5D - par8) / d7;

 

                                        if (d14 > -0.7D && d12 * d12 + d14 * d14 + d13 * d13 < 1.0D)

                                        {

                                            if (isTopBlock(par5ArrayOfByte, j4, j3, k4, k3, par3, par4))

                                            {

                                                flag3 = true;

                                            }

 

                                            digBlock(par5ArrayOfByte, j4, j3, k4, k3, par3, par4, flag3);

                                        }

 

                                        --j4;

                                    }

                                }

                            }

                        }

 

                        if (flag)

                        {

                            break;

                        }

                    }

                }

            }

        }

    }

 

    /**

    * Recursively called by generate() (generate) and optionally by itself.

    */

    protected void recursiveGenerate(World par1World, int par2, int par3, int par4, int par5, byte[] par6ArrayOfByte)

    {

        int i1 = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(40) + 1) + 1);

 

        if (this.rand.nextInt(15) != 0)

        {

            i1 = 0;

        }

 

        for (int j1 = 0; j1 < i1; ++j1)

        {

            double d0 = (double)(par2 * 16 + this.rand.nextInt(16));

            double d1 = (double)this.rand.nextInt(this.rand.nextInt(120) + 8);

            double d2 = (double)(par3 * 16 + this.rand.nextInt(16));

            int k1 = 1;

 

            if (this.rand.nextInt(4) == 0)

            {

                this.generateLargeCaveNode(this.rand.nextLong(), par4, par5, par6ArrayOfByte, d0, d1, d2);

                k1 += this.rand.nextInt(4);

            }

 

            for (int l1 = 0; l1 < k1; ++l1)

            {

                float f = this.rand.nextFloat() * (float)Math.PI * 2.0F;

                float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;

                float f2 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat();

 

                if (this.rand.nextInt(10) == 0)

                {

                    f2 *= this.rand.nextFloat() * this.rand.nextFloat() * 3.0F + 1.0F;

                }

 

                this.generateCaveNode(this.rand.nextLong(), par4, par5, par6ArrayOfByte, d0, d1, d2, f2, f, f1, 0, 0, 1.0D);

            }

        }

    }

 

    protected boolean isOceanBlock(byte[] data, int index, int x, int y, int z, int chunkX, int chunkZ)

    {

        return data[index] == Block.waterMoving.blockID || data[index] == Block.waterStill.blockID;

    }

 

    //Exception biomes to make sure we generate like vanilla

    private boolean isExceptionBiome(BiomeGenBase biome)

    {

        if (biome == BiomeGenBase.mushroomIsland) return true;

        if (biome == BiomeGenBase.beach) return true;

        if (biome == BiomeGenBase.desert) return true;

        return false;

    }

 

    //Determine if the block at the specified location is the top block for the biome, we take into account

    //Vanilla bugs to make sure that we generate the map the same way vanilla does.

    private boolean isTopBlock(byte[] data, int index, int x, int y, int z, int chunkX, int chunkZ)

    {

        BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16);

        return (isExceptionBiome(biome) ? data[index] == Block.grass.blockID : data[index] == biome.topBlock);

    }

 

    /**

    * Digs out the current block, default implementation removes stone, filler, and top block

    * Sets the block to lava if y is less then 10, and air other wise.

    * If setting to air, it also checks to see if we've broken the surface and if so

    * tries to make the floor the biome's top block

    *

    * @param data Block data array

    * @param index Pre-calculated index into block data

    * @param x local X position

    * @param y local Y position

    * @param z local Z position

    * @param chunkX Chunk X position

    * @param chunkZ Chunk Y position

    * @param foundTop True if we've encountered the biome's top block. Ideally if we've broken the surface.

    */

    protected void digBlock(byte[] data, int index, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop)

    {

        BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16);

        int top    = (isExceptionBiome(biome) ? Block.grass.blockID : biome.topBlock);

        int filler = (isExceptionBiome(biome) ? Block.dirt.blockID  : biome.fillerBlock);

        int block  = data[index];

 

        if (block == LegendofZelda.LoZRock.blockID || block == filler || block == top)

        {

            if (y < 10)

            {

                data[index] = (byte)Block.lavaMoving.blockID;

            }

            else

            {

                data[index] = 0;

 

                if (foundTop && data[index - 1] == filler)

                {

                    data[index - 1] = (byte)top;

                }

            }

        }

    }

}

 

 

 

 

 

package net.CJCutrone.LegendofZelda.Dimension;

 

import java.util.List;

import java.util.Random;

 

import net.CJCutrone.LegendofZelda.common.LegendofZelda;

import net.minecraft.block.Block;

import net.minecraft.client.main.Main;

import net.minecraft.entity.EnumCreatureType;

import net.minecraft.util.IProgressUpdate;

import net.minecraft.util.MathHelper;

import net.minecraft.world.ChunkPosition;

import net.minecraft.world.SpawnerAnimals;

import net.minecraft.world.World;

import net.minecraft.world.biome.BiomeGenBase;

import net.minecraft.world.chunk.Chunk;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.gen.MapGenBase;

 

import net.minecraft.world.gen.MapGenRavine;

import net.minecraft.world.gen.NoiseGeneratorOctaves;

import net.minecraft.world.gen.feature.MapGenScatteredFeature;

import net.minecraft.world.gen.feature.WorldGenLakes;

import net.minecraft.world.gen.structure.MapGenMineshaft;

import net.minecraft.world.gen.structure.MapGenStronghold;

import net.minecraft.world.gen.structure.MapGenVillage;

 

public class LegendofZeldaChunkProvider implements IChunkProvider

{

private Random rand;

private NoiseGeneratorOctaves noiseGen1;

private NoiseGeneratorOctaves noiseGen2;

private NoiseGeneratorOctaves noiseGen3;

private NoiseGeneratorOctaves noiseGen4;

public NoiseGeneratorOctaves noiseGen5;

public NoiseGeneratorOctaves noiseGen6;

public NoiseGeneratorOctaves mobSpawnerNoise;

private World worldObj;

private final boolean mapFeaturesEnabled;

private double[] noiseArray;

private double[] stoneNoise = new double[256];

private MapGenBase caveGenerator = new MapGenCavesLoZ();

private MapGenStronghold strongholdGenerator = new MapGenStronghold();

private MapGenVillage villageGenerator = new MapGenVillage();

private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();

private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();

private MapGenBase ravineGenerator = new MapGenRavine();

private BiomeGenBase[] biomesForGeneration;

double[] noise3;

double[] noise1;

double[] noise2;

double[] noise5;

double[] noise6;

float[] parabolicField;

int[][] field_73219_j = new int[32][32];

public LegendofZeldaChunkProvider(World par1World, long par2, boolean par4) {

this.worldObj = par1World;

this.mapFeaturesEnabled = par4;

this.rand = new Random(par2);

this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16);

this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16);

this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8);

this.noiseGen4 = new NoiseGeneratorOctaves(this.rand, 4);

this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);

this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);

this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8);

}

/**

* Generates the shape of the terrain for the chunk though its all stone though the water is frozen if the

* temperature is low enough

*/

public void generateTerrain(int par1, int par2, byte[] par3ArrayOfByte)

{

byte b0 = 4;

byte b1 = 16;

byte b2 = 63;

int k = b0 + 1;

byte b3 = 17;

int l = b0 + 1;

this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, k + 5, l + 5);

this.noiseArray = this.initializeNoiseField(this.noiseArray, par1 * b0, 0, par2 * b0, k, b3, l);

for (int i1 = 0; i1 < b0; ++i1)

{

for (int j1 = 0; j1 < b0; ++j1)

{

for (int k1 = 0; k1 < b1; ++k1)

{

        double d0 = 0.125D;

        double d1 = this.noiseArray[((i1 + 0) * l + j1 + 0) * b3 + k1 + 0];

        double d2 = this.noiseArray[((i1 + 0) * l + j1 + 1) * b3 + k1 + 0];

        double d3 = this.noiseArray[((i1 + 1) * l + j1 + 0) * b3 + k1 + 0];

        double d4 = this.noiseArray[((i1 + 1) * l + j1 + 1) * b3 + k1 + 0];

        double d5 = (this.noiseArray[((i1 + 0) * l + j1 + 0) * b3 + k1 + 1] - d1) * d0;

        double d6 = (this.noiseArray[((i1 + 0) * l + j1 + 1) * b3 + k1 + 1] - d2) * d0;

        double d7 = (this.noiseArray[((i1 + 1) * l + j1 + 0) * b3 + k1 + 1] - d3) * d0;

        double d8 = (this.noiseArray[((i1 + 1) * l + j1 + 1) * b3 + k1 + 1] - d4) * d0;

        for (int l1 = 0; l1 < 8; ++l1)

        {

        double d9 = 0.25D;

        double d10 = d1;

        double d11 = d2;

        double d12 = (d3 - d1) * d9;

        double d13 = (d4 - d2) * d9;

        for (int i2 = 0; i2 < 4; ++i2)

        {

        int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1;

        short short1 = 128;

        j2 -= short1;

        double d14 = 0.25D;

        double d15 = (d11 - d10) * d14;

        double d16 = d10 - d15;

        for (int k2 = 0; k2 < 4; ++k2)

        {

        if ((d16 += d15) > 0.0D)

        {

                /** Main filler block fill's all the underground, replaces block stone **/

                par3ArrayOfByte[j2 += short1] = (byte)253;//

        }

        else if (k1 * 8 + l1 < b2)

        {

                par3ArrayOfByte[j2 += short1] = (byte)Block.waterStill.blockID;

        }

        else

        {

                par3ArrayOfByte[j2 += short1] = 0;

        }

        }

        d10 += d12;

        d11 += d13;

        }

        d1 += d5;

        d2 += d6;

        d3 += d7;

        d4 += d8;

        }

}

}

}

}

public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)

{

byte var5 = 63;

double var6 = 0.03125D;

this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D);

for (int var8 = 0; var8 < 16; var8++)

{

for (int var9 = 0; var9 < 16; var9++)

{

BiomeGenBase var10 = par4ArrayOfBiomeGenBase[(var9 + var8 * 16)];

float var11 = var10.getFloatTemperature();

int var12 = (int)(this.stoneNoise[(var8 + var9 * 16)] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);

int var13 = -1;

byte var14 = var10.topBlock;

byte var15 = var10.fillerBlock;

for (int var16 = 127; var16 >= 0; var16--)

{

        int var17 = (var9 * 16 + var8) * 128 + var16;

        if (var16 <= 0 + this.rand.nextInt(5))

        {

        par3ArrayOfByte[var17] = ((byte)Block.bedrock.blockID);

        }

        else

        {

        byte var18 = par3ArrayOfByte[var17];

        if (var18 == 0)

        {

        var13 = -1;

        }

        /** Main filler block fill's all the underground, replaces block stone **/

        else if (var18 != 253)

        {

        if (var13 == -1)

        {

        if (var12 == 0)

        {

                var14 = 0;

               

                /** change to custom dirt **/

                var15 = (byte)LegendofZelda.LoZDirt.blockID;//

        }

        else if ((var16 >= var5 - 4) && (var16 <= var5 + 1))

        {

                var14 = var10.topBlock;

                var15 = var10.fillerBlock;

        }

        if ((var16 < var5) && (var14 == 0))

        {

                if (var11 < 0.15F)

                {

                var14 = (byte)Block.ice.blockID;

                }

                else

                {

                var14 = (byte)Block.waterStill.blockID;

                }

        }

        var13 = var12;

        if (var16 >= var5 - 1)

        {

                par3ArrayOfByte[var17] = var14;

        }

        else

        {

                par3ArrayOfByte[var17] = var15;

        }

        }

        else if (var13 > 0)

        {

        var13--;

        par3ArrayOfByte[var17] = var15;

        if ((var13 == 0) && (var15 == Block.sand.blockID))

        {

                var13 = this.rand.nextInt(4);

                var15 = (byte)Block.sandStone.blockID;

        }

        }

        }

        }

}

}

}

}

public Chunk loadChunk(int par1, int par2)

{

return provideChunk(par1, par2);

}

public Chunk provideChunk(int par1, int par2)

{

this.rand.setSeed(par1 * 341873128712L + par2 * 132897987541L);

byte[] var3 = new byte[32768];

generateTerrain(par1, par2, var3);

this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);

replaceBlocksForBiome(par1, par2, var3, this.biomesForGeneration);

this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);

this.ravineGenerator.generate(this, this.worldObj, par1, par2, var3);

if (this.mapFeaturesEnabled)

{

this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, var3);

this.villageGenerator.generate(this, this.worldObj, par1, par2, var3);

this.strongholdGenerator.generate(this, this.worldObj, par1, par2, var3);

this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, var3);

}

Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);

byte[] var5 = var4.getBiomeArray();

for (int var6 = 0; var6 < var5.length; var6++)

{

var5[var6] = ((byte)this.biomesForGeneration[var6].biomeID);

}

var4.generateSkylightMap();

return var4;

}

private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7)

{

if (par1ArrayOfDouble == null)

{

par1ArrayOfDouble = new double[par5 * par6 * par7];

}

if (this.parabolicField == null)

{

this.parabolicField = new float[25];

for (int var8 = -2; var8 <= 2; var8++)

{

for (int var9 = -2; var9 <= 2; var9++)

{

        float var10 = 10.0F / MathHelper.sqrt_float(var8 * var8 + var9 * var9 + 0.2F);

        this.parabolicField[(var8 + 2 + (var9 + 2) * 5)] = var10;

}

}

}

double var44 = 684.41200000000003D;

double var45 = 684.41200000000003D;

this.noise5 = this.noiseGen5.generateNoiseOctaves(this.noise5, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D);

this.noise6 = this.noiseGen6.generateNoiseOctaves(this.noise6, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D);

this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, par2, par3, par4, par5, par6, par7, var44 / 80.0D, var45 / 160.0D, var44 / 80.0D);

this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44);

this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44);

boolean var43 = false;

boolean var42 = false;

int var12 = 0;

int var13 = 0;

for (int var14 = 0; var14 < par5; var14++)

{

for (int var15 = 0; var15 < par7; var15++)

{

float var16 = 0.0F;

float var17 = 0.0F;

float var18 = 0.0F;

byte var19 = 2;

BiomeGenBase var20 = this.biomesForGeneration[(var14 + 2 + (var15 + 2) * (par5 + 5))];

for (int var21 = -var19; var21 <= var19; var21++)

{

        for (int var22 = -var19; var22 <= var19; var22++)

        {

        BiomeGenBase var23 = this.biomesForGeneration[(var14 + var21 + 2 + (var15 + var22 + 2) * (par5 + 5))];

        float var24 = this.parabolicField[(var21 + 2 + (var22 + 2) * 5)] / (var23.minHeight + 2.0F);

        if (var23.minHeight > var20.minHeight)

        {

        var24 /= 2.0F;

        }

        var16 += var23.maxHeight * var24;

        var17 += var23.minHeight * var24;

        var18 += var24;

        }

}

var16 /= var18;

var17 /= var18;

var16 = var16 * 0.9F + 0.1F;

var17 = (var17 * 4.0F - 1.0F) / 8.0F;

double var47 = this.noise6[var13] / 8000.0D;

if (var47 < 0.0D)

{

        var47 = -var47 * 0.3D;

}

var47 = var47 * 3.0D - 2.0D;

if (var47 < 0.0D)

{

        var47 /= 2.0D;

        if (var47 < -1.0D)

        {

        var47 = -1.0D;

        }

        var47 /= 1.4D;

        var47 /= 2.0D;

}

else

{

        if (var47 > 1.0D)

        {

        var47 = 1.0D;

        }

        var47 /= 8.0D;

}

var13++;

for (int var46 = 0; var46 < par6; var46++)

{

        double var48 = var17;

        double var26 = var16;

        var48 += var47 * 0.2D;

        var48 = var48 * par6 / 16.0D;

        double var28 = par6 / 2.0D + var48 * 4.0D;

        double var30 = 0.0D;

        double var32 = (var46 - var28) * 12.0D * 128.0D / 128.0D / var26;

        if (var32 < 0.0D)

        {

        var32 *= 4.0D;

        }

        double var34 = this.noise1[var12] / 512.0D;

        double var36 = this.noise2[var12] / 512.0D;

        double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D;

        if (var38 < 0.0D)

        {

        var30 = var34;

        }

        else if (var38 > 1.0D)

        {

        var30 = var36;

        }

        else

        {

        var30 = var34 + (var36 - var34) * var38;

        }

        var30 -= var32;

        if (var46 > par6 - 4)

        {

        double var40 = (var46 - (par6 - 4)) / 3.0F;

        var30 = var30 * (1.0D - var40) + -10.0D * var40;

        }

        par1ArrayOfDouble[var12] = var30;

        var12++;

}

}

}

return par1ArrayOfDouble;

}

public boolean chunkExists(int par1, int par2)

{

return true;

}

public void populate(IChunkProvider par1IChunkProvider, int par2, int par3)

{

net.minecraft.block.BlockSand.fallInstantly = true;

int var4 = par2 * 16;

int var5 = par3 * 16;

BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);

this.rand.setSeed(this.worldObj.getSeed());

long var7 = this.rand.nextLong() / 2L * 2L + 1L;

long var9 = this.rand.nextLong() / 2L * 2L + 1L;

this.rand.setSeed(par2 * var7 + par3 * var9 ^ this.worldObj.getSeed());

boolean var11 = false;

if (this.mapFeaturesEnabled)

{

this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

var11 = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);

}

if ((!var11) && (this.rand.nextInt(4) == 0))

{

int var12 = var4 + this.rand.nextInt(16) + 8;

int var13 = this.rand.nextInt(128);

int var14 = var5 + this.rand.nextInt(16) + 8;

new WorldGenLakes(Block.waterStill.blockID).generate(this.worldObj, this.rand, var12, var13, var14);

}

var6.decorate(this.worldObj, this.rand, var4, var5);

SpawnerAnimals.performWorldGenSpawning(this.worldObj, var6, var4 + 8, var5 + 8, 16, 16, this.rand);

var4 += 8;

var5 += 8;

for (int var12 = 0; var12 < 16; var12++)

{

for (int var13 = 0; var13 < 16; var13++)

{

int var14 = this.worldObj.getPrecipitationHeight(var4 + var12, var5 + var13);

if (this.worldObj.isBlockFreezable(var12 + var4, var14 - 1, var13 + var5))

{

        this.worldObj.setBlock(var12 + var4, var14 - 1, var13 + var5, Block.ice.blockID);

}

if (this.worldObj.canSnowAt(var12 + var4, var14, var13 + var5))

{

        this.worldObj.setBlock(var12 + var4, var14, var13 + var5, Block.snow.blockID);

}

}

}

net.minecraft.block.BlockSand.fallInstantly = false;

}

public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate)

{

return true;

}

public boolean unload100OldestChunks()

{

return false;

}

public boolean canSave()

{

return true;

}

public String makeString()

{

return "RandomLevelSource";

}

public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4)

{

BiomeGenBase var5 = this.worldObj.getBiomeGenForCoords(par2, par4);

return var5 == null ? null : var5.getSpawnableList(par1EnumCreatureType);

}

public ChunkPosition findClosestStructure(World par1World, String par2Str, int par3, int par4, int par5)

{

return ("Stronghold".equals(par2Str)) && (this.strongholdGenerator != null) ? this.strongholdGenerator.getNearestInstance(par1World, par3, par4, par5) : null;

}

public int getLoadedChunkCount() {

return 0;

}

public boolean unloadQueuedChunks()

{

return false;

}

public void recreateStructures(int i, int j)

{

}

@Override

public void saveExtraData(){

 

}

}

 

 

Link to comment
Share on other sites

Ok so went to look at this again and was having the same issue you did so spent a few hours trying to figure this out, turns out answer is pretty easy.  I noticed the cave would generate in my replacement stone when it was also listed as the filler block in my biome, so went over the code trying different things trying to figure out why it wasn't digging the block.  Anyway it's such a stupid thing but at least I figured it out hopefully for people in the future.

 

This code should work for you, I just changed everything to byte instead of integer.

 

   protected void digBlock(byte[] data, int index, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop)
    {
        BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16);
        byte top    = (isExceptionBiome(biome) ? (byte)Block.grass.blockID : biome.topBlock);
        byte filler = (isExceptionBiome(biome) ? (byte)Block.dirt.blockID  : biome.fillerBlock);
        byte block  = data[index];

        if (block == (byte)LegendofZelda.LoZRock.blockID || block == filler || block == top)
        {
            if (y < 10)
            {
                data[index] = (byte)Block.lavaMoving.blockID;
            }
            else
            {
                data[index] = 0;

                if (foundTop && data[index - 1] == filler)
                {
                    data[index - 1] = (byte)top;
                }
            }
        }
    }
}

 

NSeUglf.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.