Standalone [1.3] tModLoader - A Modding API

Simple

Official Terrarian
c:\Users\AARONCITO\Documents\My Games\Terraria\ModLoader\Mod Sources\noname\Items\LatormWings.cs(10,30) : error CS0115: 'noname.Items.WingsName.Autoload(ref string, ref string, System.Collections.Generic.IList<Terraria.ModLoader.EquipType>)': no se encontró ningún miembro adecuado que invalidar

c:\Users\AARONCITO\Documents\My Games\Terraria\ModLoader\Mod Sources\noname\Items\LatormWings.cs(32,30) : error CS0115: 'noname.Items.WingsName.VerticalWingSpeeds(ref float, ref float, ref float, ref float, ref float)': no se encontró ningún miembro adecuado que invalidar

c:\Users\AARONCITO\Documents\My Games\Terraria\ModLoader\Mod Sources\noname\Items\LatormWings.cs(42,30) : error CS0115: 'noname.Items.WingsName.HorizontalWingSpeeds(ref float, ref float)': no se encontró ningún miembro adecuado que invalidar

(sorry i have terraria in spanish)

code:

using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace noname.Items
{
public class LatormWings : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
equips.Add(EquipType.Wings);
return true;
}

public override void SetDefaults()
{
item.name = "LatormWings";
item.width = 22;
item.height = 20;
item.toolTip = "";
item.value = 10000;
item.rare = 4;
item.accessory = true;
}

public override void UpdateAccessory(Player player, bool hideVisual)
{
player.wingTimeMax = 10; //wings Height
}

public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising,
ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}

public override void HorizontalWingSpeeds(ref float speed, ref float acceleration)
{
speed = 9f;
acceleration *= 2.5f;
}

public override void AddRecipes() //How to craft this item
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(null, "latorm", 10); //you need 10 Wood
recipe.AddTile(TileID.anvil); //at work bench
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

the code is from Al0n37 . i think i have this error because its outdated
To Al0n37 does have an outdated code. Add "Player player," to and public override void HorizontalWingSpeeds(ref float speed, ref float acceleration) and public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)

There are some extra errors I have noticed:
TileID.anvil is not the ID for an anvil, it should be this instead: TileID.Anvils
In SetDefaults, item.toolTip = ""; and item.name = "LatormWings"; is outdated. Instead, make a new class thingy called SetStaticDefaults
public override void SetStaticDefaults() {
DisplayName.SetDefault("LatormWings");
Tooltip.SetDefault("");
}

C#:
using System.Collections.Generic;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace noname.Items

{

    public class LatormWings : ModItem

    {

        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)

        {

            equips.Add(EquipType.Wings);

            return true;

        }

        public override void SetStaticDefaults() {

            DisplayName.SetDefault("LatormWings");
            Tooltip.SetDefault("");

        }

        public override void SetDefaults()

        {

            item.width = 22;

            item.height = 20;

            item.value = 10000;

            item.rare = 4;

            item.accessory = true;

        }



        public override void UpdateAccessory(Player player, bool hideVisual)

        {

            player.wingTimeMax = 10;  //wings Height

        }



        public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)

        {

            ascentWhenFalling = 0.85f;

            ascentWhenRising = 0.15f;

            maxCanAscendMultiplier = 1f;

            maxAscentMultiplier = 3f;

            constantAscend = 0.135f;

        }



        public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)

        {

            speed = 9f;

            acceleration *= 2.5f;

        }



        public override void AddRecipes()  //How to craft this item

        {

            ModRecipe recipe = new ModRecipe (mod);

            recipe.AddIngredient(null, "latorm", 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }

    }

}

I hope that works! :D

P.S: There is another modding tutorial video called Modding Master class made by Lynx on youtube, although cancelled for 1.4, it is up to date.
 

Nyanisty

Terrarian
can someone help me out here?
My Tmodloader is up to date however my terraria server.exe is not it's using v0.11.6.2

im running v0.11.7.5


Edit 1: Resolved
 
Last edited:

Dacern

Terrarian
I'm pretty new to modding, I have done it for only a couple of days, and I need help. For some reason, some of my enemies despawn instantly when coming into contact with about 75% of my modded weapons. Can you figure out why, and help me? I'll attach code of one of the enemies. (I know that this enemy will not spawn by the way.)
public class Legs : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Legs");
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Harpy];
}


