TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ SetDefaults() [1/2]

void Terraria.Item.SetDefaults ( int Type,
bool noMatCheck = false,
ItemVariant variant = null )
inline

Definition at line 48818 of file Item.cs.

48819 {
48820 if (Type < 0)
48821 {
48822 netDefaults(Type);
48823 return;
48824 }
48825 if (Main.netMode == 1 || Main.netMode == 2)
48826 {
48828 }
48829 else
48830 {
48831 playerIndexTheItemIsReservedFor = Main.myPlayer;
48832 }
48833 ResetStats(Type);
48834 if (variant == null)
48835 {
48837 }
48838 else if (!ItemVariants.HasVariant(Type, variant))
48839 {
48840 variant = null;
48841 }
48842 Variant = variant;
48843 if (type == 0)
48844 {
48845 netID = 0;
48846 stack = 0;
48847 }
48848 else if (ItemID.Sets.IsFood[type])
48849 {
48851 }
48852 else if (type <= 1000)
48853 {
48855 }
48856 else if (type <= 2001)
48857 {
48859 }
48860 else if (type <= 3000)
48861 {
48863 }
48864 else if (type <= 3989)
48865 {
48867 }
48868 else
48869 {
48871 }
48874 if (type < ItemID.Count && rare == -13)
48875 {
48876 master = true;
48877 }
48878 dye = GameShaders.Armor.GetShaderIdFromItemId(type);
48879 if (hairDye != 0)
48880 {
48881 hairDye = GameShaders.Hair.GetShaderIdFromItemId(type);
48882 }
48883 if (type == 2015)
48884 {
48885 value = sellPrice(0, 0, 5);
48886 }
48887 if (type == 2016)
48888 {
48889 value = sellPrice(0, 0, 7, 50);
48890 }
48891 if (type == 2017)
48892 {
48893 value = sellPrice(0, 0, 7, 50);
48894 }
48895 if (type == 5212)
48896 {
48897 value = sellPrice(0, 0, 7, 50);
48898 }
48899 if (type == 5300)
48900 {
48901 value = sellPrice(0, 0, 7, 50);
48902 }
48903 if (type == 5311)
48904 {
48905 value = sellPrice(0, 0, 7, 50);
48906 }
48907 if (type == 5312)
48908 {
48909 value = sellPrice(0, 0, 7, 50);
48910 }
48911 if (type == 5313)
48912 {
48913 value = sellPrice(0, 0, 7, 50);
48914 }
48915 if (type == 2019)
48916 {
48917 value = sellPrice(0, 0, 5);
48918 }
48919 if (type == 2018)
48920 {
48921 value = sellPrice(0, 0, 5);
48922 }
48923 if (type == 3563)
48924 {
48925 value = sellPrice(0, 0, 5);
48926 }
48927 if (type == 261)
48928 {
48929 value = sellPrice(0, 0, 7, 50);
48930 }
48931 if (type == 2205)
48932 {
48933 value = sellPrice(0, 0, 12, 50);
48934 }
48935 if (type == 2123)
48936 {
48937 value = sellPrice(0, 0, 7, 50);
48938 }
48939 if (type == 2122)
48940 {
48941 value = sellPrice(0, 0, 7, 50);
48942 }
48943 if (type == 2003)
48944 {
48945 value = sellPrice(0, 0, 10);
48946 }
48947 if (type == 2156)
48948 {
48949 value = sellPrice(0, 0, 15);
48950 }
48951 if (type == 2157)
48952 {
48953 value = sellPrice(0, 0, 15);
48954 }
48955 if (type == 2121)
48956 {
48957 value = sellPrice(0, 0, 10);
48958 }
48959 if (type == 1992)
48960 {
48961 value = sellPrice(0, 0, 3);
48962 }
48963 if (type == 2004)
48964 {
48965 value = sellPrice(0, 0, 5);
48966 }
48967 if (type == 2002)
48968 {
48969 value = sellPrice(0, 0, 5);
48970 }
48971 if (type == 2740)
48972 {
48973 value = sellPrice(0, 0, 2, 50);
48974 }
48975 if (type == 2006)
48976 {
48977 value = sellPrice(0, 0, 10);
48978 }
48979 if (type == 3191)
48980 {
48981 value = sellPrice(0, 0, 20);
48982 }
48983 if (type == 3192)
48984 {
48985 value = sellPrice(0, 0, 2, 50);
48986 }
48987 if (type == 3193)
48988 {
48989 value = sellPrice(0, 0, 5);
48990 }
48991 if (type == 3194)
48992 {
48993 value = sellPrice(0, 0, 10);
48994 }
48995 if (type == 2007)
48996 {
48997 value = sellPrice(0, 0, 50);
48998 }
48999 if (type == 2673)
49000 {
49001 value = sellPrice(0, 10);
49002 }
49003 if (bait > 0)
49004 {
49005 if (bait >= 50)
49006 {
49007 rare = 3;
49008 }
49009 else if (bait >= 30)
49010 {
49011 rare = 2;
49012 }
49013 else if (bait >= 15)
49014 {
49015 rare = 1;
49016 }
49017 }
49018 if (type >= 1994 && type <= 2001)
49019 {
49020 int num = type - 1994;
49021 if (num == 0)
49022 {
49023 value = sellPrice(0, 0, 5);
49024 }
49025 if (num == 4)
49026 {
49027 value = sellPrice(0, 0, 10);
49028 }
49029 if (num == 6)
49030 {
49031 value = sellPrice(0, 0, 15);
49032 }
49033 if (num == 3)
49034 {
49035 value = sellPrice(0, 0, 20);
49036 }
49037 if (num == 7)
49038 {
49039 value = sellPrice(0, 0, 30);
49040 }
49041 if (num == 2)
49042 {
49043 value = sellPrice(0, 0, 40);
49044 }
49045 if (num == 1)
49046 {
49047 value = sellPrice(0, 0, 75);
49048 }
49049 if (num == 5)
49050 {
49051 value = sellPrice(0, 1);
49052 }
49053 }
49054 if (type == 2663 || type == 1720 || type == 2137 || type == 2155 || type == 2151 || type == 1704 || type == 2143 || type == 1710 || type == 2238 || type == 2133 || type == 2147 || type == 2405 || type == 1716 || type == 1705)
49055 {
49056 value = sellPrice(0, 2);
49057 }
49058 if (Main.projHook[shoot])
49059 {
49060 useStyle = 0;
49061 useTime = 0;
49062 useAnimation = 0;
49063 }
49064 if (ItemID.Sets.IsDrill[type] || ItemID.Sets.IsChainsaw[type] || type == 1262)
49065 {
49066 useTime = (int)((double)useTime * 0.6);
49067 if (useTime < 1)
49068 {
49069 useTime = 1;
49070 }
49071 useAnimation = (int)((double)useAnimation * 0.6);
49072 if (useAnimation < 1)
49073 {
49074 useAnimation = 1;
49075 }
49076 tileBoost--;
49077 }
49078 if (ItemID.Sets.IsFood[type])
49079 {
49080 holdStyle = 1;
49081 }
49082 if (type >= 1803 && type <= 1807)
49083 {
49084 SetDefaults(1533 + type - 1803);
49085 }
49086 if (dye > 0)
49087 {
49089 }
49090 if (createTile == 19)
49091 {
49093 }
49094 netID = type;
49095 ItemLoader.SetDefaults(this);
49096 if (!noMatCheck)
49097 {
49099 }
49101 if (type > 0 && ItemID.Sets.Deprecated[type])
49102 {
49103 TurnToAir();
49104 }
49105 }
static ItemVariant SelectVariant(int itemId)
Determines which T:Terraria.GameContent.Items.ItemVariant should be applied to an item of type itemId...
static bool HasVariant(int itemId, ItemVariant variant)
Determines if an F:Terraria.Item.type has a particular T:Terraria.GameContent.Items....
Handles conditional variants for T:Terraria.Items, commonly used for secret seeds.
static HairShaderDataSet Hair
Definition GameShaders.cs:9
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static bool[] IsAMaterial
Indicates that an item should show the material tooltip. Typically this means that the item is used i...
Definition ItemID.cs:379
static bool[] Deprecated
If true for a given item type (F:Terraria.Item.type), then that item cannot exist normally: It will b...
Definition ItemID.cs:1319
static bool[] IsChainsaw
If true for a given item type (F:Terraria.Item.type), then that item is a chainsaw....
Definition ItemID.cs:423
static bool[] IsFood
If true for a given item type (F:Terraria.Item.type), then that item is food. Food items can be pla...
Definition ItemID.cs:446
static bool[] IsDrill
If true for a given item type (F:Terraria.Item.type), then that item is a drill. Drills have 40% fa...
Definition ItemID.cs:413
static readonly short Count
Definition ItemID.cs:12719
void RebuildTooltip()
Definition Item.cs:1909
int hairDye
The numerical ID of the hair shader in F:Terraria.Graphics.Shaders.GameShaders.Hair this item will ap...
Definition Item.cs:309
int useAnimation
The time span of the using animation for the item in ticks. This is independent of the time it takes ...
Definition Item.cs:384
void SetDefaults2(int type)
Definition Item.cs:15763
int dye
The numerical ID of the armor shader in F:Terraria.Graphics.Shaders.GameShaders.Armor this item activ...
Definition Item.cs:224
bool material
Indicates that an item should show the material tooltip. Typically this means that the item is used i...
Definition Item.cs:670
void SetDefaults3(int type)
Definition Item.cs:24682
void netDefaults(int type)
Definition Item.cs:1927
void ResetStats(int Type)
Definition Item.cs:49116
int value
The number of copper coins this item is worth (aka, cost to buy from a merchant). Setting it to 10462...
Definition Item.cs:655
int stack
The current stack of the item. F:Terraria.Item.maxStack indicates the max possible stack.
Definition Item.cs:396
int rare
Indicates the rarity of an item. Assign to a T:Terraria.ID.ItemRarityID value. Vanilla values range f...
Definition Item.cs:587
int shoot
The ID of the projectile that is fired by this item on use. Either a T:Terraria.ID....
Definition Item.cs:594
int maxStack
The maximum number of items that can be contained within a single stack. F:Terraria....
Definition Item.cs:402
int createTile
The ID of the tile this item places on use. Either a T:Terraria.ID.TileID entry or M:Terraria....
Definition Item.cs:435
int useStyle
Assign to an T:Terraria.ID.ItemUseStyleID value to give this item a specific animation while in use....
Definition Item.cs:366
static int sellPrice(int platinum=0, int gold=0, int silver=0, int copper=0)
Converts the provided sell value into copper coins. This value is five times larger than M:Terraria....
Definition Item.cs:49553
static int CommonMaxStack
The default stack size for stackable items: 9999.
Definition Item.cs:94
void SetFoodDefaults(int type)
Definition Item.cs:48020
int tileBoost
Additional tile range provided by this tool or tile. Copper Pickaxe has a value of -1,...
Definition Item.cs:429
int playerIndexTheItemIsReservedFor
Definition Item.cs:578
void RestoreMeleeSpeedBehaviorOnVanillaItems()
Definition Item.cs:52083
int netID
Definition Item.cs:739
int holdStyle
Assign to an T:Terraria.ID.ItemHoldStyleID value to give this item a specific animation while the pla...
Definition Item.cs:360
ItemVariant Variant
Definition Item.cs:950
int useTime
The time span of using the item in ticks. This is independent of the time it takes for the item anima...
Definition Item.cs:391
void ApplyItemAnimationCompensationsToVanillaItems()
Definition Item.cs:52063
void TurnToAir(bool fullReset=false)
Definition Item.cs:51791
void SetDefaults4(int type)
Definition Item.cs:31458
void SetDefaults(int Type=0)
Definition Item.cs:48800
void SetDefaults5(int type)
Definition Item.cs:39727
void SetDefaults1(int type)
Definition Item.cs:3504
int bait
The numerical value this item adds to a player's fishing skill when used as bait. If greater than 0,...
Definition Item.cs:241
bool master
If true, then the given item is automatically given the Master rarity, causing its name to be drawn i...
Definition Item.cs:296
int type
The Item ID of this item. The Item ID is a unique number assigned to each Item loaded into the game....
Definition Item.cs:345
static void SetDefaults(Item item, bool createModItem=true)
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26

