• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

tModLoader Official tModLoader Help Thread

So I'm a pretty new modder, and this is my code. I'm trying to make a clone of the Enchanted Boomerang to test out projectiles, but I keep receiving the message "error CS0246 The type or namespace name 'ModProjectile' could not be found. I'm confused by this since this is the exact same as in the example code on the "Basic Projectile"

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TestMod.Projectiles
{
public class NanorangProjectile : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("English Display Name Here");
}

public override void SetDefaults()
{
projectile.CloneDefaults(ProjectileID.EnchantedBoomerang);
// projectile.aiStyle = 3; This line is not needed since CloneDefaults sets it.
aiType = ProjectileID.EnchantedBoomerang;
}

// Additional hooks/methods here.
}
}
 

GrayMech

Terrarian
is the mod browser not working for anyone else? me and three of my friends wanted to play together but tmodloader wasnt working properly, the mod browser is offline and we cant join each others worlds
 

Kazzymodus

Moderator
Staff member
Moderator
is the mod browser not working for anyone else? me and three of my friends wanted to play together but tmodloader wasnt working properly, the mod browser is offline and we cant join each others worlds
Yes, the Mod Browser is down and will likely remain so for a couple of days. As per the tModLoader discord:

1571315710044.png
 
TheBestPortato24 said:
Hey, anyone else know how to get the rainbow trails like on the Meowmere?
You should ether look at the games source code, just clone it or get one or find two kind good modders.

Code:
float Re = (float)Main.DiscoR / 255f;
float Gr = (float)Main.DiscoG / 255f;
float Bu = (float)Main.DiscoB / 255f;
Re = (0.5f + Re) / 2f;
Gr = (0.5f + Gr) / 2f;
Bu = (0.5f + Bu) / 2f;
Lighting.AddLight(projectile.Center, Re, Gr, Bu);

Yes there is rainbow lighting. for some reason

Code:
            int num3;
            for (int num318 = 0; num318 < projectile.oldPos.Length; num318 = num3 + 1)
            {
                if (!(projectile.oldPos[num318] == Vector2.Zero))
                {
                    int num319 = Dust.NewDust(projectile.oldPos[num318] + value13, 0, 0, 66, 0f, 0f, 150, Color.Transparent, 0.7f);
                    Main.dust[num319].color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f);
                    Main.dust[num319].noGravity = true;
                }
                num3 = num318;
            }
should work but i'm not testing it. put it in wherever you put dust.
 
Last edited:

g4l4xic

Terrarian
Hey everyone, I'm basically new to the whole Terraria community. and well i have a problem or error with the calamity mod. Sorry if I am posting this in the wrong place, but the problem is that the lore items from the calamity mod are showing as unloaded items. I think its only the lore items you get after defeating bosses that are unloaded. This happened after I updated Overhaul and Tmodloader, but I only went into my world after updating both, so im not sure which update caused it. Its hard to remember the exact details of what happened but I do need help. I tried disabling all the mods I have in the mods list (Calamity, Thorium, Recipe Browser, Calamity music, and Overhaul) and re enabling them, but that didnt work. As of now all my mods are fully updated along with terraria itself im pretty sure, but The lore items are still unloaded. Does anyone have a solution? I have found no solutions online so Im posting here
 

foxyfo

Terrarian
Im getting this error and i cant seem to fix it:

