FANDOM


Difficulty: noframe
Clock: N/A


Under Contruction

Under Construction
This page has been marked as under construction, which means information may change rapidly as it updated, or that the page is awaiting updates.


See this thread post: http://www.terrariaonline.com/threads/released-wip-tconfig-a-mod-to-make-mods.52207/page-230#post-1507210


  1. Create a Tile.cs file withing your Tile folder.
  2. Put within it
public void ModifyWorld() 
{
    Main.statusText = "Adding My Ores..."; //feel free to tweak
    int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); //feel free to tweak
    for(int i=0;i<Amount_Of_Spawns;i++) AddMyOres();
}
public void AddMyOres() 
{
    int LowX = 200;                     //after ocean on left edge of map
    int HighX = Main.maxTilesX-200;     //before ocean on right edge of map
    int LowY = (int)Main.worldSurface;  //where the brown background and the sky background meets
    int HighY = Main.maxTilesY-200;     //where hell and the grey background meets
    
    int X = WorldGen.genRand.Next(LowX,HighX); //don't touch
    int Y = WorldGen.genRand.Next(LowY,HighY); //don't touch

    int OreMinimumSpread = 5; //feel free to tweak
    int OreMaximumSpread = 8; //feel free to tweak

    int OreMinimumFrequency = 5; //feel free to tweak
    int OreMaximumFrequency = 8; //feel free to tweak

    int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); //don't touch
    int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); //don't touch

    WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, Config.tileDefs.ID["Name of My tile"]);
}
  • Code by Yoraiz0r
  • Amount_Of_Spawns is the amount of times your ore will attempt to spawn.
  • LowX is the most left point in the world where your tile spawns , tile grid wise.
  • HighX is the most right point.
  • LowY is the most highest point (closest to space).
  • HighY is the lowest point (closest to hell)
  • OreSpread and OreFrequency values are for your ore density and radius of spawn , per spawn (where spread is the radius , and frequency is the density)
  • lastly , the name of your tile should be added in the last line instead of 'Name of My tile'.


Some useful notes for those that want to change where the ore spawns

The hell area is everything in the area of LowY = Main.maxTilesY-200 , and HIghY = Main.maxTilesY.

The grey background (underground) is everything in the area of LowY=(int)Main.rockLayer , and HighY = Main.maxTilesY-200.

The Brown background is everything between the area of LowY=(int)Main.worldSurface , and HighY = (int)Main.rockLayer.

The Ocean is two different areas , where one is LowX=0 , HIghX=200 , and the other is LowX=Main.maxTilesX-200 , HighX = Main.maxTilesX.



Spawning Multiple Custom OresEdit

You can spawn just the one custom ore, or you can try this to spawn multiple custom ores.

1. Create a Tile.cs file(if you haven't already, use the above code) within your Tile folder.

2. This is what it should look like.

For an example I changed everything that had to do with My Ores to Titanium. May use if you like or change to your critique.

public void ModifyWorld() 
{
    Main.statusText = "Adding Titanium..."; //feel free to tweak
    int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); //feel free to tweak
    for(int i=0;i<Amount_Of_Spawns;i++) AddTitan();
}
public void AddTitan() 
{
    int LowX = 200;                     //after ocean on left edge of map
    int HighX = Main.maxTilesX-200;     //before ocean on right edge of map
    int LowY = (int)Main.worldSurface;  //where the brown background and the sky background meets
    int HighY = Main.maxTilesY-200;     //where hell and the grey background meets
    
    int X = WorldGen.genRand.Next(LowX,HighX); //don't touch
    int Y = WorldGen.genRand.Next(LowY,HighY); //don't touch

    int OreMinimumSpread = 5; //feel free to tweak
    int OreMaximumSpread = 8; //feel free to tweak

    int OreMinimumFrequency = 5; //feel free to tweak
    int OreMaximumFrequency = 8; //feel free to tweak

    int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); //don't touch
    int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); //don't touch

    WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, Config.tileDefs.ID["Titanium"]);
}

A few notes:

  • Everywhere it says AddTitan() it is completely customizable to you. If I wanted, I could make an ore called Blubolt Ore and make it say AddBB() or AddBlueBolt() or whatever you like! This is what makes it possible to make multiple ores. Further explanation in next step...
  • Amount of Spawns is not very sensitive. Put it somewhere between 400 and 1000. 400 being about as rare as gold or some of the hardmode ores, and 1000 being a little too easy to find. Anything below or over these could be a little frustrating, or if you want them, a little fun!!!
  • As far as I know the OreMaximum and OreMinimum spread thing just restricts how wide or tall the ore can be found in. Example: What it is set at now 5 and 8... you will never find your ore spawned less than 5 blocks in width and/or height, and it can't be found wider than 8 blocks in width and/or height.
  • Same with ore frequency, but instead of width it's how much can be found within the width and height restrictions. Therefore, if I went ahead and created the modpack like this, I would find the ores no less than 5 in a bunch, but no more than 8 in a bunch. I may be wrong, but you can tweak it to suit your needs. To save you some time...
  • ^^^ Cont...An OreMaximumSpread of 8 and an OreMinimumSpread of 3, and an OreMaximumFrequency of 10 and an OreMinimum of 5 will make your ore in about the same portions of copper ore. To make it rarer, just size these numbers down about 2 or 3 from the default this tutorial is set on (5 and 8).

3. Add this code after the line of code "for(int i=0;i<Amount_Of_Spawns;i++) AddTitanium();".

Main.statusText = "Adding Radium..."; //feel free to tweak
    int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); //feel free to tweak
    for(int i=0;i<Amount_Of_Spawns;i++) AddRadium();

After you do this, copy and paste the block of code starting with the line of code that reads

"public void AddTitan() "

and paste it right after that whole block of code.

Afterwards, change anything with the first ore's given name (Example: Titanium) to your next ore's name (Example: Radium).

Now for the further explanation... (bear with me... this can get confusing...)

SO... if you haven't noticed, the AddTitan/AddRadium is just your own sort of custom variable. Just to show you, the name doesn't even have to be Add"Whatever"() it could be birdspooponpeople(). Just so long as you duplicate this after the public void "blahblahblah"... then it's fine. Just don't make two blocks of code with the same variable. EXAMPLE AGAIN...:

BAD:

public void ModifyWorld() 
{
    Main.statusText = "Adding My First Ore..."; 
    int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); 
    for(int i=0;i<Amount_Of_Spawns;i++) AddFirstOre();

    Main.statusText = "Adding My First Ore..."; //feel free to tweak
    int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); //We already set the variable "Amount_Of_Spawns" in the first block of code.
    for(int i=0;i<Amount_Of_Spawns;i++) AddFirstOre();//notice how both are AddFirstOre() ?? This is bad!!!

}
public void AddFirstOre() 
{
    int LowX = 200;                     
    int HighX = Main.maxTilesX-200;    
    int LowY = (int)Main.worldSurface;  
    int HighY = Main.maxTilesY-200;    
    
    int X = WorldGen.genRand.Next(LowX,HighX); 
    int Y = WorldGen.genRand.Next(LowY,HighY); 

    int OreMinimumSpread = 5; 
    int OreMaximumSpread = 8; 

    int OreMinimumFrequency = 5; 
    int OreMaximumFrequency = 8; 

    int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); 
    int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); 

    WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, Config.tileDefs.ID["First Ore"]);
}
public void AddFirstOre() 
{
    int LowX = 200;                     
    int HighX = Main.maxTilesX-200;    
    int LowY = (int)Main.worldSurface;  
    int HighY = Main.maxTilesY-200;    
    
    int X = WorldGen.genRand.Next(LowX,HighX); 
    int Y = WorldGen.genRand.Next(LowY,HighY); 

    int OreMinimumSpread = 5; 
    int OreMaximumSpread = 8; 

    int OreMinimumFrequency = 5; 
    int OreMaximumFrequency = 8; 

    int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); 
    int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); 

    WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, Config.tileDefs.ID["First Ore"]);
}
public void AddMyOres() //once again, AddFirstOre() is used twice with the same kind of block of code. BAD!!!!
}

}

This code above shows that you want to create the first ore twice and set the value of Amount_Of_Spawns twice, this will result in a crash/error.

GOOD: :)

