IDK if be real, but here is the first way:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace testMod.Items
{
public class whyNot : ModItem
{
public int swing = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("chonkSword");
Tooltip.SetDefault("This is not basic modded sword.");
}
public override void SetDefaults()
{
item.damage = 2140;
item.melee = true;
item.width = 40;
item.height = 40;
item.useTime = 30;
item.useAnimation = 20;
item.useStyle = swing;
item.knockBack = 90;
item.value = 10000;
item.rare = ItemRarityID.Cyan;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override bool UseItem(Player player)
{
swing += 1;
if (swing > 3) swing = 0;
return true; //using weapon after setting
}
}
}
And the second way:
C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace testMod.Items
{
public class whyNot : ModItem
{
public int swing = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("chonkSword");
Tooltip.SetDefault("This is not basic modded sword.");
}
public override void SetDefaults()
{
item.damage = 2140;
item.melee = true;
item.width = 40;
item.height = 40;
item.useTime = 30;
item.useAnimation = 20;
item.useStyle = 0; //that's standard swing (on start)
item.knockBack = 90;
item.value = 10000;
item.rare = ItemRarityID.Cyan;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
public override bool UseItem(Player player)
{
swing += 1;
if (swing > 3) swing = 0;
item.useStyle = swing; //changing swing right from there
return true; //using weapon
}
}
}
Quote this post if you will have compile (send screen of error, but try to fix it yourself if possible) / in-game error (describe it and send video if possible).