tModLoader Custom Background

Ziiio

Official Terrarian
Can someone help me? I downloaded Example Mod folder. I did a several custom items such as armor but I couldn't turn on the custom background... Please help, I appreciate it! Thanks for reading
 
Making a background requires a seperate script:

Code:
using Terraria;
using Terraria.ModLoader;

namespace YourMmod.Backgrounds
{
    public class CustomBackground : ModSurfaceBgStyle
    {
        public override bool ChooseBgStyle()
        {
            return !Main.gameMenu && Main.LocalPlayer.GetModPlayer<YourModPlayer>().ZoneExample;
        }

        // Use this to keep far Backgrounds like the mountains.
        public override void ModifyFarFades(float[] fades, float transitionSpeed)
        {
            for (int i = 0; i < fades.Length; i++)
            {
                if (i == Slot)
                {
                    fades[i] += transitionSpeed;
                    if (fades[i] > 1f)
                    {
                        fades[i] = 1f;
                    }
                }
                else
                {
                    fades[i] -= transitionSpeed;
                    if (fades[i] < 0f)
                    {
                        fades[i] = 0f;
                    }
                }
            }
        }

        public override int ChooseFarTexture()
        {
            return mod.GetBackgroundSlot("Backgrounds/ExampleBgFar");
        }

        public override int ChooseMiddleTexture()
        {
            return mod.GetBackgroundSlot("Backgrounds/ExampleBgMiddle");
        }

        public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b)
        {
            return mod.GetBackgroundSlot("Backgrounds/ExampleBgClose");
        }
    }
}

Just change the values to match your code and it should work fine. Assuming you have your ModPlayer setup to detect your biome correctly.
 
Back
Top Bottom