Noble Four A239
Terrarian
How to correctly use the postdrawininventory to apply glowmask. Thanks in advance
Last edited:
Hello, please I need help, i'm trying to make Everscream drop a custom item that I have made.
i'm using this code for the drop
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace MoreRecipe.NPCs
{
public class ModGlobalNPC : GlobalNPC
{
public override void NPCLoot(NPC npc)
{
if (npc.type == NPCID.Everscream)
{
if (Main.rand.Next(2) == 0)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("SnowPowerCell"), 1);
}
}
}
}
}
and this code for the item
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace MoreRecipe.Items
{
public class SnowPowerCell : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Snow Power Cell");
Tooltip.SetDefault("Used to make frost moon boss item");
}
public override void SetDefaults()
{
item.width = 20;
item.height = 20;
item.maxStack = 999;
item.value = 25000;
item.rare = 7;
}
}
}
where is the error ?
Thanks everyone for the help![]()
no idea. seems you are doing the right thing.
try this:
int NPCType = npc.type;//this just save some code
Player player = Main.player[0];//this is how you refer to the character you play if there is no Player parameter in the function
//the drop num for the bosses. differ from hardness.
if (NPCType == NPCID.KingSlime || NPCType == NPCID.EyeofCthulhu)
{
player.QuickSpawnItem(mod.ItemType("UniversalCraftingMaterial"), 3 + Main.rand.Next(0, 3));//item direct appear in your inventory
}
just replace the "UniversalCraftingMaterial" with the item id you want to drop.
should be like this:I have another question, if I want to add an item from another mod as ingredient for my recipe, what I have to write ?
I have also run into this problem:
c:\Users\Big D\Documents\My Games\Terraria\ModLoader\Mod Sources\FurtherWorlds\Items\Weapons\Pole.cs(32,7) : error CS0101: The namespace '<global namespace>' already contains a definition for 'MyGlobalNPC'
Here is the code for dropping the item:
class MyGlobalNPC : GlobalNPC
{
public override void NPCLoot(NPC npc)
{
if(npc.type == NPCID.TwiggyZombie)
{
if (Main.rand.Next(50) == 0)
Item.NewItem(npc.getRect(), mod.ItemType("Pole"), 1);
}
// Addtional if statements here for adding drops to other vanilla npc.
}
}
It worked before but now I am trying to update my mod and now it is saying the error message listed above help would be much appreciated
Disable kRPG.get a crash while loading the mod browser https://pastebin.com/23GUR6c5
should be like this:
Player player = Main.player[0];//without this line the game won't know what is "player" in the next line
player.QuickSpawnItem(mod.ItemType("UniversalCraftingMaterial"), 3 + Main.rand.Next(0, 3));// this will drop 3-5 items in player's inventory
just change the "UniversalCraftingMaterial" to the item id. item id is the class name.
something wrong with the KRPG mod. check it out there. might be a better choice.get a crash while loading the mod browser https://pastebin.com/23GUR6c5
that won't be a drop then, my bad. if "item A from mod A is REQUIRED to make item B from mod B", then here is the answer:Disable kRPG.
that won't be a drop then, my bad. if "item A from mod A is REQUIRED to make item B from mod B", then here is the answer:
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(74,9999);//this is vanilla item, just change the 74 to the id you want. id is easy to find with terraria official wiki.
recipe.AddIngredient(null, "GodEmblem"); // this is how you add item as an ingredient from the same mod
recipe.AddIngredient(GetItem("UniversalCraftingMaterial"), 10);// this is how you add MULTIPLE item as an ingredient from the same mod
recipe.AddIngredient(ModLoader.GetMod("CalamityMod").ItemType("YharimsCrystal"));//this is how you can add the "Yharim's Crystal" from "Calamity" as an ingredient
recipe.AddIngredient(ModLoader.GetMod("Fargowiltas").ItemType("UniverseSoul"));//this is how you can add the "Soul of Universe" from "Fargowiltas" as an ingredient
recipe.AddTile(412);//this is the required crafting station.412 is ancient manipulator. more info is on the official wiki
recipe.SetResult(this);//so obviously this method is in that class or the "this" keyword won't work
recipe.AddRecipe();
}
last but not least, just a little hint: you can get the mod id in the mods folder which can be easily found by click 2 buttons in game menu.(Mods-open mods folder) some mod name and mod id is different. the name is a piece of, but the id MATTERS.
also, just in case you need, i will show you the mod I wrote. nothing else, just hell lot of recipes depends on an item I created called "Universal Crafting Material", which can be dropped from every mob in the game.
seems lots of us getting the same error. 100% no idea why. and what is more interesting, when i google this error, i found the earliest one is in 2012, which is the second year when terraria first came out.
There are at least two things that are causing errors here.I have a problem with my code here. Im trying to add an ore called Erothium, but error code CS1519 is getting in the way.
<snip>
You need a space between void at SetDefaults(), and the semicolon after SetDefaults() isn't expected (aka remove it).public override voidSetDefaults();
Two missing semicolons.item.createTile =mod.TileType("ErothiumOreTile")
item.maxStack=999