tAPI Gretarria mod - The past being rewritten

...a mod... ...that adds... ...world generated... ...STRUCTURES? i really see this mod having a great future (pun intended), keep up the good work!
P.S: can i use that structure code?
Is it really that simple? Thank you so much!
Bad that the worm does not work. This happens in all mods, when the worm is summoned without a body. :(
Necropolis's Seiryu has the bodypart spawning code in its AI, not in the summon item, and i used the same code in my mod too for Steeldrake, so yeah, not in all mods
 
Last edited:
You sure can, it's a bit scruffy at the moment, but here:


Code:
public void AddAncientForges()
        {
            Main.statusText = "Building ancient forges...";

            int HX = Main.maxTilesX - 1200;
            int LX = 1200;                                                                                      
            int HY = Main.maxTilesY - 200;          //This is the bounds of where it can be placed
            int LY = Main.maxTilesY - 700;

            x = WorldGen.genRand.Next(LX, HX + 1);          //this is the actual position
            y = WorldGen.genRand.Next(LY, HY + 1);

            if (!WorldGen.EmptyTileCheck(x, x, y, y) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y, y) && !WorldGen.EmptyTileCheck(x, x, y - 6, y - 6 ) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y - 6, y - 6))  //this checks if the for coners of the structure are blocks, you can get rid of this honestly
            {
                //Kill all the tiles
                for (int i = 0; i < 8; i++)
                {
                    WorldGen.KillTile(x + i, y, false, false, true);
                    WorldGen.KillTile(x + i, y - 1, false, false, true);
                    WorldGen.KillTile(x + i, y - 2, false, false, true);
                    WorldGen.KillTile(x + i, y - 3, false, false, true);
                    WorldGen.KillTile(x + i, y - 4, false, false, true);
                    WorldGen.KillTile(x + i, y - 5, false, false, true);
                    WorldGen.KillTile(x + i, y - 6, false, false, true);
                }

                //Kill all the walls

                for (int q = 0; q < 8; q++)
                {
                    WorldGen.KillWall(x + q, y);
                    WorldGen.KillWall(x + q, y - 1);
                    WorldGen.KillWall(x + q, y - 2);
                    WorldGen.KillWall(x + q, y - 3);
                    WorldGen.KillWall(x + q, y - 4);
                    WorldGen.KillWall(x + q, y - 5);
                    WorldGen.KillWall(x + q, y - 6);
                }

                //Generate tiles surrounding the sword forge

                //FLOOR
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y, TileDef.byName["Gretarria:GretarrianBrick"], true, true);      //My bricks name
                //LEFT AND RIGHT WALLS
                WorldGen.PlaceTile(x, y - 4, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x, y - 5, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x + 7, y - 4, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x + 7, y - 5, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                //CEILING
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y - 6, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                //WALLS
                int x1 = x + 1;
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 1, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);  //The wall
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 2, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 3, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 4, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 5, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                //SWORD FORGE
                WorldGen.PlaceTile(x + 3, y - 1, TileDef.byName["Gretarria:AncientForge"], true, true);     //The actual thing (this regards it's placed position, which is bottom left for my tile
            }
            else
            {
                AddAncientForges();
            }

        }
 
You sure can, it's a bit scruffy at the moment, but here:


Code:
public void AddAncientForges()
        {
            Main.statusText = "Building ancient forges...";

            int HX = Main.maxTilesX - 1200;
            int LX = 1200;                                                                                     
            int HY = Main.maxTilesY - 200;          //This is the bounds of where it can be placed
            int LY = Main.maxTilesY - 700;

            x = WorldGen.genRand.Next(LX, HX + 1);          //this is the actual position
            y = WorldGen.genRand.Next(LY, HY + 1);

            if (!WorldGen.EmptyTileCheck(x, x, y, y) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y, y) && !WorldGen.EmptyTileCheck(x, x, y - 6, y - 6 ) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y - 6, y - 6))  //this checks if the for coners of the structure are blocks, you can get rid of this honestly
            {
                //Kill all the tiles
                for (int i = 0; i < 8; i++)
                {
                    WorldGen.KillTile(x + i, y, false, false, true);
                    WorldGen.KillTile(x + i, y - 1, false, false, true);
                    WorldGen.KillTile(x + i, y - 2, false, false, true);
                    WorldGen.KillTile(x + i, y - 3, false, false, true);
                    WorldGen.KillTile(x + i, y - 4, false, false, true);
                    WorldGen.KillTile(x + i, y - 5, false, false, true);
                    WorldGen.KillTile(x + i, y - 6, false, false, true);
                }

                //Kill all the walls

                for (int q = 0; q < 8; q++)
                {
                    WorldGen.KillWall(x + q, y);
                    WorldGen.KillWall(x + q, y - 1);
                    WorldGen.KillWall(x + q, y - 2);
                    WorldGen.KillWall(x + q, y - 3);
                    WorldGen.KillWall(x + q, y - 4);
                    WorldGen.KillWall(x + q, y - 5);
                    WorldGen.KillWall(x + q, y - 6);
                }

                //Generate tiles surrounding the sword forge

                //FLOOR
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y, TileDef.byName["Gretarria:GretarrianBrick"], true, true);      //My bricks name
                //LEFT AND RIGHT WALLS
                WorldGen.PlaceTile(x, y - 4, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x, y - 5, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x + 7, y - 4, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x + 7, y - 5, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                //CEILING
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y - 6, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                //WALLS
                int x1 = x + 1;
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 1, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);  //The wall
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 2, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 3, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 4, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 5, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                //SWORD FORGE
                WorldGen.PlaceTile(x + 3, y - 1, TileDef.byName["Gretarria:AncientForge"], true, true);     //The actual thing (this regards it's placed position, which is bottom left for my tile
            }
            else
            {
                AddAncientForges();
            }

        }
no need to post it again... i read the above posts
 
You sure can, it's a bit scruffy at the moment, but here:


Code:
public void AddAncientForges()
        {
            Main.statusText = "Building ancient forges...";

            int HX = Main.maxTilesX - 1200;
            int LX = 1200;                                                                                     
            int HY = Main.maxTilesY - 200;          //This is the bounds of where it can be placed
            int LY = Main.maxTilesY - 700;

            x = WorldGen.genRand.Next(LX, HX + 1);          //this is the actual position
            y = WorldGen.genRand.Next(LY, HY + 1);

            if (!WorldGen.EmptyTileCheck(x, x, y, y) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y, y) && !WorldGen.EmptyTileCheck(x, x, y - 6, y - 6 ) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y - 6, y - 6))  //this checks if the for coners of the structure are blocks, you can get rid of this honestly
            {
                //Kill all the tiles
                for (int i = 0; i < 8; i++)
                {
                    WorldGen.KillTile(x + i, y, false, false, true);
                    WorldGen.KillTile(x + i, y - 1, false, false, true);
                    WorldGen.KillTile(x + i, y - 2, false, false, true);
                    WorldGen.KillTile(x + i, y - 3, false, false, true);
                    WorldGen.KillTile(x + i, y - 4, false, false, true);
                    WorldGen.KillTile(x + i, y - 5, false, false, true);
                    WorldGen.KillTile(x + i, y - 6, false, false, true);
                }

                //Kill all the walls

                for (int q = 0; q < 8; q++)
                {
                    WorldGen.KillWall(x + q, y);
                    WorldGen.KillWall(x + q, y - 1);
                    WorldGen.KillWall(x + q, y - 2);
                    WorldGen.KillWall(x + q, y - 3);
                    WorldGen.KillWall(x + q, y - 4);
                    WorldGen.KillWall(x + q, y - 5);
                    WorldGen.KillWall(x + q, y - 6);
                }

                //Generate tiles surrounding the sword forge

                //FLOOR
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y, TileDef.byName["Gretarria:GretarrianBrick"], true, true);      //My bricks name
                //LEFT AND RIGHT WALLS
                WorldGen.PlaceTile(x, y - 4, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x, y - 5, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x + 7, y - 4, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                WorldGen.PlaceTile(x + 7, y - 5, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                //CEILING
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y - 6, TileDef.byName["Gretarria:GretarrianBrick"], true, true);
                //WALLS
                int x1 = x + 1;
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 1, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);  //The wall
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 2, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 3, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 4, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 5, TileDef.wallByName["Gretarria:GretarrianBrickWall"], true);
                //SWORD FORGE
                WorldGen.PlaceTile(x + 3, y - 1, TileDef.byName["Gretarria:AncientForge"], true, true);     //The actual thing (this regards it's placed position, which is bottom left for my tile
            }
            else
            {
                AddAncientForges();
            }

        }


Oh right, sorry. Forgot I posted the first one. This ones neater anyway
 
i modified your code a bit, but it gives me this crash whenever i kill the wall of flesh (i set it so it spawns only in hardmode)

