tModLoader Official tModLoader Help Thread

I have no doubt it's some sort of newb error but I'm getting the following error:
Code:
\Documents\My Games\Terraria\ModLoader\Mod Sources\CustomRespawnTime\CustomRespawnTime.cs(42,18) : error CS1518: Expected class, delegate, enum, interface, or struct

The code of the referenced file is:
Code:
using Terraria.ModLoader;
using Terraria;
using System;
using Terraria.DataStructures;

namespace CustomRespawnTime
{
    class CustomRespawnTime : Mod
    {
        public CustomRespawnTime()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
    public class CustomRespawnTimePlayer : ModPlayer
    {
        public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
        {
            if(Config.UseOnyxSteelPref)
            {
                player.respawnTimer = 600;
                return;
            }
           
            if(Config.UsePresetTime)
            {
                player.respawnTimer = (int)(Config.RespawnSeconds * 60);
                return;
            }
           
            if(Config.UseMultiplier)
            {
                player.respawnTimer = (int)(player.respawnTimer * Config.RespawnMultiplier);
            }
        }
    }
    public override void Load()
    {
        Config.Load();
    }
}

I have no idea what is going wrong here...
 
can i get help with this i get this error when i try to join my friend's server via steam
Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at Terraria.UI.UIElement.Update(GameTime gameTime)
at Terraria.UI.UIElement.Update(GameTime gameTime)
at Terraria.UI.UIElement.Update(GameTime gameTime)
at Terraria.UI.UIElement.Update(GameTime gameTime)
at Terraria.UI.UIElement.Update(GameTime gameTime)
at Terraria.UI.UserInterface.Update(GameTime time)
at Terraria.Main.DoUpdate(GameTime gameTime)
at Terraria.Main.Update(GameTime gameTime)
 
Hello, I am attempting to create my own UI. How you go about this seems to be different, but I cannot get it to work.

Expected: A UIPanel to be drawn across the screen
What I got: Absolutely Nothing.

Code:
TestMod.cs
Code:
using TestMod.UI;

namespace TestMod
{
	public class TestMod: Mod
    {
        internal static TestModmod;
        public UserInterface TestInterface;
        public TestUI TestUI;

        public TestMod()
		{
			Properties = new ModProperties()
			{
				Autoload = true,
				AutoloadGores = true,
				AutoloadSounds = true
			};
        }

        public override void Load()
        {
            mod = this;
            if (!Main.dedServ)
            {
                TestUI = new TestUI();
				TestUI.Activate();
				TestInterface = new UserInterface();
				TestInterface.SetState(TestUI);
			}
		}

        public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
		{
			int MouseTextIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));
			if (MouseTextIndex != -1)
			{
				layers.Insert(MouseTextIndex, new LegacyGameInterfaceLayer(
					"Test UI",
					delegate
					{
						if (TestUI.visible)
						{
							TestInterface.Update(Main._drawInterfaceGameTime);
							TestUI.Draw(Main.spriteBatch);
						}
						return true;
					},
					InterfaceScaleType.UI)
				);
			}
		}
    }
}
TestModUI.cs
Code:
namespace TestModUI.UI
{
	public class TestModUI : UIState
	{
		public static bool visible = true;

		public override void OnInitialize()
		{
			UIPanel parent = new UIPanel();
			parent.Height.Set(0f, 0.9f);
			parent.Width.Set(0f, 0.9f);
			parent.Left.Set(0f, 0.1f);
			parent.Top.Set(0f, 0.1f);
			parent.BackgroundColor = new Color(255, 255, 255, 255);
		}
	}
}
 
Hello, I've been resuming work on a mod after taking a break from it for a while. When I left it I'm pretty sure it worked fine, but now it... Uhm, seems to be claiming that items cant have names or something.



