tModLoader Official tModLoader Help Thread

Oh, thanks for the reminder. :)
Also, the images don't show up for me as well, it just brings me to an error page. o_O
Also also, which category in Discord would be best to ask my question above? Getting confused between "General", "Support" and "Off Topic".
Help for code questions
 
Have you figured this out yet? I know the person above recommended that you visit the discord server, which makes tracking the problem a little difficult for those of us still on TCF.
If you still need help, I'm pretty sure its because you are using .jpg, which I don't believe is a valid tModloader format - try switching to .png.
I was using JPG and I didn't realize- although I already fixed it. Thanks anyways.
 
  • Like
Reactions: 000
Im having trouble with world generation, i keep getting this error: c:\Users\user-1\Documents\My Games\Terraria\ModLoader\Mod Sources\BeastPack\MyWorld.cs(20,21) : error CS1518: Expected class, delegate, enum, interface, or struct // Heres my code:
Code:
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;
using System.Linq;


namespace BeastPack
{
    public class BeastPackWorld : ModWorld
    {
        public static bool spawnOre = false;
        public static bool spawnOreComet = false;

    }
}
        public override void OreComet()
    {
        int x = Main.rand.Next(0, Main.maxTilesX);
        int y = Main.worldSurface - 200;
        int[] tileIDs = { 189, 202, 196 };
        if (Main.tile[x, y].type <= -1)
        {
            y--;
        }
        else
        {
            WorldGen.TileRunner(x, y, 2, 4, tileIDs[Main.rand.Next(tileIDs.Length)], false, 0f, 0f, true, true);
            return;
        }
    }
 
Im having trouble with world generation, i keep getting this error: c:\Users\user-1\Documents\My Games\Terraria\ModLoader\Mod Sources\BeastPack\MyWorld.cs(20,21) : error CS1518: Expected class, delegate, enum, interface, or struct // Heres my code:
Code:
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;
using System.Linq;


namespace BeastPack
{
    public class BeastPackWorld : ModWorld
    {
        public static bool spawnOre = false;
        public static bool spawnOreComet = false;

    }
}
        public override void OreComet()
    {
        int x = Main.rand.Next(0, Main.maxTilesX);
        int y = Main.worldSurface - 200;
        int[] tileIDs = { 189, 202, 196 };
        if (Main.tile[x, y].type <= -1)
        {
            y--;
        }
        else
        {
            WorldGen.TileRunner(x, y, 2, 4, tileIDs[Main.rand.Next(tileIDs.Length)], false, 0f, 0f, true, true);
            return;
        }
    }
You have everything after spawnOreComet outside of the class.
 
new error, c:\Users\user-1\Documents\My Games\Terraria\ModLoader\Mod Sources\BeastPack\MyWorld.cs(21,21) : error CS0266: Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
Code:
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;
using System.Linq;


namespace BeastPack
{
    public class BeastPackWorld : ModWorld
    {
        public static bool spawnOre = false;
        public static bool spawnOreComet = false;

        public void OreComet()
        {
            int x = Main.rand.Next(0, Main.maxTilesX);
            int y = Main.worldSurface - 200;
            int[] tileIDs = { 189, 202, 196 };
            if (Main.tile[x, y].type <= -1)
            {
                y--;
            }
            else
            {
                WorldGen.TileRunner(x, y, 2, 4, tileIDs[Main.rand.Next(tileIDs.Length)], false, 0f, 0f, true, true);
                return;
            }
        }
    }
}
[/QUOTE]
 
Hi, I've made a projectile that works in basically the same way as a drill, but without the sound/dust. It doesn't deal damage however, which is annoying because that's the whole point of it. Here's the projectile's code:

Code:
using System;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.DataStructures;

namespace Testmod.Projectiles
{
    public class TestalisProjectile : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.damage = 30;
            projectile.melee = true;
            projectile.knockBack = 2;
            projectile.width = 15;
            projectile.height = 50;
            projectile.timeLeft = 5;
            projectile.hostile = false;
            projectile.friendly = true;
            projectile.penetrate = -1;
            projectile.scale = 1f;
            projectile.tileCollide = false;
            projectile.hide = false;
            projectile.ownerHitCheck = false;
        }
        public override void AI()
        {
            int owner = projectile.owner;
            Vector2 vector23 = Main.player[owner].RotatedRelativePoint(Main.player[owner].MountedCenter, true);
            if (Main.myPlayer == owner)
            {
                if (Main.player[owner].channel)
                {
                    float num264 = Main.player[owner].inventory[Main.player[owner].selectedItem].shootSpeed * projectile.scale;
                    Vector2 vector24 = vector23;
                    float num265 = (float)Main.mouseX + Main.screenPosition.X - vector24.X;
                    float num266 = (float)Main.mouseY + Main.screenPosition.Y - vector24.Y;
                    if (Main.player[owner].gravDir == -1f)
                    {
                        num266 = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector24.Y;
                    }
                    float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266));
                    num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266));
                    num267 = num264 / num267;
                    num265 *= num267;
                    num266 *= num267;
                    if (num265 != projectile.velocity.X || num266 != projectile.velocity.Y)
                    {
                        projectile.netUpdate = true;
                    }
                    projectile.velocity.X = num265;
                    projectile.velocity.Y = num266;
                }
                else
                {
                    projectile.Kill();
                }
            }
            if (projectile.velocity.X > 0f)
            {
                Main.player[owner].ChangeDir(1);
            }
            else if (projectile.velocity.X < 0f)
            {
                Main.player[owner].ChangeDir(-1);
            }
            projectile.spriteDirection = projectile.direction;
            Main.player[owner].ChangeDir(projectile.direction);
            Main.player[owner].heldProj = projectile.whoAmI;
            Main.player[owner].itemTime = 1;
            Main.player[owner].itemAnimation = 1;
            projectile.position.X = vector23.X - (float)(projectile.width / 2);
            projectile.position.Y = vector23.Y - (float)(projectile.height / 2);
            projectile.rotation = (float)(Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.5700000524520874);
            if (Main.player[owner].direction == 1)
            {
                Main.player[owner].itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction));
            }
            else
            {
                Main.player[owner].itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction));
            }
            projectile.position.X -= 8.5f;
        }
    }
}

