Standalone [1.3] tModLoader - A Modding API

For some reason, my items can't be crafted - I think it's a problem with the code. Here's a copy;

{


"displayName": "Zero Cannon",

"size": [52,28],

"maxStack": 1,

"value": [0,30,0,0],

"rare": 9,

"tooltip": "Not for mere mortals.",

"useStyle": 5,

"useAnimation": 20,

"useTime": 5,

"damage": 100,

"knockback": 5,

"useSound": 11,

"autoReuse": true,

"ranged": true,

"noMelee": true,

"shoot": 207,

"shootSpeed": 4,

"useAmmo": 14,

"recipes":

[{

"items": { "Soul of Night": 10, "Luminite Bar": 5 },

"tiles": { "Ancient Manipulator" },

"creates": 1

}]

}
 
For some reason, my items can't be crafted - I think it's a problem with the code. Here's a copy;

{


"displayName": "Zero Cannon",

"size": [52,28],

"maxStack": 1,

"value": [0,30,0,0],

"rare": 9,

"tooltip": "Not for mere mortals.",

"useStyle": 5,

"useAnimation": 20,

"useTime": 5,

"damage": 100,

"knockback": 5,

"useSound": 11,

"autoReuse": true,

"ranged": true,

"noMelee": true,

"shoot": 207,

"shootSpeed": 4,

"useAmmo": 14,

"recipes":

[{

"items": { "Soul of Night": 10, "Luminite Bar": 5 },

"tiles": { "Ancient Manipulator" },

"creates": 1

}]

}
You're using a tAPI format. tModLoader requires .cs files, which work entirely different.
 
View attachment 74357
I cry everytime.
AI 19 is a spear, right?
While AI 19 is for spears, it's hardcoded to only work for certain types. So you'll either have to copy the AI code into your own AI hook and set your aiStyle to 0, or keep the aiStyle as 19 and set the ModProjectile's aiType field to copy the exact AI of a vanilla projectile.

For some reason, my items can't be crafted - I think it's a problem with the code. Here's a copy;

{


"displayName": "Zero Cannon",

"size": [52,28],

"maxStack": 1,

"value": [0,30,0,0],

"rare": 9,

"tooltip": "Not for mere mortals.",

"useStyle": 5,

"useAnimation": 20,

"useTime": 5,

"damage": 100,

"knockback": 5,

"useSound": 11,

"autoReuse": true,

"ranged": true,

"noMelee": true,

"shoot": 207,

"shootSpeed": 4,

"useAmmo": 14,

"recipes":

[{

"items": { "Soul of Night": 10, "Luminite Bar": 5 },

"tiles": { "Ancient Manipulator" },

"creates": 1

}]

}
tModLoader doesn't support json files yet. I'd recommend looking at the example mod to see how to make items.
 
I know I a complete idiot when it comes to this C# coding but what's wrong with this?
using System;

using Microsoft.Xna.Framework;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;

namespace Matter.Items.Weapons {

publicclassZeroCannon : ModItem


{

publicoverridevoid SetDefaults()


{

item.name = "Zero Blaster";


item.damage = 120;

item.ranged = true;


item.width = 52;

item.height = 28;

item.toolTip = "Not for un-derts.";


item.useTime = 5;

item.useAnimation = 20;

item.useStyle = 5;

item.noMelee = true; //so the item's animation doesn't do damage

item.knockBack = 4;

item.value = 10000;

item.rare = 9;

item.useSound = 11;

item.autoReuse = true;

item.shoot = 10; //idk why but all the guns in the vanilla source have this

item.shootSpeed = 5f;

item.useAmmo = ProjectileID.ChlorophyteBullet;

}

publicoverridevoid AddRecipes()


{

ModRecipe recipe = new ModRecipe(mod);

recipe.AddIngredient(null, "Soul of Night", 10);

recipe.AddTile(null, "Ancient Manipulator");

recipe.SetResult(this);


recipe.AddRecipe();

}

}}

I copied off of the example gun (sorry) and it doesn't want to craft.
 
recipe.AddIngredient(null, "Soul of Night", 10);

recipe.AddTile(null, "Ancient Manipulator");
Should be
Code:
recipe.AddIngredient(ItemID.SoulOfNight, 10);
recipe.AddTile(TileID.AncientManipulator); //if this TileID doesn't work, replace with 3549
 
Should be
Code:
recipe.AddIngredient(ItemID.SoulOfNight, 10);
recipe.AddTile(TileID.AncientManipulator); //if this TileID doesn't work, replace with 3549
No - not showing up at the Guide or the Manipulator. I really have no idea what to do.
 
No - not showing up at the Guide or the Manipulator. I really have no idea what to do.
Have you tried this?
Code:
 recipe.AddTile(412);
(3549 was the item ID)
If all else fails, change ItemID.SoulofNight to 521. :dryadsmile:
 
Have you tried this?
Code:
 recipe.AddTile(412);