c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicArrow.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicArrow.cs(17,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicHook.cs(16,18) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicTalons.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicTalons.cs(16,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\HorizonsEdge.cs(14,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\HorizonsEdge.cs(20,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\Salamanisku.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\Salamanisku.cs(16,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\ShroomiteThunderbow.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\ShroomiteThunderbow.cs(16,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Projectiles\CosmicArrowProj.cs(14,24) : error CS1061: 'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)


I've gone through my code and cross-referenced it with example mods and stuff. I have rigorously examined every single character and cant find a single difference other than the name and stats of the weapon.

Heres an example of one of the simpler items, the Shroomite Thunderbow;


namespace Thunderbolt.Items
{
public class ShroomiteThunderbow : ModItem
{
public override void SetDefaults()
{
item.name = "Shroomite Thunderbow";
item.damage = 72;
item.ranged = true;
item.width = 24;
item.height = 55;
item.toolTip = "Shroomite Thunderbows shoot with deadly force";
item.useTime = 21;
item.useAnimation = 21;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 3;
item.value = 10000;
item.rare = 8;
item.shoot = 10;
item.shootSpeed = 28;
item.useAmmo = AmmoID.Arrow;
item.UseSound = SoundID.Item1;
item.autoReuse = false;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(2,10);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

Any help would be greatly appreciated
(Sorry I cant figure out how to put the code into its own box like some other people do. How do you do that btw?)
 
Hello, I've been resuming work on a mod after taking a break from it for a while. When I left it I'm pretty sure it worked fine, but now it... Uhm, seems to be claiming that items cant have names or something.



c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicArrow.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicArrow.cs(17,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicHook.cs(16,18) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicTalons.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\CosmicTalons.cs(16,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\HorizonsEdge.cs(14,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\HorizonsEdge.cs(20,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\Salamanisku.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\Salamanisku.cs(16,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\ShroomiteThunderbow.cs(11,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Items\ShroomiteThunderbow.cs(16,9) : error CS1061: 'Terraria.Item' does not contain a definition for 'toolTip' and no extension method 'toolTip' accepting a first argument of type 'Terraria.Item' could be found (are you missing a using directive or an assembly reference?)

c:\Users\spiri\Documents\My Games\Terraria\ModLoader\Mod Sources\Thunderbolt\Projectiles\CosmicArrowProj.cs(14,24) : error CS1061: 'Terraria.Projectile' does not contain a definition for 'name' and no extension method 'name' accepting a first argument of type 'Terraria.Projectile' could be found (are you missing a using directive or an assembly reference?)


I've gone through my code and cross-referenced it with example mods and stuff. I have rigorously examined every single character and cant find a single difference other than the name and stats of the weapon.

Heres an example of one of the simpler items, the Shroomite Thunderbow;


namespace Thunderbolt.Items
{
public class ShroomiteThunderbow : ModItem
{
public override void SetDefaults()
{
item.name = "Shroomite Thunderbow";
item.damage = 72;
item.ranged = true;
item.width = 24;
item.height = 55;
item.toolTip = "Shroomite Thunderbows shoot with deadly force";
item.useTime = 21;
item.useAnimation = 21;
item.useStyle = 5;
item.noMelee = true;
item.knockBack = 3;
item.value = 10000;
item.rare = 8;
item.shoot = 10;
item.shootSpeed = 28;
item.useAmmo = AmmoID.Arrow;
item.UseSound = SoundID.Item1;
item.autoReuse = false;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(2,10);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

Any help would be greatly appreciated
(Sorry I cant figure out how to put the code into its own box like some other people do. How do you do that btw?)
Name and Tolltips now in public override void SetStaticDefaults() use this guide https://docs.google.com/document/d/1GY6Jyj0IkqfvQlXJUwXg60d2V8tIzumoNVgh5OWzGIc/edit
 
Thanks. Now, just why couldnt I find any mention of this anywhere...
[doublepost=1499604058,1499604030][/doublepost]On another subject related to the mod loader is there any way to use my characters on the cloud while using it
 
Aaaand now every time it tries to load the mod it crashes.

I have no idea why.


System.InvalidOperationException: A previous Draw call threw an unhandled exception. See InnerException for details. ---> Microsoft.Xna.Framework.Graphics.NoSuitableGraphicsDeviceException: Unable to create the graphics device. ---> System.InvalidOperationException: An unexpected error has occurred.
 
Thanks. Now, just why couldnt I find any mention of this anywhere...
[doublepost=1499604058,1499604030][/doublepost]On another subject related to the mod loader is there any way to use my characters on the cloud while using it
To the cloud don't use it with tmodloader it's really buggy
 
Hello, I am attempting to create my own UI. How you go about this seems to be different, but I cannot get it to work.

Expected: A UIPanel to be drawn across the screen
What I got: Absolutely Nothing.

So I found out that I didn't append the UIPanel to the base, but when I do that when I load into the game ALL of the UI is gone and I get a rapid 'click' sound, as if my mouse were repeatedly hovering over and then away from a button
 
I have no doubt it's some sort of newb error but I'm getting the following error:
Code:
\Documents\My Games\Terraria\ModLoader\Mod Sources\CustomRespawnTime\CustomRespawnTime.cs(42,18) : error CS1518: Expected class, delegate, enum, interface, or struct

The code of the referenced file is:
Code:
using Terraria.ModLoader;
using Terraria;
using System;
using Terraria.DataStructures;

namespace CustomRespawnTime
{
    class CustomRespawnTime : Mod
    {
        public CustomRespawnTime()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }
    }
    public class CustomRespawnTimePlayer : ModPlayer
    {
        public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
        {
            if(Config.UseOnyxSteelPref)
            {
                player.respawnTimer = 600;
                return;
            }
          
            if(Config.UsePresetTime)
            {
                player.respawnTimer = (int)(Config.RespawnSeconds * 60);
                return;
            }
          
            if(Config.UseMultiplier)
            {
                player.respawnTimer = (int)(player.respawnTimer * Config.RespawnMultiplier);
            }
        }
    }
    public override void Load()
    {
        Config.Load();
    }
}

I have no idea what is going wrong here...
public override void Load()
{
Config.Load();
}

You put this outside of the class, put it in the class
 
public override void Load()
{
Config.Load();
}

You put this outside of the class, put it in the class
Which one? The Mod class or the ModPlayer class?

EDIT: Tried ModPlayer and it couldn't find a valid thing to override so I tried Mod and it worked.
 
Last edited:
I am having an issue with the vanilla tmodLoader, no mods enabled. I start a new server and if I build torches then throw them they appear where my character was a few seconds ago and when I go to pick them up they duplicate the number of torches in my inventory.

Any ideas? This is with a fresh install and a fresh tmodLoader without any mods.
 
I'm just starting using this tool. I'm making the first sword. I cannot seem to change the size of the weapon in-game? (With item.width and item.height.)
All my other changes are loading fine. Thanks.

item.width and item.height only increase size of the weapon when in inventory. For your item to be bigger, you need to increase size of the sprite.
 
Alright I'm having an issue I haven't had before with tmodloader. Apparently with the mods I have enabled my game is using 2.5gbs of ram. While that's not all that I have, 8 is what I have total, it's quite a bit for little ole Terraria. Now it is tModloader and I have like 8 mods enabled so some could be unoptimized, but I have played with all of these mods before and never had this issue. I'm using 0.10.0.2

I'm in the middle of a play through on my youtube channel and want to continue it, but I've been having to wait for some updates for the mods to continue playing without disabling any. It's annoying because I've waited over two months now.

EDIT:. I just noticed if I reload any mods, by disabling and re-enabling them my game uses more and more memory. I'm currently at 3 now, and my game just crashed, lol.
 
item.width and item.height only increase size of the weapon when in inventory. For your item to be bigger, you need to increase size of the sprite.
Actually this is incorrect, changing the width and height of an item changes the "hitbox" of the item, meaning it is possible for an item to go beyond the sprite's actual size. I'm not really sure if "item.scale" would affect the size of an item when in use, however it does change the size of the item when in world, not in inventory.
 
Last edited:
Actually this is incorrect, changing the width and height of an item changes the "hitbox" of the item, meaning it is possible for an item to go beyond the sprite's actual size. I'm not really sure if "item.scale" would affect the size of an item when in use, however it does change the size of the item when in world, not in inventory.
item.scale is the multiplier for the item's size which is 1f by default.
So: actualSize = item.Size * item.Scale
And indeed, you're right, the item's sprite size does not have to define the in-game size of the item.

Handy note: you can actually just set item.Size in SetDefaults() instead of setting width and height manually.
[doublepost=1499708112,1499708040][/doublepost]
Alright I'm having an issue I haven't had before with tmodloader. Apparently with the mods I have enabled my game is using 2.5gbs of ram. While that's not all that I have, 8 is what I have total, it's quite a bit for little ole Terraria. Now it is tModloader and I have like 8 mods enabled so some could be unoptimized, but I have played with all of these mods before and never had this issue. I'm using 0.10.0.2

I'm in the middle of a play through on my youtube channel and want to continue it, but I've been having to wait for some updates for the mods to continue playing without disabling any. It's annoying because I've waited over two months now.

EDIT:. I just noticed if I reload any mods, by disabling and re-enabling them my game uses more and more memory. I'm currently at 3 now, and my game just crashed, lol.
So you're using 8 mods, and the game is using 2.5 GB RAM? That's okay honestly.
 
I'm getting the following error:
Code:
...\Terraria\ModLoader\Mod Sources\imkSushisDeathCountersMod\imkSushisDeathCounterWorld.cs(34,94) : error CS0120: An object reference is required for the non-static field, method, or property 'Terraria.ModLoader.ModWorld.mod.get'
for this code:
Code:
    public static void announce()
    {
        foreach(Player players in AllPlayers)
        {
Main.NewText(players.name + " has died " + players.GetModPlayer<imkSushisDeathCounterPlayer>(mod).DeathPlayer.ToString() + " times", 0,0,0); //line 34
        }
        Main.NewText("So far, there have been " + DeathTotal.ToString() + " deaths in this world");
    }
why?
 
Back
Top Bottom