tModLoader Need a bit of help for my mod

1639774653839.png

I'm trying to add dust to a projectile but I'm getting this error and I don't know how to fix it, this is the code:
using Terraria;
using Terraria.Modloader;

namespace PowerRising.Dusts;
{
public class HeroDust : ModDust;
{
public override void OnSpawn(Dusts dust);
{
dust.noGravity = true;
dust.noLight = false;
dust.scale 2f;

}
}
}
 
Sorry if you have already fixed this but here is the solution. As the error message states it is expecting a } to close a { . So your code wasn't really wrong it was just formatted incorrectly. There were also a few other errors in your code that I fixed too.

Fixed code:
C#:
using Terraria;
using Terraria.ModLoader;

namespace PowerRising.Dusts
{
    public class HeroDust : ModDust
    {
        public override void OnSpawn(Dust dust)
        {
            dust.noGravity = true;
            dust.noLight = false;
            dust.scale = 2f;
        }
    }
}

If you have any other errors post them here and I will try to respond as fast as I can.
 
Last edited:
Sorry if you have already fixed this but here is the solution. As the error message states it is expecting a } to close a { . So your code wasn't really wrong it was just formatted incorrectly. There were also a few other errors in your code that I fixed too.

Fixed code:
C#:
using Terraria;
using Terraria.ModLoader;

namespace PowerRising.Dusts
{
    public class HeroDust : ModDust
    {
        public override void OnSpawn(Dust dust)
        {
            dust.noGravity = true;
            dust.noLight = false;
            dust.scale = 2f;
        }
    }
}

If you have any other errors post them here and I will try to respond as fast as I can.
It worked!
 
Send me the code of the sword so I can try to fix the dust trail. Also, are you trying to make the dust another color? If so tell me what color.
I'm tryna make it red coloured.

int num309 = Dust.NewDust(new Vector2(projectile.position.X - projectile.velocity.X * 4f + 2f, projectile.position.Y + 2f - projectile.velocity.Y * 4f), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default(Color), 1.25f);
Main.dust[num309].velocity *= -0.25f;
num309 = Dust.NewDust(new Vector2(projectile.position.X - projectile.velocity.X * 4f + 2f, projectile.position.Y + 2f - projectile.velocity.Y * 4f), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default(Color), 1.25f);
Main.dust[num309].velocity *= -0.25f;
Main.dust[num309].position -= projectile.velocity * 0.5f;
 
I'm tryna make it red coloured.

int num309 = Dust.NewDust(new Vector2(projectile.position.X - projectile.velocity.X * 4f + 2f, projectile.position.Y + 2f - projectile.velocity.Y * 4f), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default(Color), 1.25f);
Main.dust[num309].velocity *= -0.25f;
num309 = Dust.NewDust(new Vector2(projectile.position.X - projectile.velocity.X * 4f + 2f, projectile.position.Y + 2f - projectile.velocity.Y * 4f), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, default(Color), 1.25f);
Main.dust[num309].velocity *= -0.25f;
Main.dust[num309].position -= projectile.velocity * 0.5f;

OK, I assume you want a dust projectile trail (sorry if im wrong I am just assuming). I have not worked with dusts much so sorry if I have not exactly got this right but I think this will do what you want.

C#:
 public override void AI()
        {
            Vector2 dustPosition = projectile.Center + new Vector2(Main.rand.Next(-4, 5), Main.rand.Next(-4, 5));
            Dust dust = Dust.NewDustPerfect(dustPosition, ModContent.DustType<HeroDust>(), null, 100, Color.Red, 0.8f);
        }
Also, make sure you have
C#:
using PowerRising.Dusts;
at the top of your projectile page.

Sorry if I did not quite understand what you were asking for but I hope this helps.
 
Not what I intended the texture to look like but it's still cool so I'm gonna keep it
View attachment 351655

Glad I could help! Also, if you would like a more standard texture for the dust I have one that looks similar to many other dusts in Terraria.

This is what it would look like
1639950795607.png

Here is the texture if you do want to use it.
SampleDust.png
 
View attachment 351662
recipe.AddIngredient(ItemID.DragonEssence, 1);
You are calling for a vanilla ItemID but using the ID for a modded item.

Try replaceing it with mod.ItemType("DragonEssence");

ItemID only works with items from vanilla Terraria. For example, ff you were tying to call for a modded projectile you would use mod.ProjectileType . Or for a tile, you would use mod.TileType .

Hope this helps!

EDIT: I posted this a few minutes ago and saw that you were using this as a recipe and I wanted to show another way you could do this specifically for recipes.

Code:
recipe.AddIngredient(null, "NameOfModdedItemHere");

This should also work but I would only recommend using it in recipes.
 
Last edited:
You are calling for a vanilla ItemID but using the ID for a modded item.

Try replaceing it with mod.ItemType("DragonEssence");

ItemID only works with items from vanilla Terraria. For example, ff you were tying to call for a modded projectile you would use mod.ProjectileType . Or for a tile, you would use mod.TileType .

Hope this helps!

EDIT: I posted this a few minutes ago and saw that you were using this as a recipe and I wanted to show another way you could do this specifically for recipes.

Code:
recipe.AddIngredient(null, "NameOfModdedItemHere");

This should also work but I would only recommend using it in recipes.
Thanks!
 
1640019720978.png

1640019744140.png

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

namespace RisingPower.Items.Armor
{
[AutoloadEquip(EquipType.Body)]
public class HeroChestplate : ModItem
{
public override void SetStaticDefaults()
{
base.SetStaticDefaults();
DisplayName.SetDefault("Hero Chestplate");
Tooltip.SetDefault("This is a piece of the legendary Hero Armor.");

}

public override void SetDefaults()
{
item.width = 18;
item.height = 18;
item.value = 10;
item.rare = 8;
item.defense = 35;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.BeetleScaleMail);
recipe.AddIngredient(mod.ItemType("DragonEssence"));
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
recipe.AddIngredient(ItemID.BeetleShell);
recipe.AddIngredient(mod.ItemType("DragonEssence"));
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
View attachment 351682
View attachment 351683
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace RisingPower.Items.Armor
{
[AutoloadEquip(EquipType.Body)]
public class HeroChestplate : ModItem
{
public override void SetStaticDefaults()
{
base.SetStaticDefaults();
DisplayName.SetDefault("Hero Chestplate");
Tooltip.SetDefault("This is a piece of the legendary Hero Armor.");

}

public override void SetDefaults()
{
item.width = 18;
item.height = 18;
item.value = 10;
item.rare = 8;
item.defense = 35;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.BeetleScaleMail);
recipe.AddIngredient(mod.ItemType("DragonEssence"));
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
recipe.AddIngredient(ItemID.BeetleShell);
recipe.AddIngredient(mod.ItemType("DragonEssence"));
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Sorry if this gets complex but armor textures can be complicated .

This error means you are missing a texture for an item. Chestplates need multiple textures all with different purposes to work. First, rename your texture called "HerosChestplate" to "HerosChestplate_Body" Then, you will also need to get textures for "HerosChestplate_Arms" and "HerosChestplate_FemaleBody" and a texture just named "HerosChestplate" which will be the texture you see when you have the item in your inventory.

Here are a few sample textures for those so you can get an idea of what they need to look like.

Arms texture:
ExampleBreastplate_Arms.png

FemaleBody texture(For this one I would recommend just copy/pastinging your already existing HerosChestplate_Body texture):

ExampleBreastplate_FemaleBody.png

ItemTexture(What you would see in inventory):
ExampleBreastplate.png


Hopefully I could help you with this, sorry if my explanation was too complicated.
 
Sorry if this gets complex but armor textures can be complicated .

This error means you are missing a texture for an item. Chestplates need multiple textures all with different purposes to work. First, rename your texture called "HerosChestplate" to "HerosChestplate_Body" Then, you will also need to get textures for "HerosChestplate_Arms" and "HerosChestplate_FemaleBody" and a texture just named "HerosChestplate" which will be the texture you see when you have the item in your inventory.

Here are a few sample textures for those so you can get an idea of what they need to look like.

Arms texture:
ExampleBreastplate_Arms.png

FemaleBody texture(For this one I would recommend just copy/pastinging your already existing HerosChestplate_Body texture):

ExampleBreastplate_FemaleBody.png

ItemTexture(What you would see in inventory):
ExampleBreastplate.png


Hopefully I could help you with this, sorry if my explanation was too complicated.
Thanks! I have the sprites for the female and arms
 

Hmm, you need another texture called "HeroChestplate" that will be what you see when the item is in your inventory. The error message is saying that you are missing HeroChestplate_Body which is weird because you already have it. Assuming that your namepaces are correct then I guess the error message is just displaying weirdly.

So I would try just adding the other texture you need then if the error is still there then tell me.

Example of the texture you need:

1640030711725.png


I will try to respond faster text time.
 
Back
Top Bottom