(3549 was the item ID)
If all else fails, change ItemID.SoulofNight to 521. :dryadsmile:
Sadly, no. There is a slight hint of what is happening - the loading bar for "adding recipes" goes without loading at all. I must have the smallest brain on the forums or the biggest problem `:sigh:
 
Ok, now I'm confused.
The only thing I can see wrong now (If it affects the code at all) is publicoverridevoid being all smashed together.

Try spacing that out, otherwise, I would wait to ask bluemagic.
 
Ok, now I'm confused.
The only thing I can see wrong now (If it affects the code at all) is publicoverridevoid being all smashed together.

Try spacing that out, otherwise, I would wait to ask bluemagic.
Thank you so much for taking the time to figure this out. :)
 
It looks like the problem is that an ArrayIndexOutOfBoundsException is causing the entire NPCLoot to end. You're setting the first index of a list with size 0. What you want to do is add the item's ID, not set an index in the list to the ID. So for example, like "NPCLoader.blockLoot.Add(ItemID.DemoniteOre);".
That was actually the first thing I had tried, apparently I had never capitalized "Add" though. Whoops. It is working now. Thanks.
 
How do you make a boss drop more then one of an item? I know this is probably a ridiculous and easy question but I get an error whenever I try to add a ", <number>" to anywhere in there.
 
Nope - didn't work either. I'm using v0.4 - does that help?

I copied your code in, fixed the obvious missing spaces, and added an image to my folder, then clicked build and reload, and it works for me. Doubt being on 0.4 matters. FYI, "item.useAmmo = ProjectileID.ChlorophyteBullet;" doesn't seem to work for me, you might have to do it manually in your own shoot method if you only want it to shoot cholorophyte bullets.

You'll have to change the namespace and class name if you copy my code.

using Microsoft.Xna.Framework;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;

namespace JopojellyLearningMod.Items
{

public class ForumItem : ModItem


{

public override void SetDefaults()


{

item.name = "Zero Blaster";

item.damage = 120;

item.ranged = true;


item.width = 52;

item.height = 28;

item.toolTip = "Not for un-derts.";


item.useTime = 5;

item.useAnimation = 20;

item.useStyle = 5;

item.noMelee = true; //so the item's animation doesn't do damage

item.knockBack = 4;

item.value = 10000;

item.rare = 9;

item.useSound = 11;

item.autoReuse = true;

item.shoot = 10; //idk why but all the guns in the vanilla source have this

item.shootSpeed = 5f;

item.useAmmo = ProjectileID.Bullet;

}

public override void AddRecipes()


{

ModRecipe recipe = new ModRecipe(mod);

recipe.AddIngredient(Terraria.ID.ItemID.SoulofNight, 10);
recipe.AddTile(Terraria.ID.TileID.LunarCraftingStation);

recipe.SetResult(this);


recipe.AddRecipe();

recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(ItemID.LunarCraftingStation);
recipe.AddRecipe();


recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(ItemID.SoulofNight, 100);
recipe.AddRecipe();

recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(ItemID.ChlorophyteBullet, 999);
recipe.AddRecipe();
}

}
}
[DOUBLEPOST=1440554854,1440554637][/DOUBLEPOST]
How do you make a boss drop more then one of an item? I know this is probably a ridiculous and easy question but I get an error whenever I try to add a ", <number>" to anywhere in there.
Are you using this method?

public static int NewItem(int X, int Y, int Width, int Height, int Type, int Stack = 1, bool noBroadcast = false, int pfix = 0, bool noGrabDelay = false, bool reverseLookup = false)

Stack is right there, I haven't done NPC drops yet though.

If you don't want them stacked, just duplicate the line.
 
I copied your code in, fixed the obvious missing spaces, and added an image to my folder, then clicked build and reload, and it works for me. Doubt being on 0.4 matters. FYI, "item.useAmmo = ProjectileID.ChlorophyteBullet;" doesn't seem to work for me, you might have to do it manually in your own shoot method if you only want it to shoot cholorophyte bullets.

You'll have to change the namespace and class name if you copy my code.

using Microsoft.Xna.Framework;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;

namespace JopojellyLearningMod.Items
{

public class ForumItem : ModItem


{

public override void SetDefaults()


{

item.name = "Zero Blaster";

item.damage = 120;

item.ranged = true;


item.width = 52;

item.height = 28;

item.toolTip = "Not for un-derts.";


item.useTime = 5;

item.useAnimation = 20;

item.useStyle = 5;

item.noMelee = true; //so the item's animation doesn't do damage

item.knockBack = 4;

item.value = 10000;

item.rare = 9;

item.useSound = 11;

item.autoReuse = true;

item.shoot = 10; //idk why but all the guns in the vanilla source have this

item.shootSpeed = 5f;

item.useAmmo = ProjectileID.Bullet;

}

public override void AddRecipes()


{

ModRecipe recipe = new ModRecipe(mod);

recipe.AddIngredient(Terraria.ID.ItemID.SoulofNight, 10);
recipe.AddTile(Terraria.ID.TileID.LunarCraftingStation);

recipe.SetResult(this);


recipe.AddRecipe();

recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(ItemID.LunarCraftingStation);
recipe.AddRecipe();


recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(ItemID.SoulofNight, 100);
recipe.AddRecipe();

recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock);
recipe.SetResult(ItemID.ChlorophyteBullet, 999);
recipe.AddRecipe();
}

}
}
[DOUBLEPOST=1440554854,1440554637][/DOUBLEPOST]
Are you using this method?

public static int NewItem(int X, int Y, int Width, int Height, int Type, int Stack = 1, bool noBroadcast = false, int pfix = 0, bool noGrabDelay = false, bool reverseLookup = false)

Stack is right there, I haven't done NPC drops yet though.

If you don't want them stacked, just duplicate the line.
No I'm just adding the item in the setDefaults area but that prob is the wrong place isn't it lol.
 
tfw using summoning item to test out monster that spawns in Bloodmoon...
tfw no cheat-menu
tfw "Phantom has awoken!"
 
Back
Top Bottom