Help fixing a pet mod made by someone who has no idea what they're doing?

Zinniavanilla

Terrarian
Hi. I'm playing through Terraria with my boyfriend and I wanted to make him a pet mod. Problem is I've never touched modding Terraria before. I've been trying my best but I've gotten stuck. Here's my code.

Pet Buff
using Terraria;
using Terraria.ModLoader;

namespace MyModForDummy.Buffs
{
public class Jaxx : ModBuff
{
public override void SetDefaults()
{
// DisplayName and Description are automatically set from the .lang files, but below is how it is done normally.
DisplayName.SetDefault("Jaxx");
Description.SetDefault("\"He Loves You!\"");
Main.buffNoTimeDisplay[Type] = true;
Main.vanityPet[Type] = true;
}

public override void Update(Player player, ref int buffIndex)
{
player.buffTime[buffIndex] = 18000;
player.GetModPlayer<MyModForDummyPlayer>().Jaxx = true;
bool petProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType<Projectiles.Pets.Jaxx>()] <= 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, ModContent.ProjectileType<Projectiles.Pets.Jaxx>(), 0, 0f, player.whoAmI, 0f, 0f);
}
}
}
}

Pet Item:
using MyModForDummy.Items;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MyModForDummy.Items
{
public class Jaxx : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Jaxx");
Tooltip.SetDefault("He Loves You!");
}

public override void SetDefaults()
{
Item.CloneDefaults(ItemID.ZephyrFish);
Item.shoot = ModContent.ProjectileType<Projectiles.Pets.Jaxx>();
Item.buffType = ModContent.BuffType<Buffs.Jaxx>();
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(Mod);
recipe.AddIngredient(ItemID.Banana);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(ModContent.ItemType<Jaxx>);
recipe.AddRecipe();
}

public override void UseStyle(Player player)
{
if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
{
player.AddBuff(Item.buffType, 3600, true);
}
}
}
}


Pet Projectile
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MyModForDummy.Projectiles.Pets
{
public class Jaxx : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Jaxx");
Main.projFrames[Projectile.type] = 4;
Main.projPet[Projectile.type] = true;
}

public override void SetDefaults()
{
Projectile.CloneDefaults(ProjectileID.ZephyrFish);
AIType = ProjectileID.ZephyrFish;
}

public override bool PreAI()
{
Player player = Main.player[Projectile.owner];
player.zephyrfish = false; // Relic from aiType
return true;
}

public override void AI()
{
Player player = Main.player[Projectile.owner];
ExamplePlayer modPlayer = player.GetModPlayer<ExamplePlayer>();
if (player.dead)
{
modPlayer.Jaxx = false;
}
if (modPlayer.Jaxx)
{
Projectile.timeLeft = 2;
}
}
}
}

TModLoader warns me of 10 errors and gives me "No Suitable method to override" error.
I don't understand how to implement the "modplayer/ExamplePlayer"
ModRecipe isn't recognized as correct no matter what I do.

Thank you to anyone who can help me.
 
It seems like you're basing this off of ExampleMod. What you're missing is the actual ExamplePlayer file, in the root directory of the mod here. tModLoader/ExampleMod at master · tModLoader/tModLoader

1646133183857.png
 
Can you post a screenshot of the exact error? I'm comparing your code to ExampleMod and my own modded pets, and what you have seems to be correct.

Are you sure the folder structures and namespaces all match? For example, the filepath for the buff should be Mod Sources/MyModForDummy/Buffs/Jaxx.cs
 
Can you post a screenshot of the exact error? I'm comparing your code to ExampleMod and my own modded pets, and what you have seems to be correct.

Are you sure the folder structures and namespaces all match? For example, the filepath for the buff should be Mod Sources/MyModForDummy/Buffs/Jaxx.cs
File.png


File2.png


After some more fecking about I'm left now with these errors.

The Usestyle one I think might be caused by the ExampleMod being slightly outdated? I had to change the way the recipe was written for that reason, but I'm unsure of the proper way to write it. The underlined "0f,"s at the end in the first screenshot seem to be also caused by an issue with "float".
 
So your code for UseStyle and Projectile.NewProjectile look exactly the same as mine. Here's UseStyle since I can't see your whole code block.

Code:
        public override void UseStyle(Player player)
        {
            if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
            {
                player.AddBuff(item.buffType, 3600, true);
            }
        }

Have you tried compiling the mod in tmodloader itself? The code I am using compiles just fine. Also, I should ask, are you using the 1.4 alpha of Tmodloader? Or Tmodloader for 1.3.5.3?
 
So your code for UseStyle and Projectile.NewProjectile look exactly the same as mine. Here's UseStyle since I can't see your whole code block.

Code:
        public override void UseStyle(Player player)
        {
            if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
            {
                player.AddBuff(item.buffType, 3600, true);
            }
        }

Have you tried compiling the mod in tmodloader itself? The code I am using compiles just fine. Also, I should ask, are you using the 1.4 alpha of Tmodloader? Or Tmodloader for 1.3.5.3?
Hmm. I'm using 1.4, I believe.

I'll try compiling when I'm able to use my laptop, I think I've done it but it wouldn't hurt.
 
I'd recommend actually hopping on the tmodloader discord and asking for help with the 1.4 version of tmodloader. There have been changes, but I'm not familiar with them myself.
 
Back
Top Bottom