Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm incredibly new to code (as in the only code I wrote were basic changes to models and blockstates for a minecraft resourcepack) and I'm stuck trying to find anything wrong in this
I couldn't find anything online either (not anything I understood anyway)
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ObjectData;
using static Terraria.ModLoader.ModContent;

namespace ExampleMod.Tiles
{
	public class ExampleBar : ModTile
	{
		public override void SetDefaults()
		{
			Main.tileShine[Type] = 1100;
			Main.tileSolid[Type] = true;
			Main.tileSolidTop[Type] = true;
			Main.tileFrameImportant[Type] = true;

			TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1);
			TileObjectData.newTile.StyleHorizontal = true;
			TileObjectData.newTile.LavaDeath = false;
			TileObjectData.addTile(Type);

			AddMapEntry(new Color(200, 200, 200), Language.GetText("MapObject.MetalBar")); // localized text for "Metal Bar"
		}

		public override bool Drop(int i, int j)
		{
			Tile t = Main.tile[i, j];
			int style = t.frameX / 18;
			if (style == 0) // It can be useful to share a single tile with multiple styles. This code will let you drop the appropriate bar if you had multiple.
			{
				Item.NewItem(i * 16, j * 16, 16, 16, (mod.ItemType("Items.Placeable.NetheriteBar"));
			}
			return base.Drop(i, j);
		}
	}
}

any help is appreciateted, thanks!

What I have tried:

I tried changing
Item.NewItem(i * 16, j * 16, 16, 16, ItemType<Items.Placeable.NetheriteBar>());

into
Item.NewItem(i * 16, j * 16, 16, 16, (mod.ItemType("Items.Placeable.NetheriteBar"));

Which did help a little (3 errors into just 1)
Posted
Updated 6-May-20 12:22pm

1 solution

CS1026 is ")" expected, which means that you are missing a ) somewhere, making your syntax invalid. And indeed, if you look at this line:
C#
Item.NewItem(i * 16, j * 16, 16, 16, (mod.ItemType("Items.Placeable.NetheriteBar"));
You have three opening parentheses there, but only two closing ones, so that cannot be correct. You can just get rid of the one before mod though, so turning it into:
C#
Item.NewItem(i * 16, j * 16, 16, 16, mod.ItemType("Items.Placeable.NetheriteBar"));
 
Share this answer
 
Comments
[no name] 7-May-20 2:17am    
Christ alive I'm blind. Seems to work. Thank you so much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900