Brand New To Modding, How Do I Enable A Furniture Block To Be Orientated In A Different Direction?

IceCold!

Terrarian
I've essentially made a piece of decoration that is just a shoe, but the issue is that I cant seem to figure out how to get it to face right when looking right, and left when looking left much like the chairs and other furniture is done in terraria. I think it might be TileObjectData.newTile.Direction but I don't know enough about it to program it in and test it. Any help?
 
Okay: I've managed to get the game to recognize im trying to place it in different directions, however when I try to place it to the left I get an error saying "Object reference not set to an instance of an object". Any solutions? Code is set below.

C#:
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Creative;
using Terraria.DataStructures;
using Terraria.ObjectData;
using Terraria.Localization;
using Terraria.Enums;

namespace TestMod.Content.Tiles
{
    internal class ShoeTile : ModTile
    {
        public override void SetStaticDefaults()
        {

            Main.tileSolid[Type] = false;
            Main.tileSolidTop[Type] = false;
            Main.tileFrameImportant[Type] = true;
            Main.tileNoAttach[Type] = true;

            TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1);
            TileObjectData.newTile.LavaDeath = true;


            TileObjectData.newTile.Direction = TileObjectDirection.PlaceLeft;
            TileObjectData.newTile.StyleHorizontal = true;
            TileObjectData.newAlternate.CopyFrom(TileObjectData.newTile);
            TileObjectData.newAlternate.Direction = TileObjectDirection.PlaceRight;
            TileObjectData.addAlternate(1);

            TileObjectData.addTile(Type);

            ItemDrop = ModContent.ItemType<Items.Placeables.Shoe>();
            SoundType = SoundID.Dig;
            SoundStyle = 1;


            AddMapEntry(new Color(27, 41, 75), CreateMapEntryName("Shoe"));

        }

        


    }

}
[/ISPOILER]
 
So it sounds like the game cannot find the object when you place it down. I'm not 100% sure but here's a few things to check.
Check that your namespace matches the folder directory to where the tile graphic is. Does the graphic contain frames for both left / right?
Change 'internal class ShoeTile' to 'public class ShoeTile'.
 
I've got the alternate facing side on there indeed, and I've tried making it a public class. Is there something I have to do to get the code to recognize and use the other frame in specific?
 

Attachments

  • Geta (1).png
    Geta (1).png
    450 bytes · Views: 43
Your tile should look like this (with the dividing lines) Example Chair

But I'm not sure if that will solve the issue or not. It could also be because your sprite does not look like it's the proper size. Every pixel in Terraria is actually a 2x2 of pixels. Meaning once you draw your sprite, you need to resize it to 200% to have it match up with the rest of the game's graphics. It could be that your sprite is too small and the game is looking for a frame that doesn't exist.

If those don't fix your issues, I recommend asking on the Discord.
 
Back
Top Bottom