How to Make Custom Terraria Item and NPC Sprites with AI (tModLoader Guide)
tutorial8 min

How to Make Custom Terraria Item and NPC Sprites with AI (tModLoader Guide)

Make Terraria mod sprites with AI: tModLoader texture naming, right-facing item art, vertical NPC sheets, frame counts and a full workflow.

To make custom Terraria sprites with AI, generate the item or NPC in one locked style, save each PNG with exactly the same name as its tModLoader class, and match the layout the game draws from: one image per item, and every NPC frame stacked in a single vertical column. Sprixen generates the sprite and the animation strip in the same style; restacking that strip vertically takes one command or a minute in an image editor.

This guide covers the texture rules tModLoader enforces, the sizes its own ExampleMod uses, and a repeatable workflow for a weapon, an enemy and a town NPC that all look like they came from the same mod.

How tModLoader finds your textures

tModLoader autoloads textures by name. The Basic Autoload wiki page states the rule: the PNG shares the class name and lives in the folder its namespace points to. A ModNPC class called FlutterSlime in namespace ExampleMod.NPCs loads ExampleMod/NPCs/FlutterSlime.png, and the .cs and .png files sit side by side.

MyMod/
  Content/
    Items/
      EmberBlade.cs
      EmberBlade.png        (item texture)
    NPCs/
      AshCrawler.cs
      AshCrawler.png        (enemy, frames stacked vertically)
      Blacksmith.cs
      Blacksmith.png        (town NPC, frames stacked vertically)
      Blacksmith_Head.png   (map and housing icon)

Town NPCs add a head texture. ExampleMod marks its town NPC class with [AutoloadHead] and ships ExamplePerson_Head.png next to ExamplePerson.png; the code comments call that attribute necessary for any town NPC to work.

Item sprites: one image, pointing right

An item texture is a single PNG. Its size is the item's size in the world, and the item code repeats it: ExampleSword sets Item.width = 40 and Item.height = 40, with the comment that these are the texture's dimensions. Orientation follows the vanilla convention, which you can see in ExampleMod's own art:

Item typeExampleMod textureOrientation
Swung swordExampleSword.png, 40x40Diagonal, tip in the top right corner
GunExampleGun.png, 62x32Horizontal, barrel pointing right
Town NPC headExamplePerson_Head.png, 16x16Front-facing icon

The game rotates and mirrors held items when the player turns, so you only draw one direction. A sword drawn pointing straight up, or a gun facing left, will swing or aim wrong in game even though the PNG looks fine.

NPC sprites: frames stacked in one column

NPC sheets are a single column of equal-height frames. You declare the frame count with Main.npcFrameCount[Type], and the NPC's FindFrame override moves a source rectangle down the texture by one frame height at a time. ExampleMod's MinionBossBody shows the pattern: it registers 6 frames and steps NPC.frame.Y by frameHeight, looping frames 0 to 2 in its first stage and 3 to 5 in its second.

That gives you one hard rule: texture height = frame count x frame height, with every frame the same width. If you register 6 frames and the PNG holds 5, the animation slides out of alignment.

Town NPC frame counts

Town NPCs need many more frames because the game uses them for walking, sitting, talking and attacking. ExamplePerson declares:

Main.npcFrameCount[Type] = 25;             // total frames in the texture
NPCID.Sets.ExtraFramesCount[Type] = 9;     // sitting, talking to other NPCs
NPCID.Sets.AttackFrameCount[Type] = 4;     // attack animation

Its texture is 40 pixels wide and 1400 pixels tall, which is 25 frames of 40x56. The NPC's hitbox (NPC.width = 18, NPC.height = 40) is smaller than the frame, so leave transparent room around the body. The cleanest way to plan a town NPC is to open the ExampleMod texture, keep its frame grid as a template, and replace the art frame by frame.

The workflow: one style for the whole mod

Terraria's art reads as one game because every sprite shares a palette, an outline weight and a pixel density. A mod that mixes three AI styles looks pasted in. Lock the style once and generate everything inside it.

  1. Create one Sprixen project for the mod. Choose the pixel art style, a side-scroll view angle, and a palette sampled from the biome your content belongs to. Project resolutions go from 16x16 to 512x512; 32x32 or 64x64 is a practical working size for Terraria items. Every sprite generated in the project inherits these settings.
  2. Generate the item. Describe it with the orientation in the prompt: "ember greatsword, diagonal, tip pointing to the top right, side view". Each variant costs 2 credits and you can ask for up to 3 per call. The background is removed with an ML segmentation model, so the PNG arrives with real transparency.
  3. Fit it to the item size. Downscale with nearest neighbor to your target dimensions (for example 40x40) and set Item.width and Item.height to match.
  4. Generate the enemy or NPC base sprite in the same project. Ask for a side view so the walk cycle reads correctly.
  5. Animate it. Request a walk or idle animation from the base sprite. Animations take 2 to 12 frames (8 by default), cost 4 credits at standard quality or 8 at premium, and come back as one horizontal strip at the sprite's frame size.
  6. Restack the strip vertically. Slice the strip into frames and paste them top to bottom in the order your FindFrame code expects. Then set Main.npcFrameCount to the number of frames you stacked.
  7. Build and test in game. Rebuild the mod in tModLoader, spawn the NPC, and watch a full loop at normal zoom.

Restacking a horizontal strip

Any image editor works: set the canvas to the frame width and to frame height x frame count, then paste each frame one row lower than the last. If your agent works with the open source universal-modder toolkit, its um CLI includes both steps:

# split an 8-frame horizontal strip of 40x56 frames
um sprite slice crawler_walk.png frames/ --frame 40x56

# stack the frames into a single column for Terraria
um sprite sheet AshCrawler.png frames/*.png --vertical

Check the result height: 8 frames of 56 pixels must produce a 448 pixel tall PNG.

Frame plans that work

ContentSuggested framesNotes
Simple ground enemy4 to 8 walk framesLoop them in FindFrame; add one hurt frame if you want feedback
Flying enemy4 to 6 wing framesGenerate with a winged archetype so the motion reads as flight
Boss with phases3 per phaseSame idea as MinionBossBody: one frame range per phase
Town NPCFollow ExamplePerson's 25Use its texture as a frame template and replace the art

Sprixen's animation request accepts an archetype (humanoid_biped, quadruped, winged, amorphous or serpentine) and, for armed characters, the weapon hand and weapon type. Setting these keeps a slime squashing like a slime and keeps the sword in the same hand across every frame.

Common mistakes

  • Class and file names differ. Emberblade.png will not load for EmberBlade. Match the case exactly.
  • Soft edges after resizing. Bilinear scaling blurs pixel art and leaves semi-transparent halos. Always scale with nearest neighbor, once, to the final size.
  • Frames of different heights. One frame that is two pixels taller shifts every frame below it. Pad all frames to the same cell before stacking.
  • Feet that drift. Keep the character anchored at the bottom center of each cell so it does not bob through the floor.
  • Shipping vanilla art. Use ExampleMod or vanilla sheets as private layout references, and ship only textures you made.

For the general frame contract behind any sheet (cell size, pivot, order, fps), see the companion guide on 2D walk cycle sprite sheets. When you are ready to generate the set, open the Sprixen generator and start with the item that defines the mod's look.

FAQ

What size should a Terraria item sprite be?

Any size, as long as Item.width and Item.height match the texture. ExampleMod's sword is 40x40 and its gun is 62x32, which are good references for melee and ranged weapons.

Why are Terraria NPC frames stacked vertically?

The NPC draw code reads frames from one column. Main.npcFrameCount sets how many frames the texture holds, and FindFrame moves the source rectangle down by one frame height per step, so the PNG height must equal frame count times frame height.

How many frames does a Terraria town NPC need?

ExampleMod's town NPC uses 25 frames, with 9 extra frames for sitting and talking and 4 attack frames, on a 40x1400 texture. Copying that layout is the safest starting point for a custom town NPC.

Can I use AI sprites in a tModLoader mod I publish?

Yes, for art you generated yourself, within the terms of the tool you used. Do not redistribute vanilla Terraria textures or other mods' art, and treat the game's own sheets as layout references only.

How much does it cost to make a weapon and an animated enemy in Sprixen?

One sprite variant is 2 credits and a standard animation is 4, so a weapon plus an enemy with a walk cycle is about 8 credits. New accounts get 6 free credits, and the Pro plan is $10 a month for 200 credits.

TerrariatModLoaderTerraria mod spritesNPC sprite sheetpixel artgame modding

Generate sprites that actually match.

Style-locked sprite generation keeps every character, tile and animation in your project visually consistent. 6 free credits on signup, no credit card required.