References Terraria.Item.ApplyItemAnimationCompensationsToVanillaItems(), Terraria.Graphics.Shaders.GameShaders.Armor, Terraria.Item.bait, Terraria.Item.CommonMaxStack, Terraria.ID.ItemID.Count, Terraria.Item.createTile, Terraria.ID.ItemID.Sets.Deprecated, Terraria.Item.dye, Terraria.Graphics.Shaders.GameShaders.Hair, Terraria.Item.hairDye, Terraria.GameContent.Items.ItemVariants.HasVariant(), Terraria.Item.holdStyle, Terraria.ID.ItemID.Sets.IsAMaterial, Terraria.ID.ItemID.Sets.IsChainsaw, Terraria.ID.ItemID.Sets.IsDrill, Terraria.ID.ItemID.Sets.IsFood, Terraria.Item.master, Terraria.Item.material, Terraria.Item.maxStack, Terraria.Main.myPlayer, Terraria.Item.netDefaults(), Terraria.Item.netID, Terraria.Main.netMode, Terraria.Item.playerIndexTheItemIsReservedFor, Terraria.Main.projHook, Terraria.Item.rare, Terraria.Item.RebuildTooltip(), Terraria.Item.ResetStats(), Terraria.Item.RestoreMeleeSpeedBehaviorOnVanillaItems(), Terraria.GameContent.Items.ItemVariants.SelectVariant(), Terraria.Item.sellPrice(), Terraria.Item.SetDefaults(), Terraria.ModLoader.ItemLoader.SetDefaults(), Terraria.Item.SetDefaults1(), Terraria.Item.SetDefaults2(), Terraria.Item.SetDefaults3(), Terraria.Item.SetDefaults4(), Terraria.Item.SetDefaults5(), Terraria.Item.SetFoodDefaults(), Terraria.Item.shoot, Terraria.Item.stack, Terraria.Item.tileBoost, Terraria.Item.TurnToAir(), Terraria.Item.type, Terraria.Item.useAnimation, Terraria.Item.useStyle, Terraria.Item.useTime, Terraria.Item.value, and Terraria.Item.Variant.

+ Here is the call graph for this function: