DEV Community

Cover image for Generating 3D Animated Sword Textures with Python and AI — For a Minecraft Mod About Cloud Computing

Generating 3D Animated Sword Textures with Python and AI — For a Minecraft Mod About Cloud Computing

I Generated 3D Animated Sword Textures with Python and AI — For a Minecraft Mod About Cloud Computing

In Part 1, we built 4 swords where each one represents an AWS service. Lambda summons ephemeral allies, S3 stores items, EC2 auto-scales damage. The abilities worked. The code compiled. But the swords looked... generic.

This is the story of how I went from flat placeholder textures to fully animated, UV-mapped 3D sword models — using Python scripts, Blockbench, and 7 iterations of a texture generator. And why the visual design of a game item can teach you more about cloud services than a whitepaper ever could.

Animated sword textures showing the evolution from v1 to v6

🎮 The learning angle: When you design a texture for "Sword of Lambda," you have to think about what Lambda represents visually. Ephemeral? Use fire that fades. Event-driven? Add energy pulses. Serverless? Make it feel lightweight. This design process forces you to internalize service characteristics in a way that reading docs never does.

The Problem: Minecraft Textures Are Harder Than They Look

Minecraft items use 16x16 pixel textures. That's 256 pixels to communicate:

  • What service this sword represents
  • What tier it belongs to
  • That it's special (not just another iron sword)
  • Its elemental/thematic identity

And for animated textures, you need 8 frames in a vertical sprite sheet (16x128) plus a .mcmeta file that controls animation speed and interpolation.

For 3D models (which we used via Blockbench), you need UV-mapped textures where specific pixel regions map to specific faces of the 3D geometry. One wrong pixel and your blade has a handle texture on it.

The Solution: Python + PIL + Iteration

Instead of hand-painting each texture in a pixel editor, I wrote Python scripts that generate textures programmatically. Here's why:

  1. Consistency — All swords share the same UV layout structure
  2. Iteration speed — Change a color palette, regenerate all textures instantly
  3. Animation — Generate 8 frames with programmatic color shifts per frame
  4. Theming — Each service gets a color palette that maps to its identity

Version 1: Basic UV Layout

#!/usr/bin/env python3
"""Generate UV-mapped textures for AWS Swords 3D models."""
from PIL import Image

def sword_of_lambda():
    """16x16 UV texture for Sword of Lambda.
    UV layout:
      Row 0-3:   blade (orange/purple gradient with energy)
      Row 4-5:   blade edge highlight
      Row 6-7:   crossguard (gold/dark)
      Row 8:     gem (bright orange center)
      Row 9-11:  handle (dark purple with grip lines)
      Row 12-13: pommel (gold)
      Row 14-15: energy glow / emissive accents
    """
    img = Image.new("RGBA", (16, 16), (0, 0, 0, 0))
    px = img.load()

    # Lambda theme: orange fire + purple energy
    blade_dark = (180, 80, 20)
    blade_mid = (230, 120, 30)
    purple_energy = (160, 50, 200)
    gem_core = (255, 160, 0)
    gold = (220, 180, 50)
    # ... fill rows with themed colors
Enter fullscreen mode Exit fullscreen mode

This first version was functional but flat. No animation, no depth, no personality.

Version 6: Animated Frames with Energy Pulses

By version 6, the generator produced 8-frame sprite sheets with:

  • Frame-by-frame color cycling for energy effects
  • Gem pulsing (brightness oscillates across frames)
  • Edge highlights that shift position per frame
  • Enchant glint compatibility (transparent pixels in the right spots)

The .mcmeta file that controls animation:

{
  "animation": {
    "interpolate": true,
    "frametime": 4
  }
}
Enter fullscreen mode Exit fullscreen mode

interpolate: true makes Minecraft blend between frames smoothly. frametime: 4 means each frame lasts 4 ticks (0.2 seconds), giving us a ~1.6 second full animation cycle.

Color Palettes as Cloud Identity

Here's where the cloud learning happens. Each sword needed a color palette that communicates the service:

Sword Primary Secondary Why
Lambda Orange/fire Purple energy Lambda's icon is orange. Ephemeral = fire that burns out
S3 Green/teal Teal gems S3's icon is green. Storage = solid, stable colors
EC2 Blue/cyan Orange sparks EC2's icon is orange on blue. Electric = scaling power
Greatsword Purple/pink Holy fire Lambda variant but "holy" — massive invocations

When you play the mod, you can identify each sword at a glance. The visual language maps directly to the service identity. This is the same principle behind good cloud architecture diagrams — color coding services by category.

cloud swords

Blockbench: From Flat to 3D

Minecraft's default item rendering is a flat sprite held at an angle. But with Blockbench, you can create actual 3D geometry:

  • Blade: elongated cuboid with tapered edges
  • Crossguard: horizontal bar with decorative ends
  • Handle: wrapped cylinder with grip texture
  • Gem: small centered cube with emissive-looking colors

The model exports as a JSON file that Minecraft loads:

{
  "parent": "item/handheld",
  "textures": {
    "layer0": "awsswords:item/sword_of_lambda"
  },
  "display": {
    "thirdperson_righthand": {
      "rotation": [0, -90, 55],
      "translation": [0, 4.0, 0.5],
      "scale": [0.85, 0.85, 0.85]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

7 Iterations — What Changed Each Time

Version What Changed Why
v1 Basic UV layout, flat colors Proof of concept
v2 Added gradients within rows Depth perception
v3 Gem highlights, edge glow Visual focal point
v4 8-frame animation support Movement = life
v5 Per-service color palettes Identity at a glance
v6 Energy pulse patterns per frame Unique animation per sword
v7 Enchant glint layer compatibility Works with vanilla enchanting

cloud swords making of

Each iteration was a conversation: "This looks too flat" → add gradients. "I can't tell Lambda from EC2" → differentiate palettes. "The animation feels static" → add per-frame energy shifts.

The Cloud Computing Connection

Here's what surprised me: designing game visuals for cloud services forces you to understand them deeply.

To make Lambda's texture "feel ephemeral," I had to think about what ephemeral looks like. Fire that fades. Energy that pulses and disappears. Particles that spawn and despawn.

To make S3's texture "feel like storage," I needed stability. Solid green. Consistent glow. A gem that represents the "object" being stored.

To make EC2's texture "feel like scaling," I used electric sparks that multiply. More energy = more power. The visual metaphor IS the service behavior.

This is why game-based learning works. You're not memorizing — you're designing. And design requires understanding.

Lessons Learned

Challenge Solution
UV mapping is confusing Document the layout (which row = which part)
16x16 is tiny Every pixel matters — use contrast aggressively
Animation needs subtlety interpolate: true saves you from choppy frames
Color blindness Don't rely on color alone — use shape/pattern too
7 script versions Each iteration taught something new about PIL

What's Next

The textures are done, but the mod needs more than pretty swords. In the next post, we'll build the Cloud Console — a block that randomizes sword stats like choosing an EC2 instance type. And the Cloud Deployer — a time-based crafting machine that works like a CI/CD pipeline.

Because in cloud computing, you don't just have tools — you have infrastructure. And infrastructure needs machines.


**The full texture generation scripts (all 7 versions) are:

vscode and generating swords

pixelorama

Connect with me:

I'm Carlos Cortez, this is Breaking the Cloud, and today we painted the cloud in 256 pixels. See you in the next one!

Top comments (0)