tModLoader Official tModLoader Help Thread

New to the forum, so I'll try posting here first. I tried making my first mod. This item I tried to add is a vanity item, but when trying to build and reload I get this error. Any tips?
code1.PNG
code2.PNG
 
Simple problem: When I try to use the .jar installer it just opens a Notepad file with a bunch of unintelligible symbols instead of actually downloading TModLoader.
 
New to the forum, I had taken the code from examplemod to create a boss, but now I get this.


error CS1061: 'NPC' does not contain a definition for 'ModNPC' and no accessible extension method 'ModNPC' accepting a first argument of type 'NPC' could be found (are you missing a using directive or an assembly reference?)

error CS0120: An object reference is required for the non-static field, method, or property 'ModNPC.npc'



[AutoloadBossHead]
public class CaptiveElement : ModNPC
{
public const string CaptiveElementHead = "Thovam/NPCs/eee/CaptiveElement_Head_Boss_";
public override bool Autoload(ref string name) {
// Adds boss head textures for the eee boss
for (int k = 1; k <= 4; k++) {
mod.AddBossHeadTexture(CaptiveElementHead + k);
}
return base.Autoload(ref name);
}
private int center {
get => (int)npc.ai[0];
set => npc.ai[0] = value;
}
private int captiveType {
get => (int)npc.ai[1];
set => npc.ai[1] = value;
}
private float attackCool {
get => npc.ai[2];
set => npc.ai[2] = value;
}
private int change {
get => (int)npc.ai[3];
set => npc.ai[3] = value;
}
public override void SetStaticDefaults() {
DisplayName.SetDefault("Captive Element");
Main.npcFrameCount[npc.type] = 10;
}
public override void SetDefaults() {
npc.aiStyle = -1;
npc.lifeMax = 15000;
npc.damage = 100;
npc.defense = 55;
npc.knockBackResist = 0f;
npc.dontTakeDamage = true;
npc.width = 100;
npc.height = 100;
npc.value = Item.buyPrice(0, 20, 0, 0);
npc.npcSlots = 10f;
npc.boss = true;
npc.lavaImmune = true;
npc.noGravity = true;
npc.noTileCollide = true;
npc.HitSound = SoundID.NPCHit1;
npc.DeathSound = SoundID.NPCDeath1;
music = MusicID.Boss2;
}
public override void ScaleExpertStats(int numPlayers, float bossLifeScale) {
npc.lifeMax = (int)(npc.lifeMax * 0.6f * bossLifeScale);
npc.damage = (int)(npc.damage * 0.6f);
}
public override void AI() {
NPC eee= Main.npc
;
if (!eee.active || eee.type != NPCType<eee>()) {
if (change > 0 || NPC.AnyNPCs(NPCType<eeeRun>())) {
if (change == 0) {
npc.netUpdate = true;
}
change++;
}
else {
npc.life = -1;
npc.active = false;
return;
}
}
if (change > 0) {
Color? color = GetColor();
if (color.HasValue) {
for (int x = 0; x < 5; x++) {
int dust = Dust.NewDust(npc.position, npc.width, npc.height, DustType<Pixel>(), 0f, 0f, 0, color.Value);
double angle = Main.rand.NextDouble() * 2.0 * Math.PI;
Main.dust[dust].velocity = 3f * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
}
}
if (Main.netMode != 1 && change >= 100f) {
int next = NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, NPCType<CaptiveElement2>());
Main.npc[next].ai[0] = captiveType;
if (captiveType != 4) {
Main.npc[next].ai[1] = 300f + (float)Main.rand.Next(100);
}
npc.life = -1;
npc.active = false;
}
return;
}
else if (npc.timeLeft < 750) {
npc.timeLeft = 750;
}
if (npc.localAI[0] == 0f) {
if (GetDebuff() >= 0f) {
npc.buffImmune[GetDebuff()] = true;
}
if (captiveType == 3f) {
npc.buffImmune[20] = true;
}
if (captiveType == 0f) {
npc.coldDamage = true;
}
npc.localAI[0] = 1f;
}
SetPosition(npc);
attackCool -= 1f;
if (Main.netMode != 1 && attackCool <= 0f) {
attackCool = 200f + 200f * (float)111.life / (float)eee.lifeMax + (float)Main.rand.Next(200);
Vector2 delta = Main.player[npc.target].Center - npc.Center;
float magnitude = (float)Math.Sqrt(delta.X * delta.X + delta.Y * delta.Y);
if (magnitude > 0) {
delta *= 5f / magnitude;
}
else {
delta = new Vector2(0f, 5f);
}
int damage = (npc.damage - 30) / 2;
if (Main.expertMode) {
damage = (int)(damage / Main.expertDamage);
}
Projectile.NewProjectile(npc.Center.X, npc.Center.Y, delta.X, delta.Y, ProjectileType<ElementBall>(), damage, 3f, Main.myPlayer, GetDebuff(), GetDebuffTime());
npc.netUpdate = true;
}
}
public static void SetPosition(NPC npc) {
CaptiveElement modNPC = npc.ModNPC as CaptiveElement;
if (modNPC != null) {
Vector2 center = Main.npc[modNPC.center].Center;
double angle = Main.npc[modNPC.center].ai[3] + 2.0 * Math.PI * modNPC.captiveType / 5.0;
npc.position = center + 300f * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) - npc.Size / 2f;
}
}
public override void FindFrame(int frameHeight) {
npc.frame.Y = captiveType * frameHeight;
if (captiveType == 1) {
npc.alpha = 100;
}
if (attackCool < 50f) {
npc.frame.Y += 5 * frameHeight;
}
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot) {
if (captiveType == 2 && Main.expertMode) {
cooldownSlot = 1;
}
return true;
}
public override void OnHitPlayer(Player player, int dmgDealt, bool crit) {
if (Main.expertMode || Main.rand.NextBool()) {
int debuff = GetDebuff();
if (debuff >= 0) {
player.AddBuff(debuff, GetDebuffTime(), true);
}
}
}
public int GetDebuff() {
switch (captiveType) {
case 0:
return BuffID.Frostburn;
case 1:
return BuffType<Buffs.EtherealFlames>();
case 3:
return BuffID.Venom;
case 4:
return BuffID.Ichor;
default:
return -1;
}
}
public int GetDebuffTime() {
int time;
switch (captiveType) {
case 0:
time = 400;
break;
case 1:
time = 300;
break;
case 3:
time = 400;
break;
case 4:
time = 900;
break;
default:
return -1;
}
return time;
}
public Color? GetColor() {
switch (captiveType) {
case 0:
return new Color(0, 230, 230);
case 1:
return new Color(0, 153, 230);
case 3:
return new Color(0, 178, 0);
case 4:
return new Color(230, 192, 0);
default:
return null;
}
}
public override void BossHeadSlot(ref int index) {
if (captiveType > 0) {
index = ModContent.GetModBossHeadSlot(CaptiveElementHead + captiveType);
}
}
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) {
eee eee= Main.npc
.modNPC as eee;
if (Main.expertMode && eee!= null && eee.npc.active && eee.laserTimer <= 60 && (eee.laser1 == captiveType || eee.laser2 == captiveType)) {
Color? color = GetColor();
if (!color.HasValue) {
color = Color.White;
}
float rotation = eee.laserTimer / 30f;
if (eee.laser1 == captiveType) {
rotation *= -1f;
}
spriteBatch.Draw(ModContent.GetTexture("Thovam/NPCs/eee/Rune"), npc.Center - Main.screenPosition, null, color.Value, rotation, new Vector2(64, 64), 1f, SpriteEffects.None, 0f);
}
return true;
}​
 
