tModLoader Official tModLoader Help Thread

This is from my Jackhamshromm and his projectile not fall on the ground
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace BettertakeaPowerTool.Projectiles
{
    public class Jackhamshroom : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.CloneDefaults(ProjectileID.ChlorophyteJackhammer);
            Main.projFrames[projectile.type] = 4;
        }
              public override Color? GetAlpha(Color lightColor)
             {
            return Color.White;
              }
        private int shootCounter;
         public override void AI()
            {
            shootCounter++;
            if (shootCounter >= 24)
                    {
                shootCounter = 0;
                Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, projectile.velocity.X/3, projectile.velocity.Y/3, 131, projectile.damage, 0f, projectile.owner, 0f, 0f);
                   }
                 projectile.frameCounter++;
                 if (projectile.frameCounter >= 4.44444444444f)
                    {
                projectile.frameCounter = 0;
                     projectile.frame = (projectile.frame + 1) % 4;
                   }
             }
    }
}
Thanks, but your code has a vanilla projectile that stationary floats in the air, I'm trying to make a custom projectile that travels like a demon scythe, or like a spinning bullet. I don't know where to convince the projectile to move, let alone spin (and eventually fire other projectiles itself).
 
Thanks, but your code has a vanilla projectile that stationary floats in the air, I'm trying to make a custom projectile that travels like a demon scythe, or like a spinning bullet. I don't know where to convince the projectile to move, let alone spin (and eventually fire other projectiles itself).
Try to clone the defaults of the daemon scythe projectile
 
Two questions on accessories;

1) Is there a line I can type that lets me add a number of extra jumps? The cloud in a bottle, as an example, has doubleJumpCloud, while there's also Fart, Sandstorm, and so on. Would I just duplicate this line multiple times for multiple jumps? Or is there something else I need?

2) What would I put in [AutoloadEquip(EquipType.xxx)] for an accessory that is not shown on the character's sprite, like the Philosopher's Stone? I can't find an EquipType that works in the github, nor can I find any mods with accessories to peek at that allow extraction.


EDIT:

On a separate note, I am trying to make monsters drop materials to make these accessories, and I've ALMOST got it working. Only problem is that when it decides to give loot on a kill, it gives everything on the kill. Here's how the monster looks right now (It's mostly a shameless zombie clone);

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace My_Mod.NPCs
{
   public class ZombieBunny : ModNPC
   {
     public override void SetStaticDefaults()
     {
       DisplayName.SetDefault("Zombie");
       Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Zombie];
     }

     public override void SetDefaults()
     {
       npc.width = 18;
       npc.height = 40;
       npc.damage = 14;
       npc.defense = 6;
       npc.lifeMax = 200;
       npc.HitSound = SoundID.NPCHit1;
       npc.DeathSound = SoundID.NPCDeath2;
       npc.value = 60f;
       npc.knockBackResist = 0.5f;
       npc.aiStyle = 3;
       aiType = NPCID.Zombie;
       animationType = NPCID.Zombie;
     }

     public override float SpawnChance(NPCSpawnInfo spawnInfo)
     {
       return SpawnCondition.OverworldNightMonster.Chance * 0.5f;
     }
     
     public override void NPCLoot()
     {
       if (Main.rand.Next(5) == 0)
       {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial01"));
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial02"));
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial03"));
       }
     }

     public override void HitEffect(int hitDirection, double damage)
     {
  if (npc.life <= 0)
  {
  Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/gore_ZombieBunny01"), 1f);  
  Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/gore_ZombieBunny02"), 1f);
  Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/gore_ZombieBunny03"), 1f);
  }
  }
     }
   }

How do I change the drops so that it's separate chances for each item? Like, it'll randomly drop one piece, two pieces, two other pieces, or all three.
 
Last edited:
Two questions on accessories;

1) Is there a line I can type that lets me add a number of extra jumps? The cloud in a bottle, as an example, has doubleJumpCloud, while there's also Fart, Sandstorm, and so on. Would I just duplicate this line multiple times for multiple jumps? Or is there something else I need?