public override void SetDefaults()
{
npc.width = 32;
npc.height = 32;
npc.lifeMax = 1000;
npc.damage = 25;
npc.defense = 0;
npc.HitSound = SoundID.NPCHit17;
npc.DeathSound = SoundID.NPCDeath15;
npc.value = 7500f;
npc.knockBackResist = 1f;
npc.aiStyle = 26;
aiType = NPCID.Unicorn;
animationType = NPCID.Zombie;
}

public override void HitEffect(int hitDirection, double damage)
{
for (int i = 0; i < 10; i++)
{
int dustType = 5;
int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
Dust dust = Main.dust[dustIndex];
dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
}
}
}
 

Simple

Official Terrarian
I'm pretty new to modding, I have done it for only a couple of days, and I need help. For some reason, some of my enemies despawn instantly when coming into contact with about 75% of my modded weapons. Can you figure out why, and help me? I'll attach code of one of the enemies. (I know that this enemy will not spawn by the way.)
public class Legs : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Legs");
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Harpy];
}


public override void SetDefaults()
{
npc.width = 32;
npc.height = 32;
npc.lifeMax = 1000;
npc.damage = 25;
npc.defense = 0;
npc.HitSound = SoundID.NPCHit17;
npc.DeathSound = SoundID.NPCDeath15;
npc.value = 7500f;
npc.knockBackResist = 1f;
npc.aiStyle = 26;
aiType = NPCID.Unicorn;
animationType = NPCID.Zombie;
}

public override void HitEffect(int hitDirection, double damage)
{
for (int i = 0; i < 10; i++)
{
int dustType = 5;
int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
Dust dust = Main.dust[dustIndex];
dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
}
}
}
I don't see something wrong with this NPC other than it have no defense at all.
There may be a chance the error is caused by the 75% of your weapons, so you may want to attach your weapon code too.
 

Kakuvadas

Golem
Hello, I am creating a modded adventure map for quite a while. Does anyone have any knowledge of how to make statues, which spawn modded enemies?
I've seen statues like that in Thorium or Split mods, but the devs aren't really answering:( :D

p.s. statues for vanilla enemies works
 

Dacern

Terrarian
I don't see something wrong with this NPC other than it have no defense at all.
There may be a chance the error is caused by the 75% of your weapons, so you may want to attach your weapon code too.

Here's one of the weapons that always instantly kills enemies.

public class FirebloomSpellbook : ModItem
{

public override void SetDefaults()
{
item.damage = 500;
item.magic = true;
item.mana = 10;
item.width = 28;
item.height = 32;
item.useTime = 75;
item.useAnimation = 75;
item.useStyle = 5;
item.knockBack = 10;
item.value = 30000;
item.rare = 8;
item.UseSound = SoundID.Item88;
item.autoReuse = true;
item.shootSpeed = 15f;
item.shoot = 85;

}

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 = 20;
float rotation = MathHelper.ToRadians(180);
position += Vector2.Normalize(new Vector2(speedX, speedY)) * 180f;
for (int i = 0; i < numberProjectiles; i++)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; // Watch out for dividing by 0 if there is only 1 projectile.
Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
return false;


}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<Upgrade>(), 1);
recipe.AddIngredient(ItemID.FlowerofFire, 1);
recipe.AddIngredient(ItemID.Sunflower, 5);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
 

Simple

Official Terrarian
Here's one of the weapons that always instantly kills enemies.

public class FirebloomSpellbook : ModItem
{

public override void SetDefaults()
{
item.damage = 500;
item.magic = true;
item.mana = 10;
item.width = 28;
item.height = 32;
item.useTime = 75;
item.useAnimation = 75;
item.useStyle = 5;
item.knockBack = 10;
item.value = 30000;
item.rare = 8;
item.UseSound = SoundID.Item88;
item.autoReuse = true;
item.shootSpeed = 15f;
item.shoot = 85;

}

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 = 20;
float rotation = MathHelper.ToRadians(180);
position += Vector2.Normalize(new Vector2(speedX, speedY)) * 180f;
for (int i = 0; i < numberProjectiles; i++)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; // Watch out for dividing by 0 if there is only 1 projectile.
Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
return false;


}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<Upgrade>(), 1);
recipe.AddIngredient(ItemID.FlowerofFire, 1);
recipe.AddIngredient(ItemID.Sunflower, 5);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
Nothing wrong with that either... The extremely high damage of the weapon and the absolute zero defense of the NPC might've caused it to die immediately. Another thing that could've happened was that your sound was off and the NPC did not have gore.
 

silent_ptr

