Klasse ModTile

Basisklasse zum Erstellen benutzerdefinierter Kacheln, Blöcke und Möbel.

Übersicht

Die Klasse ModTile ermöglicht es Ihnen, benutzerdefinierte platzierbare Blöcke, Möbel und dekorative Kacheln mit benutzerdefiniertem Verhalten zu erstellen.

Einfaches Block-Beispiel

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;

namespace YourMod.Tiles
{
    public class ExampleTile : ModTile
    {
        public override void SetStaticDefaults()
        {
            Main.tileSolid[Type] = true; // Block is solid
            Main.tileMergeDirt[Type] = true; // Merges with dirt
            Main.tileBlockLight[Type] = true; // Blocks light
            TileID.Sets.Ore[Type] = true; // Ore type (optional)
            AddMapEntry(new Color(100, 100, 100)); // Map color
            DustType = DustID.Stone;
            HitSound = SoundID.Tink;
            MinPick = 50; // Requires 50+ pickaxe power
        }
    }
}

Möbel erstellen

Möbelkacheln sind komplexer mit Platzierungsregeln:

public class ExampleChair : ModTile
{
    public override void SetStaticDefaults()
    {
        Main.tileFrameImportant[Type] = true; // Critical for furniture
        Main.tileNoAttach[Type] = true;
        TileID.Sets.HasOutlines[Type] = true;
        TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2);
        TileObjectData.newTile.CoordinateHeights = new[] { 16, 18 };
        TileObjectData.addTile(Type);
        AddMapEntry(new Color(120, 85, 60), "Example Chair");
        DustType = DustID.WoodFurniture;
        TileID.Sets.DisableSmartCursor[Type] = true;
    }
}

Häufige Kachel-Eigenschaften

tileSolid

Block ist fest (nicht durchgehbar)

Main.tileSolid[Type] = true;

tileBlockLight

Block verhindert Lichtdurchlass

Main.tileBlockLight[Type] = true;

MinPick

Mindest-Spitzhackenstärke zum Abbauen

MinPick = 100;

DustType

Partikeleffekt beim Abbauen

DustType = DustID.Stone;

Vollständige ModTile-Dokumentation:

Vollständige Dokumentation anzeigen