2) What would I put in [AutoloadEquip(EquipType.xxx)] for an accessory that is not shown on the character's sprite, like the Philosopher's Stone? I can't find an EquipType that works in the github, nor can I find any mods with accessories to peek at that allow extraction.


EDIT:

On a separate note, I am trying to make monsters drop materials to make these accessories, and I've ALMOST got it working. Only problem is that when it decides to give loot on a kill, it gives everything on the kill. Here's how the monster looks right now (It's mostly a shameless zombie clone);

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace My_Mod.NPCs
{
   public class ZombieBunny : ModNPC
   {
     public override void SetStaticDefaults()
     {
       DisplayName.SetDefault("Zombie");
       Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Zombie];
     }

     public override void SetDefaults()
     {
       npc.width = 18;
       npc.height = 40;
       npc.damage = 14;
       npc.defense = 6;
       npc.lifeMax = 200;
       npc.HitSound = SoundID.NPCHit1;
       npc.DeathSound = SoundID.NPCDeath2;
       npc.value = 60f;
       npc.knockBackResist = 0.5f;
       npc.aiStyle = 3;
       aiType = NPCID.Zombie;
       animationType = NPCID.Zombie;
     }

     public override float SpawnChance(NPCSpawnInfo spawnInfo)
     {
       return SpawnCondition.OverworldNightMonster.Chance * 0.5f;
     }
    
     public override void NPCLoot()
     {
       if (Main.rand.Next(5) == 0)
       {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial01"));
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial02"));
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial03"));
       }
     }

     public override void HitEffect(int hitDirection, double damage)
     {
  if (npc.life <= 0)
  {
  Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/gore_ZombieBunny01"), 1f); 
  Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/gore_ZombieBunny02"), 1f);
  Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/gore_ZombieBunny03"), 1f);
  }
  }
     }
   }

How do I change the drops so that it's separate chances for each item? Like, it'll randomly drop one piece, two pieces, two other pieces, or all three.

2. Just don't put that line in there at all.

Edit Q: You need to do something like "if else" or a switch statement. https://github.com/bluemagic123/tMo...pleMod/NPCs/PuritySpirit/PuritySpirit.cs#L785
 
2. Just don't put that line in there at all.

Edit Q: You need to do something like "if else" or a switch statement. https://github.com/bluemagic123/tMo...pleMod/NPCs/PuritySpirit/PuritySpirit.cs#L785

2. Thanks, that was the simple answer and I'm feeling dumb for not even trying that. I'm always worried about snipping parts of working code out.

Edit Q: I managed to finally understand (sort of) how it works, but I hit another snag.

Code:
public override void NPCLoot()
     {
       int choice = Main.rand.Next(10);
       int item = 0;
       switch (choice)
       {
         case 0:
           item = mod.ItemType("craftingmaterial01");
           break;
         case 1:
           item = mod.ItemType("craftingmaterial02");
           break;
         case 2:
           item = mod.ItemType("craftingmaterial03");
           break;
       }
       if (item > 0)
       {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, item);
       }
       else
       {
         choice = Main.rand.Next(100);
         if (choice == 0)
         {
           Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial01"));
         }
         else if (choice == 1)
         {
           Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial02"));
         }
         if (choice == 2)
         {
           Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height,mod.ItemType("craftingmaterial03"));
         }
       }
     }

I spawned over 50 of my monster with that Cheat Sheet mod to test the drop rates, and I ended up with 8, 13, and 9 of my items, in order from the list. I thought the number in Next () was for percentage, but this drop rate doesn't seem to be 1/100. Is there something I need to change, or did I do it right and it's just my playing with Cheat Sheet that makes it seem like I did something wrong? I'm aiming for a 1/100 drop rate, but I'm not sure I got that right.
 
2. Thanks, that was the simple answer and I'm feeling dumb for not even trying that. I'm always worried about snipping parts of working code out.

