Standalone [1.3] tModLoader - A Modding API

You mean there are characters with no pictures and they can't be played, or that are no characters at all, or something else?
There still there but there's no sprite and there unplayable
[DOUBLEPOST=1457287791,1457287629][/DOUBLEPOST]
I think you have to make a new charactor if it is not created in the modded version. If it is i dont know...
I have tried that but thank you for the effort
 
2 things: How do you edit the loottables of randomly generated chests (like pyridmid chests) and 2: how to do ore generation (on world creation)
 
There still there but there's no sprite and there unplayable
[DOUBLEPOST=1457287791,1457287629][/DOUBLEPOST]
I have tried that but thank you for the effort
I've had this problem - first make sure you have the latest tModLoader and then go to your ModLoader/Players folder and remove the .tplr files of the faulty characters. (that will probably somewhat hurt their inventory, but the characters should work afterwards).

You can try just moving the files to your desktop or somewhere, if you don't want to delete them. But if the characters work afterwards, they will create new .tplr files for themselves, so the old files will be useless for you.
 
I've had this problem - first make sure you have the latest tModLoader and then go to your ModLoader/Players folder and remove the .tplr files of the faulty characters. (that will probably somewhat hurt their inventory, but the characters should work afterwards).

You can try just moving the files to your desktop or somewhere, if you don't want to delete them. But if the characters work afterwards, they will create new .tplr files for themselves, so the old files will be useless for you.
? is there a file location dor this?
 
Oh and can we make Minecarts yet. There is no example. Im guessing its some kind of mount.
Maybe, but no one has tried yet.

2 things: How do you edit the loottables of randomly generated chests (like pyridmid chests) and 2: how to do ore generation (on world creation)
1. In probably postworldgen, iterate through chests, find a spot in the item array that is empty, call Setdefaults on the item.

Code:
    for (int i = 0; i < 1000; i++)
            {
                Chest chest = Main.chest[i];
                                other code....

2. Like this:
Code:
        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
            {
                progress.Message = "Example Mod Ores";

                for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
                {
                    WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
                }
            }));
        }
 
Maybe, but no one has tried yet.


1. In probably postworldgen, iterate through chests, find a spot in the item array that is empty, call Setdefaults on the item.

Code:
    for (int i = 0; i < 1000; i++)
            {
                Chest chest = Main.chest[i];
                                other code....

2. Like this:
Code:
        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
            {
                progress.Message = "Example Mod Ores";

                for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
                {
                    WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
                }
            }));
        }
what do I have to edit to make it work with EnderuimOre? And where (Im assuming the ore cs). Im sorry im new to world genning
 
Maybe, but no one has tried yet.


1. In probably postworldgen, iterate through chests, find a spot in the item array that is empty, call Setdefaults on the item.

Code:
    for (int i = 0; i < 1000; i++)
            {
                Chest chest = Main.chest[i];
                                other code....

2. Like this:
Code:
        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

            tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
            {
                progress.Message = "Example Mod Ores";

                for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
                {
                    WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
                }
            }));
        }
tremor has tried the mounts and made 1 (i think only one by now) so minecrats are possible i think
 
what do I have to edit to make it work with EnderuimOre? And where (Im assuming the ore cs). Im sorry im new to world genning
Change mod.TileType("ExampleBlock")
[DOUBLEPOST=1457298568,1457298505][/DOUBLEPOST]
tremor has tried the mounts and made 1 (i think only one by now) so minecrats are possible i think
I know mounts are possible, just not sure how to specifically make a Minecraft mount.
 
How would I go about making vanilla enemies immune to modded debuffs?

Edit - Welp, never mind. I think I figured it out... :guidesigh:
 
Last edited:
So as it turns out, it was a Missing Texture exception... needless to say, it was caused by my dumb mistake :/

Anyway it draws now. After some time of trial of error it even draws in the right place but:
  1. It seems that the sprite isn't affected by light, so at night it's much brighter than the rest of the clothes, even though it's the same color
  2. When my character (for example) jumps, the sprite sometimes "doesn't keep up" and is drawn elsewhere than the character...
(The border of the sleeve is [supposed to be] the same color as the rest of the borders)

