tModLoader biome help well i was trying to make a biome and sometimes it works but now everytime when i am make

Xag

Terrarian
...a world is showing me this


Index was outside the bounds of the array. at Darkarmod.Darkar.DarkarBiome.<ModifyWorldGenTasks>b__1(GenerationProgress progress) at Terraria.GameContent.Generation.PassLegacy.Apply(GenerationProgress progress) at Terraria.World.Generation.WorldGenerator.GenerateWorld(GenerationProgress progress) at Terraria.WorldGen.generateWorld(Int32 seed, GenerationProgress customProgressObject) at Terraria.WorldGen.do_worldGenCallBack(Object threadContext) at Terraria.WorldGen.worldGenCallBack(Object threadContext)

and here is the code
Code:
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;
using System.Linq;

namespace Darkarmod.Darkar
{
    public class DarkarkBiome : ModWorld
    {

        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int genIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
            if (genIndex == -1)
            {
                return;
            }
            tasks.Insert(genIndex + 1, new PassLegacy("Darkar Stuff..", delegate (GenerationProgress progress)
            {
                progress.Message = "Darkar Stuff..";
                for (int i = 0; i < Main.maxTilesX / 300; i++)     
                {
                    int X = WorldGen.genRand.Next(1, Main.maxTilesX - 300);
                    int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer - 100, Main.maxTilesY - 200);
                    int TileType = mod.TileType("Darkdirt1tile");     

                    WorldGen.TileRunner(X, Y, 600, WorldGen.genRand.Next(100, 200), TileType, false, 0f, 0f, true, true); random it looks.
                                                                                                                    
                    for (int k = 0; k < 100; k++)                 
                    {
                        int Xo = X + Main.rand.Next(-240, 240);
                        int Yo = Y + Main.rand.Next(-240, 240);
                        if (Main.tile[Xo, Yo].type == mod.TileType("Darkdirt1tile"))  
                        {

                            {
                                WorldGen.TileRunner(Xo, Yo, (double)WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(5, 10), mod.TileType("DararOreBlock1tile"), false, 0f, 0f, false, true);  
                            }
                        }
                    }
                }

            }));
        }
    }
}
 
Code:
                    for (int k = 0; k < 100; k++)                
                    {
                        int Xo = X + Main.rand.Next(-240, 240);
                        int Yo = Y + Main.rand.Next(-240, 240);
                        if (Main.tile[Xo, Yo].type == mod.TileType("Darkdirt1tile")) 
                        {

                            {
                                WorldGen.TileRunner(Xo, Yo, (double)WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(5, 10), mod.TileType("DararOreBlock1tile"), false, 0f, 0f, false, true); 
                            }
                        }
                    }

You're passing Xo and Yo as indices, however those can be negative, or outside of the array bounds. You should add a failsafe like this:
Code:
if(Xo < 0)
    Xo = 0;
else if(Xo > Main.maxTilesX)
    Xo = Main.maxTilesX - 1;
And do the same for Yo.
 
  • Like
Reactions: Xag
You're passing Xo and Yo as indices, however those can be negative, or outside of the array bounds. You should add a failsafe like this:
Code:
if(Xo < 0)
    Xo = 0;
else if(Xo > Main.maxTilesX)
    Xo = Main.maxTilesX - 1;
And do the same for Yo.
oh ok thanks so much
 
ok is working but is doing it again I may not have written it correctly do u can write it for me i mean the code its ok if u say no.
 
ok
Code:
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;
using System.Linq;

namespace Darkarmod.Darkar
{
    public class DarkarkBiome : ModWorld
    {

        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int genIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
            if (genIndex == -1)
            {
                return;
            }
            tasks.Insert(genIndex + 1, new PassLegacy("Darkar Stuff..", delegate (GenerationProgress progress)
            {
                progress.Message = "Darkar Stuff..";
                for (int i = 0; i < Main.maxTilesX / 300; i++)    
                {
                    int X = WorldGen.genRand.Next(1, Main.maxTilesX - 300);
                    int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer - 100, Main.maxTilesY - 200);
                    int TileType = mod.TileType("Darkdirt1tile");    

                    WorldGen.TileRunner(X, Y, 600, WorldGen.genRand.Next(100, 200), TileType, false, 0f, 0f, true, true);
                                                                                                                   
                    for (int k = 0; k < 100; k++)                
                    {
                        int Xo = X + Main.rand.Next(-240, 240);
                        int Yo = Y + Main.rand.Next(-240, 240);
                        if (Main.tile[Xo, Yo].type == mod.TileType("Darkdirt1tile")) 
                        {

                            {
                                WorldGen.TileRunner(Xo, Yo, (double)WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(5, 10), mod.TileType("DararOreBlock1tile"), false, 0f, 0f, false, true); 
                            }
                        }
                    }
                }

            }));
        }
    }
};
 
ok
Code:
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;
using System.Linq;

namespace Darkarmod.Darkar
{
    public class DarkarkBiome : ModWorld
    {

        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int genIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
            if (genIndex == -1)
            {
                return;
            }
            tasks.Insert(genIndex + 1, new PassLegacy("Darkar Stuff..", delegate (GenerationProgress progress)
            {
                progress.Message = "Darkar Stuff..";
                for (int i = 0; i < Main.maxTilesX / 300; i++)   
                {
                    int X = WorldGen.genRand.Next(1, Main.maxTilesX - 300);
                    int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer - 100, Main.maxTilesY - 200);
                    int TileType = mod.TileType("Darkdirt1tile");   

                    WorldGen.TileRunner(X, Y, 600, WorldGen.genRand.Next(100, 200), TileType, false, 0f, 0f, true, true);
                                                                                                                  
                    for (int k = 0; k < 100; k++)               
                    {
                        int Xo = X + Main.rand.Next(-240, 240);
                        int Yo = Y + Main.rand.Next(-240, 240);
                        if (Main.tile[Xo, Yo].type == mod.TileType("Darkdirt1tile"))
                        {

                            {
                                WorldGen.TileRunner(Xo, Yo, (double)WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(5, 10), mod.TileType("DararOreBlock1tile"), false, 0f, 0f, false, true);
                            }
                        }
                    }
                }

            }));
        }
    }
};
You did put in the failsaves like I told you to, right? I don't see them anywhere.
 
no is a really big story but i will try to explain it ,well i try to put the code but still errors and stuffs like (},; expected) and it was messed up and i paste the old version because the new is messed up
 
Don't take this the wrong way, but if you are still having problems with basic syntax I think custom world gen is a bit out of your league. You should stick to simple items for now unless you get a proper grasp of the syntax.
 
  • Like
Reactions: Xag
Don't take this the wrong way, but if you are still having problems with basic syntax I think custom world gen is a bit out of your league. You should stick to simple items for now unless you get a proper grasp of the syntax.
ok
 
Back
Top Bottom