Standalone [1.3] tModLoader - A Modding API

I'm having trouble with my tiles. I can't get my 3x3 tile to display properly. I only get the left third showing. I tried 2x2 and a few other smaller variants and they seemed to display normally, but incomplete of course. I'm wondering what mistake I could have made, or if something is up with the 3x3 style.

Here's my setDefaults hook.
Code:
public override void SetDefaults()
    {
        Main.tileFrameImportant[Type] = true;
        Main.tileNoAttach[Type] = true;
        Main.tileTable[Type] = true;
        Main.tileLavaDeath[Type] = true;
        TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3);
        TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 };
        TileObjectData.addTile(Type);
        AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable);
        mapColor = new Color(170, 60, 40);
        mapName = "Artists Desk";
        adjTiles = new int[]{TileID.Tables};
    }

And I've attached my tile.
Try (Maybe it won't help but try)
Code:
      TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 18 };
 
интересно, как будет создан спаун мобов в определённых биомах. может они будут нумированы? Наконец я смогу доделать свой мод...
Есть такае чудесная вещ как ZoneCrimson, ZoneСorrupt и т. д.
ты русский?
Не кто не мешает учить мне русский
 
Damnit ... I tried that but it seems to crash the rendering thread, but Terraria is too damn stubborn to crash or give me an exception to work with. Is there any sort of log that I can get to (I tried catch{exception.tostring}, no cigar)? Here's my code:
Code:
public override void PostDraw(int i, int j, SpriteBatch spriteBatch) {
     try {
     int num9 = 32;
     int num11 = 0;
     Vector2 zero = new Vector2((float)Main.offScreenRange, (float)Main.offScreenRange);
     if (Main.drawToScreen)
     {
       zero = Vector2.Zero;
     }
     var rect = new Vector2((float)(i * 16 - (int)Main.screenPosition.X) - ((float)num9 - 16f) / 2f, (float)(j * 16 - (int)Main.screenPosition.Y + num11)) + zero;
     var color = new Microsoft.Xna.Framework.Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, 255);
    
     spriteBatch.Draw(Main.tileTexture[mod.ItemType("RainbowWorkbench")], rect, color);
     }
     catch (Exception e)
     { //doesn't work
        System.IO.File.WriteAllText(@"C:\tModLoaderLog.txt", e.ToString());
     }
   }
View attachment 72675Keep in mind that this is for a furniture item (hence num9/width being 32 instead of 16), but it also dies for blocks.
It looks like the problem is that you're using the item type of the rainbow workbench instead of the tile type to find out which texture to draw. I don't know why that try catch isn't working though.

I'm having trouble with my tiles. I can't get my 3x3 tile to display properly. I only get the left third showing. I tried 2x2 and a few other smaller variants and they seemed to display normally, but incomplete of course. I'm wondering what mistake I could have made, or if something is up with the 3x3 style.

Here's my setDefaults hook.
Code:
public override void SetDefaults()
    {
        Main.tileFrameImportant[Type] = true;
        Main.tileNoAttach[Type] = true;
        Main.tileTable[Type] = true;
        Main.tileLavaDeath[Type] = true;
        TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3);
        TileObjectData.newTile.CoordinateHeights = new int[] { 16, 18 };
        TileObjectData.addTile(Type);
        AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable);
        mapColor = new Color(170, 60, 40);
        mapName = "Artists Desk";
        adjTiles = new int[]{TileID.Tables};
    }

And I've attached my tile.
Try deleting the CoordinateHeights line. By default the 3x3 style uses {16, 16, 16} for the coordinate heights.

I guess, but that is not a nice solution. I wanted to make recipes to disassemble many accessories.
Is that a feature bluemagic123 could add to tModLoader?
Well, the problem with that would be that I'd have to make some messy changes to the Terraria code itself, since Terraria doesn't support that. And I'm trying to minimize the changes I make to the source.
 
Does anyone else here get the problem where if you have just a certain mod enabled and when you enable other mods the mod will then show that it's enabled but act like its disabled? Whats even worse is that when you disable the other mods then load into a world your inventory will disappear and you have to force it to close with alt f4 or something like that and the only way to fix it is build and reload the mod again while the other mods are disabled. If anyone else gets this problem and knows how to fix it please let me know because I just find it strange and tiny bit annoying that I can't have more mods on then just that mod.
 
Does anyone else here get the problem where if you have just a certain mod enabled and when you enable other mods the mod will then show that it's enabled but act like its disabled? Whats even worse is that when you disable the other mods then load into a world your inventory will disappear and you have to force it to close with alt f4 or something like that and the only way to fix it is build and reload the mod again while the other mods are disabled. If anyone else gets this problem and knows how to fix it please let me know because I just find it strange and tiny bit annoying that I can't have more mods on then just that mod.
Which mods are you using that are causing this?
 
