tModLoader Logo tModLoader / Blog / Buat Mod Pertama Anda
Kembali ke Blog
DEVELOPMENT Diterbitkan September 23, 2025

Cara Membuat Mod Terraria Pertama Anda di 2025

Ready to join the ranks of mod developers? This comprehensive tutorial will guide you through creating your first Terraria mod from setup to publishing, with practical examples and expert tips.

Apa yang Akan Anda Pelajari

  • • Setting up your development environment
  • • Creating a custom sword with unique properties
  • • Understanding tModLoader's C# API
  • • Testing and debugging your mod
  • • Publishing to Steam Workshop

Prasyarat

Pengetahuan yang Diperlukan

  • • Basic C# programming (variables, methods, classes)
  • • Familiarity with Terraria gameplay
  • • Basic understanding of object-oriented programming

Perangkat Lunak yang Diperlukan

  • • tModLoader installed and working
  • • Visual Studio 2022 (recommended) or VS Code
  • • .NET 6.0 SDK or later

Langkah 1: Pengaturan Lingkungan Pengembangan

Membuat Template Mod Anda

  1. Luncurkan tModLoader and go to "Workshop" → "Develop Mods"
  2. Click "Create Mod"
  3. Enter your mod name (e.g., "MyFirstMod" - no spaces!)
  4. Fill in author name and description
  5. Click "Create"

This creates a mod template in your ModSources folder with all necessary files.

Langkah 2: Membuat Pedang Kustom

Let's create a simple but effective custom sword. This will teach you the basics of item creation.

Create the Item Class

Create a new file: Items/BeginnerSword.cs

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MyFirstMod.Items
{
    public class BeginnerSword : ModItem
    {
        public override void SetDefaults()
        {
            // Basic item properties
            Item.damage = 45;                    // Damage value
            Item.DamageType = DamageClass.Melee; // Damage type
            Item.width = 40;                     // Hitbox width
            Item.height = 40;                    // Hitbox height
            Item.useTime = 20;                   // Use speed
            Item.useAnimation = 20;              // Animation speed
            Item.useStyle = ItemUseStyleID.Swing;// How it's used
            Item.knockBack = 6;                  // Knockback strength
            Item.value = Item.buyPrice(gold: 2); // Sell value
            Item.rare = ItemRarityID.Green;      // Rarity color
            Item.UseSound = SoundID.Item1;       // Use sound
            Item.autoReuse = true;               // Can auto-swing
        }

        public override void AddRecipes()
        {
            Recipe recipe = CreateRecipe();
            recipe.AddIngredient(ItemID.IronBar, 15);
            recipe.AddIngredient(ItemID.Wood, 10);
            recipe.AddTile(TileID.Anvils);
            recipe.Register();
        }
    }
}

Memahami Kode

  • SetDefaults(): Defines all the item's properties like damage, size, and behavior
  • AddRecipes(): Creates crafting recipes for your item
  • DamageClass.Melee: Makes it scale with melee damage bonuses
  • ItemRarityID.Green: Sets the rarity color (affects item name color)

Langkah 3: Build dan Uji

Using Build + Reload

tModLoader's best feature for developers is the "Build + Reload" system that lets you test changes instantly:

  1. In tModLoader, go to "Workshop" → "Develop Mods"
  2. Find your mod and click "Build + Reload"
  3. Wait for compilation (should take 5-10 seconds)
  4. Your mod reloads automatically with changes
  5. Test your new sword in-game!

Testing Your Sword

To test your new sword:

  • 1. Open your inventory and check if you can craft it (you'll need iron bars and wood)
  • 2. Craft the sword and test its damage on enemies
  • 3. Check that the sound effect and animation work correctly
  • 4. Verify the auto-swing functionality

Menambahkan Fitur Lanjutan

Efek Kustom Saat Mengenai

Let's add a special effect when your sword hits an enemy:

public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone)
{
    // 20% chance to inflict fire debuff
    if (Main.rand.NextBool(5))
    {
        target.AddBuff(BuffID.OnFire, 180); // 3 seconds of fire
    }

    // Spawn some visual effects
    for (int i = 0; i < 10; i++)
    {
        Dust.NewDust(target.position, target.width, target.height, DustID.Fire);
    }
}

This adds a 20% chance to set enemies on fire and creates fire particle effects on hit.

Tooltip Kustom

Add custom text to your item's tooltip:

public override void ModifyTooltips(List<TooltipLine> tooltips)
{
    TooltipLine line = new TooltipLine(Mod, "CustomTooltip", "A sword forged by a beginner modder!");
    line.OverrideColor = Color.Orange;
    tooltips.Add(line);
}

Menerbitkan Mod Anda

Menerbitkan ke Steam Workshop

  1. Ensure your mod builds without errors
  2. Add an icon.png file (64x64 pixels) to your mod folder
  3. Write a good description.txt explaining what your mod does
  4. In "Develop Mods", click "Publish" next to your mod
  5. Fill out the Steam Workshop form with tags and description
  6. Upload screenshots showing your mod in action
  7. Click "Publish" to make it live!

Tips untuk Penerbitan yang Sukses

  • • Write clear, detailed descriptions
  • • Include high-quality screenshots
  • • Use relevant tags for discoverability
  • • Test thoroughly before publishing
  • • Respond to user feedback and comments

Selamat! Anda Sekarang Seorang Pengembang Mod!

You've created your first Terraria mod! This is just the beginning - tModLoader's API can do incredible things. Explore NPCs, projectiles, tiles, and world generation next.