tModLoader Display Inventory Sprite?

Hi!
I was wondering how you change a weapon's sprite in inventory.
An example is a weapon like Last Prism or Nebula Arcanum, notice how the weapon uses a slightly different sprite when shooting compared to when you're looking at it inside your inventory?
Visual given when looking at Last Prism from inventory.
$


Visual given when looking at Last Prism while firing it. -> https://giphy.com/gifs/prism-AASpp9bYRQplm

Here's my code.

using Terraria.Enums;
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using System.Collections.Generic;

namespace WeaponMOD.Items.Weapons
{
public class Weapon6 : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Weapon6");
Tooltip.SetDefault("ayy");
}
public override void SetDefaults()
{

item.noMelee = true;
item.damage = 10000;
item.magic = true;
item.width = 40;
item.height = 40;
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.knockBack = 30;
item.value = 10000;
item.rare = 11;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.channel = true;
item.mana = 1;
item.UseSound = SoundID.Item13;
item.shootSpeed = 16f;
item.shoot = mod.ProjectileType("ExampleP6");

}

I'm relatively new to modding starting about 2 weeks ago, I've been ignoring aesthetics up until now :>

Thank you in advance!
 
You would probably need to do this the other way around. Have the default sprite be the one you want in the inventory, and then manually draw whatever you want next to the player when it is used. I am sure modItem has a method for that that you can override.
 
If you have the time, could you show me an example? That would be greatly appreciated as I'm still learning about modding. Thanks for the response!
 
Actually,, never mind what I just said. There is a method in ModItem that does precisely what you want.
Code:
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
      //New item inventory sprite is Items/someItem.png
      spriteBatch.Draw(mod.GetTexture("Items/SomeItem"),
            new Rectangle((int)position.X, (int)position.Y, (int)(frame.Width * scale), (int)(frame.Height * scale)),
            drawColor);
      return false; //Stops default drawing
}
 
Actually,, never mind what I just said. There is a method in ModItem that does precisely what you want.
Code:
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
      //New item inventory sprite is Items/someItem.png
      spriteBatch.Draw(mod.GetTexture("Items/SomeItem"),
            new Rectangle((int)position.X, (int)position.Y, (int)(frame.Width * scale), (int)(frame.Height * scale)),
            drawColor);
      return false; //Stops default drawing
}
It works! Thanks!
 
Back
Top Bottom