System.NullReferenceException: Object reference not set to an instance of an object.
at Terraria.Main.RandomMod(System.Int32 percents, System.Single multiplier, System.Single offset)
at Terraria.Main.PlaySound(System.Int32 type, System.Int32 x = -1, System.Int32 y = -1, System.Int32 Style = 1)
at Terraria.WorldGen.KillTileLogic(System.Int32 i, System.Int32 j, System.Boolean& cont, System.Boolean fail = False, System.Boolean effectOnly = False, System.Boolean noItem = False)
at BriansMod.HMGenOres.PlasmaStructures() in \The Epic Mod\WorldGenClasses.cs at line 152
at BriansMod.HMGenOres.PlasmaStructures() in \The Epic Mod\WorldGenClasses.cs at line 198
at BriansMod.HMGenOres.PlasmaStructures() in \The Epic Mod\WorldGenClasses.cs at line 198
at BriansMod.HMGenOres.PlasmaStructures() in \The Epic Mod\WorldGenClasses.cs at line 198
at BriansMod.HMGenOres.PlasmaStructures() in \The Epic Mod\WorldGenClasses.cs at line 198
at BriansMod.HMGenOres.Generate() in \The Epic Mod\WorldGenClasses.cs at line 38

here's my modified code

EDIT: turns out i can only make it spawn at initial worldgen...
 
Last edited:
err... I don't know why it didn't work... it should work even if it's hardmode. Lemme look real quick.

I got it to work, I did it like this:


Code:
public override void WorldGenModifyHardmodeTaskList(List<WorldGenTask> list)
        {
            list.Insert(0, new WorldGenTask.Action("Gretarria:AncientForges", delegate
            {
                int amount = 40;  //(Main.maxTilesY / 100) - 7
                for (int i = 0; i < amount + 1; i++) AddAncientForges();
            }));
           
        }
 
err... I don't know why it didn't work... it should work even if it's hardmode. Lemme look real quick.

I got it to work, I did it like this:


Code:
public override void WorldGenModifyHardmodeTaskList(List<WorldGenTask> list)
        {
            list.Insert(0, new WorldGenTask.Action("Gretarria:AncientForges", delegate
            {
                int amount = 40;  //(Main.maxTilesY / 100) - 7
                for (int i = 0; i < amount + 1; i++) AddAncientForges();
            }));
          
        }
it's exactly the same thing as this...
Code:
public class GenStructures : WorldGenTask
    {
        private readonly ModBase modBase;
       
        public GenStructures(ModBase modBase) : base(modBase.mod.InternalName)
        {
            this.modBase = modBase;
        }

        public override void Generate()
        {
            try
            {
                int StructureAmount = 20;

                for (int i = 0; i < StructureAmount; i++) PlasmaStructures();
            }
            catch (Exception e)
            {
                ErrorHandling.Handle(e);
            }
        }

        public void PlasmaStructures()
        {
            Main.statusText = "Placing Plasma Reactors...";
           
            int HX = Main.maxTilesX - 200;
            int LX = 200;
            int HY = Main.maxTilesY - 200;
            int LY = Main.maxTilesY - 700;

            int x = WorldGen.genRand.Next(LX, HX + 1);
            int y = WorldGen.genRand.Next(LY, HY + 1);

            //Checks if the corners aren't empty, so it doesn't mess up your caves
            if (!WorldGen.EmptyTileCheck(x, x, y, y) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y, y) && !WorldGen.EmptyTileCheck(x, x, y - 6, y - 6) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y - 6, y - 6))
            {
                //Delete all the tiles in the way
                for (int i = 0; i < 8; i++)
                {
                    WorldGen.KillTile(x + i, y, false, false, true);
                    WorldGen.KillTile(x + i, y - 1, false, false, true);
                    WorldGen.KillTile(x + i, y - 2, false, false, true);
                    WorldGen.KillTile(x + i, y - 3, false, false, true);
                    WorldGen.KillTile(x + i, y - 4, false, false, true);
                    WorldGen.KillTile(x + i, y - 5, false, false, true);
                    WorldGen.KillTile(x + i, y - 6, false, false, true);
                }

                //Delete all the walls in the way
                for (int q = 0; q < 8; q++)
                {
                    WorldGen.KillWall(x + q, y);
                    WorldGen.KillWall(x + q, y - 1);
                    WorldGen.KillWall(x + q, y - 2);
                    WorldGen.KillWall(x + q, y - 3);
                    WorldGen.KillWall(x + q, y - 4);
                    WorldGen.KillWall(x + q, y - 5);
                    WorldGen.KillWall(x + q, y - 6);
                }

                //Actual structure placement

                //Floor placement
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                //Left and right tile placement
                WorldGen.PlaceTile(x, y - 4, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                WorldGen.PlaceTile(x, y - 5, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                WorldGen.PlaceTile(x + 7, y - 4, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                WorldGen.PlaceTile(x + 7, y - 5, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                //Ceiling tile placement
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y - 6, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                //Walls placement
                int x1 = x + 1;
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 1, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 2, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 3, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 4, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 5, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                //Center object placement
                WorldGen.PlaceTile(x + 3, y - 1, TileDef.byName["BriansMod:SteampunkStatueTile"], true, true);
            }
            else
            {
                PlasmaStructures();
            }
        }
    }
maybe i need to remove the catch exception part?
 
it's exactly the same thing as this...
Code:
public class GenStructures : WorldGenTask
    {
        private readonly ModBase modBase;
      
        public GenStructures(ModBase modBase) : base(modBase.mod.InternalName)
        {
            this.modBase = modBase;
        }

        public override void Generate()
        {
            try
            {
                int StructureAmount = 20;

                for (int i = 0; i < StructureAmount; i++) PlasmaStructures();
            }
            catch (Exception e)
            {
                ErrorHandling.Handle(e);
            }
        }

        public void PlasmaStructures()
        {
            Main.statusText = "Placing Plasma Reactors...";
          
            int HX = Main.maxTilesX - 200;
            int LX = 200;
            int HY = Main.maxTilesY - 200;
            int LY = Main.maxTilesY - 700;

            int x = WorldGen.genRand.Next(LX, HX + 1);
            int y = WorldGen.genRand.Next(LY, HY + 1);

            //Checks if the corners aren't empty, so it doesn't mess up your caves
            if (!WorldGen.EmptyTileCheck(x, x, y, y) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y, y) && !WorldGen.EmptyTileCheck(x, x, y - 6, y - 6) && !WorldGen.EmptyTileCheck(x + 7, x + 7, y - 6, y - 6))
            {
                //Delete all the tiles in the way
                for (int i = 0; i < 8; i++)
                {
                    WorldGen.KillTile(x + i, y, false, false, true);
                    WorldGen.KillTile(x + i, y - 1, false, false, true);
                    WorldGen.KillTile(x + i, y - 2, false, false, true);
                    WorldGen.KillTile(x + i, y - 3, false, false, true);
                    WorldGen.KillTile(x + i, y - 4, false, false, true);
                    WorldGen.KillTile(x + i, y - 5, false, false, true);
                    WorldGen.KillTile(x + i, y - 6, false, false, true);
                }

                //Delete all the walls in the way
                for (int q = 0; q < 8; q++)
                {
                    WorldGen.KillWall(x + q, y);
                    WorldGen.KillWall(x + q, y - 1);
                    WorldGen.KillWall(x + q, y - 2);
                    WorldGen.KillWall(x + q, y - 3);
                    WorldGen.KillWall(x + q, y - 4);
                    WorldGen.KillWall(x + q, y - 5);
                    WorldGen.KillWall(x + q, y - 6);
                }

                //Actual structure placement

                //Floor placement
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                //Left and right tile placement
                WorldGen.PlaceTile(x, y - 4, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                WorldGen.PlaceTile(x, y - 5, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                WorldGen.PlaceTile(x + 7, y - 4, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                WorldGen.PlaceTile(x + 7, y - 5, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                //Ceiling tile placement
                for (int i = 0; i < 8; i++) WorldGen.PlaceTile(x + i, y - 6, TileDef.byName["BriansMod:PlasmaBrickTile"], true, true);
                //Walls placement
                int x1 = x + 1;
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 1, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 2, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 3, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 4, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                for (int i = 0; i < 6; i++) WorldGen.PlaceWall(x1 + i, y - 5, TileDef.wallByName["BriansMod:PlasmaBrickWall"], true);
                //Center object placement
                WorldGen.PlaceTile(x + 3, y - 1, TileDef.byName["BriansMod:SteampunkStatueTile"], true, true);
            }
            else
            {
                PlasmaStructures();
            }
        }
    }
maybe i need to remove the catch exception part?

Maybe, but I'm no good with try catch so I wouldn't know.
 
Back
Top Bottom