x


Minecraft In Unity, Coal and Iron

I have a terrain generator that i got off of this site.

http://sourceforge.net/projects/minepackage/

I have textures and stuff, and im not using there svn download since its messed up so I download there older one which is available here

http://sourceforge.net/projects/minepackage/files/WhereToGetTheStuff.txt/download

Well that txt file has the download link in it. I understand alot of it but im still confused on how to add stuff like coal into it. I have the textures and i set the texture options to what is required.

In the WorldData.cs I have this for the specific coal texture SetBlockUVCoordinates(BlockType.Coal, 9,9,9);

The 9th element in the WorldGameObject Script/Prefab is set to look like this

World_Textures(Variable)

  • Size 10
  • Element 0 - Grass
  • Element 1 - Grass
  • Element 2 - Grass
  • I think you get the picture
  • Element 9 - Coal

In the Block.cs Script I Have this, plus more but this is all thats needed

public enum BlockType : byte

{

    TopSoil=0,

    Dirt=1,

    Light = 2,

    Lava = 3,

    Leaves=4,

    Stone = 5,

    Bark = 6,

    Water = 7,

    Coal = 8,

    Air = 255



}

For the DualLayerTerrainWithMediumValleys.cs How could i implement coal being placed at random? I was looking at the TreeScript that have and I noticed how they did the Random and in the DualLayerTerrainWithMediumValleys.cs I found this

if (sunlit)

                            {

                                blockType = BlockType.TopSoil;

                                chunk.TopSoilBlocks.Add(new IntVect(blockX, blockY, z));

                                sunlit = false;

                            }

                            else

                            {

                                blockType = BlockType.Dirt;

                                if (caveNoise < 0.2f)

                                {







                             blockType = BlockType.Stone; 



                                }

                            }

Which would explain how it generates stone... I think, but i played around with that script for hours on end so how would i set up coal with it?

This is what i tried (FOR THAT SECTION OF CODE!)

if (sunlit)

                            {

                                blockType = BlockType.TopSoil;

                                chunk.TopSoilBlocks.Add(new IntVect(blockX, blockY, z));

                                sunlit = false;

                            }

                            else

                            {

                                blockType = BlockType.Dirt;

                                if (caveNoise < 0.2f)

                                {





                        if (random.RandomRange(1, 100) < 99)

                           {

                             blockType = BlockType.Coal;  



                           }

                        else

                        {

                           blockType = BlockType.Stone;

                        }



                                }

                            }

Which was basically a copy a paste from the terrain generation and i got this error

Assets/MineCraft/Scripts/TerrainGenerationMethods/DualLayerTerrainWithMediumValleys.cs(61,77): error CS0103: The name `random' does not exist in the current context

So where that function began I put Random random, in between the parameters so it looked like this

public void GenerateTerrain(WorldData worldData, Random random, Chunk chunk, int noiseBlockOffset)

Which sadly resulted in another error

Assets/MineCraft/Scripts/TerrainGenerationMethods/DualLayerTerrainWithMediumValleys.cs(3,16): error CS0535: `DualLayerTerrainWithMediumValleys' does not implement interface member `ITerrainGenerationMethod.GenerateTerrain(WorldData, Chunk, int)'

After I put the random code in, before i added it to the parameters in when i started going with my gut so i have no idea if i was even doing it somewhat right.

Thanks in Advanced

more ▼

asked Dec 29 '11 at 11:55 PM

CursedScripter gravatar image

CursedScripter
31 12 13 14

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The tool is looking for a 'Random' class to generate the random values. Parsing in unity's random isn't going to work if they use different methods.

You could create a wrapper that wraps unity's Random class with a class of your own to translate their method calls into methods that exist in Unity's Random Class..

i.e.

public class MC_Random()
{
    private int m_seed = 1337;

    public MC_Random()
    {
        Random.seed = m_seed;
    }
    // not sure this is what they are requesting
    public float forRange(float p_min, float p_max)
    {
        float result = UnityEngine.Random.Range(p_min, p_max);
        // do other random code
        return result;
    }
}
more ▼

answered Dec 30 '11 at 12:52 AM

Rod Green gravatar image

Rod Green
3.1k 3 11 44

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2972
x885
x136
x60

asked: Dec 29 '11 at 11:55 PM

Seen: 2770 times

Last Updated: Dec 30 '11 at 12:54 AM