Which mods are you using that are causing this?
My Star Mod (that you helped fix earlier) and it acts all weird when I use it with the Example Mod and my own Super Fun Mod where I just have an item like the example item but it only just crafts out of dirt and it builds into a thing a lot like the example mod explorer's bag. Star Mod is the only one that is acting weird though.
 
Last edited:
Welp, it's pretty much impossible to decompile with a 4GB system. I'd like to contribute to the project, but I'll have to wait on that.
 
My Star Mod (that you helped fix earlier) and it acts all weird when I use it with the Example Mod and my own Super Fun Mod where I just have an item like the example item but it only just crafts out of dirt and it builds into a thing a lot like the example mod explorer's bag. Star Mod is the only one that is acting weird though.
Hm, not really sure what's going wrong there. I might have to test multiple content mods later.

Welp, it's pretty much impossible to decompile with a 4GB system. I'd like to contribute to the project, but I'll have to wait on that.
Did it crash in the middle, or was it taking too long? Decompiling normally takes 1-2 hours, but there was this really weird time once when it took 4 hours for me.

I can patch as much as I want but the Backup and the modified file won't show!
Are you talking about installation? It doesn't create a backup anymore; instead it creates the modded file separate from the vanilla file. You need to put the vanilla exe in the Vanilla folder and the modded exe should appear in the tModLoader folder. If it still doesn't work, then try to see if any of the files are blocked by your computer (the computer often blocks files downloaded from the Internet).
 
Hm, not really sure what's going wrong there. I might have to test multiple content mods later.


Did it crash in the middle, or was it taking too long? Decompiling normally takes 1-2 hours, but there was this really weird time once when it took 4 hours for me.


Are you talking about installation? It doesn't create a backup anymore; instead it creates the modded file separate from the vanilla file. You need to put the vanilla exe in the Vanilla folder and the modded exe should appear in the tModLoader folder. If it still doesn't work, then try to see if any of the files are blocked by your computer (the computer often blocks files downloaded from the Internet).
Ok, Thanks. I'll try that tomorrow. Bed now (I live in Europe).
 
Did it crash in the middle, or was it taking too long? Decompiling normally takes 1-2 hours, but there was this really weird time once when it took 4 hours for me.

On decompiling NPC.cs, it takes up all available RAM and swaps to disk. I let it run a couple days while on vacation and it still didn't finish. Seems to be a known issue.

Anyway, looking at the Abomination NPC in ExampleMod, how did you know to use "npc.aiStyle = 56;" Trial and error? Basing it off an existing NPC and copying the value? There doesn't seem to be an enum for aistyles as there are for other things such as NPCs, projectiles, etc.

Also, are there similarities between the aistyle in NPC and the aistyle in projectile? or should I assume they are mutually exclusive sets of numbers?
 
Last edited:
On decompiling NPC.cs, it takes up all available RAM and swaps to disk. I let it run a couple days while on vacation and it still didn't finish. Seems to be a known issue.

Anyway, looking at the Abomination NPC in ExampleMod, how did you know to use "npc.aiStyle = 56;" Trial and error? Basing it off an existing NPC and copying the value? There doesn't seem to be an enum for aistyles as there are for other things such as NPCs, projectiles, etc.

Also, are there similarities between the aistyle in NPC and the aistyle in projectile? or should I assume they are mutually exclusive sets of numbers?
What I did was look up the dungeon spirit in the NPC class in the SetDefaults method and use the aiStyle that it was using. And yes, NPC and projectile aiStyles are different. The programming is pretty messy; basically the AI method uses a big if/else for aiStyles in each class.
 
One last question for now: Is the "Sparkling Ball" projectile used anywhere in the ExampleMod? I don't see it used anywhere.
 
One last question for now: Is the "Sparkling Ball" projectile used anywhere in the ExampleMod? I don't see it used anywhere.
At the moment I have it so that the example sword shoots it. In the next update I'll probably move it over to a magic weapon though.
 
How can I have my custom projectile use a vanilla projectile image?
At the moment, you can either assign an index of Main.projectileTexture to a vanilla index of Main.projectileTexture (I suppose in the SetDefaults method), or if you have the png versions of the xnb files you can copy the image file into your mod (that's what I did in tAPI).
 
At the moment, you can either assign an index of Main.projectileTexture to a vanilla index of Main.projectileTexture (I suppose in the SetDefaults method), or if you have the png versions of the xnb files you can copy the image file into your mod (that's what I did in tAPI).
K, I tried "Main.projectileTexture[mod.ProjectileType("BubbleProjectile")] = Main.projectileTexture[Terraria.ID.ProjectileID.Bubble];" in the projectiles setDefaults method but it didn't work. I just found the xnb and converted it.
 
Back
Top Bottom