tModLoader Tile placing not working properly + texture glitch

Status
Not open for further replies.

Dradonhunter11

Official Terrarian
Hello everyone,

I've been recently working on my mod and encountered a weird bug where texture as it shown here
N6sftGg.png


The tile is a 4x3 format and here is the code

Silently Caught Exception: Object reference not set to an instance of an object. at Terraria.TileObject.CanPlace(Int32 x, Int32 y, Int32 type, Int32 style, Int32 dir, TileObject& objectData, Boolean onlyCheck, Boolean checkStay) at Terraria.ModLoader.ModCompile.<>c.<ActivateExceptionReporting>b__15_0(Object sender, FirstChanceExceptionEventArgs exceptionArgs)
at Terraria.TileObject.CanPlace(Int32 x, Int32 y, Int32 type, Int32 style, Int32 dir, TileObject& objectData, Boolean onlyCheck, Boolean checkStay)
at Terraria.WorldGen.PlaceObject(Int32 x, Int32 y, Int32 type, Boolean mute, Int32 style, Int32 alternate, Int32 random, Int32 direction)
at Terraria.WorldGen.PlaceTile(Int32 i, Int32 j, Int32 type, Boolean mute, Boolean forced, Int32 plr, Int32 style)
at Terraria.Player.PlaceThing()
at Terraria.Player.ItemCheck(Int32 i)
at Terraria.Player.ItemCheckWrapped(Int32 i)
at Terraria.Player.Update(Int32 i)
at Terraria.Main.DoUpdate(GameTime gameTime)
at Terraria.Main.Update(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)
at Terraria.WindowsLaunch.Main(String[] args)

Code:
class TerraFurnace : TUABlock
    {
        public override void SetDefaults()
        {

            //TileObjectData.newTile.CoordinateHeights = new int[] { 60, 60, 42 };
            Main.tileFrameImportant[Type] = true;
            TileObjectData.newTile.Origin = new Point16(3, 2);
            TileObjectData.newTile.Width = 4;
            TileObjectData.newTile.Height = 3;
            TileObjectData.newTile.CoordinateHeights = new int[] { 64, 16, 48 };
            TileObjectData.newTile.CoordinateWidth = 16;
            TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(mod.GetTileEntity<TerraFurnaceEntity>().Hook_AfterPlacement, -1, 0, false);
            TileObjectData.addTile(Type);


        }


    }

    class TerraFurnaceEntity : StorageEntity
    {
        public Item[] inventory = new Item[2];

        public TerraFurnaceEntity() {
            maxEnergy = 50000;
        }

        public void setItem(Item i) {
            inventory[0] = i;
        }

        public Item sendItem(int i) {
            return inventory[i];
        }

        public override void Update()
        {
            base.Update();
        }

        public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction)
        {
            Main.NewText("X " + i + " Y " + j);
            return Place(i - 4, j - 3);
        }

        public override bool ValidTile(int i, int j)
        {
            Tile tile = Main.tile[i, j];
            //Main.NewText((tile.active() && (tile.type == mod.TileType<BasicTECapacitor>() || tile.type == mod.TileType<BasicTECapacitor>()) && tile.frameX == 0 && tile.frameY == 0));
            return tile.active() && (tile.type == mod.TileType<TerraFurnace>()) && tile.frameX == 0 && tile.frameY == 0;
        }
    }

Thx!
 
Status
Not open for further replies.
Back
Top Bottom