Edit Q: I managed to finally understand (sort of) how it works, but I hit another snag.

Code:
public override void NPCLoot()
     {
       int choice = Main.rand.Next(10);
       int item = 0;
       switch (choice)
       {
         case 0:
           item = mod.ItemType("craftingmaterial01");
           break;
         case 1:
           item = mod.ItemType("craftingmaterial02");
           break;
         case 2:
           item = mod.ItemType("craftingmaterial03");
           break;
       }
       if (item > 0)
       {
         Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, item);
       }
       else
       {
         choice = Main.rand.Next(100);
         if (choice == 0)
         {
           Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial01"));
         }
         else if (choice == 1)
         {
           Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("craftingmaterial02"));
         }
         if (choice == 2)
         {
           Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height,mod.ItemType("craftingmaterial03"));
         }
       }
     }

I spawned over 50 of my monster with that Cheat Sheet mod to test the drop rates, and I ended up with 8, 13, and 9 of my items, in order from the list. I thought the number in Next () was for percentage, but this drop rate doesn't seem to be 1/100. Is there something I need to change, or did I do it right and it's just my playing with Cheat Sheet that makes it seem like I did something wrong? I'm aiming for a 1/100 drop rate, but I'm not sure I got that right.
You seem to have duplicated your logic for some reason. The first half does a 10% chance each, and then it does a 1% additional chance if that fails, which in total is almost 11% chance. Just delete some of the code. In this case, change the first 10 to 100 and then delete all the else code after the if(item>0)
 
You seem to have duplicated your logic for some reason. The first half does a 10% chance each, and then it does a 1% additional chance if that fails, which in total is almost 11% chance. Just delete some of the code. In this case, change the first 10 to 100 and then delete all the else code after the if(item>0)
Let it be on the record that I'm definitely not smart when it comes to proofreading my work. I literally just copied the code from what you suggested earlier, and tweaked it a bit based entirely on guessing. After making the changes you pointed out, it went as good as I wanted it to. I spawned about 100~ (RIP my mouse), and only got two of the pieces. That's just as rare as I was hoping for, and I got a good slap to the face reminder on what not to do next time. Thank you so much.

EDIT: After thorough testing (read; spawning a lot), it seems that the odds are stacked in favor of the first item. After goodness knows how many spawns, I had 14 of the first, 3 of the second, and one of the third. I can work with this, but is this normal? That feels a bit uneven.
 
Last edited:
Hello modding community, this is my first time posting on modding with Terraria, and I'm hitting quite a few snags. As of this post, I've only attempted modding for one day, and I literally never touched any kind of real coding, so I'm still far below a novice at this sort of thing. I've a few things I'd like help and clarification on, as well as a couple of general questions I could not find the answer to by searching Google, the forums, or asking on other sites. Sprite work is not an issue, especially with how simple it is to mimic the art style in the game (though I wonder why sprites are drawn tiny and upscaled 2x), but coding is something I've never been good with. I spent a good chunk of the day trying to learn how to do this, since I had a lot of free time, and I might've missed stuff in my searching. If I ask something that was answered that I missed, I apologize and would be greatly appreciative if I could be pointed to the post with the answer if that happened.

I also apologize for the wall of text that I'm about to drop. I wanted to be thorough on what I wanted to explain, and it got a bit winded. It's also 4:30 AM when I posted this, so I'm tired when I posted it.

I. Accessories
First, I've been trying to make a few accessories. The first issue is the most obnoxious of the bunch, being that I get this error every time I try to build the mod in the game;
"accessory01.cs(11,30) : error CS0115: 'My_Mod.Items.CustomShield.Autoload(ref string, ref string, System.Collections.Generic.IList<Terraria.ModLoader.EquipType>)': no suitable method found to override"
The code for it is as follows;
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace My_Mod.Items
{
  public class CustomShield : ModItem
  {
  public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
  {
  equips.Add(EquipType.Shield);
  return true;
  }

  public override void SetDefaults()
  {
  item.name = "Mythic Bulwark";
  item.width = 24;
  item.height = 28;
  item.toolTip = "Grants immunity to knockback.";
  item.value = Item.buyPrice(0, 2, 0, 0);
  item.rare = 4;
  item.accessory = true;
  item.defense = 4;

  }
  public override void UpdateAccessory(Player player, bool hideVisual)  // Does this actually hide the shield? I don't want that, how would I remove this safely?
  {
  player.noKnockback = true; 
  }


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

  }
}

