Standalone [1.3] tModLoader - A Modding API

Like The Build?

author = TaloniusZan
version = 0.1
displayName = Talonius' Modification
homepage = ???
hideCode = false
hideResources = false
includeSource = true
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*
includePDB = true
 
Like The Build?

author = TaloniusZan
version = 0.1
displayName = Talonius' Modification
homepage = ???
hideCode = false
hideResources = false
includeSource = true
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*
includePDB = true
No, the Mod class. Look at ExampleMod.cs, and what I posted above
 
IT WORKED!

well sort of
npc.frame.Y = npc.frame * frameHeight; gave a similar error to last time. but then I grabbed my old code and said

npc.frameCounter %= Main.npcFrameCount[npc.type];
int frame = (int)npc.frameCounter;

and then said

npc.frame.Y = frame * frameHeight; and then it worked

Thanks for the help

If there is an easier way to do that please say so. I have several more enemies I want to make.

also it's still a bit fast, but it's noticeably slower

also

How do I make an Item drop only from enemies in the Jungle Temple.

I have
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Pack.NPCs
{
   public class ModGlobalNPC : GlobalNPC
   {
      public override void NPCLoot(NPC npc)
      {
         if (Main.rand.Next(4) == 0 && zoneTemple)
         {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("TempliteIngot"), 3);
         }
      }
   }
}
in ModGlobalNPC

and zoneTemple gives an error.

does anyone know what to put there instead
Ah, yes. I meant to have "npc.frame.Y = myFrame * frameHeight;" instead of "npc.frame.Y = npc.frame * frameHeight;", but I'm glad you got it worked out. Sorry about that mistake.

You actually can't check which zone a NPC is in, only which zone the nearest player is in. The correct syntax for detecting which zone the nearest player is in is as follows:
Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].ZoneCorrupt
Which will give you the Corruption.

However, it seems there is no zone for the temple. The best solution that I could find was to use the same check that the music uses when selecting which song to play:
(Main.tile[(int)(Main.player[Main.myPlayer].Center.X / 16f), (int)(Main.player[Main.myPlayer].Center.Y / 16f)].wall == 87)
You should probably replace "(int)(Main.player[Main.myPlayer].Center.X / 16f)" with "(int)(npc.position.X / 16)", and do the same with the Y value.
 
How would I make a ore spawn like the hardmode ores (Cobalt, Mythril, Adamantite etc) do?

Is it possible to change the image of the moon after the Wall of Flesh and later the Moon Lord are defeated? (Like how wearing sunglasses causes the sun image to change).

Also how would I make a item spawn in one of the dungeon gold chests?

Also how would I make modded biome chests?

For recipes how would I make the tile required be the hardmode anvils (Mythril or Orichalcum) or forges (Adamantite or Titanium) without the pre-hardmode ones being usable?

Also how would I make something require the Demon/Crimson altar to be made?
 
Last edited:
hello i need some help ive installed tmodloader the manual way but when i try to launch terraria from steam it just says error please launch game from your steam client but like i am doing that! ive tried evrything verifing the cache uninstalling reinstalling restarting steam etc etc can anyone give me some insight into this? i really wanna try terraria with mods!
 

hello i need some help ive installed tmodloader the manual way but when i try to launch terraria from steam it just says error please launch game from your steam client but like i am doing that! ive tried evrything verifing the cache uninstalling reinstalling restarting steam etc etc can anyone give me some insight into this? i really wanna try terraria with mods!
Did you backup terraria.exe before installing tModLoader?
 
Then I would delete the tmodloader version of terraria, double check to make sure the normal terraria.exe still works, then attempt to unzip the file again.

i did it still wont work i can launch the normal one fine but although mine dosnt show up as terraria.exe just terraria like the exe isnt there
 
I'm trying to make a custom door and have basically copied the code from ExampleMod's ExampleDoor. The new item works, but when I try to place the door, nothing happens. If, in the open/closed classes, I comment out the 'TileObjectData.newTile.UsesCustomCanPlace = true;' lines, then the door will place, but it is immediately destroyed and returns the item. I'm hoping it is the code, because otherwise there are bigger issues I have to look into. Any idea what I'm doing wrong?