Hello, I would like help with a mod I am working on. It's going to be a mod that adds more functional statues that summon enemies. any idea how to make a wiring component?
Thanks in advance!
 
Ay bois, i just playing some mods like every time, but, i always ask myself: It's possible to enchant mod weapons? Because, every time that i try to put the weapon in the forge, i just can't, it's like trying to enchant an ore, you can't put him. So, if anyone have an solution for this or a mod that fix it, tell me pls.
 
I need some help. When I try to update a mod, the bar is fully yellow but nothing else happens. The only thing I can do is cancel. Does anybody know why it’s happening and how to deal with it?
 
Hey so im trying to download the modloader and the exe file that should be there is a zip file. In the zip file is more files but still no exe. What could I have done wrong?
 

Attachments

  • thissucks.PNG
    thissucks.PNG
    20.8 KB · Views: 168
Hey so im trying to download the modloader and the exe file that should be there is a zip file. In the zip file is more files but still no exe. What could I have done wrong?

It's there! It's just called an application in file explorer. If you look at the picture or the zipped up folder, you'll notice an application called terraria (and if you have file explorer set up to show file type/ extensions, it would display as terraria.exe). So yeah, you have everything that you need to move into the steam/gog game folder.

attachment: an image showing what the files look like with type/ extension showing in file explorer.
 

Attachments

  • explorer_2020-02-29_16-50-05.png
    explorer_2020-02-29_16-50-05.png
    44.5 KB · Views: 109
How do I add multiple items to one mod?

To elaborate, I wanted to have multiple weapons in a mod I'm making. However, I'm unsure of how to do so. Do I just add another file for the code of the item with the sprite and everything, or is something specific that I need to do?
 
Help please, me and my friend have been trying all day to make a tmodloader server, we've done it before but now it just says "Gathering information" when i try to start it, and it stays on that forever.
 
Back
Top Bottom