I followed a guide on youtube to creating a shield, which was my first accessory choice. I was able to get a proper melee weapon added in, which was surprisingly simple, but accessories seem to be much harder. The error tells me that the item.name line is the problem, but I cannot figure out why as the videos I watch on making mods for tmodloader clearly use the same code with different text. What am I doing wrong with the code that causes the error?

II. Visual Studio Question
The shortest question I have is related to Visual Studio. In the guide on how to set up MVS to work with Terraria, I followed everything step by step. Thankfully, everything does work, and I've had little to no trouble at all getting used to it. Unfortunately, the IntelliSense stated in the opening post of this thread doesn't happen. It'll fill in stuff like "Items" when I try to type "item", but it doesn't fill in anything like I've seen in the opening post or in the tutorials I've watched and read. Is there some small detail I somehow missed?

III. Monsters
On the next topic, I'm also making sprites for monsters. I figured out how to implement basic zombies and slimes, but I only know how to make them spawn at night since the zombie was the first thing I managed to make. I want to make more monsters, specifically things similar to a Wyvern since I want to make bigger monster sprites without going into boss territory (that's biting way too much for a beginner, most likely). I found how to make the zombie as it was the first tutorial I found, but I can't find ANYTHING on how to make a Wyvern. I mainly just want to make variants spawn, much like there's a bunch of zombies, slimes, and skeletons. I just want to have different skins on default Wyvern stats, and I've got a few already sprited. I just can't find the details on a Wyvern. I have access to decompiled data, thanks to Google, but even then I can't find anything at all. Would someone be capable of posting a modded wyvern's code? This is one of my more ambitious goals, even if it's not much.

On two similar notes, how would I increase the movement speed and jump height of the other mentioned enemies, and what are the codes to allow monsters to spawn at certain times and biomes? I want mad hopping skeletons in the purity, zombies running at mach four in the desert, and slimes jumping into space like the dolphins from the Hitchhiker's Guide movie.

IV. Weapons
Next on my questions, and hearkening back to the weapon I mentioned, I don't know how to make them fire projectiles. I'm not aiming to make something absurd like Meowmere and Starwrath, but I just want to make a melee weapon that you upgrade over time that is useful in every tier. I understand how to do the crafting and recipes, since that's incredibly simple, but I've had a hard time finding anything that's not a basic melee weapon. No yoyos, no thrown items, but a normal sword/hammer/axe/fish that has a projectile that progressively gets better as the weapon upgrades. How would I go about making a melee weapon that sends out a projectile?

V. Buffs on Items
My last question can probably be lumped together with the above questions, but I kept it separate because it's also a bit off topic from the above parts. As is evident from the above code, I don't have anything in the way of buffs on the accessory other than knockback resistance. I found a single, incredibly lacking wiki with a few possible things, but half of them didn't work and provided a similar error as stated above. Is there a list with all the buffs that can be applied to accessories and armor?


I'm using Notepad ++ and MSV 2017. I've downloaded the files from the various threads on setting up tmodloader and MSV for Terraria, so I've prepared as best as I could for actually doing this. I just lack the resources and know how to make the very things I want to make.
Incase nobody has explained this yet, you were getting errors in points I and II even though you were following a guide was because Terraria had a update recently that overhauled much of the code. So most guides are out of date now. Dennisw100 showed you one change, but if you find something else from a guide that doesn't work, check the migration guide. And if you haven't found it already, the Example Mod is really useful.

Good luck and happy modding.
 
