Terraria ModLoader  0.11.4
A framework for Terraria mods
GlobalItem.cs
Go to the documentation of this file.
1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
3 using System;
4 using System.Collections.Generic;
5 using System.Collections.ObjectModel;
6 using System.IO;
7 using Terraria.ModLoader.IO;
8 using Terraria.Utilities;
9 
10 namespace Terraria.ModLoader
11 {
15  public class GlobalItem
16  {
20  public Mod mod {
21  get;
22  internal set;
23  }
24 
28  public string Name {
29  get;
30  internal set;
31  }
32 
33  internal int index;
34  internal int instanceIndex;
35 
39  public virtual bool Autoload(ref string name) {
40  return mod.Properties.Autoload;
41  }
42 
48  public virtual bool InstancePerEntity => false;
49 
50  public GlobalItem Instance(Item item) => InstancePerEntity ? item.globalItems[instanceIndex] : this;
51 
56  public virtual bool CloneNewInstances => false;
57 
63  public virtual GlobalItem Clone() => (GlobalItem)MemberwiseClone();
64 
71  public virtual GlobalItem Clone(Item item, Item itemClone) => NewInstance(item);
72 
79  public virtual GlobalItem NewInstance(Item item) {
80  if (CloneNewInstances)
81  return Clone();
82 
83  var copy = (GlobalItem)Activator.CreateInstance(GetType());
84  copy.mod = mod;
85  copy.Name = Name;
86  copy.index = index; //not necessary, but consistency
87  copy.instanceIndex = instanceIndex;//shouldn't be used, but someone might
88  return copy;
89  }
90 
94  public virtual void SetDefaults(Item item) {
95  }
96 
101  public virtual int ChoosePrefix(Item item, UnifiedRandom rand) {
102  return -1;
103  }
104 
108  public virtual bool CanUseItem(Item item, Player player) {
109  return true;
110  }
111 
115  public virtual void UseStyle(Item item, Player player) {
116  }
117 
121  public virtual void HoldStyle(Item item, Player player) {
122  }
123 
127  public virtual void HoldItem(Item item, Player player) {
128  }
129 
134  public virtual float UseTimeMultiplier(Item item, Player player) {
135  return 1f;
136  }
137 
142  public virtual float MeleeSpeedMultiplier(Item item, Player player) {
143  return 1f;
144  }
145 
153  public virtual void GetHealLife(Item item, Player player, bool quickHeal, ref int healValue) {
154  }
155 
163  public virtual void GetHealMana(Item item, Player player, bool quickHeal, ref int healValue) {
164  }
165 
173  public virtual void ModifyManaCost(Item item, Player player, ref float reduce, ref float mult) {
174  }
175 
184  public virtual void OnMissingMana(Item item, Player player, int neededMana) {
185  }
186 
193  public virtual void OnConsumeMana(Item item, Player player, int manaConsumed) {
194  }
195 
206  [Obsolete("Use ModifyWeaponDamage", true)]
207  public virtual void GetWeaponDamage(Item item, Player player, ref int damage) {
208  }
209 
217  [Obsolete("Use ModifyWeaponDamage overload with the additional flat parameter")]
218  public virtual void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult) {
219  }
220 
229  public virtual void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat) {
230  }
231 
242  public virtual void GetWeaponKnockback(Item item, Player player, ref float knockback) {
243  }
244 
256  public virtual void GetWeaponCrit(Item item, Player player, ref int crit) {
257  }
258 
269  public virtual void PickAmmo(Item weapon, Item ammo, Player player, ref int type, ref float speed, ref int damage, ref float knockback) {
270  }
271 
272  [Obsolete("PickAmmo now has a weapon parameter that represents the item using the ammo.")]
273  public virtual void PickAmmo(Item item, Player player, ref int type, ref float speed, ref int damage, ref float knockback) {
274  }
275 
280  public virtual bool ConsumeAmmo(Item item, Player player) {
281  return true;
282  }
283 
288  public virtual void OnConsumeAmmo(Item item, Player player) {
289  }
290 
303  public virtual bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) {
304  return true;
305  }
306 
310  public virtual void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox) {
311  }
312 
316  public virtual void MeleeEffects(Item item, Player player, Rectangle hitbox) {
317  }
318 
322  public virtual bool? CanHitNPC(Item item, Player player, NPC target) {
323  return null;
324  }
325 
329  public virtual void ModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) {
330  }
331 
335  public virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit) {
336  }
337 
341  public virtual bool CanHitPvp(Item item, Player player, Player target) {
342  return true;
343  }
344 
348  public virtual void ModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit) {
349  }
350 
354  public virtual void OnHitPvp(Item item, Player player, Player target, int damage, bool crit) {
355  }
356 
360  public virtual bool UseItem(Item item, Player player) {
361  return false;
362  }
363 
368  public virtual bool ConsumeItem(Item item, Player player) {
369  return true;
370  }
371 
376  public virtual void OnConsumeItem(Item item, Player player) {
377  }
378 
382  public virtual bool UseItemFrame(Item item, Player player) {
383  return false;
384  }
385 
389  public virtual bool HoldItemFrame(Item item, Player player) {
390  return false;
391  }
392 
396  public virtual bool AltFunctionUse(Item item, Player player) {
397  return false;
398  }
399 
403  public virtual void UpdateInventory(Item item, Player player) {
404  }
405 
409  public virtual void UpdateEquip(Item item, Player player) {
410  }
411 
415  public virtual void UpdateAccessory(Item item, Player player, bool hideVisual) {
416  }
417 
425  public virtual string IsArmorSet(Item head, Item body, Item legs) {
426  return "";
427  }
428 
435  public virtual void UpdateArmorSet(Player player, string set) {
436  }
437 
445  public virtual string IsVanitySet(int head, int body, int legs) {
446  Item headItem = new Item();
447  if (head >= 0) {
448  headItem.SetDefaults(Item.headType[head], true);
449  }
450  Item bodyItem = new Item();
451  if (body >= 0) {
452  bodyItem.SetDefaults(Item.bodyType[body], true);
453  }
454  Item legItem = new Item();
455  if (legs >= 0) {
456  legItem.SetDefaults(Item.legType[legs], true);
457  }
458  return IsArmorSet(headItem, bodyItem, legItem);
459  }
460 
467  public virtual void PreUpdateVanitySet(Player player, string set) {
468  }
469 
475  public virtual void UpdateVanitySet(Player player, string set) {
476  }
477 
484  public virtual void ArmorSetShadows(Player player, string set) {
485  }
486 
499  public virtual void SetMatch(int armorSlot, int type, bool male, ref int equipSlot, ref bool robes) {
500  }
501 
505  public virtual bool CanRightClick(Item item) {
506  return false;
507  }
508 
512  public virtual void RightClick(Item item, Player player) {
513  }
514 
524  public virtual bool PreOpenVanillaBag(string context, Player player, int arg) {
525  return true;
526  }
527 
537  public virtual void OpenVanillaBag(string context, Player player, int arg) {
538  }
539 
545  public virtual bool ReforgePrice(Item item, ref int reforgePrice, ref bool canApplyDiscount) {
546  return true;
547  }
548 
554  public virtual bool NewPreReforge(Item item) {
555  return true;
556  }
557 
558  // @todo: PreReforge marked obsolete until v0.11
559  [method: Obsolete("PreReforge now returns a bool to control whether the reforge takes place. For now, use NewPreReforge")]
560  public virtual void PreReforge(Item item) {
561  NewPreReforge(item);
562  }
563 
568  public virtual void PostReforge(Item item) {
569  }
570 
577  public virtual void DrawHands(int body, ref bool drawHands, ref bool drawArms) {
578  }
579 
585  public virtual void DrawHair(int head, ref bool drawHair, ref bool drawAltHair) {
586  }
587 
593  public virtual bool DrawHead(int head) {
594  return true;
595  }
596 
602  public virtual bool DrawBody(int body) {
603  return true;
604  }
605 
611  public virtual bool DrawLegs(int legs, int shoes) {
612  return true;
613  }
614 
620  public virtual void DrawArmorColor(EquipType type, int slot, Player drawPlayer, float shadow, ref Color color,
621  ref int glowMask, ref Color glowMaskColor) {
622  }
623 
629  public virtual void ArmorArmGlowMask(int slot, Player drawPlayer, float shadow, ref int glowMask, ref Color color) {
630  }
631 
635  public virtual void VerticalWingSpeeds(Item item, Player player, ref float ascentWhenFalling, ref float ascentWhenRising,
636  ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) {
637  }
638 
642  public virtual void HorizontalWingSpeeds(Item item, Player player, ref float speed, ref float acceleration) {
643  }
644 
653  public virtual bool WingUpdate(int wings, Player player, bool inUse) {
654  return false;
655  }
656 
660  public virtual void Update(Item item, ref float gravity, ref float maxFallSpeed) {
661  }
662 
666  public virtual void PostUpdate(Item item) {
667  }
668 
672  public virtual void GrabRange(Item item, Player player, ref int grabRange) {
673  }
674 
678  public virtual bool GrabStyle(Item item, Player player) {
679  return false;
680  }
681 
685  public virtual bool CanPickup(Item item, Player player) {
686  return true;
687  }
688 
692  public virtual bool OnPickup(Item item, Player player) {
693  return true;
694  }
695 
699  public virtual bool ItemSpace(Item item, Player player) {
700  return false;
701  }
702 
706  public virtual Color? GetAlpha(Item item, Color lightColor) {
707  return null;
708  }
709 
713  public virtual bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) {
714  return true;
715  }
716 
720  public virtual void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) {
721  }
722 
726  public virtual bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame,
727  Color drawColor, Color itemColor, Vector2 origin, float scale) {
728  return true;
729  }
730 
734  public virtual void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame,
735  Color drawColor, Color itemColor, Vector2 origin, float scale) {
736  }
737 
746  public virtual Vector2? HoldoutOffset(int type) {
747  return null;
748  }
749 
757  public virtual Vector2? HoldoutOrigin(int type) {
758  return null;
759  }
760 
767  public virtual bool CanEquipAccessory(Item item, Player player, int slot) {
768  return true;
769  }
770 
778  public virtual void ExtractinatorUse(int extractType, ref int resultType, ref int resultStack) {
779  }
780 
784  public virtual void CaughtFishStack(int type, ref int stack) {
785  }
786 
793  public virtual bool IsAnglerQuestAvailable(int type) {
794  return true;
795  }
796 
803  public virtual void AnglerChat(int type, ref string chat, ref string catchLocation) {
804  }
805 
809  public virtual void AddRecipes() {
810  }
811 
815  public virtual void OnCraft(Item item, Recipe recipe) {
816  }
817 
826  public virtual bool PreDrawTooltip(Item item, ReadOnlyCollection<TooltipLine> lines, ref int x, ref int y) {
827  return true;
828  }
829 
835  public virtual void PostDrawTooltip(Item item, ReadOnlyCollection<DrawableTooltipLine> lines) {
836  }
837 
845  public virtual bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) {
846  return true;
847  }
848 
854  public virtual void PostDrawTooltipLine(Item item, DrawableTooltipLine line) {
855  }
856 
860  public virtual void ModifyTooltips(Item item, List<TooltipLine> tooltips) {
861  }
862 
866  public virtual bool NeedsSaving(Item item) {
867  return false;
868  }
869 
873  public virtual TagCompound Save(Item item) {
874  return null;
875  }
876 
880  public virtual void Load(Item item, TagCompound tag) {
881  }
882 
886  public virtual void LoadLegacy(Item item, BinaryReader reader) {
887  }
888 
892  public virtual void NetSend(Item item, BinaryWriter writer) {
893  }
894 
898  public virtual void NetReceive(Item item, BinaryReader reader) {
899  }
900  }
901 }
virtual string IsArmorSet(Item head, Item body, Item legs)
Allows you to determine whether the player is wearing an armor set, and return a name for this set...
Definition: GlobalItem.cs:425
virtual void PreReforge(Item item)
Definition: GlobalItem.cs:560
virtual void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult)
Allows you to temporarily modify this weapon&#39;s damage based on player buffs, etc. This is useful for ...
Definition: GlobalItem.cs:218
virtual void ModifyManaCost(Item item, Player player, ref float reduce, ref float mult)
Allows you to temporarily modify the amount of mana an item will consume on use, based on player buff...
Definition: GlobalItem.cs:173
virtual bool PreDrawTooltip(Item item, ReadOnlyCollection< TooltipLine > lines, ref int x, ref int y)
Allows you to do things before this item&#39;s tooltip is drawn.
Definition: GlobalItem.cs:826
virtual void GrabRange(Item item, Player player, ref int grabRange)
Allows you to modify how close an item must be to the player in order to move towards the player...
Definition: GlobalItem.cs:672
virtual void LoadLegacy(Item item, BinaryReader reader)
Allows you to load pre-v0.9 custom data that you have saved for the given item.
Definition: GlobalItem.cs:886
virtual float MeleeSpeedMultiplier(Item item, Player player)
Allows you to change the effective useAnimation of an item.
Definition: GlobalItem.cs:142
virtual bool OnPickup(Item item, Player player)
Allows you to make special things happen when the player picks up an item. Return false to stop the i...
Definition: GlobalItem.cs:692
virtual void UpdateVanitySet(Player player, string set)
Allows you to create special effects (such as dust) when the player wears the vanity set with the giv...
Definition: GlobalItem.cs:475
virtual bool CanEquipAccessory(Item item, Player player, int slot)
Allows you to disallow the player from equipping an accessory. Return false to disallow equipping the...
Definition: GlobalItem.cs:767
virtual void ModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that a melee weapon does to a player.
Definition: GlobalItem.cs:348
virtual bool ReforgePrice(Item item, ref int reforgePrice, ref bool canApplyDiscount)
Returns if the normal reforge pricing is applied. If true or false is returned and the price is alter...
Definition: GlobalItem.cs:545
virtual void PostUpdate(Item item)
Allows you to make things happen when an item is lying in the world. This will always be called...
Definition: GlobalItem.cs:666
virtual bool NewPreReforge(Item item)
This hook gets called when the player clicks on the reforge button and can afford the reforge...
Definition: GlobalItem.cs:554
virtual bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset)
Allows you to do things before a tooltip line of this item is drawn. The line contains draw info...
Definition: GlobalItem.cs:845
virtual void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox)
Changes the hitbox of a melee weapon when it is used.
Definition: GlobalItem.cs:310
virtual bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
Allows you to draw things behind an item in the inventory. Return false to stop the game from drawing...
Definition: GlobalItem.cs:726
virtual bool CanUseItem(Item item, Player player)
Returns whether or not any item can be used. Returns true by default. The inability to use a specific...
Definition: GlobalItem.cs:108
virtual void NetReceive(Item item, BinaryReader reader)
Definition: GlobalItem.cs:898
virtual void PostDrawTooltipLine(Item item, DrawableTooltipLine line)
Allows you to do things after a tooltip line of this item is drawn. The line contains draw info...
Definition: GlobalItem.cs:854
virtual void DrawHands(int body, ref bool drawHands, ref bool drawArms)
Allows you to determine whether the skin/shirt on the player&#39;s arms and hands are drawn when a body a...
Definition: GlobalItem.cs:577
virtual void ArmorArmGlowMask(int slot, 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&#39;s arms. Note that this is only called for body armor.
Definition: GlobalItem.cs:629
virtual void OnMissingMana(Item item, Player player, int neededMana)
Allows you to make stuff happen when a player doesn&#39;t have enough mana for an item they are trying to...
Definition: GlobalItem.cs:184
virtual bool DrawHead(int head)
Return false to hide the player&#39;s head when a head armor is worn. Returns true by default...
Definition: GlobalItem.cs:593
virtual bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
This is called before the weapon creates a projectile. You can use it to create special effects...
Definition: GlobalItem.cs:303
virtual void GetWeaponDamage(Item item, Player player, ref int damage)
Allows you to temporarily modify this weapon&#39;s damage based on player buffs, etc. This is useful for ...
Definition: GlobalItem.cs:207
virtual TagCompound Save(Item item)
Allows you to save custom data for the given item. Only called when NeedsCustomSaving returns true...
Definition: GlobalItem.cs:873
virtual Vector2 HoldoutOrigin(int type)
Allows you to determine the point on an item&#39;s sprite that the player holds onto when using the item...
Definition: GlobalItem.cs:757
virtual void MeleeEffects(Item item, Player player, Rectangle hitbox)
Allows you to give melee weapons special effects, such as creating light or dust. ...
Definition: GlobalItem.cs:316
virtual void ExtractinatorUse(int extractType, ref int resultType, ref int resultStack)
Allows you to modify what item, and in what quantity, is obtained when an item of the given type is f...
Definition: GlobalItem.cs:778
virtual void UseStyle(Item item, Player player)
Allows you to modify the location and rotation of any item in its use animation.
Definition: GlobalItem.cs:115
virtual void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
Allows you to draw things in front of an item. This method is called even if PreDrawInWorld returns f...
Definition: GlobalItem.cs:720
virtual bool ConsumeItem(Item item, Player player)
If the item is consumable and this returns true, then the item will be consumed upon usage...
Definition: GlobalItem.cs:368
virtual void PostReforge(Item item)
This hook gets called immediately after an item gets reforged by the Goblin Tinkerer. Useful for modifying modded data based on the reforge result.
Definition: GlobalItem.cs:568
virtual bool AltFunctionUse(Item item, Player player)
Allows you to make an item usable by right-clicking. Returns false by default. When the item is used ...
Definition: GlobalItem.cs:396
virtual void GetWeaponKnockback(Item item, Player player, ref float knockback)
Allows you to temporarily modify this weapon&#39;s knockback based on player buffs, etc. This allows you to customize knockback beyond the Player class&#39;s limited fields. Note that tModLoader follows vanilla principle of only allowing one effective damage class at a time. This means that if you want your own custom damage class, all vanilla damage classes must be set to false. Vanilla checks classes in this order: melee, ranged, magic, thrown, summon So if you set both melee class and another class to true, only the melee knockback will actually be used.
Definition: GlobalItem.cs:242
virtual void AnglerChat(int type, ref string chat, ref string catchLocation)
Allows you to set what the Angler says when the Quest button is clicked in his chat. The chat parameter is his dialogue, and catchLocation should be set to "Caught at [location]" for the given type.
Definition: GlobalItem.cs:803
virtual bool CanRightClick(Item item)
Returns whether or not an item does something when right-clicked in the inventory. Returns false by default.
Definition: GlobalItem.cs:505
virtual void OnHitPvp(Item item, Player player, Player target, int damage, bool crit)
Allows you to create special effects when a melee weapon hits a player.
Definition: GlobalItem.cs:354
virtual void SetDefaults(Item item)
Allows you to set the properties of any and every item that gets created.
Definition: GlobalItem.cs:94
virtual void SetMatch(int armorSlot, int type, bool male, ref int equipSlot, ref bool robes)
Allows you to modify the equipment that the player appears to be wearing.
Definition: GlobalItem.cs:499
EquipType
This is an enum of all the types of equipment that exist. An equipment type is defined as a type or l...
Definition: EquipType.cs:6
virtual bool PreOpenVanillaBag(string context, Player player, int arg)
Allows you to make vanilla bags drop your own items and stop the default items from being dropped...
Definition: GlobalItem.cs:524
This class allows you to modify and use hooks for all items, including vanilla items. Create an instance of an overriding class then call Mod.AddGlobalItem to use this.
Definition: GlobalItem.cs:15
virtual void UpdateEquip(Item item, Player player)
Allows you to give effects to armors and accessories, such as increased damage.
Definition: GlobalItem.cs:409
virtual bool DrawLegs(int legs, int shoes)
Return false to hide the player&#39;s legs when a leg armor or shoe accessory is worn. Returns true by default.
Definition: GlobalItem.cs:611
virtual void HoldItem(Item item, Player player)
Allows you to make things happen when the player is holding an item (for example, torches make light ...
Definition: GlobalItem.cs:127
virtual void UpdateArmorSet(Player player, string set)
Allows you to give set bonuses to your armor set with the given name. The set name will be the same a...
Definition: GlobalItem.cs:435
virtual int ChoosePrefix(Item item, UnifiedRandom rand)
Allows you to manually choose what prefix an item will get.
Definition: GlobalItem.cs:101
virtual void OnCraft(Item item, Recipe recipe)
Allows you to make anything happen when the player crafts the given item using the given recipe...
Definition: GlobalItem.cs:815
virtual void GetHealLife(Item item, Player player, bool quickHeal, ref int healValue)
Allows you to temporarily modify the amount of life a life healing item will heal for...
Definition: GlobalItem.cs:153
virtual void VerticalWingSpeeds(Item item, 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 wings are equipped.
Definition: GlobalItem.cs:635
virtual void DrawHair(int head, ref bool drawHair, ref bool drawAltHair)
Allows you to determine whether the player&#39;s hair or alt (hat) hair will be drawn when a head armor i...
Definition: GlobalItem.cs:585
virtual bool DrawBody(int body)
Return false to hide the player&#39;s body when a body armor is worn. Returns true by default...
Definition: GlobalItem.cs:602
virtual void UpdateInventory(Item item, Player player)
Allows you to make things happen when an item is in the player&#39;s inventory (for example, how the cell phone makes information display).
Definition: GlobalItem.cs:403
virtual void OnConsumeMana(Item item, Player player, int manaConsumed)
Allows you to make stuff happen when a player consumes mana on use of an item.
Definition: GlobalItem.cs:193
virtual bool HoldItemFrame(Item item, Player player)
Allows you to modify the player&#39;s animation when the player is holding an item. Return true if you mo...
Definition: GlobalItem.cs:389
virtual bool ItemSpace(Item item, Player player)
Return true to specify that the item can be picked up despite not having enough room in inventory...
Definition: GlobalItem.cs:699
virtual void NetSend(Item item, BinaryWriter writer)
Allows you to send custom data for the given item between client and server.
Definition: GlobalItem.cs:892
virtual bool WingUpdate(int wings, Player player, bool inUse)
Allows for Wings to do various things while in use. "inUse" is whether or not the jump button is curr...
Definition: GlobalItem.cs:653
virtual void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
Allows you to draw things in front of an item in the inventory. This method is called even if PreDraw...
Definition: GlobalItem.cs:734
virtual bool IsAnglerQuestAvailable(int type)
Whether or not specific conditions have been satisfied for the Angler to be able to request the given...
Definition: GlobalItem.cs:793
virtual void PreUpdateVanitySet(Player player, string set)
Allows you to create special effects (such as the necro armor&#39;s hurt noise) when the player wears the...
Definition: GlobalItem.cs:467
virtual Vector2 HoldoutOffset(int type)
Allows you to determine the offset of an item&#39;s sprite when used by the player. This is only used for...
Definition: GlobalItem.cs:746
virtual void PickAmmo(Item item, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
Definition: GlobalItem.cs:273
virtual void RightClick(Item item, Player player)
Allows you to make things happen when an item is right-clicked in the inventory. Useful for goodie ba...
Definition: GlobalItem.cs:512
virtual void Update(Item item, ref float gravity, ref float maxFallSpeed)
Allows you to customize an item&#39;s movement when lying in the world. Note that this will not be called...
Definition: GlobalItem.cs:660
virtual void PickAmmo(Item weapon, Item ammo, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
Allows you to modify the projectile created by a weapon based on the ammo it is using.
Definition: GlobalItem.cs:269
virtual bool GrabStyle(Item item, Player player)
Allows you to modify the way an item moves towards the player. Return false to allow the vanilla grab...
Definition: GlobalItem.cs:678
virtual Color GetAlpha(Item item, Color lightColor)
Allows you to determine the color and transparency in which an item is drawn. Return null to use the ...
Definition: GlobalItem.cs:706
virtual bool Autoload(ref string name)
Allows you to automatically load a GlobalItem instead of using Mod.AddGlobalItem. Return true to allo...
Definition: GlobalItem.cs:39
virtual GlobalItem NewInstance(Item item)
Create a new instance of this GlobalItem for an Item instance. Called at the end of Item...
Definition: GlobalItem.cs:79
virtual void DrawArmorColor(EquipType type, int slot, Player drawPlayer, float shadow, ref Color color, ref int glowMask, ref Color glowMaskColor)
Allows you to modify the colors in which the player&#39;s armor and their surrounding accessories are dra...
Definition: GlobalItem.cs:620
virtual void OnConsumeItem(Item item, Player player)
Allows you to make things happen when this item is consumed. Called before the item stack is reduced...
Definition: GlobalItem.cs:376
virtual bool NeedsSaving(Item item)
Whether or not the given item needs to save custom data. Returning false will save on the memory used...
Definition: GlobalItem.cs:866
virtual void GetHealMana(Item item, Player player, bool quickHeal, ref int healValue)
Allows you to temporarily modify the amount of mana a mana healing item will heal for...
Definition: GlobalItem.cs:163
virtual void Load(Item item, TagCompound tag)
Allows you to load custom data that you have saved for the given item.
Definition: GlobalItem.cs:880
virtual bool CanHitNPC(Item item, Player player, NPC target)
Allows you to determine whether a melee weapon can hit the given NPC when swung. Return true to allow...
Definition: GlobalItem.cs:322
Mod is an abstract class that you will override. It serves as a central place from which the mod&#39;s co...
Definition: Mod.cs:23
virtual void HorizontalWingSpeeds(Item item, Player player, ref float speed, ref float acceleration)
Allows you to modify the horizontal flight speed and acceleration of wings.
Definition: GlobalItem.cs:642
virtual void ModifyTooltips(Item item, List< TooltipLine > tooltips)
Allows you to modify all the tooltips that display for the given item. See here for information about...
Definition: GlobalItem.cs:860
This class serves as a way to store information about a line that will be drawn of tooltip for an ite...
virtual void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit)
Allows you to create special effects when a melee weapon hits an NPC (for example how the Pumpkin Swo...
Definition: GlobalItem.cs:335
virtual bool CanHitPvp(Item item, Player player, Player target)
Allows you to determine whether a melee weapon can hit the given opponent player when swung...
Definition: GlobalItem.cs:341
virtual void AddRecipes()
This is essentially the same as Mod.AddRecipes or ModItem.AddRecipes. Use whichever method makes orga...
Definition: GlobalItem.cs:809
virtual void ArmorSetShadows(Player player, string set)
Allows you to determine special visual effects a vanity has on the player without having to code them...
Definition: GlobalItem.cs:484
virtual bool UseItem(Item item, Player player)
Allows you to make things happen when an item is used. Return true if using the item actually does st...
Definition: GlobalItem.cs:360
virtual void PostDrawTooltip(Item item, ReadOnlyCollection< DrawableTooltipLine > lines)
Allows you to do things after this item&#39;s tooltip is drawn. The lines contain draw information as thi...
Definition: GlobalItem.cs:835
virtual void CaughtFishStack(int type, ref int stack)
Allows you to modify how many of an item a player obtains when the player fishes that item...
Definition: GlobalItem.cs:784
virtual void UpdateAccessory(Item item, Player player, bool hideVisual)
Allows you to give effects to accessories. The hideVisual parameter is whether the player has marked ...
Definition: GlobalItem.cs:415
virtual bool ConsumeAmmo(Item item, Player player)
Whether or not ammo will be consumed upon usage. Called both by the gun and by the ammo; if at least ...
Definition: GlobalItem.cs:280
virtual void ModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
Allows you to modify the damage, knockback, etc., that a melee weapon does to an NPC.
Definition: GlobalItem.cs:329
virtual void HoldStyle(Item item, Player player)
Allows you to modify the location and rotation of the item the player is currently holding...
Definition: GlobalItem.cs:121
virtual void OpenVanillaBag(string context, Player player, int arg)
Allows you to make vanilla bags drop your own items in addition to the default items. This method will not be called if any other GlobalItem returns false for PreOpenVanillaBag. Context will either be "present", "bossBag", "crate", "lockBox", "herbBag", or "goodieBag". For boss bags and crates, arg will be set to the type of the item being opened. This method is also called for modded bossBags that are properly implemented.
Definition: GlobalItem.cs:537
virtual bool UseItemFrame(Item item, Player player)
Allows you to modify the player&#39;s animation when an item is being used. Return true if you modify the...
Definition: GlobalItem.cs:382
virtual void GetWeaponCrit(Item item, Player player, ref int crit)
Allows you to temporarily modify this weapon&#39;s crit chance based on player buffs, etc...
Definition: GlobalItem.cs:256
virtual float UseTimeMultiplier(Item item, Player player)
Allows you to change the effective useTime of an item.
Definition: GlobalItem.cs:134
virtual void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat)
Allows you to temporarily modify this weapon&#39;s damage based on player buffs, etc. This is useful for ...
Definition: GlobalItem.cs:229
virtual bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
Allows you to draw things behind an item, or to modify the way an item is drawn in the world...
Definition: GlobalItem.cs:713
virtual string IsVanitySet(int head, int body, int legs)
Returns whether or not the head armor, body armor, and leg armor textures make up a set...
Definition: GlobalItem.cs:445
virtual bool CanPickup(Item item, Player player)
Allows you to determine whether or not the item can be picked up
Definition: GlobalItem.cs:685
virtual void OnConsumeAmmo(Item item, Player player)
Allows you to make things happen when ammo is consumed. Called both by the gun and by the ammo...
Definition: GlobalItem.cs:288