[20/ERROR] [tML]: An error occurred while loading ThoriumMod
The mod(s) have been automatically been disabled.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Terraria.ModLoader.Core.AssemblyManager.Instantiate(LoadedMod mod)
at Terraria.ModLoader.Core.AssemblyManager.<>c__DisplayClass10_0.<InstantiateMods>b__1(LoadedMod mod)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Terraria.ModLoader.Core.AssemblyManager.InstantiateMods(List`1 modsToLoad, CancellationToken token)
at Terraria.ModLoader.Core.ModOrganizer.LoadMods(CancellationToken token)
at Terraria.ModLoader.ModLoader.Load(CancellationToken token)

Does anyone else know how to?
 

Calamituff

Terrarian
Right, what the hell is this?
error CS0019: Operator '&&' cannot be applied to operands of type 'Rain[]' and 'bool'
error CS0019: Operator '&&' cannot be applied to operands of type 'bool' and 'Rain[]'
error CS0019: Operator '==' cannot be applied to operands of type 'Rain[]' and 'bool'
error CS0019: Operator '==' cannot be applied to operands of type 'Rain[]' and 'bool'

All I did was use the Main.rain bool like I was using all the other bools, then this.
 

Kazzymodus

Moderator
Staff member
Moderator
Right, what the hell is this?
error CS0019: Operator '&&' cannot be applied to operands of type 'Rain[]' and 'bool'
error CS0019: Operator '&&' cannot be applied to operands of type 'bool' and 'Rain[]'
error CS0019: Operator '==' cannot be applied to operands of type 'Rain[]' and 'bool'
error CS0019: Operator '==' cannot be applied to operands of type 'Rain[]' and 'bool'

All I did was use the Main.rain bool like I was using all the other bools, then this.
Main.rain is not a bool, rather it's an array of the individual raindrops (or rainlines, more accurately). To check if it's raining, use Main.raining.
 

MattPatrick

Terrarian
So the people from discord told me that this feature is set to default in 0.11.+ so this is pretty much solved xD. Sorry for this dumb question <3

Hello, can anybody help me to properly setup Visual Studio Community 2019 to work with Terraria?

I have everything ready and up, but i don't know how to setup te Edit and Continue feature.

-eac $(TargetPath)

TargetPath needs to be an especific path? or it's meant to be pasted just like that. Also where do i paste that command?

Should i paste here?
1573578649603.png


Or here? (Build Events tab btw)
1573578497950.png


I've tried everything and can't edit in-game values. Please help :<
 
Last edited:

Samiii

Terrarian
Whenever i try to open the Mod Browser in v0.11.5 it crashes with this crash log:

EDIT: All I had to do was click cancel as the mods were loading in and update the Mod Helpers mod which, I now realise, was causing the problem.

1573600394643.png


anyone know a fix or should i just reinstall terraria?
 
Last edited:

Portulo

Terrarian
Hey! I'm newish to modding, and I have no idea what I'm doing. I have two questions. First, I have an accessory (Yes, Kinkyboots) whose effect should be to have a small chance to confuse the enemy upon hit. I'm trying to make it work, as you can see here:

C#:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace Flummox.Items
{
    public class kinkyboots : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Kinkyboots");
            Tooltip.SetDefault("Attacks have a small chance to confuse enemies");
        }
        public override void SetDefaults()
        {
            item.width = 26;
            item.height = 28;
            item.value = 10;
            item.rare = 2;
            item.accessory = true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.SpiderFang, 10);
            recipe.AddIngredient(ItemID.Silk, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
            {
                target.AddBuff(BuffID.Confused, 240)
            }
        }
    }
}

I've tried putting the OnHitNPC method outside of the UpdateAccessory method but it just does nothing, and when I put it inside the UpdateAccessory method, it gives me this log:

[23:07:57] [39/INFO] [tML]: Reading properties: Flummox
[23:07:57] [39/INFO] [tML]: Building: Flummox
[23:07:57] [39/INFO] [tML]: Compiling Flummox.XNA.dll
[23:07:57] [39/INFO] [tML]: Compilation finished with 2 errors and 0 warnings
[23:07:57] [39/ERROR] [tML]: C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(35,9) : error CS1513: } expected
[23:07:57] [39/ERROR] [tML]: C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(42,0) : error CS1022: Type or namespace definition, or end-of-file expected
[23:07:57] [39/ERROR] [tML]: Compiling Flummox.XNA.dll failed with 2 errors and C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(35,9) : error CS1513: } expected warnings
Terraria.ModLoader.Exceptions.BuildException: Compiling Flummox.XNA.dll failed with 2 errors and C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(35,9) : error CS1513: } expected warnings
en Terraria.ModLoader.Core.ModCompile.CompileMod(BuildingMod mod, String outputPath, List`1& refMods, Boolean xna)
en Terraria.ModLoader.Core.ModCompile.BuildModForPlatform(BuildingMod mod, List`1& refMods, Boolean xna)
en Terraria.ModLoader.Core.ModCompile.Build(BuildingMod mod)
en Terraria.ModLoader.Core.ModCompile.BuildAll()
en Terraria.ModLoader.UI.UIBuildMod.<>c.<BuildAll>b__6_0(ModCompile mc)
en Terraria.ModLoader.UI.UIBuildMod.BuildMod(Action`1 buildAction, Boolean reload)
[23:08:02] [1/DEBUG] [Terraria]: Device Reset, Profile: HiDef, Width: 1920, Height: 1080, Fullscreen: True, Display: \\.\DISPLAY1
[23:08:06] [1/DEBUG] [tML]: Process.Start (UseShellExecute = True): "C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Logs\client.log"

So my first question is how the heck would I make that work.