I'm trying to make armor for the first time (just a vanity hat for now) and this happens:
Items/Armor/BunnyMask_Head
bei Terraria.ModLoader.Mod.GetTexture(String name)
bei Terraria.ModLoader.ModLoader.GetTexture(String name)
bei Terraria.ModLoader.Mod.AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
bei Terraria.ModLoader.Mod.AddEquipTexture(ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
bei Terraria.ModLoader.Mod.AutoloadItem(Type type)
bei Terraria.ModLoader.Mod.Autoload()
bei Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

I literally copied the cs-file and sprites from the BunnyMask example mod after failing at my own thing, same problem. Help?
 
I'm trying to make armor for the first time (just a vanity hat for now) and this happens:
Items/Armor/BunnyMask_Head
bei Terraria.ModLoader.Mod.GetTexture(String name)
bei Terraria.ModLoader.ModLoader.GetTexture(String name)
bei Terraria.ModLoader.Mod.AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
bei Terraria.ModLoader.Mod.AddEquipTexture(ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
bei Terraria.ModLoader.Mod.AutoloadItem(Type type)
bei Terraria.ModLoader.Mod.Autoload()
bei Terraria.ModLoader.ModLoader.do_Load(Object threadContext)

I literally copied the cs-file and sprites from the BunnyMask example mod after failing at my own thing, same problem. Help?
Heist die Png auch BunnyMask_Head weil soweit ich weis sagt der code aus das er das Bild nicht findet
oder hast du beide bild dateine kopiert
 
Question about the 1.3.5 update:


Main.fontDeathText.MeasureString(text13);

We do not use that anymore?
-If yes, where i have fail where before 1.3.5, all work without problem? (Not found the problem on the search button)
-If no, we replace per what? (Because, when i look open source of others mods, they use always the Main.fontDeathText.MeasureString(text13);)


Thank you for your help!
 
I genuinely keep having issues finding things.

1. How do I make a monster glow like the Undead Miner? I can't find the glow in its data.
2. How do I make a monster shimmer, like golden critters? Same as above.
3. What is the line I need to type for the Tsunami in a Bottle's jump? I can't find it at all.
4. Say I wanted to make an upgraded Bundle of Balloons, but only use multiple cloud jumps (no farts, sandstorms, etc). How would I do this?
4. I want to make multiple recipes for the same item, much like Avenger Emblem. How would I do that?


EDIT: I did something wrong again, this time with a pet.

Projectile:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace My_Mod.Projectiles
{
   public class Pet_Ugly : ModProjectile
   {
     public override void SetStaticDefaults()
     {
       DisplayName.SetDefault("Baby Ugly");
       Main.projFrames[projectile.type] = 2;
       Main.projPet[projectile.type] = true;
     }
     
     public override void SetDefaults()
     {
       projectile.CloneDefaults(ProjectileID.BabyEater);
       aiType = ProjectileID.BabyEater;
     }
     
     public override bool PreAI()
     {
       Player player = Main.player[projectile.owner];
       player.BabyEater = false;
       return true;
     }
     
     public override void AI()
     {
       Player player = Main.player[projectile.owner];
       MyPlayer modPlayer = player.GetModPlayer<MyPlayer>(mod);
       if (player.dead)
       {
         modPlayer.Pet = false;
       }
       if (modPlayer.Pet)
       {
         projectile.timeLeft = 2;
       }
     }
   }
}

Buff:
Code:
using Terraria;
using Terraria.ModLoader;

namespace My_Mod.Buffs
{
   public class Pet_UglyBuff : ModBuff
   {
     public override void SetDefaults()
     {
       DisplayName.SetDefault("Baby Ugly");
       Description.SetDefault("A little lovely red thing is following you!");
       Main.buffNoTimeDisplay[Type] = true;
       Main.vanityPet[Type] = true;
     }
     
     public override void Update(Player player, ref int buffIndex)
     {
       player.buffTime(buffIndex) = 18000;
       player.GetModPlayer<MyPlayer>(mod).Pet = true;
       bool petProjectileNotSpawned = player.ownedProjectileCounts[mod.ProjectileType("Pet_UglyBuff")] <= 0;
       if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer)
       {
         Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, mod.ProjectileType("Pet_UglyBuff"), 0, 0f, player.whoAmI, 0f, 0f);
       }
     }
   }
}

