Well, to generate ores when the world starts, override WorldGenPostGen() with a function. So, for example, if you're ore is called Tintium (random name), then you would make a function like this:
Code:
public void AddTintium()
{
int LowX = 200; //How far left in the world it's generated
int HighX = Main.maxTilesX - 200; //How far right in the world it's generated
int LowY = Main.maxTilesY - 400; //Height in the world (uppermost)
int HighY = Main.maxTilesY - 200; //Height in the world (lowermost)
int X = WorldGen.genRand.Next(LowX, HighX); //Picks a random position on the X axis
int Y = WorldGen.genRand.Next(LowY, HighY); //Picks a random position on the Y axis
int OreMinimumSize= 4;
int OreMaximumSize = 6; // This is (from what I've found) the size of vein
int OreMinimumStretch = 8;
int OreMaximumStretch = 15; //This is how stretched out the vein is (from what I've found), so a higher variable would make a really elongated vein (mess around with this if you want)
int OreSpread = WorldGen.genRand.Next(OreMinimumSpread, OreMaximumSpread + 1); //Randomized variable
int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency, OreMaximumFrequency + 1); //Another randomized variable
WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, TileDef.byName["InternalModName:TintiumOre"]); //Ores tile name at the end, leave the rest.
}
Presuming you've already made a file that extends the ModWorld class, in their, you would type this:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using TAPI;
using Terraria;
public class MWorld : ModWorld //Replace MWorld with name of the .cs file
{
public override void WorldGenPostGen()
{
Main.statusText = "Adding Tintium Ore..."; //Not necessary, but you can use it if you want to make it say something whilst generating the world.
int amount = 400; //How many times you want the ore to be generated (how many veins)
for (int x = 0; x < amount + 1; x++) AddTintium();
}
}
I think that's everything you need, and If you want, I can sprite stuff but I wouldn't call myself an expert, your choice
EDIT: For your convenience, I'll just post the whole code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using TAPI;
using Terraria;
namespace ModName //Make this your mod name
{
public class MWorld : ModWorld //Replace MWorld with name of the .cs file
{
public override void WorldGenPostGen()
{
Main.statusText = "Adding Tintium Ore..."; //Not necessary, but you can use it if you want to make it say something whilst generating the world.
int amount = 400; //How many times you want the ore to be generated (how many veins)
for (int x = 0; x < amount + 1; x++) AddTintium();
}
public void AddTintium()
{
int LowX = 200; //How far left in the world it's generated
int HighX = Main.maxTilesX - 200; //How far right in the world it's generated
int LowY = Main.maxTilesY - 400; //Height in the world (uppermost)
int HighY = Main.maxTilesY - 200; //Height in the world (lowermost)
int X = WorldGen.genRand.Next(LowX, HighX); //Picks a random position on the X axis
int Y = WorldGen.genRand.Next(LowY, HighY); //Picks a random position on the Y axis
int OreMinimumSize = 4;
int OreMaximumSize = 6; // This is (from what I've found) the size of vein
int OreMinimumStretch = 8;
int OreMaximumStretch = 15; //This is how stretched out the vein is (from what I've found), so a higher variable would make a really elongated vein (mess around with this if you want)
int OreSpread = WorldGen.genRand.Next(OreMinimumSpread, OreMaximumSpread + 1); //Randomized variable
int OreFrequency = WorldGen.genRand.Next(OreMinimumFrequency, OreMaximumFrequency + 1); //Another randomized variable
WorldGen.OreRunner(X, Y, (double)OreSpread, OreFrequency, TileDef.byName["InternalModName:TintiumOre"]); //Ores tile name at the end, leave the rest.
}
}
}