My second question is a bit more complicated and I have no clue how to implement it: I have a staff, and I want it to fire three projectiles, one after the other, on a straight line. I've been looking up tutorials on the Internet and I've found a way to make it fire three projectiles at the same time, spreading out:

C#:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Flummox.Dusts;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using System.Threading;
 
namespace Flummox.Items
{
    public class antiqueMicrophone : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Antique Microphone");
            Tooltip.SetDefault("Perfect for singing old-timey songs!");
            Item.staff[item.type] = true;
        }
        public override void SetDefaults()
        {      
            item.damage = 34;                        
            item.magic = true;                     //this make the item do magic damage
            item.width = 58;
            item.height = 58;
            item.useTime = 30;
            item.useAnimation = 30;
            item.useStyle = 5;        //this is how the item is holded
            item.noMelee = true;
            item.knockBack = 2;        
            item.value = 1000;
            item.rare = 6;
            item.mana = 5;             //mana use
            item.UseSound = SoundID.Item21;            //this is the sound when you use the item
            item.autoReuse = true;
            item.shoot = mod.ProjectileType ("alastorBlast");  //this make the item shoot your projectile
            item.shootSpeed = 8f;    //projectile speed when shoot
        }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
              float numberProjectiles = 3; // This defines how many projectiles to shot
              float rotation = MathHelper.ToRadians(45);
              position += Vector2.Normalize(new Vector2(speedX, speedY)) * 45f; //this defines the distance of the projectiles form the player when the projectile spawns
              for (int i = 0; i < numberProjectiles; i++)
              {
                  Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .4f; // This defines the projectile roatation and speed. .4f == projectile speed
                  Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
              }
              return false;
        }
    }
}

I guess it didn't help that the tutorial wasn't much of a tutorial at all, and the guy didn't explain what he was doing at all. I have zero clue what most of the code or the arguments do. If y'all could help me with any of my problems, even a tiny bit, I would very much appreciate it!
 

Shinkun [ModDev]

Official Terrarian
Hey! I'm newish to modding, and I have no idea what I'm doing. I have two questions. First, I have an accessory (Yes, Kinkyboots) whose effect should be to have a small chance to confuse the enemy upon hit. I'm trying to make it work, as you can see here:

C#:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace Flummox.Items
{
    public class kinkyboots : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Kinkyboots");
            Tooltip.SetDefault("Attacks have a small chance to confuse enemies");
        }
        public override void SetDefaults()
        {
            item.width = 26;
            item.height = 28;
            item.value = 10;
            item.rare = 2;
            item.accessory = true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.SpiderFang, 10);
            recipe.AddIngredient(ItemID.Silk, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override void UpdateAccessory(Player player, bool hideVisual)
        {
            public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
            {
                target.AddBuff(BuffID.Confused, 240)
            }
        }
    }
}

I've tried putting the OnHitNPC method outside of the UpdateAccessory method but it just does nothing, and when I put it inside the UpdateAccessory method, it gives me this log:

[23:07:57] [39/INFO] [tML]: Reading properties: Flummox
[23:07:57] [39/INFO] [tML]: Building: Flummox
[23:07:57] [39/INFO] [tML]: Compiling Flummox.XNA.dll
[23:07:57] [39/INFO] [tML]: Compilation finished with 2 errors and 0 warnings
[23:07:57] [39/ERROR] [tML]: C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(35,9) : error CS1513: } expected
[23:07:57] [39/ERROR] [tML]: C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(42,0) : error CS1022: Type or namespace definition, or end-of-file expected
[23:07:57] [39/ERROR] [tML]: Compiling Flummox.XNA.dll failed with 2 errors and C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(35,9) : error CS1513: } expected warnings
Terraria.ModLoader.Exceptions.BuildException: Compiling Flummox.XNA.dll failed with 2 errors and C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Mod Sources\Flummox\Items\kinkyboots.cs(35,9) : error CS1513: } expected warnings
en Terraria.ModLoader.Core.ModCompile.CompileMod(BuildingMod mod, String outputPath, List`1& refMods, Boolean xna)
en Terraria.ModLoader.Core.ModCompile.BuildModForPlatform(BuildingMod mod, List`1& refMods, Boolean xna)
en Terraria.ModLoader.Core.ModCompile.Build(BuildingMod mod)
en Terraria.ModLoader.Core.ModCompile.BuildAll()
en Terraria.ModLoader.UI.UIBuildMod.<>c.<BuildAll>b__6_0(ModCompile mc)
en Terraria.ModLoader.UI.UIBuildMod.BuildMod(Action`1 buildAction, Boolean reload)
[23:08:02] [1/DEBUG] [Terraria]: Device Reset, Profile: HiDef, Width: 1920, Height: 1080, Fullscreen: True, Display: \\.\DISPLAY1
[23:08:06] [1/DEBUG] [tML]: Process.Start (UseShellExecute = True): "C:\Users\Diego Tapia\Documents\My Games\Terraria\ModLoader\Logs\client.log"

So my first question is how the heck would I make that work.

My second question is a bit more complicated and I have no clue how to implement it: I have a staff, and I want it to fire three projectiles, one after the other, on a straight line. I've been looking up tutorials on the Internet and I've found a way to make it fire three projectiles at the same time, spreading out:

C#:
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Flummox.Dusts;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;
using System.Threading;

namespace Flummox.Items
{
    public class antiqueMicrophone : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Antique Microphone");
            Tooltip.SetDefault("Perfect for singing old-timey songs!");
            Item.staff[item.type] = true;
        }
        public override void SetDefaults()
        {     
            item.damage = 34;                       
            item.magic = true;                     //this make the item do magic damage
            item.width = 58;
            item.height = 58;
            item.useTime = 30;
            item.useAnimation = 30;
            item.useStyle = 5;        //this is how the item is holded
            item.noMelee = true;
            item.knockBack = 2;       
            item.value = 1000;
            item.rare = 6;
            item.mana = 5;             //mana use
            item.UseSound = SoundID.Item21;            //this is the sound when you use the item
            item.autoReuse = true;
            item.shoot = mod.ProjectileType ("alastorBlast");  //this make the item shoot your projectile
            item.shootSpeed = 8f;    //projectile speed when shoot
        }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
              float numberProjectiles = 3; // This defines how many projectiles to shot
              float rotation = MathHelper.ToRadians(45);
              position += Vector2.Normalize(new Vector2(speedX, speedY)) * 45f; //this defines the distance of the projectiles form the player when the projectile spawns
              for (int i = 0; i < numberProjectiles; i++)
              {
                  Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .4f; // This defines the projectile roatation and speed. .4f == projectile speed
                  Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
              }
              return false;
        }
    }
}

I guess it didn't help that the tutorial wasn't much of a tutorial at all, and the guy didn't explain what he was doing at all. I have zero clue what most of the code or the arguments do. If y'all could help me with any of my problems, even a tiny bit, I would very much appreciate it!
First things first, for accessories you should always make them set a player value when equipped, create a new class and name it something like PlayerMod
Here is an example


C#:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ShinkunsAccessories
{
    public class PlayerEditMod : ModPlayer
    {
        public bool KinkyBoots;
        
        public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
        {
            if(KinkyBoots) 
            {
                 target.AddBuff(BuffID.Confused, 240);
            }
        }
    }
}
then in your item class make the UpdateEquip event set this boolean to true, so that when the item is equipped the player value will be true, which will execute the code after "if(KinkyBoots)" because that boolean will be true.
So your accessory will look like this:


Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using static Terraria.ModLoader.ModContent;

namespace Flummox.Items
{
    public class kinkyboots : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Kinkyboots");
            Tooltip.SetDefault("Attacks have a small chance to confuse enemies");
        }
        public override void SetDefaults()
        {
            item.width = 26;
            item.height = 28;
            item.value = 10;
            item.rare = 2;
            item.accessory = true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.SpiderFang, 10);
            recipe.AddIngredient(ItemID.Silk, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }

        public override void UpdateEquip(Player player)
        {
            Player.getModPlayer<PlayerEditMod>().KinkyBoots = true;
        }

    }
}
where <PlayerEditMod> is the name of your class that extends ModPlayer

reason your original code doesn't work: you can't override an event inside of a method that overrides another event.

As for the projectile I don't really have much experience with that, but since you're using a for loop to spawn them you could use int i to change the angle slightly so that the first fires a bit down from straight when i = 0, the second projectile fires straight when i = 1 and the last one slightly up when i = 2

You'll have to do some math or clever coding there
hope that helps ^^
 

Shinkun [ModDev]

Official Terrarian
In NPC I'm assuming
Boss1 = eye of cthulu
Boss2 = eater of worlds/brain of cthulu
Boss3 = skeletron

and MechBoss 1 through 3 are those same ones but their mechanical form? 2 always being destroyer of worlds
Is that right?
 

Speeder

Terrarian
There is a mod that can move stuff to chests and whatnot that I wanted to try.

But the mod seemly loads on Windows, but not on Linux, the author said that is because tModLoader do some compatibility shenanigans with mods compiled with old version, and it must be working on Windows and not on Linux...

Can I get more info on that?
 
Top Bottom