1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
5using System.Collections.ObjectModel;
8using System.Linq.Expressions;
9using System.Reflection;
11using Terraria.Localization;
14using Terraria.Utilities;
24 internal static readonly IList<ModItem> items =
new List<ModItem>();
25 internal static readonly IList<GlobalItem> globalItems =
new List<GlobalItem>();
28 internal static readonly IDictionary<string, int> globalIndexes =
new Dictionary<string, int>();
29 internal static readonly IDictionary<Type, int> globalIndexesByType =
new Dictionary<Type, int>();
30 internal static readonly ISet<int> animations =
new HashSet<int>();
31 internal static readonly
int vanillaQuestFishCount = Main.anglerQuestItemNetIDs.Length;
32 internal static readonly
int[] vanillaWings =
new int[Main.maxWings];
44 private static List<HookList>
hooks =
new List<HookList>();
53 if (vanillaWings[1] != 0)
57 for (
int k = 0; k < ItemID.Count; k++) {
59 if (item.wingSlot > 0) {
60 vanillaWings[item.wingSlot] = k;
65 internal static int ReserveItemID() {
77 return type >= ItemID.Count && type <
ItemCount ? items[type - ItemID.Count] :
null;
82 internal static void ResizeArrays(
bool unloading) {
83 Array.Resize(ref Main.itemTexture,
nextItem);
84 Array.Resize(ref Main.itemFlameLoaded,
nextItem);
85 Array.Resize(ref Main.itemFlameTexture,
nextItem);
86 Array.Resize(ref Main.itemAnimations,
nextItem);
90 Array.Resize(ref Lang._itemNameCache,
nextItem);
91 Array.Resize(ref Lang._itemTooltipCache,
nextItem);
92 Array.Resize(ref ItemID.Sets.BannerStrength,
nextItem);
93 Array.Resize(ref ItemID.Sets.KillsToBanner,
nextItem);
94 Array.Resize(ref ItemID.Sets.CanFishInLava,
nextItem);
96 Array.Resize(ref ItemID.Sets.TrapSigned,
nextItem);
97 Array.Resize(ref ItemID.Sets.Deprecated,
nextItem);
98 Array.Resize(ref ItemID.Sets.NeverShiny,
nextItem);
99 Array.Resize(ref ItemID.Sets.ItemIconPulse,
nextItem);
100 Array.Resize(ref ItemID.Sets.ItemNoGravity,
nextItem);
101 Array.Resize(ref ItemID.Sets.ExtractinatorMode,
nextItem);
102 Array.Resize(ref ItemID.Sets.StaffMinionSlotsRequired,
nextItem);
103 Array.Resize(ref ItemID.Sets.ExoticPlantsForDyeTrade,
nextItem);
104 Array.Resize(ref ItemID.Sets.NebulaPickup,
nextItem);
105 Array.Resize(ref ItemID.Sets.AnimatesAsSoul,
nextItem);
106 Array.Resize(ref ItemID.Sets.gunProj,
nextItem);
107 Array.Resize(ref ItemID.Sets.SortingPriorityBossSpawns,
nextItem);
108 Array.Resize(ref ItemID.Sets.SortingPriorityWiring,
nextItem);
109 Array.Resize(ref ItemID.Sets.SortingPriorityMaterials,
nextItem);
110 Array.Resize(ref ItemID.Sets.SortingPriorityExtractibles,
nextItem);
111 Array.Resize(ref ItemID.Sets.SortingPriorityRopes,
nextItem);
112 Array.Resize(ref ItemID.Sets.SortingPriorityPainting,
nextItem);
113 Array.Resize(ref ItemID.Sets.SortingPriorityTerraforming,
nextItem);
114 Array.Resize(ref ItemID.Sets.GamepadExtraRange,
nextItem);
115 Array.Resize(ref ItemID.Sets.GamepadWholeScreenUseRange,
nextItem);
116 Array.Resize(ref ItemID.Sets.GamepadSmartQuickReach,
nextItem);
117 Array.Resize(ref ItemID.Sets.Yoyo,
nextItem);
118 Array.Resize(ref ItemID.Sets.AlsoABuildingItem,
nextItem);
119 Array.Resize(ref ItemID.Sets.LockOnIgnoresCollision,
nextItem);
120 Array.Resize(ref ItemID.Sets.LockOnAimAbove,
nextItem);
121 Array.Resize(ref ItemID.Sets.LockOnAimCompensation,
nextItem);
122 Array.Resize(ref ItemID.Sets.SingleUseInGamepad,
nextItem);
123 Array.Resize(ref ItemID.Sets.ItemsThatCountAsBombsForDemolitionistToSpawn,
nextItem);
124 ItemID.Sets.IsAMaterial =
new bool[
nextItem];
125 for (
int k = ItemID.Count; k <
nextItem; k++) {
126 Lang._itemNameCache[k] = LocalizedText.Empty;
127 Lang._itemTooltipCache[k] = ItemTooltip.None;
128 ItemID.Sets.BannerStrength[k] =
new ItemID.BannerEffect(1f);
129 ItemID.Sets.KillsToBanner[k] = 50;
130 Item.itemCaches[k] = -1;
132 ItemID.Sets.ExtractinatorMode[k] = -1;
133 ItemID.Sets.StaffMinionSlotsRequired[k] = 1;
134 ItemID.Sets.SortingPriorityBossSpawns[k] = -1;
135 ItemID.Sets.SortingPriorityWiring[k] = -1;
136 ItemID.Sets.SortingPriorityMaterials[k] = -1;
137 ItemID.Sets.SortingPriorityExtractibles[k] = -1;
138 ItemID.Sets.SortingPriorityRopes[k] = -1;
139 ItemID.Sets.SortingPriorityPainting[k] = -1;
140 ItemID.Sets.SortingPriorityTerraforming[k] = -1;
144 Array.Resize(ref Main.anglerQuestItemNetIDs, vanillaQuestFishCount);
146 Main.anglerQuestItemNetIDs = Main.anglerQuestItemNetIDs
147 .Concat(items.Where(modItem => modItem.IsQuestFish()).Select(modItem => modItem.item.type))
152 InstancedGlobals = globalItems.Where(g => g.InstancePerEntity).ToArray();
153 for (
int i = 0; i < InstancedGlobals.Length; i++) {
154 InstancedGlobals[i].instanceIndex = i;
156 NetGlobals =
ModLoader.BuildGlobalHook<
GlobalItem, Action<Item, BinaryWriter>>(globalItems, g => g.NetSend);
157 foreach (var hook
in hooks)
158 hook.arr =
ModLoader.BuildGlobalHook(globalItems, hook.method);
161 internal static void Unload() {
165 globalIndexes.Clear();
166 globalIndexesByType.Clear();
170 internal static bool IsModItem(
int index) {
171 return index >= ItemID.Count;
175 return item.maxStack == 1 && item.damage > 0 && item.ammo == 0 && !item.accessory;
178 internal static bool MeleePrefix(Item item) {
179 return item.modItem !=
null &&
GeneralPrefix(item) && item.melee && !item.noUseGraphic;
182 internal static bool WeaponPrefix(Item item) {
183 return item.modItem !=
null &&
GeneralPrefix(item) && item.melee && item.noUseGraphic;
186 internal static bool RangedPrefix(Item item) {
187 return item.modItem !=
null &&
GeneralPrefix(item) && (item.ranged || item.thrown);
190 internal static bool MagicPrefix(Item item) {
191 return item.modItem !=
null &&
GeneralPrefix(item) && (item.magic || item.summon);
196 internal static void SetDefaults(Item item,
bool createModItem =
true) {
197 if (IsModItem(item.type) && createModItem)
200 item.globalItems = InstancedGlobals.Select(g => g.NewInstance(item)).ToArray();
202 item.modItem?.AutoDefaults();
206 g.Instance(item).SetDefaults(item);
209 internal static GlobalItem GetGlobalItem(Item item,
Mod mod,
string name) {
211 return globalIndexes.TryGetValue(mod.
Name +
':' + name, out index) ? globalItems[index].
Instance(item) :
null;
214 internal static GlobalItem GetGlobalItem(Item item, Type type) {
216 return globalIndexesByType.TryGetValue(type, out index) ? (index > -1 ? globalItems[index].Instance(item) :
null) :
null;
222 internal static void DrawAnimatedItem(Item item,
int whoAmI, Color color, Color alpha,
float rotation,
float scale) {
223 int frameCount = Main.itemAnimations[item.type].FrameCount;
224 int frameDuration = Main.itemAnimations[item.type].TicksPerFrame;
225 Main.itemFrameCounter[whoAmI]++;
226 if (Main.itemFrameCounter[whoAmI] >= frameDuration) {
227 Main.itemFrameCounter[whoAmI] = 0;
228 Main.itemFrame[whoAmI]++;
230 if (Main.itemFrame[whoAmI] >= frameCount) {
231 Main.itemFrame[whoAmI] = 0;
233 Rectangle frame = Main.itemTexture[item.type].Frame(1, frameCount, 0, Main.itemFrame[whoAmI]);
234 float offX = (float)(item.width / 2 - frame.Width / 2);
235 float offY = (float)(item.height - frame.Height);
236 Main.spriteBatch.Draw(Main.itemTexture[item.type],
new Vector2(item.position.X - Main.screenPosition.X + (
float)(frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (
float)(frame.Height / 2) + offY),
new Rectangle?(frame), alpha, rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f);
237 if (item.color !=
default(Color)) {
238 Main.spriteBatch.Draw(Main.itemTexture[item.type],
new Vector2(item.position.X - Main.screenPosition.X + (
float)(frame.Width / 2) + offX, item.position.Y - Main.screenPosition.Y + (
float)(frame.Height / 2) + offY),
new Rectangle?(frame), item.GetColor(color), rotation, frame.Size() / 2f, scale, SpriteEffects.None, 0f);
243 int frameCount = Main.itemAnimations[item.type].FrameCount;
244 int frameDuration = Main.itemAnimations[item.type].TicksPerFrame;
245 return Main.itemAnimations[item.type].GetFrame(Main.itemTexture[item.type]);
252 int pre = g.Instance(item).ChoosePrefix(item, rand);
257 if (item.modItem !=
null) {
258 int pre = item.modItem.ChoosePrefix(rand);
273 public static bool?
PrefixChance(Item item,
int pre, UnifiedRandom rand) {
276 bool? r = g.Instance(item).PrefixChance(item, pre, rand);
278 result = r.Value && (result ??
true);
280 if (item.modItem !=
null) {
281 bool? r = item.modItem.PrefixChance(pre, rand);
283 result = r.Value && (result ??
true);
292 result &= g.Instance(item).AllowPrefix(item, pre);
294 if (item.modItem !=
null) {
295 result &= item.modItem.AllowPrefix(pre);
312 if (item.modItem !=
null)
313 flag &= item.modItem.CanUseItem(player);
316 flag &= g.Instance(item).CanUseItem(item, player);
326 public static void UseStyle(Item item, Player player) {
330 item.modItem?.UseStyle(player);
333 g.Instance(item).UseStyle(item, player);
341 public static void HoldStyle(Item item, Player player) {
342 if (item.IsAir || player.pulley || player.itemAnimation > 0)
345 item.modItem?.HoldStyle(player);
348 g.Instance(item).HoldStyle(item, player);
356 public static void HoldItem(Item item, Player player) {
360 item.modItem?.HoldItem(player);
363 g.Instance(item).HoldItem(item, player);
371 float multiplier = item.modItem?.UseTimeMultiplier(player) ?? 1f;
374 multiplier *= g.Instance(item).UseTimeMultiplier(item, player);
384 float multiplier = item.modItem?.MeleeSpeedMultiplier(player) ?? 1f;
387 multiplier *= g.Instance(item).MeleeSpeedMultiplier(item, player);
397 public static void GetHealLife(Item item, Player player,
bool quickHeal, ref
int healValue) {
401 item.modItem?.GetHealLife(player, quickHeal, ref healValue);
404 g.Instance(item).GetHealLife(item, player, quickHeal, ref healValue);
412 public static void GetHealMana(Item item, Player player,
bool quickHeal, ref
int healValue) {
416 item.modItem?.GetHealMana(player, quickHeal, ref healValue);
419 g.Instance(item).GetHealMana(item, player, quickHeal, ref healValue);
427 public static void ModifyManaCost(Item item, Player player, ref
float reduce, ref
float mult) {
431 item.modItem?.ModifyManaCost(player, ref reduce, ref mult);
434 g.Instance(item).ModifyManaCost(item, player, ref reduce, ref mult);
442 public static void OnMissingMana(Item item, Player player,
int neededMana) {
446 item.modItem?.OnMissingMana(player, neededMana);
449 g.Instance(item).OnMissingMana(item, player, neededMana);
457 public static void OnConsumeMana(Item item, Player player,
int manaConsumed) {
461 item.modItem?.OnConsumeMana(player, manaConsumed);
464 g.Instance(item).OnConsumeMana(item, player, manaConsumed);
479 item.modItem?.GetWeaponDamage(player, ref damage);
482 g.Instance(item).GetWeaponDamage(item, player, ref damage);
492 public static void ModifyWeaponDamage(Item item, Player player, ref
float add, ref
float mult, ref
float flat) {
496 item.modItem?.ModifyWeaponDamage(player, ref add, ref mult);
497 item.modItem?.ModifyWeaponDamage(player, ref add, ref mult, ref flat);
500 g.Instance(item).ModifyWeaponDamage(item, player, ref add, ref mult);
502 g.Instance(item).ModifyWeaponDamage(item, player, ref add, ref mult, ref flat);
514 item.modItem?.GetWeaponKnockback(player, ref knockback);
517 g.Instance(item).GetWeaponKnockback(item, player, ref knockback);
530 item.modItem?.GetWeaponCrit(player, ref crit);
533 g.Instance(item).GetWeaponCrit(item, player, ref crit);
540 return item.modItem ==
null || !item.modItem.OnlyShootOnSwing || player.itemAnimation == player.itemAnimationMax - 1;
543 private delegate
void DelegateOldPickAmmo(Item item, Player player, ref
int type, ref
float speed, ref
int damage, ref
float knockback);
546 private delegate
void DelegatePickAmmo(Item weapon, Item ammo, Player player, ref
int type, ref
float speed, ref
int damage, ref
float knockback);
551 public static void PickAmmo(Item weapon, Item ammo, Player player, ref
int type, ref
float speed, ref
int damage, ref
float knockback) {
552 ammo.modItem?.PickAmmo(weapon, player, ref type, ref speed, ref damage, ref knockback);
553 ammo.modItem?.PickAmmo(player, ref type, ref speed, ref damage, ref knockback);
556 g.Instance(ammo).PickAmmo(weapon, ammo, player, ref type, ref speed, ref damage, ref knockback);
559 g.Instance(ammo).PickAmmo(ammo, player, ref type, ref speed, ref damage, ref knockback);
569 public static bool ConsumeAmmo(Item item, Item ammo, Player player) {
570 if (item.modItem !=
null && !item.modItem.ConsumeAmmo(player) ||
571 ammo.modItem !=
null && !ammo.modItem.ConsumeAmmo(player))
575 if (!g.Instance(item).ConsumeAmmo(item, player) ||
576 !g.Instance(ammo).ConsumeAmmo(ammo, player))
591 item.modItem?.OnConsumeAmmo(player);
592 ammo.modItem?.OnConsumeAmmo(player);
595 g.Instance(item).OnConsumeAmmo(item, player);
596 g.Instance(ammo).OnConsumeAmmo(ammo, player);
600 private delegate
bool DelegateShoot(Item item, Player player, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack);
616 public static bool Shoot(Item item, Player player, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack) {
620 result &= g.Instance(item).Shoot(item, player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
623 if (result && item.modItem !=
null) {
624 return item.modItem.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
637 public static void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref
bool noHitbox) {
638 item.modItem?.UseItemHitbox(player, ref hitbox, ref noHitbox);
641 g.Instance(item).UseItemHitbox(item, player, ref hitbox, ref noHitbox);
650 public static void MeleeEffects(Item item, Player player, Rectangle hitbox) {
651 item.modItem?.MeleeEffects(player, hitbox);
654 g.Instance(item).MeleeEffects(item, player, hitbox);
668 public static bool?
CanHitNPC(Item item, Player player, NPC target) {
669 bool? canHit = item.modItem?.CanHitNPC(player, target);
670 if (canHit.HasValue && !canHit.Value) {
674 bool? globalCanHit = g.Instance(item).CanHitNPC(item, player, target);
675 if (globalCanHit.HasValue) {
676 if (globalCanHit.Value) {
687 private delegate
void DelegateModifyHitNPC(Item item, Player player, NPC target, ref
int damage, ref
float knockBack, ref
bool crit);
694 public static void ModifyHitNPC(Item item, Player player, NPC target, ref
int damage, ref
float knockBack, ref
bool crit) {
695 item.modItem?.ModifyHitNPC(player, target, ref damage, ref knockBack, ref crit);
698 g.Instance(item).ModifyHitNPC(item, player, target, ref damage, ref knockBack, ref crit);
707 public static void OnHitNPC(Item item, Player player, NPC target,
int damage,
float knockBack,
bool crit) {
708 item.modItem?.OnHitNPC(player, target, damage, knockBack, crit);
711 g.Instance(item).OnHitNPC(item, player, target, damage, knockBack, crit);
720 public static bool CanHitPvp(Item item, Player player, Player target) {
722 if (!g.Instance(item).CanHitPvp(item, player, target))
725 return item.modItem ==
null || item.modItem.CanHitPvp(player, target);
728 private delegate
void DelegateModifyHitPvp(Item item, Player player, Player target, ref
int damage, ref
bool crit);
735 public static void ModifyHitPvp(Item item, Player player, Player target, ref
int damage, ref
bool crit) {
736 item.modItem?.ModifyHitPvp(player, target, ref damage, ref crit);
739 g.Instance(item).ModifyHitPvp(item, player, target, ref damage, ref crit);
748 public static void OnHitPvp(Item item, Player player, Player target,
int damage,
bool crit) {
749 item.modItem?.OnHitPvp(player, target, damage, crit);
752 g.Instance(item).OnHitPvp(item, player, target, damage, crit);
760 public static bool UseItem(Item item, Player player) {
765 if (item.modItem !=
null)
766 flag |= item.modItem.UseItem(player);
769 flag |= g.Instance(item).UseItem(item, player);
781 if (item.IsAir)
return true;
782 if (item.modItem !=
null && !item.modItem.ConsumeItem(player))
786 if (!g.Instance(item).ConsumeItem(item, player))
801 item.modItem?.OnConsumeItem(player);
804 g.Instance(item).OnConsumeItem(item, player);
814 if (item.modItem !=
null && item.modItem.UseItemFrame(player))
818 if (g.Instance(item).UseItemFrame(item, player))
834 if (item.modItem !=
null && item.modItem.HoldItemFrame(player))
838 if (g.Instance(item).HoldItemFrame(item, player))
852 if (item.modItem !=
null && item.modItem.AltFunctionUse(player))
856 if (g.Instance(item).AltFunctionUse(item, player))
872 item.modItem?.UpdateInventory(player);
875 g.Instance(item).UpdateInventory(item, player);
888 item.modItem?.UpdateEquip(player);
891 g.Instance(item).UpdateEquip(item, player);
904 item.modItem?.UpdateAccessory(player, hideVisual);
907 g.Instance(item).UpdateAccessory(item, player, hideVisual);
915 int slot =
EquipLoader.GetPlayerEquip(player, type);
926 public static void UpdateArmorSet(Player player, Item head, Item body, Item legs) {
927 if (head.modItem !=
null && head.modItem.IsArmorSet(head, body, legs))
928 head.modItem.UpdateArmorSet(player);
930 if (body.modItem !=
null && body.modItem.IsArmorSet(head, body, legs))
931 body.modItem.UpdateArmorSet(player);
933 if (legs.modItem !=
null && legs.modItem.IsArmorSet(head, body, legs))
934 legs.modItem.UpdateArmorSet(player);
937 string set = globalItem.
IsArmorSet(head, body, legs);
938 if (!
string.IsNullOrEmpty(
set))
952 if (headTexture !=
null && headTexture.
IsVanitySet(player.head, player.body, player.legs))
955 if (bodyTexture !=
null && bodyTexture.
IsVanitySet(player.head, player.body, player.legs))
958 if (legTexture !=
null && legTexture.
IsVanitySet(player.head, player.body, player.legs))
962 string set = globalItem.
IsVanitySet(player.head, player.body, player.legs);
963 if (!
string.IsNullOrEmpty(
set))
977 if (headTexture !=
null && headTexture.
IsVanitySet(player.head, player.body, player.legs))
980 if (bodyTexture !=
null && bodyTexture.
IsVanitySet(player.head, player.body, player.legs))
983 if (legTexture !=
null && legTexture.
IsVanitySet(player.head, player.body, player.legs))
987 string set = globalItem.
IsVanitySet(player.head, player.body, player.legs);
988 if (!
string.IsNullOrEmpty(
set))
1003 if (headTexture !=
null && headTexture.
IsVanitySet(player.head, player.body, player.legs))
1006 if (bodyTexture !=
null && bodyTexture.
IsVanitySet(player.head, player.body, player.legs))
1009 if (legTexture !=
null && legTexture.
IsVanitySet(player.head, player.body, player.legs))
1013 string set = globalItem.
IsVanitySet(player.head, player.body, player.legs);
1014 if (!
string.IsNullOrEmpty(
set))
1019 private delegate
void DelegateSetMatch(
int armorSlot,
int type,
bool male, ref
int equipSlot, ref
bool robes);
1024 public static void SetMatch(
int armorSlot,
int type,
bool male, ref
int equipSlot, ref
bool robes) {
1026 texture?.
SetMatch(male, ref equipSlot, ref robes);
1029 g.SetMatch(armorSlot, type, male, ref equipSlot, ref robes);
1039 if (item.IsAir || !Main.mouseRight)
1042 if (item.modItem !=
null && item.modItem.CanRightClick())
1046 if (g.Instance(item).CanRightClick(item))
1066 if (!Main.mouseRightRelease)
1069 item.modItem?.RightClick(player);
1072 g.Instance(item).RightClick(item, player);
1074 if (
ConsumeItem(item, player) && --item.stack == 0)
1078 Main.stackSplit = 30;
1079 Main.mouseRightRelease =
false;
1080 Recipe.FindRecipes();
1088 return item.modItem !=
null && item.modItem.BossBagNPC > 0;
1096 public static void OpenBossBag(
int type, Player player, ref
int npc) {
1098 if (modItem !=
null && modItem.
BossBagNPC > 0) {
1115 result &= g.PreOpenVanillaBag(context, player, arg);
1133 g.OpenVanillaBag(context, player, arg);
1143 public static bool ReforgePrice(Item item, ref
int reforgePrice, ref
bool canApplyDiscount) {
1144 bool b = item.modItem?.ReforgePrice(ref reforgePrice, ref canApplyDiscount) ??
true;
1146 b &= g.Instance(item).ReforgePrice(item, ref reforgePrice, ref canApplyDiscount);
1156 bool b = item.modItem?.NewPreReforge() ??
true;
1158 b &= g.Instance(item).NewPreReforge(item);
1167 item.modItem?.PostReforge();
1169 g.Instance(item).PostReforge(item);
1177 public static void DrawHands(Player player, ref
bool drawHands, ref
bool drawArms) {
1179 texture?.
DrawHands(ref drawHands, ref drawArms);
1182 g.DrawHands(player.body, ref drawHands, ref drawArms);
1194 public static void DrawHair(Player player, ref
bool drawHair, ref
bool drawAltHair) {
1196 texture?.
DrawHair(ref drawHair, ref drawAltHair);
1199 g.DrawHair(player.head, ref drawHair, ref drawAltHair);
1211 if (texture !=
null && !texture.
DrawHead())
1215 if (!g.DrawHead(player.head))
1227 if (texture !=
null && !texture.
DrawBody())
1231 if (!g.DrawBody(player.body))
1243 if (texture !=
null && !texture.
DrawLegs())
1247 if (texture !=
null && !texture.
DrawLegs())
1251 if (!g.DrawLegs(player.legs, player.shoe))
1263 ref
int glowMask, ref Color glowMaskColor) {
1265 texture?.
DrawArmorColor(drawPlayer, shadow, ref color, ref glowMask, ref glowMaskColor);
1268 g.DrawArmorColor(type, slot, drawPlayer, shadow, ref color, ref glowMask, ref glowMaskColor);
1276 public static void ArmorArmGlowMask(
int slot, Player drawPlayer,
float shadow, ref
int glowMask, ref Color color) {
1281 g.ArmorArmGlowMask(slot, drawPlayer, shadow, ref glowMask, ref color);
1289 for (
int k = 3; k < 8 + player.extraAccessorySlots; k++) {
1290 if (player.armor[k].wingSlot == player.wingsLogic) {
1291 item = player.armor[k];
1297 if (player.wingsLogic > 0 && player.wingsLogic < Main.maxWings) {
1299 item.SetDefaults(vanillaWings[player.wingsLogic]);
1302 if (player.wingsLogic >= Main.maxWings) {
1304 if (texture?.item !=
null)
1310 private delegate
void DelegateVerticalWingSpeeds(Item item, Player player, ref
float ascentWhenFalling, ref
float ascentWhenRising, ref
float maxCanAscendMultiplier, ref
float maxAscentMultiplier, ref
float constantAscend);
1317 public static void VerticalWingSpeeds(Player player, ref
float ascentWhenFalling, ref
float ascentWhenRising,
1318 ref
float maxCanAscendMultiplier, ref
float maxAscentMultiplier, ref
float constantAscend) {
1323 player, ref ascentWhenFalling, ref ascentWhenRising, ref maxCanAscendMultiplier,
1324 ref maxAscentMultiplier, ref constantAscend);
1328 item.modItem?.VerticalWingSpeeds(player, ref ascentWhenFalling, ref ascentWhenRising, ref maxCanAscendMultiplier,
1329 ref maxAscentMultiplier, ref constantAscend);
1332 g.Instance(item).VerticalWingSpeeds(item, player, ref ascentWhenFalling, ref ascentWhenRising,
1333 ref maxCanAscendMultiplier, ref maxAscentMultiplier, ref constantAscend);
1351 item.modItem?.HorizontalWingSpeeds(player, ref player.accRunSpeed, ref player.runAcceleration);
1354 g.Instance(item).HorizontalWingSpeeds(item, player, ref player.accRunSpeed, ref player.runAcceleration);
1362 if (player.wings <= 0)
1366 bool? retVal = texture?.
WingUpdate(player, inUse);
1369 retVal |= g.WingUpdate(player.wings, player, inUse);
1371 return retVal ??
false;
1374 private delegate
void DelegateUpdate(Item item, ref
float gravity, ref
float maxFallSpeed);
1381 public static void Update(Item item, ref
float gravity, ref
float maxFallSpeed) {
1382 item.modItem?.Update(ref gravity, ref maxFallSpeed);
1385 g.Instance(item).Update(item, ref gravity, ref maxFallSpeed);
1395 if (g.Instance(item).CanBurnInLava(item))
1398 return item.modItem?.CanBurnInLava() ??
false;
1406 item.modItem?.PostUpdate();
1409 g.Instance(item).PostUpdate(item);
1419 public static void GrabRange(Item item, Player player, ref
int grabRange) {
1420 item.modItem?.GrabRange(player, ref grabRange);
1423 g.Instance(item).GrabRange(item, player, ref grabRange);
1434 if (g.Instance(item).GrabStyle(item, player))
1437 return item.modItem !=
null && item.modItem.GrabStyle(player);
1445 if (!g.Instance(item).CanPickup(item, player))
1448 return item.modItem?.CanPickup(player) ??
true;
1457 public static bool OnPickup(Item item, Player player) {
1459 if (!g.Instance(item).OnPickup(item, player))
1462 return item.modItem?.OnPickup(player) ??
true;
1470 if (g.Instance(item).ItemSpace(item, player))
1473 return item.modItem?.ItemSpace(player) ??
false;
1484 public static Color?
GetAlpha(Item item, Color lightColor) {
1489 Color? color = g.Instance(item).GetAlpha(item, lightColor);
1494 return item.modItem?.GetAlpha(lightColor);
1497 private delegate
bool DelegatePreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref
float rotation, ref
float scale,
int whoAmI);
1504 public static bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref
float rotation, ref
float scale,
int whoAmI) {
1506 if (item.modItem !=
null)
1507 flag &= item.modItem.PreDrawInWorld(spriteBatch, lightColor, alphaColor, ref rotation, ref scale, whoAmI);
1510 flag &= g.Instance(item).PreDrawInWorld(item, spriteBatch, lightColor, alphaColor, ref rotation, ref scale, whoAmI);
1521 public static void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor,
float rotation,
float scale,
int whoAmI) {
1522 item.modItem?.PostDrawInWorld(spriteBatch, lightColor, alphaColor, rotation, scale, whoAmI);
1525 g.Instance(item).PostDrawInWorld(item, spriteBatch, lightColor, alphaColor, rotation, scale, whoAmI);
1528 private static HookList HookPreDrawInInventory = AddHook<Func<Item, SpriteBatch, Vector2, Rectangle, Color, Color, Vector2, float, bool>>(g => g.PreDrawInInventory);
1535 public static bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame,
1536 Color drawColor, Color itemColor, Vector2 origin,
float scale) {
1539 flag &= g.Instance(item).PreDrawInInventory(item, spriteBatch, position, frame, drawColor, itemColor, origin, scale);
1541 if (item.modItem !=
null)
1542 flag &= item.modItem.PreDrawInInventory(spriteBatch, position, frame, drawColor, itemColor, origin, scale);
1555 Color drawColor, Color itemColor, Vector2 origin,
float scale) {
1556 item.modItem?.PostDrawInInventory(spriteBatch, position, frame, drawColor, itemColor, origin, scale);
1559 g.Instance(item).PostDrawInInventory(item, spriteBatch, position, frame, drawColor, itemColor, origin, scale);
1565 if (modItem !=
null) {
1567 if (modOffset.HasValue) {
1568 offset.X = modOffset.Value.X;
1569 offset.Y += gravDir * modOffset.Value.Y;
1573 Vector2? modOffset = g.HoldoutOffset(type);
1574 if (modOffset.HasValue) {
1575 offset.X = modOffset.Value.X;
1576 offset.Y = Main.itemTexture[type].Height / 2f + gravDir * modOffset.Value.Y;
1583 Item item = player.inventory[player.selectedItem];
1584 Vector2 modOrigin = Vector2.Zero;
1585 if (item.modItem !=
null) {
1586 Vector2? modOrigin2 = item.modItem.HoldoutOrigin();
1587 if (modOrigin2.HasValue) {
1588 modOrigin = modOrigin2.Value;
1592 Vector2? modOrigin2 = g.Instance(item).HoldoutOrigin(item.type);
1593 if (modOrigin2.HasValue) {
1594 modOrigin = modOrigin2.Value;
1597 modOrigin.X *= player.direction;
1598 modOrigin.Y *= -player.gravDir;
1599 origin += modOrigin;
1606 Player player = Main.player[Main.myPlayer];
1607 if (item.modItem !=
null && !item.modItem.CanEquipAccessory(player, slot))
1611 if (!g.Instance(item).CanEquipAccessory(item, player, slot))
1619 public static void ExtractinatorUse(ref
int resultType, ref
int resultStack,
int extractType) {
1623 g.ExtractinatorUse(extractType, ref resultType, ref resultStack);
1626 public static void AutoLightSelect(Item item, ref
bool dryTorch, ref
bool wetTorch, ref
bool glowstick) {
1627 if (item.modItem !=
null) {
1628 item.modItem.AutoLightSelect(ref dryTorch, ref wetTorch, ref glowstick);
1642 item.modItem?.CaughtFishStack(ref item.stack);
1645 g.Instance(item).CaughtFishStack(item.type, ref item.stack);
1651 if (modItem !=
null)
1655 notAvailable |= !g.IsAnglerQuestAvailable(itemID);
1662 string catchLocation =
"";
1666 g.AnglerChat(type, ref chat, ref catchLocation);
1668 if (
string.IsNullOrEmpty(chat) ||
string.IsNullOrEmpty(catchLocation))
1671 return chat +
"\n\n(" + catchLocation +
")";
1675 public static void OnCraft(Item item, Recipe recipe) {
1676 item.modItem?.OnCraft(recipe);
1678 g.Instance(item).OnCraft(item, recipe);
1683 public static bool PreDrawTooltip(Item item, ReadOnlyCollection<TooltipLine> lines, ref
int x, ref
int y) {
1684 bool modItemPreDraw = item.modItem?.PreDrawTooltip(lines, ref x, ref y) ??
true;
1685 List<bool> globalItemPreDraw =
new List<bool>();
1687 globalItemPreDraw.Add(g.PreDrawTooltip(item, lines, ref x, ref y));
1688 return modItemPreDraw && globalItemPreDraw.All(z => z);
1693 public static void PostDrawTooltip(Item item, ReadOnlyCollection<DrawableTooltipLine> lines) {
1694 item.modItem?.PostDrawTooltip(lines);
1696 g.Instance(item).PostDrawTooltip(item, lines);
1702 bool modItemPreDrawLine = item.modItem?.PreDrawTooltipLine(line, ref yOffset) ??
true;
1703 List<bool> globalItemPreDrawLine =
new List<bool>();
1705 globalItemPreDrawLine.Add(g.PreDrawTooltipLine(item, line, ref yOffset));
1706 return modItemPreDrawLine && globalItemPreDrawLine.All(x => x);
1712 item.modItem?.PostDrawTooltipLine(line);
1714 g.Instance(item).PostDrawTooltipLine(item, line);
1718 public static List<TooltipLine>
ModifyTooltips(Item item, ref
int numTooltips,
string[] names, ref
string[] text,
1719 ref
bool[] modifier, ref
bool[] badModifier, ref
int oneDropLogo, out Color?[] overrideColor) {
1720 List<TooltipLine> tooltips =
new List<TooltipLine>();
1721 for (
int k = 0; k < numTooltips; k++) {
1723 tooltip.isModifier = modifier[k];
1724 tooltip.isModifierBad = badModifier[k];
1725 if (k == oneDropLogo) {
1726 tooltip.oneDropLogo =
true;
1728 tooltips.Add(tooltip);
1730 item.modItem?.ModifyTooltips(tooltips);
1732 g.Instance(item).ModifyTooltips(item, tooltips);
1734 numTooltips = tooltips.Count;
1735 text =
new string[numTooltips];
1736 modifier =
new bool[numTooltips];
1737 badModifier =
new bool[numTooltips];
1739 overrideColor =
new Color?[numTooltips];
1740 for (
int k = 0; k < numTooltips; k++) {
1741 text[k] = tooltips[k].text;
1742 modifier[k] = tooltips[k].isModifier;
1743 badModifier[k] = tooltips[k].isModifierBad;
1744 if (tooltips[k].oneDropLogo) {
1747 overrideColor[k] = tooltips[k].overrideColor;
1755 return item.type != 0 && (item.modItem !=
null || item.prefix >= PrefixID.Count ||
HookNeedsSaving.
arr.Count(g => g.Instance(item).NeedsSaving(item)) > 0);
1758 internal static void WriteNetGlobalOrder(
BinaryWriter w) {
1759 w.Write((
short)NetGlobals.Length);
1760 foreach (var globalItem
in NetGlobals) {
1761 w.Write(globalItem.mod.netID);
1762 w.Write(globalItem.Name);
1766 internal static void ReadNetGlobalOrder(
BinaryReader r) {
1767 short n = r.ReadInt16();
1769 for (
short i = 0; i < n; i++)
1773 private static bool HasMethod(Type t,
string method, params Type[] args) {
1774 return t.GetMethod(method, args).DeclaringType != typeof(
GlobalItem);
1777 internal static void VerifyGlobalItem(
GlobalItem item) {
1778 var type = item.GetType();
1779 int saveMethods = 0;
1780 if (
HasMethod(type,
"NeedsSaving", typeof(Item))) saveMethods++;
1781 if (
HasMethod(type,
"Save", typeof(Item))) saveMethods++;
1783 if (saveMethods > 0 && saveMethods < 3)
1784 throw new Exception(type +
" must override all of (NeedsSaving/Save/Load) or none");
1789 if (netMethods == 1)
1790 throw new Exception(type +
" must override both of (NetSend/NetReceive) or none");
1792 bool hasInstanceFields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
1793 .Any(f => f.DeclaringType != typeof(
GlobalItem));
1795 if (hasInstanceFields) {
1797 throw new Exception(type +
" has instance fields but does not set InstancePerEntity to true. Either use static fields, or per instance globals");
1800 !
HasMethod(type,
"NewInstance", typeof(Item)) &&
1801 !
HasMethod(type,
"Clone", typeof(Item), typeof(Item)))
1802 throw new Exception(type +
" has InstancePerEntity but must either set CloneNewInstances to true, or override NewInstance(Item) or Clone(Item, Item)");
This serves as a central place to store equipment slots and their corresponding textures....
static EquipTexture GetEquipTexture(EquipType type, int slot)
Gets the equipment texture for the specified equipment type and ID.
static readonly EquipType[] EquipTypes
This serves as a place for you to program behaviors of equipment textures. This is useful for equipme...
virtual void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)
Allows you to modify horizontal wing speeds.
virtual bool DrawHead()
Return false to hide the player's head when this head equipment texture is worn. By default this will...
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....
virtual void ArmorSetShadows(Player player)
Allows you to determine special visual effects this vanity set has on the player without having to co...
virtual bool DrawBody()
Return false to hide the player's body when this body equipment texture is worn. By default this will...
virtual void DrawHair(ref bool drawHair, ref bool drawAltHair)
Allows you to determine whether the player's hair or alt (hat) hair draws when this head equipment te...
virtual void PreUpdateVanitySet(Player player)
Allows you to create special effects (such as the necro armor's hurt noise) when the player wears thi...
virtual void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
Allows you to modify vertical wing speeds.
virtual bool DrawLegs()
Return false to hide the player's legs when this leg or shoe equipment texture is worn....
virtual void UpdateVanitySet(Player player)
Allows you to create special effects (such as dust) when the player wears this equipment texture's va...
virtual bool WingUpdate(Player player, bool inUse)
Allows for wing textures to do various things while in use. "inUse" is whether or not the jump button...
ModItem item
The item that is associated with this equipment texture. Null if no item is associated with this.
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 call...
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....
virtual void DrawHands(ref bool drawHands, ref bool drawArms)
Allows you to determine whether the skin/shirt on the player's arms and hands are drawn when this bod...
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 texture and surrounding accessories are drawn,...
virtual void UpdateVanity(Player player, EquipType type)
Allows you to create special effects (such as dust) when this equipment texture is displayed on the p...
This class allows you to modify and use hooks for all items, including vanilla items....
virtual void PreUpdateVanitySet(Player player, string set)
Allows you to create special effects (such as the necro armor's hurt noise) when the player wears the...
virtual bool InstancePerEntity
Whether to create a new GlobalItem instance for every Item that exists. Useful for storing informatio...
virtual bool CloneNewInstances
Whether instances of this GlobalItem are created through Clone or constructor (by default implementat...
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...
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....
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...
virtual void SetDefaults(Item item)
Allows you to set the properties of any and every item that gets created.
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...
GlobalItem Instance(Item item)
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....
readonly MethodInfo method
HookList(MethodInfo method)
This serves as the central class from which item-related functions are carried out....
static void UseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox)
Calls ModItem.UseItemHitbox, then all GlobalItem.UseItemHitbox hooks.
delegate bool DelegatePreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
static bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
Returns the "and" operator on the results of all GlobalItem.PreDrawInInventory hooks and ModItem....
static HookList HookWingUpdate
static HookList HookPostDrawInInventory
static void PreUpdateVanitySet(Player player)
If the player's head texture's IsVanitySet returns true, calls the equipment texture's PreUpdateVanit...
static void ExtractinatorUse(ref int resultType, ref int resultStack, int extractType)
static void AutoLightSelect(Item item, ref bool dryTorch, ref bool wetTorch, ref bool glowstick)
static HookList HookConsumeItem
static bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
Returns the "and" operator on the results of ModItem.PreDrawInWorld and all GlobalItem....
static HookList HookDrawHead
static Rectangle AnimatedItemFrame(Item item)
static void DrawHair(Player player, ref bool drawHair, ref bool drawAltHair)
Calls the item's head equipment texture's DrawHair hook, then all GlobalItem.DrawHair hooks.
static HookList HookOnConsumeItem
static HookList HookExtractinatorUse
static void ModifyManaCost(Item item, Player player, ref float reduce, ref float mult)
Calls ModItem.ModifyManaCost, then all GlobalItem.ModifyManaCost hooks.
delegate bool DelegateReforgePrice(Item item, ref int reforgePrice, ref bool canApplyDiscount)
static bool WingUpdate(Player player, bool inUse)
If wings can be seen on the player, calls the player's wing's equipment texture's WingUpdate and all ...
static HookList HookUpdateArmorSet
static bool UseItem(Item item, Player player)
Returns true if any of ModItem.UseItem or GlobalItem.UseItem return true Does not fail fast (calls ev...
static void UpdateAccessory(Item item, Player player, bool hideVisual)
Calls ModItem.UpdateAccessory and all GlobalItem.UpdateAccessory hooks.
static void MeleeEffects(Item item, Player player, Rectangle hitbox)
Calls ModItem.MeleeEffects and all GlobalItem.MeleeEffects hooks.
static void IsAnglerQuestAvailable(int itemID, ref bool notAvailable)
delegate void DelegateOldPickAmmo(Item item, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
static HookList HookItemSpace
static HookList HookHoldItemFrame
static Item GetWing(Player player)
s Returns the wing item that the player is functionally using. If player.wingsLogic has been modified...
static HookList HookPostDrawTooltipLine
static int ChoosePrefix(Item item, UnifiedRandom rand)
static void UpdateArmorSet(Player player, Item head, Item body, Item legs)
If the head's ModItem.IsArmorSet returns true, calls the head's ModItem.UpdateArmorSet....
static ? bool PrefixChance(Item item, int pre, UnifiedRandom rand)
Allows for blocking, forcing and altering chance of prefix rolling. False (block) takes precedence ov...
static ModItem GetItem(int type)
Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the...
static bool AltFunctionUse(Item item, Player player)
Calls ModItem.AltFunctionUse, then all GlobalItem.AltFunctionUse hooks, until one of them returns tru...
static HookList HookArmorSetShadows
static HookList HookMeleeEffects
delegate void DelegateDrawArmorColor(EquipType type, int slot, Player drawPlayer, float shadow, ref Color color, ref int glowMask, ref Color glowMaskColor)
static HookList HookAltFunctionUse
static HookList HookGetWeaponCrit
static void OnConsumeMana(Item item, Player player, int manaConsumed)
Calls ModItem.OnConsumeMana, then all GlobalItem.OnConsumeMana hooks.
static HookList HookPreDrawInInventory
static void GetWeaponKnockback(Item item, Player player, ref float knockback)
Calls ModItem.GetWeaponKnockback, then all GlobalItem.GetWeaponKnockback hooks.
static void OpenBossBag(int type, Player player, ref int npc)
If the item is a modded item and ModItem.bossBagNPC is greater than 0, calls ModItem....
static HookList HookGetAlpha
static HookList HookModifyWeaponDamageOld
static HookList HookUpdateAccessory
delegate void DelegatePickAmmo(Item weapon, Item ammo, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
static void OnConsumeItem(Item item, Player player)
Calls ModItem.OnConsumeItem and all GlobalItem.OnConsumeItem hooks.
delegate bool DelegateShoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
static HookList HookSetDefaults
static void OnConsumeAmmo(Item item, Item ammo, Player player)
Calls ModItem.OnConsumeAmmo for the weapon, ModItem.OnConsumeAmmo for the ammo, then each GlobalItem....
static bool ReforgePrice(Item item, ref int reforgePrice, ref bool canApplyDiscount)
Call all ModItem.ReforgePrice, then GlobalItem.ReforgePrice hooks.
static HookList HookUseItemHitbox
static void HoldItem(Item item, Player player)
Calls ModItem.HoldItem and all GlobalItem.HoldItem hooks.
static bool PreDrawTooltip(Item item, ReadOnlyCollection< TooltipLine > lines, ref int x, ref int y)
static HookList HookUpdateEquip
delegate void DelegateGetWeaponCrit(Item item, Player player, ref int crit)
static HookList HookModifyHitPvp
static HookList HookHorizontalWingSpeeds
static void Update(Item item, ref float gravity, ref float maxFallSpeed)
Calls ModItem.Update, then all GlobalItem.Update hooks.
static HookList HookCanRightClick
static bool HasMethod(Type t, string method, params Type[] args)
static void SetMatch(int armorSlot, int type, bool male, ref int equipSlot, ref bool robes)
Calls EquipTexture.SetMatch, then all GlobalItem.SetMatch hooks.
static HookList HookCaughtFishStack
static HookList HookGetHealLife
static float UseTimeMultiplier(Item item, Player player)
static HookList HookDrawHair
static HookList HookUseStyle
static HookList HookDrawLegs
static HookList HookOnMissingMana
static HookList HookNeedsSaving
delegate void DelegateExtractinatorUse(int extractType, ref int resultType, ref int resultStack)
static HookList HookUpdateVanitySet
static void GetHealLife(Item item, Player player, bool quickHeal, ref int healValue)
Calls ModItem.GetHealLife, then all GlobalItem.GetHealLife hooks.
static HookList AddHook< F >(Expression< Func< GlobalItem, F > > func)
static HookList HookAnglerChat
static HookList HookPickAmmo
static void RightClick(Item item, Player player)
If Main.mouseRightRelease is true, the following steps are taken:
static HookList HookPrefixChance
static bool CanEquipAccessory(Item item, int slot)
static HookList HookHoldItem
static HookList HookShoot
static void GetWeaponDamage(Item item, Player player, ref int damage)
Calls ModItem.GetWeaponDamage, then all GlobalItem.GetWeaponDamage hooks.
static HookList HookPreDrawInWorld
delegate void DelegateGetWeaponDamage(Item item, Player player, ref int damage)
delegate bool DelegatePreDrawTooltip(Item item, ReadOnlyCollection< TooltipLine > lines, ref int x, ref int y)
static void UpdateVanitySet(Player player)
If the player's head texture's IsVanitySet returns true, calls the equipment texture's UpdateVanitySe...
static bool CanBurnInLava(Item item)
Calls ModItem.CanBurnInLava.
delegate void DelegateDrawHair(int body, ref bool drawHair, ref bool drawAltHair)
static void PickAmmo(Item weapon, Item ammo, Player player, ref int type, ref float speed, ref int damage, ref float knockback)
Calls ModItem.PickAmmo, then all GlobalItem.PickAmmo hooks.
delegate void DelegateDrawHands(int body, ref bool drawHands, ref bool drawArms)
static void OnCraft(Item item, Recipe recipe)
delegate void DelegateModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat)
static HookList HookCanUseItem
static bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset)
static HookList HookArmorArmGlowMask
static HookList HookGrabStyle
static bool CheckProjOnSwing(Player player, Item item)
If the item is a modded item, ModItem.checkProjOnSwing is true, and the player is not at the beginnin...
static HookList HookAllowPrefix
static bool IsModBossBag(Item item)
Returns whether ModItem.bossBagNPC is greater than 0. Returns false if item is not a modded item.
static void PostDrawTooltipLine(Item item, DrawableTooltipLine line)
static void PostReforge(Item item)
Calls ModItem.PostReforge, then all GlobalItem.PostReforge hooks.
static HookList HookOnHitNPC
static HookList HookDrawArmorColor
static HookList HookUseItemFrame
static HookList HookPreDrawTooltip
static HookList HookCanEquipAccessory
static HookList HookMeleeSpeedMultiplier
static bool OnPickup(Item item, Player player)
Calls all GlobalItem.OnPickup hooks then ModItem.OnPickup, until one of the returns false....
static bool Shoot(Item item, Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
Calls each GlobalItem.Shoot hook, then ModItem.Shoot, until one of them returns false....
static HookList HookUseTimeMultiplier
static void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
If the player is using wings, this uses the result of GetWing, and calls ModItem.VerticalWingSpeeds t...
delegate void DelegateHorizontalWingSpeeds(Item item, Player player, ref float speed, ref float acceleration)
static HookList HookChoosePrefix
static void UpdateVanity(Player player)
Calls each of the item's equipment texture's UpdateVanity hook.
delegate void DelegateModifyWeaponDamageOld(Item item, Player player, ref float add, ref float mult)
static HookList HookCanBurnInLava
static HookList HookGetWeaponKnockback
delegate void DelegateVerticalWingSpeeds(Item item, Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
static bool CanPickup(Item item, Player player)
static HookList HookGetWeaponDamage
static bool DrawHead(Player player)
Calls the item's head equipment texture's DrawHead hook, then all GlobalItem.DrawHead hooks,...
static HookList HookPreDrawTooltipLine
static void GetHealMana(Item item, Player player, bool quickHeal, ref int healValue)
Calls ModItem.GetHealMana, then all GlobalItem.GetHealMana hooks.
static List< HookList > hooks
static void UpdateInventory(Item item, Player player)
Calls ModItem.UpdateInventory and all GlobalItem.UpdateInventory hooks.
static HookList HookModifyWeaponDamage
static HookList HookGetHealMana
static HookList HookPostUpdate
static HookList HookPreUpdateVanitySet
delegate void DelegateGetHealLife(Item item, Player player, bool quickHeal, ref int healValue)
static void CaughtFishStack(Item item)
static void OnHitNPC(Item item, Player player, NPC target, int damage, float knockBack, bool crit)
Calls ModItem.OnHitNPC and all GlobalItem.OnHitNPC hooks.
static HookList HookDrawHands
static HookList HookOpenVanillaBag
static HookList HookHoldoutOrigin
static HookList HookHoldStyle
static bool ItemSpace(Item item, Player player)
delegate void DelegateGrabRange(Item item, Player player, ref int grabRange)
static HookList HookHoldoutOffset
delegate void DelegateModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit)
static void DrawArmorColor(EquipType type, int slot, Player drawPlayer, float shadow, ref Color color, ref int glowMask, ref Color glowMaskColor)
Calls the item's equipment texture's DrawArmorColor hook, then all GlobalItem.DrawArmorColor hooks.
static ? Color GetAlpha(Item item, Color lightColor)
Calls all GlobalItem.GetAlpha hooks then ModItem.GetAlpha, until one of them returns a color,...
static float MeleeSpeedMultiplier(Item item, Player player)
delegate void DelegateAnglerChat(int type, ref string chat, ref string catchLocation)
static bool GeneralPrefix(Item item)
static HookList HookPreReforge
delegate void DelegateModifyManaCost(Item item, Player player, ref float reduce, ref float mult)
static void FindVanillaWings()
static void ModifyHitPvp(Item item, Player player, Player target, ref int damage, ref bool crit)
Calls ModItem.ModifyHitPvp, then all GlobalItem.ModifyHitPvp hooks.
static void PostDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
Calls ModItem.PostDrawInWorld, then all GlobalItem.PostDrawInWorld hooks.
static void UpdateEquip(Item item, Player player)
Calls ModItem.UpdateEquip and all GlobalItem.UpdateEquip hooks.
static ? bool CanHitNPC(Item item, Player player, NPC target)
Gathers the results of ModItem.CanHitNPC and all GlobalItem.CanHitNPC hooks. If any of them returns f...
static void DrawHands(Player player, ref bool drawHands, ref bool drawArms)
Calls the item's body equipment texture's DrawHands hook, then all GlobalItem.DrawHands hooks.
static void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat)
Calls ModItem.HookModifyWeaponDamage, then all GlobalItem.HookModifyWeaponDamage hooks.
static HookList HookOnHitPvp
static HookList HookUpdate
static bool NeedsModSaving(Item item)
static List< TooltipLine > ModifyTooltips(Item item, ref int numTooltips, string[] names, ref string[] text, ref bool[] modifier, ref bool[] badModifier, ref int oneDropLogo, out Color?[] overrideColor)
static bool CanUseItem(Item item, Player player)
Returns the "and" operation on the results of ModItem.CanUseItem and all GlobalItem....
delegate bool DelegatePreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset)
static HookList HookSetMatch
static void PostUpdate(Item item)
Calls ModItem.PostUpdate and all GlobalItem.PostUpdate hooks.
static HookList HookModifyManaCost
static bool ConsumeItem(Item item, Player player)
If ModItem.ConsumeItem or any of the GlobalItem.ConsumeItem hooks returns false, sets consume to fals...
static bool CanHitPvp(Item item, Player player, Player target)
Calls all GlobalItem.CanHitPvp hooks, then ModItem.CanHitPvp, until one of them returns false....
delegate void DelegateGetHealMana(Item item, Player player, bool quickHeal, ref int healValue)
static void PostDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
Calls ModItem.PostDrawInInventory, then all GlobalItem.PostDrawInInventory hooks.
delegate void DelegateModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
static HookList HookDrawBody
static void OnMissingMana(Item item, Player player, int neededMana)
Calls ModItem.OnMissingMana, then all GlobalItem.OnMissingMana hooks.
delegate void DelegatePostDrawTooltip(Item item, ReadOnlyCollection< DrawableTooltipLine > lines)
delegate void DelegateUseItemHitbox(Item item, Player player, ref Rectangle hitbox, ref bool noHitbox)
static void HoldoutOffset(float gravDir, int type, ref Vector2 offset)
static void HoldStyle(Item item, Player player)
If the player is not holding onto a rope and is not in the middle of using an item,...
delegate void DelegateArmorArmGlowMask(int slot, Player drawPlayer, float shadow, ref int glowMask, ref Color color)
static HookList HookUpdateInventory
static void ModifyHitNPC(Item item, Player player, NPC target, ref int damage, ref float knockBack, ref bool crit)
Calls ModItem.ModifyHitNPC, then all GlobalItem.ModifyHitNPC hooks.
static HookList HookPostReforge
static bool GrabStyle(Item item, Player player)
Calls all GlobalItem.GrabStyle hooks then ModItem.GrabStyle, until one of them returns true....
static HookList HookPostDrawTooltip
static HookList HookCanHitNPC
static HookList HookReforgePrice
delegate void DelegateGetWeaponKnockback(Item item, Player player, ref float knockback)
static HookList HookOnPickup
static HookList HookOnConsumeAmmo
static HookList HookPreOpenVanillaBag
static void HorizontalWingSpeeds(Player player)
If the player is using wings, this uses the result of GetWing, and calls ModItem.HorizontalWingSpeeds...
static HookList HookUseItem
static bool ConsumeAmmo(Item item, Item ammo, Player player)
Calls ModItem.ConsumeAmmo for the weapon, ModItem.ConsumeAmmo for the ammo, then each GlobalItem....
delegate void DelegateUpdate(Item item, ref float gravity, ref float maxFallSpeed)
static HookList HookModifyHitNPC
static void OnHitPvp(Item item, Player player, Player target, int damage, bool crit)
Calls ModItem.OnHitPvp and all GlobalItem.OnHitPvp hooks.
delegate void DelegatePostDrawTooltipLine(Item item, DrawableTooltipLine line)
static HookList HookCanHitPvp
static void HoldoutOrigin(Player player, ref Vector2 origin)
static void UseStyle(Item item, Player player)
Calls ModItem.UseStyle and all GlobalItem.UseStyle hooks.
static void OpenVanillaBag(string context, Player player, int arg)
Calls all GlobalItem.OpenVanillaBag hooks.
static void GrabRange(Item item, Player player, ref int grabRange)
Calls ModItem.GrabRange, then all GlobalItem.GrabRange hooks.
static bool UseItemFrame(Item item, Player player)
Calls ModItem.UseItemFrame, then all GlobalItem.UseItemFrame hooks, until one of them returns true....
static HookList HookOnCraft
static bool PreOpenVanillaBag(string context, Player player, int arg)
Calls each GlobalItem.PreOpenVanillaBag hook until one of them returns false. Returns true if all of ...
static void GetWeaponCrit(Item item, Player player, ref int crit)
Calls ModItem.GetWeaponCrit, then all GlobalItem.GetWeaponCrit hooks.
static HookList HookModifyTooltips
delegate void DelegateSetMatch(int armorSlot, int type, bool male, ref int equipSlot, ref bool robes)
static bool PreReforge(Item item)
Calls ModItem.PreReforge, then all GlobalItem.PreReforge hooks.
static HookList HookCanPickup
static HookList HookGrabRange
static bool DrawLegs(Player player)
Calls the item's leg equipment texture's DrawLegs hook, then the item's shoe equipment texture's Draw...
static HookList HookConsumeAmmo
static string AnglerChat(int type)
static HookList HookPostDrawInWorld
static void PostDrawTooltip(Item item, ReadOnlyCollection< DrawableTooltipLine > lines)
static HookList HookVerticalWingSpeeds
static bool AllowPrefix(Item item, int pre)
static HookList HookOldPickAmmo
static bool DrawBody(Player player)
Calls the item's body equipment texture's DrawBody hook, then all GlobalItem.DrawBody hooks,...
static HookList HookRightClick
static HookList HookIsAnglerQuestAvailable
static void ArmorSetShadows(Player player)
If the player's head texture's IsVanitySet returns true, calls the equipment texture's ArmorSetShadow...
static bool CanRightClick(Item item)
Calls ModItem.CanRightClick, then all GlobalItem.CanRightClick hooks, until one of the returns true....
static void ArmorArmGlowMask(int slot, Player drawPlayer, float shadow, ref int glowMask, ref Color color)
Calls the item's body equipment texture's ArmorArmGlowMask hook, then all GlobalItem....
static HookList HookOnConsumeMana
delegate void DelegateCaughtFishStack(int type, ref int stack)
static bool HoldItemFrame(Item item, Player player)
Calls ModItem.HoldItemFrame, then all GlobalItem.HoldItemFrame hooks, until one of them returns true....
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
GlobalItem GetGlobalItem(string name)
Gets the GlobalItem instance with the given name from this mod.
virtual string Name
Stores the name of the mod. This name serves as the mod's identification, and also helps with saving ...
This class serves as a place for you to place all your properties and hooks for each item....
virtual ? Vector2 HoldoutOffset()
Allows you to determine the offset of this item's sprite when used by the player. This is only used f...
virtual ModItem NewInstance(Item itemClone)
Create a new instance of this ModItem for an Item instance. Called at the end of Item....
virtual bool IsAnglerQuestAvailable()
Whether or not specific conditions have been satisfied for the Angler to be able to request this item...
virtual int BossBagNPC
The type of NPC that drops this boss bag. Used to determine how many coins this boss bag contains....
virtual void OpenBossBag(Player player)
Allows you to give items to the given player when this item is right-clicked in the inventory if the ...
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 Extr...
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 h...
Item item
The item object that this ModItem controls.
This serves as the central class which loads mods. It contains many static fields and methods related...
static Mod GetMod(int netID)
static bool AllowVanillaClients
This serves as the central class from which NPC-related functions are carried out....
static readonly IList< int > blockLoot
Allows you to stop an NPC from dropping loot by adding item IDs to this list. This list will be clear...
EquipType
This is an enum of all the types of equipment that exist. An equipment type is defined as a type or l...