• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

Standalone [1.3] tModLoader - A Modding API

WolfeyGamer1

Terrarian
Hello hello Terraria community. So I've had Terraria on the Xbox for a long long time, but I just recently in August picked it up for the PC and got back into it again. Im just now coming around to getting into mods, but I have absolutely no experience with coding. If I want to create my own mod, where should I start? I am a complete beginner, never made a mod for any game before, but I am very interested and of course willing to learn. Any help is very appreciated, and thanks in advance.
 

S4l4kin

Steampunker
Hello hello Terraria community. So I've had Terraria on the Xbox for a long long time, but I just recently in August picked it up for the PC and got back into it again. Im just now coming around to getting into mods, but I have absolutely no experience with coding. If I want to create my own mod, where should I start? I am a complete beginner, never made a mod for any game before, but I am very interested and of course willing to learn. Any help is very appreciated, and thanks in advance.
Well for starters you should learn c# and after that look how the example mod works. And if you need help you can always come here to ask for help :p
 

Iroh The Dragon

Terrarian
Really important question would a second form boss be in a seperate cs file ? and then linked to the main boss ? How would i go about this and also would the animation on the first form support the second form or would that be seperate too ?
 

jopojelly

Retinazer
tModLoader
Index was outside the bounds of the array.
at Terraria.World.Generation.StructureMap.CanPlace(Rectangle area, Boolean[] validTiles, Int32 padding)
at Terraria.GameContent.Biomes.CaveHouseBiome.Place(Point origin, StructureMap structures)
at Terraria.World.Generation.Biomes`1.Place(Int32 x, Int32 y, StructureMap structures)
at Terraria.WorldGen.<>c__DisplayClass93.<generateWorld>b__37(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)
Your code is fine. I forgot about a bug we fixed after the release related to this. You'll have to move your generation pass to later than the "Buried Chests" pass for the time being. (change "shinies")

Really important question would a second form boss be in a seperate cs file ? and then linked to the main boss ? How would i go about this and also would the animation on the first form support the second form or would that be seperate too ?
You can do it either way. For example, Eye of Chtulu just changes it's behavior when it is at half health. Golem spawns the floating head which is a separate npc.

The animation can all be on the same sheet. You can just check for the condition you want in the FindFrame method. Here is how it looks for EoC (num is frame height):
Code:
this.frameCounter += 1.0;
                if (this.frameCounter < 7.0)
                {
                    this.frame.Y = 0;
                }
                else if (this.frameCounter < 14.0)
                {
                    this.frame.Y = num;
                }
                else if (this.frameCounter < 21.0)
                {
                    this.frame.Y = num * 2;
                }
                else
                {
                    this.frameCounter = 0.0;
                    this.frame.Y = 0;
                }
                if (this.ai[0] > 1f)
                {
                    this.frame.Y = this.frame.Y + num * 3;
                    return;
                }
            }
And here is the corresponding texture file:


Hope you can learn from this example.
 

Iroh The Dragon

Terrarian
Thankyou, i can now generate ore, i will not be downloading the Thorium Mod as i had been working on a better copy for my self. Which is awesome as.

This requires code for the health then ? I want the boss to change behaviour once it hits half way health.
 

Endershot355

Steampunker
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
using Terraria.GameContent.Generation;

namespace Enderuim.Tiles   
    {
        public class EnderuimOre : ModWorld
        {
            public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress){;
            {
                progress.Message = "Growing Enderuim Crystals...";

                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.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
                }
            };
        }));
    }
}}
This code doesnt seem to be generating anything, I was wondering if you could point whats wrong out...
 

Eldrazi

Eater of Worlds
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
using Terraria.GameContent.Generation;

namespace Enderuim.Tiles  
    {
        public class EnderuimOre : ModWorld
        {
            public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress){;
            {
                progress.Message = "Growing Enderuim Crystals...";

                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.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
                }
            };
        }));
    }
}}
This code doesnt seem to be generating anything, I was wondering if you could point whats wrong out...
I think this issue has been resolved about... Two-three posts above here...?
 

Iroh The Dragon

Terrarian
As jopojelly said

I forgot about a bug we fixed after the release related to this. You'll have to move your generation pass to later than the "Buried Chests" pass for the time being. (change "shinies")

Also this part is for the tile : Did you name it correctly as you have crazy ore than you have EnderuimOre ? Unless you called it that. Where you have crazy ore is the actual ore item.

WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
[DOUBLEPOST=1457435909,1457435735][/DOUBLEPOST]Eldrazi is it possible to change the tiles to support 4x4 and up ? for objects which ore longer. Like long tables ect.
 

Eldrazi

Eater of Worlds
As jopojelly said

I forgot about a bug we fixed after the release related to this. You'll have to move your generation pass to later than the "Buried Chests" pass for the time being. (change "shinies")

Also this part is for the tile : Did you name it correctly as you have crazy ore than you have EnderuimOre ? Unless you called it that. Where you have crazy ore is the actual ore item.

WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
[DOUBLEPOST=1457435909,1457435735][/DOUBLEPOST]Eldrazi is it possible to change the tiles to support 4x4 and up ? for objects which ore longer. Like long tables ect.
Yup, totally.
If you could specify the structure of your tile, I'd be able to give you an example in code ;)
 

Iroh The Dragon

Terrarian
Yeah so the item will be 4x4 in style.

This is the code so far,

Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
using Microsoft.Xna.Framework;

namespace DarkArmorReforged.Tiles
{
    public class LongTable : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolidTop[Type] = false;
            Main.tileFrameImportant[Type] = true;
            Main.tileNoAttach[Type] = true;
            Main.tileLavaDeath[Type] = true;
            TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); (I put this as 3x3 as it was the max without getting an error)
            TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16};
            TileObjectData.newTile.CoordinateWidth = 16;
            TileObjectData.newTile.CoordinatePadding = 2;
            TileObjectData.addTile(Type);
            AddMapEntry(new Color(255, 255, 255), "LongTable");
            adjTiles = new int[] { TileID.WorkBenches };
            AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch);
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 48, 48, mod.ItemType("LongTable"));
        }
    }
}
 

Iroh The Dragon

Terrarian
change it to "Buried Chests"
OLD
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
NEW
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Buried Chests"));
 

Iroh The Dragon

Terrarian
No only the part in my post above.
This is what it should be EnderShot
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
using Terraria.GameContent.Generation;

namespace Enderuim.Tiles
    {
        public class EnderuimOre : ModWorld
        {
            public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Buried Chests"));

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress){;
            {
                progress.Message = "Growing Enderuim Crystals...";

                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.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
                }
            };
        }));
    }
}}
 

Eldrazi

Eater of Worlds
Yeah so the item will be 4x4 in style.

This is the code so far,

Code:
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
using Microsoft.Xna.Framework;

namespace DarkArmorReforged.Tiles
{
    public class LongTable : ModTile
    {
        public override void SetDefaults()
        {
            Main.tileSolidTop[Type] = false;
            Main.tileFrameImportant[Type] = true;
            Main.tileNoAttach[Type] = true;
            Main.tileLavaDeath[Type] = true;
            TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); (I put this as 3x3 as it was the max without getting an error)
            TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16};
            TileObjectData.newTile.CoordinateWidth = 16;
            TileObjectData.newTile.CoordinatePadding = 2;
            TileObjectData.addTile(Type);
            AddMapEntry(new Color(255, 255, 255), "LongTable");
            adjTiles = new int[] { TileID.WorkBenches };
            AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTorch);
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 48, 48, mod.ItemType("LongTable"));
        }
    }
}
Allright, so one thing you can do is create your whole own 'placement style'.
Lemme give you an example (with comments, of course):

This code:
Code:
TileObjectData.newTile.Width = 4; // Set the width of the tile, 4 in this case.
TileObjectData.newTile.Height = 4; // Set the height of the tile, 4 in this case.

// Set the origin of this tile. This is used when displaying the tile preview.
// Since all Terraria objects are placed from their botom left perspective, we set the Y parameter of the Point to 3.
TileObjectData.newTile.Origin = new Point16(0, 3); 

// The following will only allow this tile to be placed on a solid surface all along the way of this tile.
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
TileObjectData.newTile.UsesCustomCanPlace = true; // We do use a custom can place.
TileObjectData.newTile.LavaDeath = true; // Optional, guess that speaks for itself.
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 }; // Since our tile is 4 pieces high, we need to define 4 values here.
TileObjectData.newTile.CoordinateWidth = 16; // The width of each of the tile pieces (default is 16).
TileObjectData.newTile.CoordinatePadding = 2; // The padding of each tile piece on the tilesheet.
TileObjectData.addTile(Type);
Basically replaces this code you already have (in the SetDefaults function):
Code:
TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); (I put this as 3x3 as it was the max without getting an error)
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16};
TileObjectData.newTile.CoordinateWidth = 16;
TileObjectData.newTile.CoordinatePadding = 2;
TileObjectData.addTile(Type);
 

Endershot355

Steampunker
because Im still not getting the progress message
[DOUBLEPOST=1457436990,1457436833][/DOUBLEPOST]using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
using Terraria.GameContent.Generation;

namespace Enderuim.Tiles
{
public class EnderuimOreGen : ModWorld
{
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Buried Chests"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress){;
{
progress.Message = "Growing Enderuim Crystals...";

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.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
}
};
}));
}
}}
[DOUBLEPOST=1457437131][/DOUBLEPOST]
No only the part in my post above.
This is what it should be EnderShot
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
using Terraria.GameContent.Generation;

namespace Enderuim.Tiles
    {
        public class EnderuimOre : ModWorld
        {
            public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Buried Chests"));

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress){;
            {
                progress.Message = "Growing Enderuim Crystals...";

                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.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
                }
            };
        }));
    }
}}
do you atleast know how to make it more common so I can find it quicker?
 

Eldrazi

Eater of Worlds
because Im still not getting the progress message
[DOUBLEPOST=1457436990,1457436833][/DOUBLEPOST]using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria.World.Generation;
using Terraria.GameContent.Generation;

namespace Enderuim.Tiles
{
public class EnderuimOreGen : ModWorld
{
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Buried Chests"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress){;
{
progress.Message = "Growing Enderuim Crystals...";

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.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("EnderuimOre"), false, 0f, 0f, false, true);
}
};
}));
}
}}
[DOUBLEPOST=1457437131][/DOUBLEPOST]
do you atleast know how to make it more common so I can find it quicker?
You can modify the third and fourth parameter of that function to make it more common (higher values).
 

Iroh The Dragon

Terrarian
This is for the custom 4x4
Im getting an error here,
TileObjectData.newTile.Origin = new Point16(0, 3);

(23,49) : error CS0246: The type or namespace name 'Point16' could not be found (are you missing a using directive or an assembly reference?)

26,55) : error CS0246: The type or namespace name 'AnchorData' could not be found (are you missing a using directive or an assembly reference?)

(26,66) : error CS0103: The name 'AnchorType' does not exist in the current context
 
Top Bottom