Item:
Code:
using Terraria;
using Terraria.ModLoader;

namespace My_Mod.Buffs
{
   public class Pet_UglyBuff : ModBuff
   {
     public override void SetDefaults()
     {
       DisplayName.SetDefault("Baby Ugly");
       Description.SetDefault("A little lovely red thing is following you!");
       Main.buffNoTimeDisplay[Type] = true;
       Main.vanityPet[Type] = true;
     }
     
     public override void Update(Player player, ref int buffIndex)
     {
       player.buffTime(buffIndex) = 18000;
       player.GetModPlayer<MyPlayer>(mod).Pet = true;
       bool petProjectileNotSpawned = player.ownedProjectileCounts[mod.ProjectileType("Pet_UglyBuff")] <= 0;
       if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer)
       {
         Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, mod.ProjectileType("Pet_UglyBuff"), 0, 0f, player.whoAmI, 0f, 0f);
       }
     }
   }
}

The errors are as follows;

Code:
c:\Users\Harble01-A\Documents\My Games\Terraria\ModLoader\Mod Sources\My_Mod\Buffs\Pet_UglyBuff.cs(18,11) : error CS1955: Non-invocable member 'Terraria.Player.buffTime' cannot be used like a method.

c:\Users\Harble01-A\Documents\My Games\Terraria\ModLoader\Mod Sources\My_Mod\Projectiles\Pet_Ugly.cs(25,11) : error CS1061: 'Terraria.Player' does not contain a definition for 'BabyEater' and no extension method 'BabyEater' accepting a first argument of type 'Terraria.Player' could be found (are you missing a using directive or an assembly reference?)

I followed the ExamplePet stuff, swapping out Zephyr Fish for Baby Eater and the stuff I assumed was supposed to be added/replaced. Clearly I screwed up, but I can't seem to understand the points it's trying to tell me. BabyEater is what the Baby Eater pet is called in the files, just like ZephyrFish is Zephyr Fish, so I'm even more clueless on that part.
 
Last edited:
Question about the 1.3.5 update:


Main.fontDeathText.MeasureString(text13);

We do not use that anymore?
-If yes, where i have fail where before 1.3.5, all work without problem? (Not found the problem on the search button)
-If no, we replace per what? (Because, when i look open source of others mods, they use always the Main.fontDeathText.MeasureString(text13);)


Thank you for your help!
I tested "Main.NewText("" + Main.fontDeathText.MeasureString("thing"));" and got the result {X:99, Y:72}. Is that normal? Could it be that "text13" isn't a string somehow?
 
I tested "Main.NewText("" + Main.fontDeathText.MeasureString("thing"));" and got the result {X:99, Y:72}. Is that normal? Could it be that "text13" isn't a string somehow?
I am stupid, i have forgot to put the error:

Gravité Code Description Projet Fichier Ligne État de la suppression
Erreur CS0012 Le type 'DynamicSpriteFont' est défini dans un assembly qui n'est pas référencé. Vous devez ajouter une référence à l'assembly 'ReLogic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

And when i try to add the ReLogic.dll like examplemod:
A reference to the "....dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component.


But i have badly search and i have found my answer, sorry for all ^^. (I have just forgot to download a "cracked" Relogic.dll and i want use the vanilla, ah ah)
 
I have a question:
I want to make a sawblade staff, e.g. it summons a melee sawblade that flies around and attacks enemies close to the player, similar to the deadly sphere staff or the optic staff, except for the fact that when a sawblade starts attacking an enemy, it locks onto it.
 
After many trials and errors, and with help from outside sources, I manageed to finally get two of my goals to finally work. Unfortunately, I've hit some problems.

First is with custom pets. The item, buff, projectile work perfectly, granting me the pets I so desired. Unfortunately, when I equip another item or remove the modded pet item, the buff remains until it is clicked off. I have two modded pets, and this lets me have both out along with another vanilla pet. Below is the code for one of the pets (Both pets share the exact same code), and the Player.cs file. What do I need to change to make it so that the pet buff falls off when the item is removed? While it's nice to have multiple pets, I do want it to work correctly.

Projectile:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace My_Mod.Projectiles
{
  public class Pet_BrainofConfusion : ModProjectile
  {
  public override void SetDefaults()
  {
  projectile.CloneDefaults(ProjectileID.ZephyrFish);
  aiType = ProjectileID.ZephyrFish;
  Main.projFrames[projectile.type] = 4;
  Main.projPet[projectile.type] = true;
  }
  public override void AI()
  {
  Player player = Main.player[projectile.owner];
  MyPlayer modPlayer = player.GetModPlayer<MyPlayer>(mod);
  if (player.dead)
  {
  modPlayer.Pet_BrainofConfusion = false;
  }
  if (modPlayer.Pet_BrainofConfusion)
  {
  projectile.timeLeft = 2;
  }
  }
  }
}

Buff:
Code:
using Terraria;
using Terraria.ModLoader;

namespace My_Mod.Buffs
{
   public class Pet_BrainofConfusionBuff : ModBuff
   {
     public override void SetDefaults()
     {
       DisplayName.SetDefault("Brain of Confusion");
       Description.SetDefault("Such a cute little abomination!");
       Main.buffNoTimeDisplay[Type] = true;
       Main.vanityPet[Type] = true;
     }
     
     public override void Update(Player player, ref int buffIndex)
     {
       player.buffTime[buffIndex] = 18000;
       player.GetModPlayer<MyPlayer>(mod).Pet = true;
       bool petProjectileNotSpawned = player.ownedProjectileCounts[mod.ProjectileType("Pet_BrainofConfusion")] <= 0;
       if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer)
       {
         Projectile.NewProjectile(player.position.X + (float)(player.width / 2), player.position.Y + (float)(player.height / 2), 0f, 0f, mod.ProjectileType("Pet_BrainofConfusion"), 0, 0f, player.whoAmI, 0f, 0f);
       }
     }
   }
}

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

namespace My_Mod.Items
{
   public class Pet_BrainofConfusionSummon : ModItem
   {
     public override void SetStaticDefaults()
     {
       DisplayName.SetDefault("Brain of Cthulhu");
       Tooltip.SetDefault("It's moving!");
     }
     public override void SetDefaults()
     {
       item.shoot = mod.ProjectileType("Pet_BrainofConfusion");
       item.buffType = mod.BuffType("Pet_BrainofConfusionBuff");
       item.width = 26;
       item.height = 28;
       item.maxStack = 1;
       item.value = 500;
       item.rare = 1;
       item.expert = true;
     }
     
     public override void AddRecipes()
     {
       ModRecipe recipe = new ModRecipe(mod);
  recipe.AddIngredient(ItemID.BrainOfConfusion, 1);
       recipe.AddTile(TileID.WorkBenches);
       recipe.SetResult(this);
       recipe.AddRecipe();
     }
     public override void UseStyle(Player player)
     {
       if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
       {
         player.AddBuff(item.buffType, 3600, true);
       }
     }
   }
}

Player.cs (named "MyPlayer" for references in other files):
Code:
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
using Terraria.GameInput;

namespace My_Mod
{
   public class MyPlayer : ModPlayer
   {
     private const int saveVersion = 0;
     public bool minionName = false;
     public bool Pet_BrainofConfusion = false;
     public bool Pet_Crimera = false;
     public bool Pet = false;
     public static bool hasProjectile;
     