Code:
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if (winter)
            {
                try
                {
                    if (npc.direction == -1)
                    {
                        spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White, 0f, new Vector2(20, 30), 1f, SpriteEffects.None, 0f);
                    }
                    else
                    {
                        spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White, 0f, new Vector2(20, 30), 1f, SpriteEffects.FlipHorizontally, 0f);
                    }
                }
                catch (Exception e)
                {
                    Main.NewText(e + "");
                }
            }
        }

Is there a way to completely change which texture is used for the NPC itself? Like - instead of drawing a collar in front of it, I'd make it draw from a spritesheet that already has the shirt. I tried to figure it out, but didn't succeed.
The only way to conditionally change the texture reliably would be to manually draw the NPC in the PreDraw hook. However, if lighting is the only problem then you can use the drawColor parameter instead of Color.White.

Do I change the numbers to define the rarity?
...SetDefaults...
 
c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(32,57) : error CS0246: The type or namespace name 'GenPass' could not be found (are you missing a using directive or an assembly reference?)

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(32,52) : error CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)


Code that I edited
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExampleMod.Tiles
{
public class ExampleBlock : ModTile
{
public override void SetDefaults()
{
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
dustType = mod.DustType("Sparkle");
AddMapEntry(new Color(200, 200, 200));
}

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

public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
r = 0.5f;
g = 0.5f;
b = 0.5f;
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
{
progress.Message = "Growing Enderuim Crystals...";

for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
}));
}
}
}
 
So as it turns out, it was a Missing Texture exception... needless to say, it was caused by my dumb mistake :/

Anyway it draws now. After some time of trial of error it even draws in the right place but:
  1. It seems that the sprite isn't affected by light, so at night it's much brighter than the rest of the clothes, even though it's the same color
  2. When my character (for example) jumps, the sprite sometimes "doesn't keep up" and is drawn elsewhere than the character...
(The border of the sleeve is [supposed to be] the same color as the rest of the borders)

Code:
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            if (winter)
            {
                try
                {
                    if (npc.direction == -1)
                    {
                        spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White, 0f, new Vector2(20, 30), 1f, SpriteEffects.None, 0f);
                    }
                    else
                    {
                        spriteBatch.Draw(mod.GetTexture("NPCs/Enthusiast_Shirt"), npc.Center - Main.screenPosition, new Rectangle(0, npc.frame.Y, 40, 60), Color.White, 0f, new Vector2(20, 30), 1f, SpriteEffects.FlipHorizontally, 0f);
                    }
                }
                catch (Exception e)
                {
                    Main.NewText(e + "");
                }
            }
        }

Is there a way to completely change which texture is used for the NPC itself? Like - instead of drawing a collar in front of it, I'd make it draw from a spritesheet that already has the shirt. I tried to figure it out, but didn't succeed.

Like BlueMagic said, you simply need to replace Color.White with the colour at the location of your NPC. To save you some time, this is what you use 'Lighting.GetColor((int)npc.Center.X / 16, (int)npc.Center.Y / 16)'.

You could also simplify your code by doing away with the npc.direction check and instead use 'npc.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally' for the sprite direction.
 
c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(32,57) : error CS0246: The type or namespace name 'GenPass' could not be found (are you missing a using directive or an assembly reference?)

c:\Users\Devin\Documents\My Games\Terraria\ModLoader\Mod Sources\Enderuim\Tiles\ExampleBlock.cs(32,52) : error CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)


Code that I edited
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExampleMod.Tiles
{
public class ExampleBlock : ModTile
{
public override void SetDefaults()
{
Main.tileSolid[Type] = true;
Main.tileMergeDirt[Type] = true;
Main.tileBlockLight[Type] = true;
Main.tileLighted[Type] = true;
dustType = mod.DustType("Sparkle");
AddMapEntry(new Color(200, 200, 200));
}

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

public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
{
r = 0.5f;
g = 0.5f;
b = 0.5f;
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));

tasks.Insert(ShiniesIndex + 1, new PassLegacy("Crazy Ore", delegate (GenerationProgress progress)
{
progress.Message = "Growing Enderuim Crystals...";

for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)
{
WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceLow, Main.maxTilesY), (double)WorldGen.genRand.Next(3, 6), WorldGen.genRand.Next(2, 6), mod.TileType("ExampleBlock"), false, 0f, 0f, false, true);
}
}));
}
}
}

Add
Code:
using System.Collections.Generic;
using Terraria.World.Generation;
to the list at the top of your code.
 
Back
Top Bottom