Plantera
How do I get my tile to only be placed on walls? I've tried this:
C#:
public override void SetDefaults()
{
    Main.tileFrameImportant[Type] = true;
    Main.tileNoAttach[Type] = true;
    Main.tileLavaDeath[Type] = true;
    TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
    TileObjectData.newTile.AnchorWall = true;
    TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 };
    TileObjectData.addTile(Type);
    disableSmartCursor = true;
}
And it doesn't let me place it at all. Is there also a way to make it face a certain direction based on what wall it was placed on? Thanks.
EDIT: I tried the following, and it worked a bit better but it needs 2 blocks on either side (and the sprite direction doesn't change):
C#:
public override void SetDefaults()
{
    Main.tileFrameImportant[Type] = true;
    Main.tileNoAttach[Type] = true;
    Main.tileLavaDeath[Type] = true;
    TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
    //TileObjectData.newTile.AnchorWall = true;
    TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
    TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
    TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 };
    TileObjectData.addTile(Type);
    disableSmartCursor = true;
}
 
Last edited:

Buddha

Terrarian
This needs to get updated ... not for the sake of "Terraria v1.4" but more like converting my buildings and such to 1.3.5.3.
TEdit is not able to process tiled buildings (with even items which are STRICTLY v1.3 based!), the array range is kinda bugging out (as if the application saves v1.4 meta data for no reason on its application footprint) and I am not able to get my fancy buildings over to tModLoader based Maps.
 

shoelid

Terrarian
Hey! New to modding, and I'm posting here with the hope that somebody can help me with my code. I want my weapon to give the player a buff when they right click with it. The issue is that once the player right clicks with the sword, item.buffType is assigned to the entire item. From that point forward, both the left and right clicks assign the buff. How do I unassign item.buffType for the left click functionality? or maybe there's a better way to go about this?

Here's the relevant code:
C#:
public override bool CanUseItem(Player player){ //right click functionality
            if (player.altFunctionUse == 2){
                item.UseSound = SoundID.Item100;//placeholder
                item.useStyle = ItemUseStyleID.HoldingUp;
                item.useTime = 10;//placeholder
                item.useAnimation = 10;//placeholder
                item.noMelee = true;
                item.buffType = ModContent.BuffType<GhostbladeBuff>();
                item.buffTime = 360;
            }
            else {
                item.UseSound = SoundID.Item1;
                item.useStyle = ItemUseStyleID.SwingThrow;
                item.useTime = 10;
                item.useAnimation = 25;
                item.noMelee = false;
            }
            return base.CanUseItem(player);
        }
 

Yeahfrick

Official Terrarian
To Al0n37 does have an outdated code. Add "Player player," to and public override void HorizontalWingSpeeds(ref float speed, ref float acceleration) and public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)

There are some extra errors I have noticed:
TileID.anvil is not the ID for an anvil, it should be this instead: TileID.Anvils
In SetDefaults, item.toolTip = ""; and item.name = "LatormWings"; is outdated. Instead, make a new class thingy called SetStaticDefaults
public override void SetStaticDefaults() {
DisplayName.SetDefault("LatormWings");
Tooltip.SetDefault("");
}

C#:
using System.Collections.Generic;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace noname.Items

{

    public class LatormWings : ModItem

    {

        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)

        {

            equips.Add(EquipType.Wings);

            return true;

        }

        public override void SetStaticDefaults() {

            DisplayName.SetDefault("LatormWings");
            Tooltip.SetDefault("");

        }

        public override void SetDefaults()

        {

            item.width = 22;

            item.height = 20;

            item.value = 10000;

            item.rare = 4;

            item.accessory = true;

        }



        public override void UpdateAccessory(Player player, bool hideVisual)

        {

            player.wingTimeMax = 10;  //wings Height

        }



        public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)

        {

            ascentWhenFalling = 0.85f;

            ascentWhenRising = 0.15f;

            maxCanAscendMultiplier = 1f;

            maxAscentMultiplier = 3f;

            constantAscend = 0.135f;

        }



        public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)

        {

            speed = 9f;

            acceleration *= 2.5f;

        }



        public override void AddRecipes()  //How to craft this item

        {

            ModRecipe recipe = new ModRecipe (mod);

            recipe.AddIngredient(null, "latorm", 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }

    }

}

I hope that works! :D

P.S: There is another modding tutorial video called Modding Master class made by Lynx on youtube, although cancelled for 1.4, it is up to date.
Aint working appears 1 error idk why (changed "name" and "texture" putted back these things but keep appearing the error)
C#:
using System.Collections.Generic;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace noname.Items

