tModLoader When I try to compile my mod in tmodloader, error CS1061 shows up. Read thread for more info. (Original thread was solved, look at my second comment)

Kurgztal

Terrarian
Like I said in the title, my csproj file doesn't show me any folders or files, but also all code from Terraria is not getting referenced in my mod either, so it's saying things like "The type or namespace name 'Vector2' could not be found (are you missing a directive or an assembly reference?)". I am confused as to why this is not working, as I was following a 1.3 tutorial at first while I am in 1.4 and it worked out just fine until then, (link to youtube tutorial playlist: https://www.youtube.com/playlist?list=PL2j68jF83kP0CRpJr1riuxslDJRIQWBx7) so I switched over to a 1.4 modding tutorial and it still doesn't work. Any help, please? I'm new to modding and have no idea what's going on.

By the way, the error code is CS0103.
 
Last edited:
You need to install VS 2022 and then open the csproj
To install it correctly, read this: Developing with Visual Studio · tModLoader/tModLoader Wiki
Thank you, this worked. Unfortunately, there is another error. I am unsure if it is because it handles things differently in the new update, or I just did the code wrong, take a look and see for yourself.


What the error screen says:

Error CS1061: 'Mod' does not contain a definition for 'ProjectileType' and no accessible extension method 'ProjectileType' accepting a first argument of type 'Mod' could not be found




My code for the file at fault:

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

namespace AndruidsAdditions.Items
{
public class GelBook : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Book of Gel"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Casts a ball of slime");
}

public override void SetDefaults()
{
Item.damage = 14;
Item.mana = 5;
Item.DamageType = DamageClass.Magic;
Item.width = 40;
Item.height = 40;
Item.useTime = 30;
Item.useAnimation = 30;
Item.useStyle = 5;
Item.knockBack = 2;
Item.value = 1200;
Item.rare = 1;
Item.UseSound = SoundID.Item8;
Item.autoReuse = true;
Item.shoot = Mod.ProjectileType("SpikeofGel");
Item.shootSpeed = 5f;
Item.noMelee = true;
}

public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.Gel, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}




Code for the custom projectile referenced:

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;

namespace AndruidsAdditions.Projectiles
{
public class SpikeofGel : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Spike of Gel"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
}

public override void SetDefaults()
{
Projectile.width = 8;
Projectile.height = 8;
Projectile.aiStyle = 1;
Projectile.friendly = true;
Projectile.hostile = false;
Projectile.penetrate = 2;
Projectile.timeLeft = 600;
Projectile.light = 0f;
Projectile.ignoreWater = false;
Projectile.tileCollide = true;
}

public override void AI()
{
int dust = Dust.NewDust(Projectile.Center, 1, 1, 103, 0f, 0f, 0, default(Color), 1f);
Main.dust[dust].velocity *= 0.2f;
Main.dust[dust].scale = (float)Main.rand.Next(80, 115) * 0.013f;
Main.dust[dust].noGravity = false;
}
}
}




Any help is appreciated, thank you for your time.
 
Error CS1061: 'Mod' does not contain a definition for 'ProjectileType' and no accessible extension method 'ProjectileType' accepting a first argument of type 'Mod' could not be found


public override void SetDefaults()
{
Item.damage = 14;
Item.mana = 5;
Item.DamageType = DamageClass.Magic;
Item.width = 40;
Item.height = 40;
Item.useTime = 30;
Item.useAnimation = 30;
Item.useStyle = 5;
Item.knockBack = 2;
Item.value = 1200;
Item.rare = 1;
Item.UseSound = SoundID.Item8;
Item.autoReuse = true;
Item.shoot = Mod.ProjectileType("SpikeofGel");
Item.shootSpeed = 5f;
Item.noMelee = true;
}
The error pretty much always tell you what the error is.
Here it's stating that Mod, doesn't understand what "ProjectileType" is.
It is also saying that ProjectileType can't get fed "Mod" in itself (here it's because you have "SpikeofGel" written as is with the " ".
In your Item.shoot you are telling "the game" to take Mod.ProjectileType("SpikeofGel");. This doesn't work like this. It means that your syntax is wrong.
The syntax you need to use is ModContent.ProjectileType<SpikeofGel>();

Hope that helps.

PS: You might also need to add using AndruidsAdditions.Projectiles; at the top.
 
Last edited:
Thank you, this helped a ton and now I know more about how the new 1.4 update works! I'll take a look at the porting to 1.4 guide to help me in the future if something like that happens again.
 
Back
Top Bottom