public void ModifyWorld() 
{
    Main.statusText = "Adding My First Ore..."; 
    int Amount_Of_Spawns = 100+(int)(Main.maxTilesY/5); 
    for(int i=0;i<Amount_Of_Spawns;i++) AddFirstOre();

    Main.statusText = "Adding My Second Ore..."; //feel free to tweak
    int Generate_Ore = 200+(int)(Main.maxTilesY/5); //Remember Generate_Ore could be anything you want, as long as the 2 match up.
    for(int i=0;i<Generate_Ore;i++) AddMySecondOre();//notice how they both are different?? Good!!!

}
public void AddMyFirstOre() 
{
    int LowX = 200;                     
    int HighX = Main.maxTilesX-200;    
    int LowY = (int)Main.worldSurface;  
    int HighY = Main.maxTilesY-200;    
    
    int X = WorldGen.genRand.Next(LowX,HighX); 
    int Y = WorldGen.genRand.Next(LowY,HighY); 

    int OreMinimumSpread = 5; 
    int OreMaximumSpread = 8; 

    int OreMinimumFrequency = 5; 
    int OreMaximumFrequency = 8; 

    int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); 
    int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); 

    WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, Config.tileDefs.ID["First Ore"]);
}
public void AddSecondOre() //This once is different than the other. Different name = no error!!! Good!!!
{
        int LowX = 200;                     
    int HighX = Main.maxTilesX-200;    
    int LowY = (int)Main.worldSurface;  
    int HighY = Main.maxTilesY-200;    
    
    int X = WorldGen.genRand.Next(LowX,HighX); 
    int Y = WorldGen.genRand.Next(LowY,HighY); 

    int OreMinimumSpread = 5; 
    int OreMaximumSpread = 8; 

    int OreMinimumFrequency = 5; 
    int OreMaximumFrequency = 8; 

    int OreSpread = WorldGen.genRand.Next(OreMinimumSpread,OreMaximumSpread+1); 
    int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency,OreMaximumFrequency+1); 

    WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, Config.tileDefs.ID["Second Ore"]);
}

}

OKAI... did ya get that?? If not, then thanks for trying... lol the above code is what you want. Just remember where to tweak and where not to tweak. And remeber to change the First Ore and Second ore to your corrosponding ore. To make more than two custom ores repeat the process by copy/paste. Dont forget to put a number after Amount of Spawns or you will get an error

Code by: Yoraiz0r

Edited by: Mango97

Other MethodsEdit

Here is a little simpler (In my eyes) way of doing this...

  • In your Tile folder, create a class called "Tile.cs"
  • Open this file, and copy the following code:
  • ​public void ModifyWorld()
    {
        //Sets what the world generator says is happening in game.
        Main.statusText = "Spawning My Tile...";

        //How far along and far down the area spawning can occur in should be.
        int areaWidth = (int)Main.maxTilesX;
        int areaHeight = 20;

        //What y co-ord should deposits always be below.
        int areaY = (int)Main.worldSurface;

        //How many deposits to create. (rarity)
        int numDeposits = Main.rand.Next(200, 500);

        //Create the specified number of deposits.
        for (int i = 0; i < numDeposits; i++)
        {
            //Choose a random x and y position within the area defined.
            int depositX = Main.rand.Next(20, areaWidth - 20);
            int depositY = Main.rand.Next(areaY, areaY + areaHeight);

            //Choose a random width for the deposit.
            int depositWidth = Main.rand.Next(5, 15);

            //Loop through each x(horizontal) value within the deposit.
            for (int x = depositX; x < depositX + depositWidth; x++)
            {
                //Choose random amounts of ore to go above and below the x position.
                int above = Main.rand.Next(2, 10);
                int below = Main.rand.Next(5, 10);

                //Loop through each y value and set the tile there.
                for (int y = depositY - above; y < depositY + below; y++)
                {
                    //Place the ore in the calculated position.
                    WorldGen.PlaceTile(x, y, Config.tileDefs.ID["My Tile"]);
                }
            }
        }
    }


  • So what we have here is code which will make a roughly circular deposit of whatever ore you put in the "My Tile" part.
  • What happens, is a set of variables are defined to say what area the deposits can be put in, and how many. Then each one is made, with random width and heights below and above.
  • Hopefully this should be clear as to whats happening


Code by me (ben657)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.