goblincat
Terrarian
EDIT: I copied another ExampleMod tile (the toilet) and it worked which is great! I just don't know why haha. This is no longer an urgent question but if anyone knows why this happened, I'm curious to know!
Original issue:
New code:
Original issue:
Hi! I have a silly issue with my first mod and first tile. It seems like for some reason, the tile displayed in the game only shows the single pixel in the bottom right of the spritesheet.
This is what it looks like in the game:
This is what the spritesheet looks like (lots of colors because I was trying to figure out what part of the spritesheet was being displayed). This is a 36x36 sheet. It did the same thing with the 16x16 sprite with only one flower.
My code is copied from ExampleMod- have tried multiple different items/tiles, I believe right now it's copying from the block.
Tile:
Item:
Any insight into what's going on is appreciated! Thank you!
This is what it looks like in the game:

This is what the spritesheet looks like (lots of colors because I was trying to figure out what part of the spritesheet was being displayed). This is a 36x36 sheet. It did the same thing with the 16x16 sprite with only one flower.

My code is copied from ExampleMod- have tried multiple different items/tiles, I believe right now it's copying from the block.
Tile:
Code:
using Microsoft.Xna.Framework;
using System;
using System.Diagnostics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace OcelotMod.Tiles
{
public class cuteFlowerTile : ModTile
{
public override void SetStaticDefaults()
{
Main.tileSolid[Type] = false;
Main.tileMergeDirt[Type] = false;
Main.tileBlockLight[Type] = false;
AddMapEntry(new Color(200, 200, 200));
DustType = DustID.BubbleBurst_Pink;
}
}
}
Item:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using OcelotMod.Tiles;
using System.ComponentModel;
namespace OcelotMod.Items
{
public class cuteFlower : ModItem
{
// The Display Name and Tooltip of this item can be edited in the Localization/en-US_Mods.OcelotMod.hjson file.
public override void SetDefaults()
{
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.cuteFlowerTile>());
Item.value = 1;
Item.width = 8;
Item.height = 8;
Item.useTime = 10;
//Item.UseAnimation = 10;
Item.autoReuse = true;
//Item.consumable = true;
//Item.UseAnimation and Item.consumable are commented out because tmodloader keeps saying they aren't valid methods in Item, but that's a secondary issue
Item.createTile = ModContent.TileType<Tiles.cuteFlowerTile>();
}
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.Wood, 1);
recipe.AddIngredient(ItemID.Acorn, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}
Any insight into what's going on is appreciated! Thank you!
New code:
Tile:
Item:
Sprite is just 16x18 version of original sprite
Code:
using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.GameContent;
using Terraria.GameContent.ObjectInteractions;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace OcelotMod.Tiles
{
//Very similar to ExampleChair, but has special HitWire code and potentially additional AdjTiles
public class cuteFlowerTile : ModTile
{
public const int NextStyleHeight = 20; // Calculated by adding all CoordinateHeights + CoordinatePaddingFix.Y applied to all of them + 2
// changed from 40
public override void SetStaticDefaults()
{
// Properties
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileLavaDeath[Type] = true;
// Names
AddMapEntry(new Color(200, 200, 200), Language.GetText("MapObject.Toilet"));
// Placement
TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); // changed from 1x2
TileObjectData.newTile.CoordinateHeights = new[] { 16, 18 };
TileObjectData.newTile.CoordinatePaddingFix = new Point16(0, 2);
TileObjectData.addTile(Type);
}
}
}
Item:
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using OcelotMod.Tiles;
using System.ComponentModel;
namespace OcelotMod.Items
{
public class cuteFlower : ModItem
{
// The Display Name and Tooltip of this item can be edited in the Localization/en-US_Mods.OcelotMod.hjson file.
public override void SetDefaults()
{
// furniture that you can set on the ground and
// has no physics
Item.DefaultToPlaceableTile(ModContent.TileType<Tiles.cuteFlowerTile>());
//https://docs.tmodloader.net/docs/stable/class_item.html#a86469ef0a3430e374432380a649bbfc3
Item.value = 1;
Item.width = 12;
Item.height = 12;
}
public override void AddRecipes()
{
// make out of 1 wood and 1 acorn
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.Wood, 1);
recipe.AddIngredient(ItemID.Acorn, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.Register();
}
}
}
Sprite is just 16x18 version of original sprite
Last edited: