tModLoader Official tModLoader Help Thread

I get this every time I open tmod, I've deleted the tmodloader files and terraria files multiple times, no change.
 

Attachments

  • image_2022-07-27_161439800.png
    image_2022-07-27_161439800.png
    17.8 KB · Views: 84
hello, I have a mod and I accidentally deleted it and didn't back it up. I didn't enable PBD or show code in the build. All it shows when I extract it is the "Extract" folder. Does anyone know how I can get my mod back? I spent a really long time on it, and want to get it back. Any help appreciated!
 
How do you make an NPC do something upon collision with a tile? Specifically, how can you make an NPC convert a tile into a different type on collision?
 
How do I animate a sword

This is my current code

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Gradient.Items
{
public class Masamuree : ModItem
{
public override void SetStaticDefaults()
{
// DisplayName.SetDefault("Masamuree"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Great for impersonating devs!");
}

public override void SetDefaults()
{
Item.damage = 15000;
Item.DamageType = DamageClass.Melee;
Item.width = 40;
Item.height = 76;
Item.useTime = 11;
Item.useAnimation = 11;
Item.useStyle = 1;
Item.knockBack = 13;
Item.value = 0;
Item.rare = 9;
Item.UseSound = SoundID.Item1;
Item.autoReuse = false;
}

public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ModContent.ItemType<Items.SnackticalsHeart>(), 1);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}

And this is the sprite I want to use
Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(12, 11));
Also anyone know how to make a projectile shoot another projectile at all?
 
Hello, I'm not sure if this is the right place to ask for help, but my tModloader has been crashing on launch consistently. I haven't played the game in about two weeks, and I'm met with the error message below every time. I have tried clean reinstallations, updating graphics drivers, and running steam as an administrator, and none of these solutions have had any success. I can't find any other solutions, so help would be greatly appreciated.

8/13/2022 11:56:21 AM
System.Exception: Multiple extensions for asset Localization\en-US, (.json, )
at ReLogic.Content.Sources.ContentSource.SetAssetNames(IEnumerable`1 paths) in D:\a\tModLoader\tModLoader\src\tModLoader\ReLogic\Content\Sources\ContentSource.cs:line 28
at ReLogic.Content.Sources.FileSystemContentSource..ctor(String basePath) in D:\a\tModLoader\tModLoader\src\tModLoader\ReLogic\Content\Sources\FileSystemContentSource.cs:line 20
at Terraria.IO.ResourcePack.GetContentSource() in tModLoader\Terraria\IO\ResourcePack.cs:line 97
at Terraria.GameContent.AssetSourceController.<>c.<UseResourcePacks>b__13_1(ResourcePack pack) in tModLoader\Terraria\GameContent\AssetSourceController.cs:line 47
at System.Linq.Enumerable.SelectIPartitionIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at Terraria.GameContent.AssetSourceController.UseResourcePacks(ResourcePackList resourcePacks) in tModLoader\Terraria\GameContent\AssetSourceController.cs:line 45
at Terraria.Main.LoadContent() in tModLoader\Terraria\Main.cs:line 8620
at Terraria.Main.Initialize() in tModLoader\Terraria\Main.cs:line 5167
at Microsoft.Xna.Framework.Game.DoInitialize() in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 779
at Microsoft.Xna.Framework.Game.Run() in D:\a\tModLoader\tModLoader\FNA\src\Game.cs:line 411
at Terraria.Program.LaunchGame_(Boolean isServer) in tModLoader\Terraria\Program.cs:line 235
 
im having issues with my server

[22:51:22.244] [.NET ThreadPool Worker/ERROR] [tML]: Unhandled Exception
System.IO.IOException: The process cannot access the file 'C:\Users\Lumeside\Documents\My Games\Terraria\tModLoader\Worlds\Takuache_Truck_MEET.wld' because it is being used by another process.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.File.ReadAllBytes(String path)
at Terraria.Utilities.FileUtilities.ReadAllBytes(String path, Boolean cloud) in tModLoader\Terraria\Utilities\FileUtilities.cs:line 70
at Terraria.IO.WorldFile.InternalSaveWorld(Boolean useCloudSaving, Boolean resetTime) in tModLoader\Terraria\IO\WorldFile.cs:line 544
at Terraria.IO.WorldFile.<>c__DisplayClass57_0.<SaveWorld>b__0() in tModLoader\Terraria\IO\WorldFile.cs:line 500
at Terraria.Utilities.FileUtilities.ProtectedInvoke(Action action) in tModLoader\Terraria\Utilities\FileUtilities.cs:line 170
at Terraria.IO.WorldFile.SaveWorld(Boolean useCloudSaving, Boolean resetTime) in tModLoader\Terraria\IO\WorldFile.cs:line 499
at Terraria.IO.WorldFile.SaveWorld() in tModLoader\Terraria\IO\WorldFile.cs:line 476
at Terraria.WorldGen.saveAndPlayCallBack(Object threadContext) in tModLoader\Terraria\WorldGen.cs:line 2630
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()


kinda just confused what this all means
 
Is promoting a mod that ports old-gen content back into 1.4 allowed on the forums? I've read the pinned posts but am still confused on this. If this isn't the right place to ask sorry but I don't know where else to
 
Is promoting a mod that ports old-gen content back into 1.4 allowed on the forums? I've read the pinned posts but am still confused on this. If this isn't the right place to ask sorry but I don't know where else to

It used to be illegal to link to mods on the forums that had old gen items in them, but after 1.3 I think, the restriction was lifted and now they're allowed
 
So I downloaded Tmodloader from steam and when I open it, it looks like this. I have tried reinstalling it. Verifying files on both Terraria and Tmodloader but I can't make it work. I need help. I'm running Windows 7 Ultimate 64bit 4Gb Ram. Terraria works just fine.
 

Attachments

  • 20220818_004110.jpg
    20220818_004110.jpg
    1.1 MB · Views: 75
Hi. I have a problem with the BusyBox. When I want to run tML it crashes and a BusyBox appears instead. Idk what it says (BusyBox appears just for a couple of seconds), tML still does not start. Checking on Steam shows that all the files are in place, so its inscriptions that something is missing are stupid :[
tml.png
 
So im wanting to make an upgraded zenith and im new to modding, i want it to have the same attack animation but dont know what to do. this is what i have so far. Ingame it still swings the sword in hand, and also the attack animation is small, centered on the player, and has no other swords in it.
 

Attachments

  • Screenshot 2022-08-28 214957.png
    Screenshot 2022-08-28 214957.png
    90.6 KB · Views: 49
Hey, i got this error on tmod loader, tried fresh installing tmod, terraria and steam, but nothing worked. Any help please?
8/29/2022 6:01:34 PM
System.DllNotFoundException: Unable to load DLL 'C:\Users\Adrian\Desktop\tModLoader\Libraries\Native\Windows\FAudio.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String libraryName, Boolean throwOnError)
at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath)
at MonoLaunch.ResolveNativeLibrary(Assembly assembly, String name) in tModLoader\Terraria\MonoLaunch.cs:line 86
at System.Runtime.Loader.AssemblyLoadContext.GetResolvedUnmanagedDll(Assembly assembly, String unmanagedDllName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDllUsingEvent(String unmanagedDllName, Assembly assembly, IntPtr gchManagedAssemblyLoadContext)
at FAudio.FAudioLinkedVersion()
at Terraria.ModLoader.Engine.FNALogging.RedirectLogs() in tModLoader\Terraria\ModLoader\Engine\FNALogging.cs:line 88
at Terraria.ModLoader.Logging.LogStartup(Boolean dedServ) in tModLoader\Terraria\ModLoader\Logging.cs:line 88
at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 187
 
I'm trying to do UI in tModLoader 1.4, I'm not getting any errors, but it's not appearing. What is wrong with it?

UI Code
C#:
using GalacticMod.Assets.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.GameContent;
using Terraria.GameContent.UI.Elements;
using Terraria.ModLoader;
using Terraria.UI;
using static Terraria.ModLoader.ModContent;

namespace GalacticMod.UI
{
    internal class OsmiumSoulBar : UIState
    {
        // For this bar we'll be using a frame texture and then a gradient inside bar, as it's one of the more simpler approaches while still looking decent.
        // Once this is all set up make sure to go and do the required stuff for most UI's in the Mod class.
        private UIText text;
        private UIElement area;
        private UIImage barFrame;
        private Color gradientA;
        private Color gradientB;

        public override void OnInitialize()
        {
            // Create a UIElement for all the elements to sit on top of, this simplifies the numbers as nested elements can be positioned relative to the top left corner of this element.
            // UIElement is invisible and has no padding. You can use a UIPanel if you wish for a background.
            area = new UIElement();
            area.Left.Set(-area.Width.Pixels - 600, 1f); // Place the resource bar to the left of the hearts.
            area.Top.Set(30, 0f); // Placing it just a bit below the top of the screen.
            area.Width.Set(182, 0f); // We will be placing the following 2 UIElements within this 182x60 area.
            area.Height.Set(60, 0f);

            barFrame = new UIImage(Request<Texture2D>("GalacticMod/UI/OsmiumSoulsBar", AssetRequestMode.ImmediateLoad));
            barFrame.Left.Set(22, 0f);
            barFrame.Top.Set(0, 0f);
            barFrame.Width.Set(100, 0f);
            barFrame.Height.Set(20, 0f);

            text = new UIText("0/0", 0.8f); // text to show stat
            text.Width.Set(100, 0f);
            text.Height.Set(20, 0f);
            text.Top.Set(40, 0f);
            text.Left.Set(0, 0f);

            gradientA = new Color(255, 128, 54); //light orange
            gradientB = new Color(191, 70, 0); //dark orange

            area.Append(text);
            area.Append(barFrame);
            Append(area);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            // This prevents drawing unless we are using an ExampleDamageItem
            if (!Main.LocalPlayer.GetModPlayer<GalacticPlayer>().OsmiumDamage)
            {
                return;
            }

            base.Draw(spriteBatch);
        }

        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            base.DrawSelf(spriteBatch);

            var modPlayer = Main.LocalPlayer.GetModPlayer<GalacticPlayer>();
            // Calculate quotient
            float quotient = (float)modPlayer.osmiumSouls / modPlayer.osmiumSoulsMax; // Creating a quotient that represents the difference of your currentResource vs your maximumResource, resulting in a float of 0-1f.
            quotient = Utils.Clamp(quotient, 0f, 1f); // Clamping it to 0-1f so it doesn't go over that.

            // Here we get the screen dimensions of the barFrame element, then tweak the resulting rectangle to arrive at a rectangle within the barFrame texture that we will draw the gradient. These values were measured in a drawing program.
            Rectangle hitbox = barFrame.GetInnerDimensions().ToRectangle();
            hitbox.X += 12;
            hitbox.Width -= 24;
            hitbox.Y += 8;
            hitbox.Height -= 16;

            // Now, using this hitbox, we draw a gradient by drawing vertical lines while slowly interpolating between the 2 colors.
            int left = hitbox.Left;
            int right = hitbox.Right;
            int steps = (int)((right - left) * quotient);
            for (int i = 0; i < steps; i += 1)
            {
                //float percent = (float)i / steps; // Alternate Gradient Approach
                float percent = (float)i / (right - left);
                spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(left + i, hitbox.Y, 1, hitbox.Height), Color.Lerp(gradientA, gradientB, percent));
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (!Main.LocalPlayer.GetModPlayer<GalacticPlayer>().OsmiumDamage)
            {
                return;
            }

            var modPlayer = Main.LocalPlayer.GetModPlayer<GalacticPlayer>();
            // Setting the text per tick to update and show our resource values.
            text.SetText($"Osmium Souls: {modPlayer.osmiumSouls} / {modPlayer.osmiumSoulsMax}");
            base.Update(gameTime);
        }
    }
}

UI System:
C#:
using Terraria;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Input;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.UI;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using System;
using System.IO;
using Terraria.GameContent.UI;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.Audio;
using Terraria.Localization;
using Terraria.ModLoader.UI;
using static Terraria.ModLoader.ModContent;
using GalacticMod.Assets.Systems;

namespace GalacticMod.UI
{
    class UI : ModSystem
    {
        private UserInterface _osmiumSoulBarUserInterface;
        internal OsmiumSoulBar OsmiumSoulBar;

        public override void Load()
        {
            if (!Main.dedServ)
            {
                _osmiumSoulBarUserInterface = new UserInterface();
                _osmiumSoulBarUserInterface.SetState(OsmiumSoulBar);

                OsmiumSoulBar = new OsmiumSoulBar();
                OsmiumSoulBar.Activate(); // Activate calls Initialize() on the UIState if not initialized, then calls OnActivate and then calls Activate on every child element
            }
        }

        public override void Unload()
        {
            //OsmiumSoulBar?.Unload(); // If you hold data that needs to be unloaded, call it in OO-fashion
            OsmiumSoulBar = null;
        }

        private GameTime _lastUpdateUiGameTime;

        public override void UpdateUI(GameTime time) //change to override
        {
            _lastUpdateUiGameTime = time;
            if (_osmiumSoulBarUserInterface?.CurrentState != null)
            {
                _osmiumSoulBarUserInterface.Update(time);
            }
        }

        public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers) //change to override
        {
            int resourceBarIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Resource Bars"));
            if (resourceBarIndex != -1)
            {
                layers.Insert(resourceBarIndex, new LegacyGameInterfaceLayer(
                    "GalacticMod: Osmium Soul Bar",
                    delegate
                    {
                        if (_osmiumSoulBarUserInterface != null && _osmiumSoulBarUserInterface?.CurrentState != null)
                        {
                            _osmiumSoulBarUserInterface.Draw(Main.spriteBatch, _lastUpdateUiGameTime);
                        }
                        return true;
                    },
                       InterfaceScaleType.UI));
            }
        }
    }
}
 
Back
Top Bottom