And here's the item that "fires" this projectile, in case that has anything to do with it:

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

namespace Testmod.Items
{
    public class Testalis : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Testalis");
            Tooltip.SetDefault("This is a fairly interesting weapon.");
        }
        public override void SetDefaults()
        {
            item.damage = 30;
            item.melee = true;
            item.width = 15;
            item.height = 50;
            item.useTime = 5;
            item.useAnimation = 5;
            item.noUseGraphic = true;
            item.noMelee = true;
            item.useStyle = 5;
            item.knockBack = 2;
            item.value = 3500;
            item.rare = 2;
            item.UseSound = null;
            item.autoReuse = true;
            item.shoot = mod.ProjectileType("TestalisProjectile");
            item.shootSpeed = 85f;
        }

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

While I'd prefer to be walked through the process of making the projectile damage enemies, any resources that may help would be nice too!

EDIT: the problem has been fixed! I just changed the use style on the item and made it invisible, whilst making sure the projectile only terminated after a few frames.
 
Last edited:
Can some one help me work out how to craft something made out of mythril also be made of its counterpart Orichalcum

i need
Adamantite/Titanium
Cobalt/Palladium
Mythril/Orichalcum
[doublepost=1526196510,1526196450][/doublepost]
Can some one help me work out how to craft something made out of mythril also be made of its counterpart Orichalcum

i need
Adamantite/Titanium
Cobalt/Palladium
Mythril/Orichalcum
because ive had no help so far
 
Can some one help me work out how to craft something made out of mythril also be made of its counterpart Orichalcum

i need
Adamantite/Titanium
Cobalt/Palladium
Mythril/Orichalcum
[doublepost=1526196510,1526196450][/doublepost]
because ive had no help so far
I believe this is covered in the intermediate recipe guide on the tmodloader wiki. Look for recipegroups
 
what does this mean
Could not find a part of the path 'C:\Users\------\Documents\My Games\Terraria\ModLoader\Mods\compile_temp\Ionic.Zip.Reduced.dll'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at Terraria.ModLoader.ModCompile.GetTerrariaReferences(String tempDir, Boolean forWindows)
at Terraria.ModLoader.ModCompile.CompileMod(BuildingMod mod, List`1 refMods, Boolean forWindows, Byte[]& dll, Byte[]& pdb)
at Terraria.ModLoader.ModCompile.Build(BuildingMod mod, IBuildStatus status)
at Terraria.ModLoader.ModCompile.Build(String modFolder, IBuildStatus status)
at Terraria.ModLoader.ModLoader.<>c.<BuildMod>b__72_0(Object _)
 
i have a steam version 1.3.5 for mac, and follow exactly the rules of tmodloader installation, but the game dont start. i see the logo and then, when de game suppose to start: black screen forever. any solution?
 
when i go to link my mod to github i get
upload_2018-5-14_17-23-52.png
and i have made a repository but the mod dosn't work without one as well so i am very confused
[doublepost=1526282847,1526282697][/doublepost]
tryed that
[doublepost=1526282866][/doublepost]doesnt say how
 
How do I make it so that the weapon spawns a projectile on your cursor and not from the weapon itself?
You would need a Shoot hook that looks something like this.
Code:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
    if (Main.myPlayer == player.whoAmI) //only on this client
    {
        int projectileID = Projectile.NewProjectile(Main.MouseWorld.X, Main.MouseWorld.Y, 0, 0, item.shoot, damage, knockBack, player.whoAmI); //Create the projectile at the mouse's position
        if (Main.netMode == 1) //when playing as a client
        {
            NetMessage.SendData(27, -1, -1, null, projectileID); //update the server and all other clients
        }
    }
    return false; //don't shoot the projectile automatically, I've just done it manually
}
This is assuming that you have set item.shoot to the projectile ID that you want, and that you want it shot with zero velocity.
 
I've been wondering if there is any fix to the server framerate issue. It has been happening everytime i play on my server with a Friend, but there isn't any lag while i'm in singleplayer tho.
Can anyone help ?
 
I've been wondering if there is any fix to the server framerate issue. It has been happening everytime i play on my server with a Friend, but there isn't any lag while i'm in singleplayer tho.
Can anyone help ?
If your computer can't handle the game turn off background and put graphics low its helps, If that isn't the problem check your internet connection, If that still isn't the problem it is the connection between you and your friend. I doubt it is tmodloader that is the problem..
 
Back
Top Bottom