tModLoader [New in modding] Trouble with WorldTime

D3X_

Terrarian
Hi! I'm new both to modding and the forum.

I have some understanding of base modding, but i'm having some trouble with changing world time. Basically i'm making a mod, and one of the items allows you to change time (kinda like the sundial but without the cooldown and it being a tile).
I'm aware that there are already some mods that add items like this, but I thought it would be fun making one of my own that goes with the aesthetics of the mod (didn't account for it being so different than any other items)

This is the code i'm working with right now: (I'm ussing Terraria 1.3.5.3 - tModLoader 0.11.8.9)

C#:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TimeSwap.Items
{
    public class TimeCrystal : ModItem
    {
        public override void SetStaticDefaults() //Object name and tooltip
        {
            DisplayName.SetDefault("Time Crystal");
            Tooltip.SetDefault("This is a basic modded crystal.");
        }

        public override void SetDefaults() //Object properties
        {
            item.width = 22;
            item.height = 26;
            item.useTime = 20;
            item.useAnimation = 20;
            item.useStyle = 4;
            item.knockBack = 1;
            item.value = Item.sellPrice(silver: 1);
            item.rare = -12;
            item.UseSound = SoundID.Item1;
            item.autoReuse = false;
            item.consumable = false;
        }

        public override void AddRecipes() //Object crafting recipe
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);
            recipe.AddTile(TileID.WorkBenches);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
        public override bool UseItem(Player player) //Object main use
        {
            if (Main.dayTime == false)
            {
                Main.time = 54000;
            }
            else
            {
                Main.time = 32400;
            }
            return (this).UseItem(player);
        }
    }
}

I'm really new to world changing properties, so any help would be very much apretiated <3
 
Last edited:
Back
Top Bottom