tModLoader v2023.01
A mod to make and play Terraria mods
|
This class serves as a place for you to place all your properties and hooks for each item. Create instances of ModItem (preferably overriding this class) to pass as parameters to Mod.AddItem.
The Basic Item Guideteaches the basics of making a modded item.
More...
Inherits Terraria.ModLoader.ModType< Item, ModItem >.
Inherited by Terraria.ModLoader.Default.ModLoaderModItem.
Public Member Functions | |
virtual void | AddRecipes () |
This is essentially the same as Mod.AddRecipes. Do note that this will be called for every instance of the overriding ModItem class that is added to the game. This allows you to avoid clutter in your overriding Mod class by adding recipes for which this item is the result. More... | |
virtual bool | AllowPrefix (int pre) |
Force a re-roll of a prefix by returning false. | |
virtual bool | AltFunctionUse (Player player) |
Allows you to make this item usable by right-clicking. Returns false by default. When this item is used by right-clicking, player.altFunctionUse will be set to 2. More... | |
virtual void | AnglerQuestChat (ref string description, ref string catchLocation) |
Allows you to set what the Angler says when he requests for this item. The description parameter is his dialogue, and catchLocation should be set to "\n(Caught at [location])". More... | |
virtual void | ArmorArmGlowMask (Player drawPlayer, float shadow, ref int glowMask, ref Color color) |
Allows you to modify which glow mask and in what color is drawn on the player's arms. Note that this is only called for body armor. Also note that this hook is only ever called through this item's associated equipment texture. More... | |
virtual void | ArmorSetShadows (Player player) |
Allows you to determine special visual effects this vanity set has on the player without having to code them yourself. Note that this hook is only ever called through this item's associated equipment texture. Use the player.armorEffectDraw bools to activate the desired effects. More... | |
virtual void | AutoDefaults () |
Automatically sets certain defaults. Override this if you do not want the properties to be set for you. | |
virtual void | AutoLightSelect (ref bool dryTorch, ref bool wetTorch, ref bool glowstick) |
Allows you to tell the game whether this item is a torch that cannot be placed in liquid, a torch that can be placed in liquid, or a glowstick. This information is used for when the player is holding down the auto-select keybind. More... | |
virtual void | AutoStaticDefaults () |
Automatically sets certain static defaults. Override this if you do not want the properties to be set for you. | |
virtual bool | CanAccessoryBeEquippedWith (Item equippedItem, Item incomingItem, Player player) |
Allows you to prevent similar accessories from being equipped multiple times. For example, vanilla Wings. Return false to have the currently equipped item swapped with the incoming item - ie both can't be equipped at same time. | |
virtual ? bool | CanAutoReuseItem (Player player) |
Allows you to modify the autoswing (auto-reuse) behavior of this item without having to mess with Item.autoReuse. Useful to create effects like the Feral Claws which makes melee weapons and whips auto-reusable. Return true to enable autoswing (if not already enabled through autoReuse), return false to prevent autoswing. Returns null by default, which applies vanilla behavior. More... | |
virtual ? bool | CanBeChosenAsAmmo (Item weapon, Player player) |
Whether or not this ammo item is valid for the given weapon. If this, or CanChooseAmmo on the weapon, returns false, then the ammo will not be valid for this weapon. By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid. If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called. More... | |
virtual bool | CanBeConsumedAsAmmo (Item weapon, Player player) |
Whether or not this ammo item will be consumed by the given weapon. By default, returns true; return false to prevent ammo consumption. If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called. More... | |
virtual ? bool | CanBurnInLava () |
Returns whether or not this item will burn in lava regardless of any conditions. Returns null by default (follow vanilla behaviour). | |
virtual ? bool | CanCatchNPC (NPC target, Player player) |
Allows you to determine whether this item can catch the given NPC. Return true or false to say the given NPC can or cannot be caught, respectively, regardless of vanilla rules. Returns null by default, which allows vanilla's NPC catching rules to decide the target's fate. If this returns false, CombinedHooks.OnCatchNPC is never called. NOTE: this does not classify the given item as an NPC-catching tool, which is necessary for catching NPCs in the first place. To do that, you will need to use the "CatchingTool" set in ItemID.Sets. More... | |
virtual ? bool | CanChooseAmmo (Item ammo, Player player) |
Whether or not the given ammo item is valid for this weapon. If this, or CanBeChosenAsAmmo on the ammo, returns false, then the ammo will not be valid for this weapon. By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid. If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called. More... | |
virtual bool | CanConsumeAmmo (Item ammo, Player player) |
Whether or not the given ammo item will be consumed by this weapon. By default, returns true; return false to prevent ammo consumption. If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called. More... | |
virtual ? bool | CanConsumeBait (Player player) |
Choose if this item will be consumed or not when used as bait. return null for vanilla behaviour. More... | |
virtual bool | CanEquipAccessory (Player player, int slot, bool modded) |
Allows you to disallow the player from equipping this accessory. Return false to disallow equipping this accessory. Returns true by default. More... | |
virtual ? bool | CanHitNPC (Player player, NPC target) |
Allows you to determine whether this melee weapon can hit the given NPC when swung. Return true to allow hitting the target, return false to block this weapon from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default. More... | |
virtual bool | CanHitPvp (Player player, Player target) |
Allows you to determine whether this melee weapon can hit the given opponent player when swung. Return false to block this weapon from hitting the target. Returns true by default. More... | |
virtual bool | CanPickup (Player player) |
Allows you to determine whether or not the item can be picked up More... | |
virtual bool | CanResearch () |
Allows you to prevent an item from being researched by returning false. True is the default behaviour. | |
virtual bool | CanRightClick () |
Returns whether or not this item does something when it is right-clicked in the inventory. Returns false by default. More... | |
virtual bool | CanShoot (Player player) |
Allows you to prevent this item from shooting a projectile on use. Returns true by default. More... | |
virtual bool | CanStack (Item decrease) |
Allows you to decide if this item is allowed to stack with another of its type. This is only called when attempting to stack with an item of the same type. This is not called for coins in inventory/UI. This covers all scenarios, if you just need to change in-world stacking behavior, use CanStackInWorld. More... | |
virtual bool | CanStackInWorld (Item decrease) |
Allows you to decide if this item is allowed to stack with another of its type in the world. This is only called when attempting to stack with an item of the same type. More... | |
virtual bool | CanUseItem (Player player) |
Returns whether or not this item can be used. By default returns true. More... | |
virtual void | CaughtFishStack (ref int stack) |
Allows you to determine how many of this item a player obtains when the player fishes this item. More... | |
virtual int | ChoosePrefix (UnifiedRandom rand) |
Allows you to manually choose what prefix an item will get. More... | |
virtual bool | ConsumeItem (Player player) |
If this item is consumable and this returns true, then this item will be consumed upon usage. Returns true by default. If false is returned, the OnConsumeItem hook is never called. More... | |
Recipe | CreateRecipe (int amount=1) |
virtual void | DrawArmorColor (Player drawPlayer, float shadow, ref Color color, ref int glowMask, ref Color glowMaskColor) |
Allows you to modify the colors in which this armor and surrounding accessories are drawn, in addition to which glow mask and in what color is drawn. Note that this hook is only ever called through this item's associated equipment texture. More... | |
virtual void | EquipFrameEffects (Player player, EquipType type) |
Allows you to create special effects (such as dust) when this item's equipment texture of the given equipment type is displayed on the player. Note that this hook is only ever called through this item's associated equipment texture. More... | |
virtual void | ExtractinatorUse (ref int resultType, ref int resultStack) |
Allows you to modify what item, and in what quantity, is obtained when this item is fed into the Extractinator. By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator. More... | |
virtual ? Color | GetAlpha (Color lightColor) |
Allows you to determine the color and transparency in which this item is drawn. Return null to use the default color (normally light color). Returns null by default. More... | |
virtual void | GetHealLife (Player player, bool quickHeal, ref int healValue) |
Allows you to temporarily modify the amount of life a life healing item will heal for, based on player buffs, accessories, etc. This is only called for items with a healLife value. More... | |
virtual void | GetHealMana (Player player, bool quickHeal, ref int healValue) |
Allows you to temporarily modify the amount of mana a mana healing item will heal for, based on player buffs, accessories, etc. This is only called for items with a healMana value. More... | |
virtual void | GrabRange (Player player, ref int grabRange) |
Allows you to modify how close this item must be to the player in order to move towards the player. More... | |
virtual bool | GrabStyle (Player player) |
Allows you to modify the way this item moves towards the player. Return true if you override this hook; returning false will allow the vanilla grab style to take place. Returns false by default. More... | |
virtual void | HoldItem (Player player) |
Allows you to make things happen when the player is holding this item (for example, torches make light and water candles increase spawn rate). More... | |
virtual void | HoldItemFrame (Player player) |
Allows you to modify the player's animation when the player is holding this item. More... | |
virtual ? Vector2 | HoldoutOffset () |
Allows you to determine the offset of this item's sprite when used by the player. This is only used for items with a useStyle of 5 that aren't staves. Return null to use the vanilla holdout offset; returns null by default. More... | |
virtual ? Vector2 | HoldoutOrigin () |
Allows you to determine the point on this item's sprite that the player holds onto when using this item. The origin is from the bottom left corner of the sprite. This is only used for staves with a useStyle of 5. Return null to use the vanilla holdout origin (zero); returns null by default. More... | |
virtual void | HoldStyle (Player player, Rectangle heldItemFrame) |
Allows you to modify the location and rotation of this item when the player is holding it. More... | |
virtual void | HorizontalWingSpeeds (Player player, ref float speed, ref float acceleration) |
Allows you to modify these wing's horizontal flight speed and acceleration. More... | |
virtual bool | IsAnglerQuestAvailable () |
Whether or not specific conditions have been satisfied for the Angler to be able to request this item. (For example, Hardmode.) Returns true by default. | |
virtual bool | IsArmorSet (Item head, Item body, Item legs) |
Returns whether or not the head armor, body armor, and leg armor make up a set. If this returns true, then this item's UpdateArmorSet method will be called. Returns false by default. More... | |
virtual bool | IsQuestFish () |
Whether or not the Angler can ever randomly request this type of item for his daily quest. Returns false by default. | |
virtual bool | IsVanitySet (int head, int body, int legs) |
Returns whether or not the head armor, body armor, and leg armor textures make up a set. This hook is used for the PreUpdateVanitySet, UpdateVanitySet, and ArmorSetShadows hooks. By default, this will return the same value as the IsArmorSet hook (passing the equipment textures' associated items as parameters), so you will not have to use this hook unless you want vanity effects to be entirely separate from armor sets. Note that this hook is only ever called through this item's associated equipment texture. More... | |
virtual bool | ItemSpace (Player player) |
Return true to specify that the item can be picked up despite not having enough room in inventory. Useful for something like hearts or experience items. Use in conjunction with OnPickup to actually consume the item and handle it. More... | |
virtual void | LoadData (TagCompound tag) |
Allows you to load custom data that you have saved for this item. Try to write defensive loading code that won't crash if something's missing. More... | |
virtual bool | MagicPrefix () |
Allows you to change whether or not a weapon receives magic prefixes. Return true if the item should receive magic prefixes and false if it should not. | |
virtual void | MeleeEffects (Player player, Rectangle hitbox) |
Allows you to give this melee weapon special effects, such as creating light or dust. More... | |
virtual bool | MeleePrefix () |
Allows you to change whether or not a weapon receives melee prefixes. Return true if the item should receive melee prefixes and false if it should not. Takes priority over WeaponPrefix, RangedPrefix, and MagicPrefix | |
virtual void | ModifyHitNPC (Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) |
Allows you to modify the damage, knockback, etc., that this melee weapon does to an NPC. More... | |
virtual void | ModifyHitPvp (Player player, Player target, ref int damage, ref bool crit) |
Allows you to modify the damage, etc., that this melee weapon does to a player. More... | |
virtual void | ModifyItemLoot (ItemLoot itemLoot) |
Allows you to add and modify the loot items that spawn from bag items when opened. The Basic NPC Drops and Loot 1.4 Guideexplains how to use the ModNPC.ModifyNPCLoot(NPCLoot) hook to modify NPC loot as well as this hook. A common usage is to use this hook and ModNPC.ModifyNPCLoot(NPCLoot) to edit non-expert exlclusive drops for bosses. This hook only runs once during mod loading, any dynamic behavior must be contained in the rules themselves. More... | |
virtual void | ModifyItemScale (Player player, ref float scale) |
Allows you to dynamically modify this item's size for the given player, similarly to the effect of the Titan Glove. More... | |
virtual void | ModifyManaCost (Player player, ref float reduce, ref float mult) |
Allows you to temporarily modify the amount of mana this item will consume on use, based on player buffs, accessories, etc. This is only called for items with a mana value. More... | |
virtual void | ModifyResearchSorting (ref ContentSamples.CreativeHelper.ItemGroup itemGroup) |
Allows you to set an item's sorting group in Journey Mode's duplication menu. This is useful for setting custom item types that group well together, or whenever the default vanilla sorting doesn't sort the way you want it. More... | |
virtual void | ModifyShootStats (Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) |
Allows you to modify the position, velocity, type, damage and/or knockback of a projectile being shot by this item. These parameters will be provided to Shoot(Player, EntitySource_ItemUse_WithAmmo, Vector2, Vector2, int, int, float) where the projectile will actually be spawned. More... | |
virtual void | ModifyTooltips (List< TooltipLine > tooltips) |
Allows you to modify all the tooltips that display for this item. See here for information about TooltipLine. More... | |
virtual void | ModifyWeaponCrit (Player player, ref float crit) |
Allows you to dynamically modify a weapon's crit chance based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. More... | |
virtual void | ModifyWeaponDamage (Player player, ref StatModifier damage) |
Allows you to dynamically modify a weapon's damage based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. More... | |
virtual void | ModifyWeaponKnockback (Player player, ref StatModifier knockback) |
Allows you to dynamically modify a weapon's knockback based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer. More... | |
virtual bool | NeedsAmmo (Player player) |
Whether or not having no ammo prevents an item that uses ammo from shooting. Return false to allow shooting with no ammo in the inventory, in which case this item will act as if the default ammo for it is being used. Returns true by default. | |
virtual void | NetReceive (BinaryReader reader) |
Receives the custom data sent in NetSend. Called whenever an item container syncs its contents (various MessageIDs and sources), or MessageID.SyncItem and MessageID.InstancedItem are successfully received. Can be called on both server and client. More... | |
virtual void | NetSend (BinaryWriter writer) |
Allows you to send custom data for this item between client and server, which will be handled in NetReceive. Called whenever an item container syncs its contents (various MessageIDs and sources), or MessageID.SyncItem and MessageID.InstancedItem are successfully sent, for example when the item is dropped into the world. Can be called on both server and client. More... | |
virtual void | OnCatchNPC (NPC npc, Player player, bool failed) |
Allows you to make things happen when this item attempts to catch the given NPC. More... | |
virtual void | OnConsumeAmmo (Item ammo, Player player) |
Allows you to make things happen when the given ammo is consumed by this weapon. Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place. More... | |
virtual void | OnConsumedAsAmmo (Item weapon, Player player) |
Allows you to make things happen when this ammo is consumed by the given weapon. Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place. More... | |
virtual void | OnConsumeItem (Player player) |
Allows you to make things happen when this item is consumed. Called before the item stack is reduced. More... | |
virtual void | OnConsumeMana (Player player, int manaConsumed) |
Allows you to make stuff happen when a player consumes mana on use of this item. More... | |
virtual void | OnCraft (Recipe recipe) |
Allows you to make anything happen when the player crafts this item using the given recipe. More... | |
virtual void | OnCreate (ItemCreationContext context) |
virtual void | OnHitNPC (Player player, NPC target, int damage, float knockBack, bool crit) |
Allows you to create special effects when this melee weapon hits an NPC (for example how the Pumpkin Sword creates pumpkin heads). More... | |
virtual void | OnHitPvp (Player player, Player target, int damage, bool crit) |
Allows you to create special effects when this melee weapon hits a player. More... | |
virtual void | OnMissingMana (Player player, int neededMana) |
Allows you to make stuff happen when a player doesn't have enough mana for the item they are trying to use. If the player has high enough mana after this hook runs, mana consumption will happen normally. Only runs once per item use. More... | |
virtual bool | OnPickup (Player player) |
Allows you to make special things happen when the player picks up this item. Return false to stop the item from being added to the player's inventory; returns true by default. More... | |
virtual void | OnResearched (bool fullyResearched) |
Allows you to create custom behaviour when an item is accepted by the Research function More... | |
virtual void | OnSpawn (IEntitySource source) |
Gets called when your item spawns in world | |
virtual void | OnStack (Item decrease, int numberToBeTransfered) |
Allows you to make things happen when items stack together. This item will have its stack increased that will have its stack increased. More... | |
virtual void | OpenBossBag (Player player) |
virtual void | PickAmmo (Item weapon, Player player, ref int type, ref float speed, ref StatModifier damage, ref float knockback) |
Allows you to modify various properties of the projectile created by a weapon based on the ammo it is using. This hook is called on the ammo. More... | |
virtual void | PostDrawInInventory (SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) |
Allows you to draw things in front of this item in the inventory. This method is called even if PreDrawInInventory returns false. More... | |
virtual void | PostDrawInWorld (SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) |
Allows you to draw things in front of this item. This method is called even if PreDrawInWorld returns false. More... | |
virtual void | PostDrawTooltip (ReadOnlyCollection< DrawableTooltipLine > lines) |
Allows you to do things after this item's tooltip is drawn. The lines contain draw information as this is ran after drawing the tooltip. More... | |
virtual void | PostDrawTooltipLine (DrawableTooltipLine line) |
Allows you to do things after a tooltip line of this item is drawn. The line contains draw info. More... | |
virtual void | PostReforge () |
This hook gets called immediately after an item gets reforged by the Goblin Tinkerer. Useful for modifying modded data based on the reforge result. | |
virtual void | PostUpdate () |
Allows you to make things happen when this item is lying in the world. This will always be called, even when it is being grabbed by a player. This hook should be used for adding light, or for increasing the age of less valuable items. | |
virtual bool | PreDrawInInventory (SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) |
Allows you to draw things behind this item in the inventory. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default. More... | |
virtual bool | PreDrawInWorld (SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) |
Allows you to draw things behind this item, or to modify the way this item is drawn in the world. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default. More... | |
virtual bool | PreDrawTooltip (ReadOnlyCollection< TooltipLine > lines, ref int x, ref int y) |
Allows you to do things before this item's tooltip is drawn. More... | |
virtual bool | PreDrawTooltipLine (DrawableTooltipLine line, ref int yOffset) |
Allows you to do things before a tooltip line of this item is drawn. The line contains draw info. More... | |
virtual ? bool | PrefixChance (int pre, UnifiedRandom rand) |
To prevent putting the item in the tinkerer slot, return false when pre is -3. To prevent rolling of a prefix on spawn, return false when pre is -1. To force rolling of a prefix on spawn, return true when pre is -1. More... | |
virtual bool | PreReforge () |
This hook gets called when the player clicks on the reforge button and can afford the reforge. Returns whether the reforge will take place. If false is returned, the PostReforge hook is never called. Reforging preserves modded data on the item. | |
virtual void | PreUpdateVanitySet (Player player) |
Allows you to create special effects (such as the necro armor's hurt noise) when the player wears this item's vanity set. This hook is called regardless of whether the player is frozen in any way. Note that this hook is only ever called through this item's associated equipment texture. More... | |
virtual bool | RangedPrefix () |
Allows you to change whether or not a weapon receives ranged prefixes. Return true if the item should receive ranged prefixes and false if it should not. Takes priority over MagicPrefix | |
virtual bool | ReforgePrice (ref int reforgePrice, ref bool canApplyDiscount) |
Returns if the normal reforge pricing is applied. If true or false is returned and the price is altered, the price will equal the altered price. The passed reforge price equals the Item.value. Vanilla pricing will apply 20% discount if applicable and then price the reforge at a third of that value. | |
virtual void | RightClick (Player player) |
Allows you to make things happen when this item is right-clicked in the inventory. More... | |
virtual void | SaveData (TagCompound tag) |
Allows you to save custom data for this item. NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization. NOTE: Try to only save data that isn't default values. More... | |
virtual void | SetDefaults () |
This is where you set all your item's properties, such as width, damage, shootSpeed, defense, etc. For those that are familiar with tAPI, this has the same function as .json files. More... | |
virtual void | SetMatch (bool male, ref int equipSlot, ref bool robes) |
Allows you to modify the equipment that the player appears to be wearing. This hook will only be called for body armor and leg armor. Note that equipSlot is not the same as the item type of the armor the player will appear to be wearing. Worn equipment has a separate set of IDs. You can find the vanilla equipment IDs by looking at the headSlot, bodySlot, and legSlot fields for items, and modded equipment IDs by looking at EquipLoader. If this hook is called on body armor, equipSlot allows you to modify the leg armor the player appears to be wearing. If you modify it, make sure to set robes to true. If this hook is called on leg armor, equipSlot allows you to modify the leg armor the player appears to be wearing, and the robes parameter is useless. Note that this hook is only ever called through this item's associated equipment texture. More... | |
sealed override void | SetupContent () |
If you make a new ModType, seal this override, and call SetStaticDefaults in it. More... | |
virtual bool | Shoot (Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) |
Allows you to modify this item's shooting mechanism. Return false to prevent vanilla's shooting code from running. Returns true by default. This method is called after the ModifyShootStats hook has had a chance to adjust the spawn parameters. More... | |
virtual void | SplitStack (Item decrease, int numberToBeTransfered) |
Allows you to make things happen when an item stack is split. Usually transfers 1 and only occurs with the first transfer. Split stack is called before the stack values are modified. Item is always the new stack which is a clone of decrease. Item.stack will always be 0. It is increased after SplitStack. More... | |
virtual void | Update (ref float gravity, ref float maxFallSpeed) |
Allows you to customize this item's movement when lying in the world. Note that this will not be called if this item is currently being grabbed by a player. More... | |
virtual void | UpdateAccessory (Player player, bool hideVisual) |
Allows you to give effects to this accessory. The hideVisual parameter is whether the player has marked the accessory slot to be hidden from being drawn on the player. More... | |
virtual void | UpdateArmorSet (Player player) |
Allows you to give set bonuses to the armor set that this armor is in. Set player.setBonus to a string for the bonus description. More... | |
virtual void | UpdateEquip (Player player) |
Allows you to give effects to this armor or accessory, such as increased damage. More... | |
virtual void | UpdateInventory (Player player) |
Allows you to make things happen when this item is in the player's inventory (for example, how the cell phone makes information display). More... | |
virtual void | UpdateVanity (Player player) |
Allows you to give effects to this accessory when equipped in a vanity slot. Vanilla uses this for boot effects, wings and merman/werewolf visual flags More... | |
virtual void | UpdateVanitySet (Player player) |
Allows you to create special effects (such as dust) when the player wears this item's vanity set. This hook will only be called if the player is not frozen in any way. Note that this hook is only ever called through this item's associated equipment texture. More... | |
virtual void | UseAnimation (Player player) |
Allows you to make things happen when this item's use animation starts. Runs on all clients and server. Use More... | |
virtual float | UseAnimationMultiplier (Player player) |
Allows you to change the effective useAnimation of an item. Note that this hook may cause items' actions to run less or more times than they should per a single use. More... | |
virtual ? bool | UseItem (Player player) |
Allows you to make things happen when this item is used. The return value controls whether or not ApplyItemTime will be called for the player. Return true if the item actually did something, to force itemTime. Return false to keep itemTime at 0. Return null for vanilla behavior. Runs on all clients and server. Use More... | |
virtual void | UseItemFrame (Player player) |
Allows you to modify the player's animation when this item is being used. More... | |
virtual void | UseItemHitbox (Player player, ref Rectangle hitbox, ref bool noHitbox) |
Changes the hitbox of this melee weapon when it is used. More... | |
virtual float | UseSpeedMultiplier (Player player) |
Allows you to safely change both useTime and useAnimation while keeping the values relative to each other. Useful for status effects. More... | |
virtual void | UseStyle (Player player, Rectangle heldItemFrame) |
Allows you to modify the location and rotation of this item in its use animation. More... | |
virtual float | UseTimeMultiplier (Player player) |
Allows you to change the effective useTime of an item. Note that this hook may cause items' actions to run less or more times than they should per a single use. More... | |
virtual void | VerticalWingSpeeds (Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) |
Allows you to modify the speeds at which you rise and fall when these wings are equipped. More... | |
virtual bool | WeaponPrefix () |
Allows you to change whether or not a weapon only receives generic prefixes. Return true if the item should only receive generic prefixes and false if it should not. Takes priority over RangedPrefix and MagicPrefix Ignored if MeleePrefix returns true | |
virtual bool | WingUpdate (Player player, bool inUse) |
Allows for Wings to do various things while in use. "inUse" is whether or not the jump button is currently pressed. Called when these wings visually appear on the player. Use to animate wings, create dusts, invoke sounds, and create lights. Note that this hook is only ever called through this item's associated equipment texture. False will keep everything the same. True, you need to handle all animations in your own code. More... | |
Public Member Functions inherited from Terraria.ModLoader.ModType< Item, ModItem > | |
virtual TModType | Clone (TEntity newEntity) |
Create a copy of this instanced global. Called when an entity is cloned. More... | |
virtual bool | IsLoadingEnabled (Mod mod) |
Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More... | |
virtual void | Load () |
Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More... | |
virtual TModType | NewInstance (TEntity entity) |
Create a new instance of this ModType for a specific entity More... | |
virtual void | SetStaticDefaults () |
Allows you to modify the properties after initial loading has completed. More... | |
virtual void | SetupContent () |
If you make a new ModType, seal this override, and call SetStaticDefaults in it. More... | |
virtual void | Unload () |
Allows you to safely unload things you added in Load. More... | |
virtual bool | IsLoadingEnabled (Mod mod) |
Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More... | |
abstract void | Load (Mod mod) |
Called when loading the type. More... | |
abstract void | Unload () |
Called during unloading when needed. More... | |
Protected Member Functions | |
override Item | CreateTemplateEntity () |
sealed override void | Register () |
If you make a new ModType, seal this override. More... | |
override void | ValidateType () |
Check for the correct overrides of different hook methods and fields and properties More... | |
Protected Member Functions inherited from Terraria.ModLoader.ModType< Item, ModItem > | |
abstract TEntity | CreateTemplateEntity () |
virtual void | InitTemplateInstance () |
Create dummy objects for instanced mod-types | |
override void | InitTemplateInstance () |
Create dummy objects for instanced mod-types | |
abstract void | Register () |
If you make a new ModType, seal this override. More... | |
virtual void | ValidateType () |
Check for the correct overrides of different hook methods and fields and properties More... | |
Properties | |
virtual int | BossBagNPC [get] |
The type of NPC that drops this boss bag. Used to determine how many coins this boss bag contains. Defaults to 0, which means this isn't a boss bag. | |
ModTranslation | DisplayName [get, set] |
The translations for the display name of this item. | |
Item | Item [get] |
The item object that this ModItem controls. | |
int | SacrificeTotal [get, set] |
Easy get/set for an item's Sacrifice Total Count | |
virtual string | Texture [get] |
The file name of this type's texture file in the mod loader's file space. | |
ModTranslation | Tooltip [get, set] |
The translations for the tooltip of this item. | |
int | Type [get] |
Shorthand for Item.type; | |
Properties inherited from Terraria.ModLoader.ModType< Item, ModItem > | |
virtual bool | CloneNewInstances [get] |
Whether to create new instances of this mod type via Clone(TEntity) or via the default constructor Defaults to false (default constructor). | |
TEntity | Entity [get, set] |
string | FullName [get] |
The internal name of this, including the mod it is from. More... | |
virtual bool | IsCloneable [get] |
Whether or not this type is cloneable. Cloning is supported if all reference typed fields in each sub-class which doesn't override Clone are marked with [CloneByReference] | |
Mod | Mod [get, set] |
The mod this belongs to. More... | |
virtual string | Name [get] |
The internal name of this. More... | |
Properties inherited from Terraria.ModLoader.IModType | |
string | FullName [get] |
=> $"{Mod.Name}/{Name}" More... | |
Mod | Mod [get] |
The mod this belongs to. More... | |
string | Name [get] |
The internal name of this instance. More... | |
This class serves as a place for you to place all your properties and hooks for each item. Create instances of ModItem (preferably overriding this class) to pass as parameters to Mod.AddItem.
The Basic Item Guide
teaches the basics of making a modded item.
|
virtual |
This is essentially the same as Mod.AddRecipes. Do note that this will be called for every instance of the overriding ModItem class that is added to the game. This allows you to avoid clutter in your overriding Mod class by adding recipes for which this item is the result.
Reimplemented in Terraria.ModLoader.Default.AprilFools.
|
virtual |
Allows you to make this item usable by right-clicking. Returns false by default. When this item is used by right-clicking, player.altFunctionUse will be set to 2.
player | The player. |
|
virtual |
Allows you to set what the Angler says when he requests for this item. The description parameter is his dialogue, and catchLocation should be set to "\n(Caught at [location])".
description | The description. |
catchLocation | The catch location. |
|
virtual |
Allows you to modify which glow mask and in what color is drawn on the player's arms. Note that this is only called for body armor. Also note that this hook is only ever called through this item's associated equipment texture.
drawPlayer | The draw player. |
shadow | The shadow. |
glowMask | The glow mask. |
color | The color. |
|
virtual |
Allows you to determine special visual effects this vanity set has on the player without having to code them yourself. Note that this hook is only ever called through this item's associated equipment texture. Use the player.armorEffectDraw bools to activate the desired effects.
player | The player. |
|
virtual |
Allows you to tell the game whether this item is a torch that cannot be placed in liquid, a torch that can be placed in liquid, or a glowstick. This information is used for when the player is holding down the auto-select keybind.
dryTorch | if set to true [dry torch]. |
wetTorch | if set to true [wet torch]. |
glowstick | if set to true [glowstick]. |
|
virtual |
Allows you to modify the autoswing (auto-reuse) behavior of this item without having to mess with Item.autoReuse.
Useful to create effects like the Feral Claws which makes melee weapons and whips auto-reusable.
Return true to enable autoswing (if not already enabled through autoReuse), return false to prevent autoswing. Returns null by default, which applies vanilla behavior.
player | The player. |
Whether or not this ammo item is valid for the given weapon. If this, or CanChooseAmmo on the weapon, returns false, then the ammo will not be valid for this weapon.
By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid.
If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called.
weapon | The weapon attempting to select the ammo. |
player | The player which the weapon and this potential ammo belong to. |
Whether or not this ammo item will be consumed by the given weapon.
By default, returns true; return false to prevent ammo consumption.
If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called.
weapon | The weapon attempting to consume the ammo. |
player | The player which the weapon and this ammo belong to. |
Allows you to determine whether this item can catch the given NPC.
Return true or false to say the given NPC can or cannot be caught, respectively, regardless of vanilla rules.
Returns null by default, which allows vanilla's NPC catching rules to decide the target's fate.
If this returns false, CombinedHooks.OnCatchNPC is never called.
NOTE: this does not classify the given item as an NPC-catching tool, which is necessary for catching NPCs in the first place.
To do that, you will need to use the "CatchingTool" set in ItemID.Sets.
target | The NPC the player is trying to catch. |
player | The player attempting to catch the NPC. |
Whether or not the given ammo item is valid for this weapon. If this, or CanBeChosenAsAmmo on the ammo, returns false, then the ammo will not be valid for this weapon.
By default, returns null and allows Item.useAmmo and Item.ammo to decide. Return true to make the ammo valid regardless of these fields, and return false to make it invalid.
If false is returned, the CanConsumeAmmo, CanBeConsumedAsAmmo, OnConsumeAmmo, and OnConsumedAsAmmo hooks are never called.
ammo | The ammo that the weapon is attempting to select. |
player | The player which this weapon and the potential ammo belong to. |
Whether or not the given ammo item will be consumed by this weapon.
By default, returns true; return false to prevent ammo consumption.
If false is returned, the OnConsumeAmmo and OnConsumedAsAmmo hooks are never called.
ammo | The ammo that the weapon is attempting to consume. |
player | The player which this weapon and the ammo belong to. |
|
virtual |
Choose if this item will be consumed or not when used as bait. return null for vanilla behaviour.
player | The Player that owns the bait |
|
virtual |
Allows you to disallow the player from equipping this accessory. Return false to disallow equipping this accessory. Returns true by default.
player | The player. |
slot | The inventory slot that the item is attempting to occupy. |
modded | If the inventory slot index is for modded slots. |
Allows you to determine whether this melee weapon can hit the given NPC when swung. Return true to allow hitting the target, return false to block this weapon from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default.
player | The player. |
target | The target. |
Allows you to determine whether this melee weapon can hit the given opponent player when swung. Return false to block this weapon from hitting the target. Returns true by default.
player | The player. |
target | The target. |
true
if this instance [can hit PVP] the specified player; otherwise, false
.
|
virtual |
Allows you to determine whether or not the item can be picked up
player | The player. |
|
virtual |
Returns whether or not this item does something when it is right-clicked in the inventory. Returns false by default.
Reimplemented in Terraria.ModLoader.Default.StartBag.
|
virtual |
Allows you to prevent this item from shooting a projectile on use. Returns true by default.
player | The player using the item. |
|
virtual |
Allows you to decide if this item is allowed to stack with another of its type.
This is only called when attempting to stack with an item of the same type.
This is not called for coins in inventory/UI.
This covers all scenarios, if you just need to change in-world stacking behavior, use CanStackInWorld.
|
virtual |
Allows you to decide if this item is allowed to stack with another of its type in the world.
This is only called when attempting to stack with an item of the same type.
|
virtual |
Returns whether or not this item can be used. By default returns true.
player | The player using the item. |
|
virtual |
Allows you to determine how many of this item a player obtains when the player fishes this item.
stack | The stack. |
|
virtual |
Allows you to manually choose what prefix an item will get.
|
virtual |
If this item is consumable and this returns true, then this item will be consumed upon usage. Returns true by default. If false is returned, the OnConsumeItem hook is never called.
player | The player. |
|
protectedvirtual |
Implements Terraria.ModLoader.ModType< Item, ModItem >.
|
virtual |
Allows you to modify the colors in which this armor and surrounding accessories are drawn, in addition to which glow mask and in what color is drawn. Note that this hook is only ever called through this item's associated equipment texture.
drawPlayer | The draw player. |
shadow | The shadow. |
color | The color. |
glowMask | The glow mask. |
glowMaskColor | Color of the glow mask. |
Allows you to create special effects (such as dust) when this item's equipment texture of the given equipment type is displayed on the player. Note that this hook is only ever called through this item's associated equipment texture.
player | The player. |
type | The type. |
|
virtual |
Allows you to modify what item, and in what quantity, is obtained when this item is fed into the Extractinator. By default the parameters will be set to the output of feeding Silt/Slush into the Extractinator.
resultType | Type of the result. |
resultStack | The result stack. |
|
virtual |
Allows you to determine the color and transparency in which this item is drawn. Return null to use the default color (normally light color). Returns null by default.
lightColor | Color of the light. |
|
virtual |
Allows you to temporarily modify the amount of life a life healing item will heal for, based on player buffs, accessories, etc. This is only called for items with a healLife value.
player | The player using the item. |
quickHeal | Whether the item is being used through quick heal or not. |
healValue | The amount of life being healed. |
|
virtual |
Allows you to temporarily modify the amount of mana a mana healing item will heal for, based on player buffs, accessories, etc. This is only called for items with a healMana value.
player | The player using the item. |
quickHeal | Whether the item is being used through quick heal or not. |
healValue | The amount of mana being healed. |
|
virtual |
Allows you to modify how close this item must be to the player in order to move towards the player.
player | The player. |
grabRange | The grab range. |
|
virtual |
Allows you to modify the way this item moves towards the player. Return true if you override this hook; returning false will allow the vanilla grab style to take place. Returns false by default.
player | The player. |
|
virtual |
Allows you to make things happen when the player is holding this item (for example, torches make light and water candles increase spawn rate).
player | The player. |
|
virtual |
Allows you to modify the player's animation when the player is holding this item.
player | The player. |
|
virtual |
Allows you to determine the offset of this item's sprite when used by the player. This is only used for items with a useStyle of 5 that aren't staves. Return null to use the vanilla holdout offset; returns null by default.
|
virtual |
Allows you to determine the point on this item's sprite that the player holds onto when using this item. The origin is from the bottom left corner of the sprite. This is only used for staves with a useStyle of 5. Return null to use the vanilla holdout origin (zero); returns null by default.
|
virtual |
Allows you to modify the location and rotation of this item when the player is holding it.
player | The player. |
heldItemFrame | The source rectangle for the held item's texture. |
|
virtual |
Allows you to modify these wing's horizontal flight speed and acceleration.
player | The player. |
speed | The speed. |
acceleration | The acceleration. |
Returns whether or not the head armor, body armor, and leg armor make up a set. If this returns true, then this item's UpdateArmorSet method will be called. Returns false by default.
head | The head. |
body | The body. |
legs | The legs. |
|
virtual |
Returns whether or not the head armor, body armor, and leg armor textures make up a set. This hook is used for the PreUpdateVanitySet, UpdateVanitySet, and ArmorSetShadows hooks. By default, this will return the same value as the IsArmorSet hook (passing the equipment textures' associated items as parameters), so you will not have to use this hook unless you want vanity effects to be entirely separate from armor sets. Note that this hook is only ever called through this item's associated equipment texture.
head | The head. |
body | The body. |
legs | The legs. |
|
virtual |
Return true to specify that the item can be picked up despite not having enough room in inventory. Useful for something like hearts or experience items. Use in conjunction with OnPickup to actually consume the item and handle it.
player | The player. |
|
virtual |
Allows you to load custom data that you have saved for this item.
Try to write defensive loading code that won't crash if something's missing.
tag | The TagCompound to load data from. |
Reimplemented in Terraria.ModLoader.Default.StartBag, and Terraria.ModLoader.Default.UnloadedItem.
|
virtual |
Allows you to give this melee weapon special effects, such as creating light or dust.
player | The player. |
hitbox | The hitbox. |
|
virtual |
Allows you to modify the damage, knockback, etc., that this melee weapon does to an NPC.
player | The player. |
target | The target. |
damage | The damage. |
knockBack | The knock back. |
crit | if set to true [crit]. |
|
virtual |
Allows you to modify the damage, etc., that this melee weapon does to a player.
player | The player. |
target | The target. |
damage | The damage. |
crit | if set to true [crit]. |
|
virtual |
Allows you to add and modify the loot items that spawn from bag items when opened. The Basic NPC Drops and Loot 1.4 Guideexplains how to use the ModNPC.ModifyNPCLoot(NPCLoot) hook to modify NPC loot as well as this hook. A common usage is to use this hook and ModNPC.ModifyNPCLoot(NPCLoot) to edit non-expert exlclusive drops for bosses.
This hook only runs once during mod loading, any dynamic behavior must be contained in the rules themselves.
itemLoot | A reference to the item drop database for this item type |
|
virtual |
Allows you to dynamically modify this item's size for the given player, similarly to the effect of the Titan Glove.
player | The player wielding this item. |
scale | The scale multiplier to be applied to this item. Will be 1.1 if the Titan Glove is equipped, and 1 otherwise. |
|
virtual |
Allows you to temporarily modify the amount of mana this item will consume on use, based on player buffs, accessories, etc. This is only called for items with a mana value.
player | The player using the item. |
reduce | Used for decreasingly stacking buffs (most common). Only ever use -= on this field. |
mult | Use to directly multiply the item's effective mana cost. Good for debuffs, or things which should stack separately (eg meteor armor set bonus). |
|
virtual |
Allows you to set an item's sorting group in Journey Mode's duplication menu. This is useful for setting custom item types that group well together, or whenever the default vanilla sorting doesn't sort the way you want it.
itemGroup | The item group this item is being assigned to |
|
virtual |
Allows you to modify the position, velocity, type, damage and/or knockback of a projectile being shot by this item.
These parameters will be provided to Shoot(Player, EntitySource_ItemUse_WithAmmo, Vector2, Vector2, int, int, float) where the projectile will actually be spawned.
player | The player using the item. |
position | The center position of the projectile. |
velocity | The velocity of the projectile. |
type | The ID of the projectile. |
damage | The damage of the projectile. |
knockback | The knockback of the projectile. |
|
virtual |
Allows you to modify all the tooltips that display for this item. See here for information about TooltipLine.
tooltips | The tooltips. |
Reimplemented in Terraria.ModLoader.Default.UnloadedItem.
|
virtual |
Allows you to dynamically modify a weapon's crit chance based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer.
player | The player using the item. |
crit | The total crit chance of the item after all normal crit chance calculations. |
|
virtual |
Allows you to dynamically modify a weapon's damage based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer.
player | The player using the item. |
damage | The StatModifier object representing the totality of the various modifiers to be applied to the item's base damage. |
|
virtual |
Allows you to dynamically modify a weapon's knockback based on player and item conditions. Can be utilized to modify damage beyond the tools that DamageClass has to offer.
player | The player using the item. |
knockback | The StatModifier object representing the totality of the various modifiers to be applied to the item's base knockback. |
|
virtual |
Receives the custom data sent in NetSend.
Called whenever an item container syncs its contents (various MessageIDs and sources), or MessageID.SyncItem and MessageID.InstancedItem are successfully received.
Can be called on both server and client.
reader | The reader. |
Reimplemented in Terraria.ModLoader.Default.UnloadedItem.
|
virtual |
Allows you to send custom data for this item between client and server, which will be handled in NetReceive.
Called whenever an item container syncs its contents (various MessageIDs and sources), or MessageID.SyncItem and MessageID.InstancedItem are successfully sent, for example when the item is dropped into the world.
Can be called on both server and client.
writer | The writer. |
Reimplemented in Terraria.ModLoader.Default.UnloadedItem.
Allows you to make things happen when the given ammo is consumed by this weapon.
Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place.
ammo | The ammo that this weapon is currently using. |
player | The player which this weapon and the ammo belong to. |
Allows you to make things happen when this ammo is consumed by the given weapon.
Called before the ammo stack is reduced, and is never called if the ammo isn't consumed in the first place.
weapon | The weapon that is currently using this ammo. |
player | The player which the weapon and this ammo belong to. |
|
virtual |
Allows you to make things happen when this item is consumed. Called before the item stack is reduced.
player | The player. |
|
virtual |
Allows you to make stuff happen when a player consumes mana on use of this item.
player | The player using the item. |
manaConsumed | The mana consumed from the player. |
|
virtual |
Allows you to make anything happen when the player crafts this item using the given recipe.
recipe | The recipe that was used to craft this item. |
|
virtual |
Allows you to create special effects when this melee weapon hits an NPC (for example how the Pumpkin Sword creates pumpkin heads).
player | The player. |
target | The target. |
damage | The damage. |
knockBack | The knock back. |
crit | if set to true [crit]. |
|
virtual |
Allows you to create special effects when this melee weapon hits a player.
player | The player. |
target | The target. |
damage | The damage. |
crit | if set to true [crit]. |
|
virtual |
Allows you to make stuff happen when a player doesn't have enough mana for the item they are trying to use. If the player has high enough mana after this hook runs, mana consumption will happen normally. Only runs once per item use.
player | The player using the item. |
neededMana | The mana needed to use the item. |
|
virtual |
Allows you to make special things happen when the player picks up this item. Return false to stop the item from being added to the player's inventory; returns true by default.
player | The player. |
|
virtual |
Allows you to create custom behaviour when an item is accepted by the Research function
fullyResearched | True if the item was completely researched, and is ready to be duplicated, false if only partially researched. |
|
virtual |
Allows you to make things happen when items stack together.
This item will have its stack increased that will have its stack increased.
decrease | The item that will be removed or have its stack reduced. |
numberToBeTransfered | The number that will be transfered from decrease to this item. |
|
virtual |
Allows you to modify various properties of the projectile created by a weapon based on the ammo it is using. This hook is called on the ammo.
weapon | The item that is using this ammo. |
player | The player using the item. |
type | The ID of the fired projectile. |
speed | The speed of the fired projectile. |
damage | The damage modifier for the projectile. Total weapon damage is included as Flat damage. Be careful not to apply flat or base damage bonuses which are already applied to the weapon. |
knockback | The knockback of the fired projectile. |
|
virtual |
Allows you to draw things in front of this item in the inventory. This method is called even if PreDrawInInventory returns false.
spriteBatch | The sprite batch. |
position | The position. |
frame | The frame. |
drawColor | Color of the draw. |
itemColor | Color of the item. |
origin | The origin. |
scale | The scale. |
|
virtual |
Allows you to draw things in front of this item. This method is called even if PreDrawInWorld returns false.
spriteBatch | The sprite batch. |
lightColor | Color of the light. |
alphaColor | Color of the alpha. |
rotation | The rotation. |
scale | The scale. |
whoAmI | The who am i. |
|
virtual |
Allows you to do things after this item's tooltip is drawn. The lines contain draw information as this is ran after drawing the tooltip.
lines | The tooltip lines for this item |
|
virtual |
Allows you to do things after a tooltip line of this item is drawn. The line contains draw info.
line | The line that was drawn |
|
virtual |
Allows you to draw things behind this item in the inventory. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default.
spriteBatch | The sprite batch. |
position | The position. |
frame | The frame. |
drawColor | Color of the draw. |
itemColor | Color of the item. |
origin | The origin. |
scale | The scale. |
|
virtual |
Allows you to draw things behind this item, or to modify the way this item is drawn in the world. Return false to stop the game from drawing the item (useful if you're manually drawing the item). Returns true by default.
spriteBatch | The sprite batch. |
lightColor | Color of the light. |
alphaColor | Color of the alpha. |
rotation | The rotation. |
scale | The scale. |
whoAmI | The who am i. |
|
virtual |
Allows you to do things before this item's tooltip is drawn.
lines | The tooltip lines for this item |
x | The top X position for this tooltip. It is where the first line starts drawing |
y | The top Y position for this tooltip. It is where the first line starts drawing |
|
virtual |
Allows you to do things before a tooltip line of this item is drawn. The line contains draw info.
line | The line that would be drawn |
yOffset | The Y offset added for next tooltip lines |
|
virtual |
To prevent putting the item in the tinkerer slot, return false when pre is -3. To prevent rolling of a prefix on spawn, return false when pre is -1. To force rolling of a prefix on spawn, return true when pre is -1.
To reduce the probability of a prefix on spawn (pre == -1) to X%, return false 100-4X % of the time. To increase the probability of a prefix on spawn (pre == -1) to X%, return true (4X-100)/3 % of the time.
To delete a prefix from an item when the item is loaded, return false when pre is the prefix you want to delete. Use AllowPrefix to prevent rolling of a certain prefix.
pre | The prefix being applied to the item, or the roll mode. -1 is when the item is naturally generated in a chest, crafted, purchased from an NPC, looted from a grab bag (excluding presents), or dropped by a slain enemy (if it's spawned with prefixGiven: -1). -2 is when the item is rolled in the tinkerer. -3 determines if the item can be placed in the tinkerer slot. |
rand | The random number generator class to be used in random choices |
|
virtual |
Allows you to create special effects (such as the necro armor's hurt noise) when the player wears this item's vanity set. This hook is called regardless of whether the player is frozen in any way. Note that this hook is only ever called through this item's associated equipment texture.
player | The player. |
|
protectedvirtual |
If you make a new ModType, seal this override.
Implements Terraria.ModLoader.ModType< Item, ModItem >.
|
virtual |
Allows you to make things happen when this item is right-clicked in the inventory.
player | The player. |
Reimplemented in Terraria.ModLoader.Default.StartBag.
|
virtual |
Allows you to save custom data for this item.
NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization.
NOTE: Try to only save data that isn't default values.
tag | The TagCompound to save data into. Note that this is always empty by default, and is provided as an argument only for the sake of convenience and optimization. |
Reimplemented in Terraria.ModLoader.Default.StartBag, and Terraria.ModLoader.Default.UnloadedItem.
|
virtual |
This is where you set all your item's properties, such as width, damage, shootSpeed, defense, etc. For those that are familiar with tAPI, this has the same function as .json files.
Reimplemented in Terraria.ModLoader.Default.AprilFools, Terraria.ModLoader.Default.StartBag, and Terraria.ModLoader.Default.UnloadedItem.
|
virtual |
Allows you to modify the equipment that the player appears to be wearing. This hook will only be called for body armor and leg armor. Note that equipSlot is not the same as the item type of the armor the player will appear to be wearing. Worn equipment has a separate set of IDs. You can find the vanilla equipment IDs by looking at the headSlot, bodySlot, and legSlot fields for items, and modded equipment IDs by looking at EquipLoader. If this hook is called on body armor, equipSlot allows you to modify the leg armor the player appears to be wearing. If you modify it, make sure to set robes to true. If this hook is called on leg armor, equipSlot allows you to modify the leg armor the player appears to be wearing, and the robes parameter is useless. Note that this hook is only ever called through this item's associated equipment texture.
male | if set to true [male]. |
equipSlot | The equip slot. |
robes | if set to true [robes]. |
|
virtual |
If you make a new ModType, seal this override, and call SetStaticDefaults in it.
Reimplemented from Terraria.ModLoader.ModType< Item, ModItem >.
|
virtual |
Allows you to modify this item's shooting mechanism. Return false to prevent vanilla's shooting code from running. Returns true by default.
This method is called after the ModifyShootStats hook has had a chance to adjust the spawn parameters.
player | The player using the item. |
source | The projectile source's information. |
position | The center position of the projectile. |
velocity | The velocity of the projectile. |
type | The ID of the projectile. |
damage | The damage of the projectile. |
knockback | The knockback of the projectile. |
|
virtual |
Allows you to make things happen when an item stack is split. Usually transfers 1 and only occurs with the first transfer. Split stack is called before the stack values are modified.
Item is always the new stack which is a clone of decrease. Item.stack will always be 0. It is increased after SplitStack.
decrease | The original item that will have it's stack reduced. |
numberToBeTransfered | The number that will be transfered from decrease to this item. |
|
virtual |
Allows you to customize this item's movement when lying in the world. Note that this will not be called if this item is currently being grabbed by a player.
gravity | The gravity. |
maxFallSpeed | The maximum fall speed. |
|
virtual |
Allows you to give effects to this accessory. The hideVisual parameter is whether the player has marked the accessory slot to be hidden from being drawn on the player.
player | The player. |
hideVisual | if set to true the accessory is hidden. |
|
virtual |
Allows you to give set bonuses to the armor set that this armor is in. Set player.setBonus to a string for the bonus description.
player | The player. |
|
virtual |
Allows you to give effects to this armor or accessory, such as increased damage.
player | The player. |
|
virtual |
Allows you to make things happen when this item is in the player's inventory (for example, how the cell phone makes information display).
player | The player. |
|
virtual |
Allows you to give effects to this accessory when equipped in a vanity slot. Vanilla uses this for boot effects, wings and merman/werewolf visual flags
player | The player. |
|
virtual |
Allows you to create special effects (such as dust) when the player wears this item's vanity set. This hook will only be called if the player is not frozen in any way. Note that this hook is only ever called through this item's associated equipment texture.
player | The player. |
|
virtual |
Allows you to make things happen when this item's use animation starts. Runs on all clients and server. Use
if (player.whoAmI == Main.myPlayer)
and if (Main.netMode == NetmodeID.??)
if appropriate.
player | The player. |
|
virtual |
Allows you to change the effective useAnimation of an item.
Note that this hook may cause items' actions to run less or more times than they should per a single use.
|
virtual |
Allows you to make things happen when this item is used. The return value controls whether or not ApplyItemTime will be called for the player.
Return true if the item actually did something, to force itemTime.
Return false to keep itemTime at 0.
Return null for vanilla behavior. Runs on all clients and server. Use
if (player.whoAmI == Main.myPlayer)
and if (Main.netMode == NetmodeID.??)
if appropriate.
player | The player. |
Reimplemented in Terraria.ModLoader.Default.AprilFools.
|
virtual |
Allows you to modify the player's animation when this item is being used.
player | The player. |
|
virtual |
Changes the hitbox of this melee weapon when it is used.
player | The player. |
hitbox | The hitbox. |
noHitbox | if set to true [no hitbox]. |
|
virtual |
Allows you to safely change both useTime and useAnimation while keeping the values relative to each other.
Useful for status effects.
|
virtual |
Allows you to modify the location and rotation of this item in its use animation.
player | The player. |
heldItemFrame | The source rectangle for the held item's texture. |
|
virtual |
Allows you to change the effective useTime of an item.
Note that this hook may cause items' actions to run less or more times than they should per a single use.
|
protectedvirtual |
Check for the correct overrides of different hook methods and fields and properties
Reimplemented from Terraria.ModLoader.ModType< Item, ModItem >.
|
virtual |
Allows you to modify the speeds at which you rise and fall when these wings are equipped.
player | The player. |
ascentWhenFalling | The ascent when falling. |
ascentWhenRising | The ascent when rising. |
maxCanAscendMultiplier | The maximum can ascend multiplier. |
maxAscentMultiplier | The maximum ascent multiplier. |
constantAscend | The constant ascend. |
|
virtual |
Allows for Wings to do various things while in use. "inUse" is whether or not the jump button is currently pressed. Called when these wings visually appear on the player. Use to animate wings, create dusts, invoke sounds, and create lights. Note that this hook is only ever called through this item's associated equipment texture. False will keep everything the same. True, you need to handle all animations in your own code.
player | The player. |
inUse | if set to true [in use]. |