Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(12, 11));How do I animate a sword
This is my current code
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace Gradient.Items
{
public class Masamuree : ModItem
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("Masamuree"); // 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("Great for impersonating devs!");
}
public override void SetDefaults()
{
Item.damage = 15000;
Item.DamageType = DamageClass.Melee;
Item.width = 40;
Item.height = 76;
Item.useTime = 11;
Item.useAnimation = 11;
Item.useStyle = 1;
Item.knockBack = 13;
Item.value = 0;
Item.rare = 9;
Item.UseSound = SoundID.Item1;
Item.autoReuse = false;
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ModContent.ItemType<Items.SnackticalsHeart>(), 1);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}
And this is the sprite I want to use
where do I put that?Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(12, 11));
Also anyone know how to make a projectile shoot another projectile at all?
In the SetStaticDefaults()where do I put that?
Is promoting a mod that ports old-gen content back into 1.4 allowed on the forums? I've read the pinned posts but am still confused on this. If this isn't the right place to ask sorry but I don't know where else to
using GalacticMod.Assets.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.UI.Elements;
using Terraria.ModLoader;
using Terraria.UI;
using static Terraria.ModLoader.ModContent;
namespace GalacticMod.UI
{
internal class OsmiumSoulBar : UIState
{
// For this bar we'll be using a frame texture and then a gradient inside bar, as it's one of the more simpler approaches while still looking decent.
// Once this is all set up make sure to go and do the required stuff for most UI's in the Mod class.
private UIText text;
private UIElement area;
private UIImage barFrame;
private Color gradientA;
private Color gradientB;
public override void OnInitialize()
{
// Create a UIElement for all the elements to sit on top of, this simplifies the numbers as nested elements can be positioned relative to the top left corner of this element.
// UIElement is invisible and has no padding. You can use a UIPanel if you wish for a background.
area = new UIElement();
area.Left.Set(-area.Width.Pixels - 600, 1f); // Place the resource bar to the left of the hearts.
area.Top.Set(30, 0f); // Placing it just a bit below the top of the screen.
area.Width.Set(182, 0f); // We will be placing the following 2 UIElements within this 182x60 area.
area.Height.Set(60, 0f);
barFrame = new UIImage(Request<Texture2D>("GalacticMod/UI/OsmiumSoulsBar", AssetRequestMode.ImmediateLoad));
barFrame.Left.Set(22, 0f);
barFrame.Top.Set(0, 0f);
barFrame.Width.Set(100, 0f);
barFrame.Height.Set(20, 0f);
text = new UIText("0/0", 0.8f); // text to show stat
text.Width.Set(100, 0f);
text.Height.Set(20, 0f);
text.Top.Set(40, 0f);
text.Left.Set(0, 0f);
gradientA = new Color(255, 128, 54); //light orange
gradientB = new Color(191, 70, 0); //dark orange
area.Append(text);
area.Append(barFrame);
Append(area);
}
public override void Draw(SpriteBatch spriteBatch)
{
// This prevents drawing unless we are using an ExampleDamageItem
if (!Main.LocalPlayer.GetModPlayer<GalacticPlayer>().OsmiumDamage)
{
return;
}
base.Draw(spriteBatch);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
var modPlayer = Main.LocalPlayer.GetModPlayer<GalacticPlayer>();
// Calculate quotient
float quotient = (float)modPlayer.osmiumSouls / modPlayer.osmiumSoulsMax; // Creating a quotient that represents the difference of your currentResource vs your maximumResource, resulting in a float of 0-1f.
quotient = Utils.Clamp(quotient, 0f, 1f); // Clamping it to 0-1f so it doesn't go over that.
// Here we get the screen dimensions of the barFrame element, then tweak the resulting rectangle to arrive at a rectangle within the barFrame texture that we will draw the gradient. These values were measured in a drawing program.
Rectangle hitbox = barFrame.GetInnerDimensions().ToRectangle();
hitbox.X += 12;
hitbox.Width -= 24;
hitbox.Y += 8;
hitbox.Height -= 16;
// Now, using this hitbox, we draw a gradient by drawing vertical lines while slowly interpolating between the 2 colors.
int left = hitbox.Left;
int right = hitbox.Right;
int steps = (int)((right - left) * quotient);
for (int i = 0; i < steps; i += 1)
{
//float percent = (float)i / steps; // Alternate Gradient Approach
float percent = (float)i / (right - left);
spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(left + i, hitbox.Y, 1, hitbox.Height), Color.Lerp(gradientA, gradientB, percent));
}
}
public override void Update(GameTime gameTime)
{
if (!Main.LocalPlayer.GetModPlayer<GalacticPlayer>().OsmiumDamage)
{
return;
}
var modPlayer = Main.LocalPlayer.GetModPlayer<GalacticPlayer>();
// Setting the text per tick to update and show our resource values.
text.SetText($"Osmium Souls: {modPlayer.osmiumSouls} / {modPlayer.osmiumSoulsMax}");
base.Update(gameTime);
}
}
}
using Terraria;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Input;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.UI;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using System;
using System.IO;
using Terraria.GameContent.UI;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.Audio;
using Terraria.Localization;
using Terraria.ModLoader.UI;
using static Terraria.ModLoader.ModContent;
using GalacticMod.Assets.Systems;
namespace GalacticMod.UI
{
class UI : ModSystem
{
private UserInterface _osmiumSoulBarUserInterface;
internal OsmiumSoulBar OsmiumSoulBar;
public override void Load()
{
if (!Main.dedServ)
{
_osmiumSoulBarUserInterface = new UserInterface();
_osmiumSoulBarUserInterface.SetState(OsmiumSoulBar);
OsmiumSoulBar = new OsmiumSoulBar();
OsmiumSoulBar.Activate(); // Activate calls Initialize() on the UIState if not initialized, then calls OnActivate and then calls Activate on every child element
}
}
public override void Unload()
{
//OsmiumSoulBar?.Unload(); // If you hold data that needs to be unloaded, call it in OO-fashion
OsmiumSoulBar = null;
}
private GameTime _lastUpdateUiGameTime;
public override void UpdateUI(GameTime time) //change to override
{
_lastUpdateUiGameTime = time;
if (_osmiumSoulBarUserInterface?.CurrentState != null)
{
_osmiumSoulBarUserInterface.Update(time);
}
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers) //change to override
{
int resourceBarIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Resource Bars"));
if (resourceBarIndex != -1)
{
layers.Insert(resourceBarIndex, new LegacyGameInterfaceLayer(
"GalacticMod: Osmium Soul Bar",
delegate
{
if (_osmiumSoulBarUserInterface != null && _osmiumSoulBarUserInterface?.CurrentState != null)
{
_osmiumSoulBarUserInterface.Draw(Main.spriteBatch, _lastUpdateUiGameTime);
}
return true;
},
InterfaceScaleType.UI));
}
}
}
}