tModLoader Problem with generating my custom ores into the world

g4l4xic

Terrarian
Hello all, I have had a problem for a while that I cant seem to fix myself, even though I've done a lot of research on it. My goal is to generate 4 of my custom ores for my mod when creating/generating a new world, but only the ore Magmalite (it can be seen in my code below) seems to generate when I log into a new world. I've searched a lot of most worlds that I've used to test, and I'm positive that the other ores simply aren't generating. I'm also a relatively new coder, although I understand most of my code. I credit example mod and the makers of it for helping me learn how to make a lot of this stuff, and thank you for any help i get for this problem

What I've tried so far:

  • messing with the code and laying it out in different ways to see if it works, in which those other ways did not work
  • watching and reading various videos and parts of the tmodloader forum that have to do with this, along with reading example mods world gen code section, but I still couldn't figure out the problem with my code that makes it so that only one of the ores generate



C#:
using System.IO;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;

namespace GalandricaMod.Worlds
{
    public class GalandricaWorld : ModWorld
    {
        private const int saveVersion = 0;
        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
            if (ShiniesIndex != -1)
            {
                tasks.Insert(ShiniesIndex, new PassLegacy("Magmalite Ore", MagmaliteOreGen));
                tasks.Insert(ShiniesIndex, new PassLegacy("Liquilate Ore", LiquilateOreGen));
                tasks.Insert(ShiniesIndex, new PassLegacy("Gairswind Ore", GairswindOreGen));
                tasks.Insert(ShiniesIndex, new PassLegacy("Erodate Ore", ErodateOreGen));
            }
        }
        private void MagmaliteOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
           
            for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)                                                                                                                                    
            {                                                                                                                                                                                                                    
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("MagmaliteOreTile"), false, 0f, 0f, false, true);
            }  
        }
        private void LiquilateOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
            for (int l = 0; l < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); l++)                                                                                                                                    
            {                                                                                                                                                                                                                    
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("LiquilateOreTile"), false, 0f, 0f, false, true);
            }
        }
        private void GairswindOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
            for (int o = 0; o < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); o++)                                                                                                                                    
            {                                                                                                                                                                                                                    
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("GairswindOreTile"), false, 0f, 0f, false, true);
            }
        }
        private void ErodateOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
            for (int p = 0; p < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); p++)                                                                                                                                    
            {                                                                                                                                                                                                                    
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ErodateOreTile"), false, 0f, 0f, false, true);
            }
        }
    }
}
 
Back
Top Bottom