{

    public class LatormWings : ModItem

    {

        public override bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips)

        {

            equips.Add(EquipType.Wings);

            return true;

        }

        public override void SetStaticDefaults() {

            DisplayName.SetDefault("LatormWings");
            Tooltip.SetDefault("a");

        }

        public override void SetDefaults()

        {

            item.width = 22;

            item.height = 20;

            item.value = 10000;

            item.rare = 4;

            item.accessory = true;

        }



        public override void UpdateAccessory(Player player, bool hideVisual)

        {

            player.wingTimeMax = 10;  //wings Height

        }



        public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)

        {

            ascentWhenFalling = 0.85f;

            ascentWhenRising = 0.15f;

            maxCanAscendMultiplier = 1f;

            maxAscentMultiplier = 3f;

            constantAscend = 0.135f;

        }



        public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)

        {

            speed = 9f;

            acceleration *= 2.5f;

        }



        public override void AddRecipes()  //How to craft this item

        {

            ModRecipe recipe = new ModRecipe (mod);

            recipe.AddIngredient(null, "latorm", 10);

            recipe.AddTile(TileID.Anvils);
        }
    }
}

error:[19:31:52] [8/ERROR] [tML]: C:\Users\AARONCITO\Documents\My Games\Terraria\ModLoader\Mod Sources\noname\Items\LatormWings.cs(19,29) : error CS0115: 'LatormWings.Autoload(ref string, ref string, IList<EquipType>)': no suitable method found to override
 

Simple

Official Terrarian
Aint working appears 1 error idk why (changed "name" and "texture" putted back these things but keep appearing the error)
C#:
using System.Collections.Generic;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace noname.Items

{

    public class LatormWings : ModItem

    {

        public override bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips)

        {

            equips.Add(EquipType.Wings);

            return true;

        }

        public override void SetStaticDefaults() {

            DisplayName.SetDefault("LatormWings");
            Tooltip.SetDefault("a");

        }

        public override void SetDefaults()

        {

            item.width = 22;

            item.height = 20;

            item.value = 10000;

            item.rare = 4;

            item.accessory = true;

        }



        public override void UpdateAccessory(Player player, bool hideVisual)

        {

            player.wingTimeMax = 10;  //wings Height

        }



        public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)

        {

            ascentWhenFalling = 0.85f;

            ascentWhenRising = 0.15f;

            maxCanAscendMultiplier = 1f;

            maxAscentMultiplier = 3f;

            constantAscend = 0.135f;

        }



        public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)

        {

            speed = 9f;

            acceleration *= 2.5f;

        }



        public override void AddRecipes()  //How to craft this item

        {

            ModRecipe recipe = new ModRecipe (mod);

            recipe.AddIngredient(null, "latorm", 10);

            recipe.AddTile(TileID.Anvils);
        }
    }
}

error:[19:31:52] [8/ERROR] [tML]: C:\Users\AARONCITO\Documents\My Games\Terraria\ModLoader\Mod Sources\noname\Items\LatormWings.cs(19,29) : error CS0115: 'LatormWings.Autoload(ref string, ref string, IList<EquipType>)': no suitable method found to override
Whenever you have this type of error: no suitable method found to override. You simply replace 'override' with 'static' or 'virtual'
So it should look like this now:

C#:
using System.Collections.Generic;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace noname.Items

{

    public class LatormWings : ModItem

    {

        public virtual bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips) // you can also do static.

        {

            equips.Add(EquipType.Wings);

            return true;

        }

        public override void SetStaticDefaults() {

            DisplayName.SetDefault("LatormWings");
            Tooltip.SetDefault("a");

        }

        public override void SetDefaults()

        {

            item.width = 22;

            item.height = 20;

            item.value = 10000;

            item.rare = 4;

            item.accessory = true;

        }



        public override void UpdateAccessory(Player player, bool hideVisual)

        {

            player.wingTimeMax = 10;  //wings Height

        }



        public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)

        {

            ascentWhenFalling = 0.85f;

            ascentWhenRising = 0.15f;

            maxCanAscendMultiplier = 1f;

            maxAscentMultiplier = 3f;

            constantAscend = 0.135f;

        }



        public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)

        {

            speed = 9f;

            acceleration *= 2.5f;

        }



        public override void AddRecipes()  //How to craft this item

        {

            ModRecipe recipe = new ModRecipe (mod);

            recipe.AddIngredient(null, "latorm", 10);

            recipe.AddTile(TileID.Anvils);
        }
    }
}
 
Top Bottom