The Item Class:
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace ConstructionMod.Items.Placeable
{
    public class Barricade : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Construction Barricade";
            item.width = 32;
            item.height = 32;
            item.maxStack = 99;
            item.toolTip = "A barricade to restrict movement.";
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.value = 150;
            item.createTile = mod.TileType("BarricadeClosed");
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

The Door Closed Class:
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace ConstructionMod.Tiles
{
  public class BarricadeClosed : ModTile
  {
  public override void SetDefaults()
  {
  Main.tileFrameImportant[Type] = true;
  Main.tileBlockLight[Type] = true;
  Main.tileSolid[Type] = true;
  Main.tileNoAttach[Type] = true;
  Main.tileLavaDeath[Type] = true;
  TileObjectData.newTile.Width = 1;
  TileObjectData.newTile.Height = 3;
  TileObjectData.newTile.Origin = new Point16(0, 0);
  TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
  TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
  TileObjectData.newTile.UsesCustomCanPlace = true;
  TileObjectData.newTile.LavaDeath = true;
  TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 };
  TileObjectData.newTile.CoordinateWidth = 16;
  TileObjectData.newTile.CoordinatePadding = 2;
  TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
  TileObjectData.newAlternate.Origin = new Point16(0, 1);
  TileObjectData.addAlternate(0);
  TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
  TileObjectData.newAlternate.Origin = new Point16(0, 2);
  TileObjectData.addAlternate(0);
  TileObjectData.addTile(Type);
  AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor);
  AddMapEntry(new Color(200, 200, 200), "Construction Barricade");
  dustType = mod.DustType("Sparkle");
  disableSmartCursor = true;
  adjTiles = new int[] { TileID.ClosedDoor };
  openDoorID = mod.TileType("BarricadeOpen");
  }

  public override void NumDust(int i, int j, bool fail, ref int num)
  {
  num = 1;
  }

  public override void KillMultiTile(int i, int j, int frameX, int frameY)
  {
  Item.NewItem(i * 16, j * 16, 16, 48, mod.ItemType("Barricade"));
  }
  }
}

The Door Open Class:
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;

namespace ConstructionMod.Tiles
{
  public class BarricadeOpen : ModTile
  {
  public override void SetDefaults()
  {
  Main.tileFrameImportant[Type] = true;
  Main.tileSolid[Type] = false;
  Main.tileLavaDeath[Type] = true;
  Main.tileNoSunLight[Type] = true;
  TileObjectData.newTile.Width = 2;
  TileObjectData.newTile.Height = 3;
  TileObjectData.newTile.Origin = new Point16(0, 0);
  TileObjectData.newTile.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 0);
  TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 0);
  TileObjectData.newTile.UsesCustomCanPlace = true;
  TileObjectData.newTile.LavaDeath = true;
  TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 };
  TileObjectData.newTile.CoordinateWidth = 16;
  TileObjectData.newTile.CoordinatePadding = 2;
  TileObjectData.newTile.StyleHorizontal = true;
  TileObjectData.newTile.StyleMultiplier = 2;
  TileObjectData.newTile.StyleWrapLimit = 2;
  TileObjectData.newTile.Direction = TileObjectDirection.PlaceRight;
  TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
  TileObjectData.newAlternate.Origin = new Point16(0, 1);
  TileObjectData.addAlternate(0);
  TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
  TileObjectData.newAlternate.Origin = new Point16(0, 2);
  TileObjectData.addAlternate(0);
  TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
  TileObjectData.newAlternate.Origin = new Point16(1, 0);
  TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1);
  TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1);
  TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft;
  TileObjectData.addAlternate(1);
  TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
  TileObjectData.newAlternate.Origin = new Point16(1, 1);
  TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1);
  TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1);
  TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft;
  TileObjectData.addAlternate(1);
  TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
  TileObjectData.newAlternate.Origin = new Point16(1, 2);
  TileObjectData.newAlternate.AnchorTop = new AnchorData(AnchorType.SolidTile, 1, 1);
  TileObjectData.newAlternate.AnchorBottom = new AnchorData(AnchorType.SolidTile, 1, 1);
  TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceLeft;
  TileObjectData.addAlternate(1);
  TileObjectData.addTile(Type);
  AddToArray(ref TileID.Sets.RoomNeeds.CountsAsDoor);
  TileID.Sets.HousingWalls[Type] = true; //needed for non-solid blocks to count as walls
  AddMapEntry(new Color(200, 200, 200), "Construction Barricade");
  dustType = mod.DustType("Sparkle");
  disableSmartCursor = true;
  adjTiles = new int[] { TileID.OpenDoor };
  closeDoorID = mod.TileType("BarricadeClosed");
  }

  public override void NumDust(int i, int j, bool fail, ref int num)
  {
  num = 1;
  }

  public override void KillMultiTile(int i, int j, int frameX, int frameY)
  {
  Item.NewItem(i * 16, j * 16, 32, 48, mod.ItemType("Barricade"));
  }
  }
}
 
Back
Top Bottom