     public override void ResetEffects()
     {
       minionName = false;
       Pet = false;
     }
   }
}
Note; I have two modded pets. Both use the exact same code, just with different names and sprites. The problem occurred when I had only one pet, so the issue is not because I have two modded pets. I tried removing the second pet entirely, and the problem still persisted.

Second question, hopefully less complex; I've got eight banners, each on one row. Each banner is dropped at 50 kill increments on my modded monsters, but only two banners work. When placed, they all look right, but only the first two banners work as banners. Even more baffling is that when broken, the banners that don't work just disappear; no item is retrieved. Below is one of the banners that does not work, followed by one that does work; what do I need to do to make all banners work correctly?

Not Working (last sprite on the banner sheet);
Code:
using Terraria;
using Terraria.ModLoader;

namespace My_Mod.Items.Banners
{
   public class BannerSharkron : ModItem
   {
     public override void SetStaticDefaults()
  {
  DisplayName.SetDefault("Sharkron Banner");
     }
     
     public override void SetDefaults()
     {
       item.width = 10;
       item.height = 24;
       item.maxStack = 99;
       item.useTurn = true;
       item.autoReuse = true;
       item.useAnimation = 15;
       item.useTime = 10;
       item.useStyle = 1;
       item.consumable = true;
       item.rare = 1;
       item.value = Item.buyPrice(0, 0, 10, 0);
       item.createTile = mod.TileType("BannersMonsters");
       item.placeStyle = 7;
     }
   }
}

Working (First sprite on the banner sheet);
Code:
using Terraria;
using Terraria.ModLoader;

namespace My_Mod.Items.Banners
{
   public class BannerZombieGuide : ModItem
   {
     public override void SetStaticDefaults()
  {
  DisplayName.SetDefault("Zombie Guide Banner");
     }
     
     public override void SetDefaults()
     {
       item.width = 10;
       item.height = 24;
       item.maxStack = 99;
       item.useTurn = true;
       item.autoReuse = true;
       item.useAnimation = 15;
       item.useTime = 10;
       item.useStyle = 1;
       item.consumable = true;
       item.rare = 1;
       item.value = Item.buyPrice(0, 0, 10, 0);
       item.createTile = mod.TileType("BannersMonsters");
       item.placeStyle = 0;
     }
   }
}
 
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace WeirdStuff.Items
{
public class Large Crystal : ModItem
{
public override void SetDefaults()
{
item.name = "Large_Crystal";
item.width = 30;
item.height = 30;
item.maxStack = 999;
AddTooltip("Shiny,isn't it".);
item.value = 100;
item.rare = 1;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}
public override bool CanUseItem(Player player)
{
return !NPC.AnyNPCs(mod.NPCType("Crystal_Lord")); //you can't spawn this boss multiple times
return !Main.dayTime; //can use only at night
}
public override bool UseItem(Player player)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Crystal_Lord")); //boss spawn
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);

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

(Im getting the CS1514 error pls help and Im using 1.3.4.4)
 
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace WeirdStuff.Items
{
public class Large Crystal : ModItem
{
public override void SetDefaults()
{
item.name = "Large_Crystal";
item.width = 30;
item.height = 30;
item.maxStack = 999;
AddTooltip("Shiny,isn't it".);
item.value = 100;
item.rare = 1;
item.useAnimation = 30;
item.useTime = 30;
item.useStyle = 4;
item.consumable = true;
}
public override bool CanUseItem(Player player)
{
return !NPC.AnyNPCs(mod.NPCType("Crystal_Lord")); //you can't spawn this boss multiple times
return !Main.dayTime; //can use only at night
}
public override bool UseItem(Player player)
{
NPC.SpawnOnPlayer(player.whoAmI, mod.NPCType("Crystal_Lord")); //boss spawn
Main.PlaySound(15, (int)player.position.X, (int)player.position.Y, 0);

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

(Im getting the CS1514 error pls help)
What tModLoader are you running.

You can't have two return statements without conditionals, mostly because the other one will never be reached, so you would need to merge the two with "&&".
 
Back
Top Bottom