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

◆ NewItem_Inner()

static int Terraria.Item.NewItem_Inner ( IEntitySource source,
int X,
int Y,
int Width,
int Height,
Item itemToClone,
int Type,
int Stack = 1,
bool noBroadcast = false,
int pfix = 0,
bool noGrabDelay = false,
bool reverseLookup = false )
inlinestaticprivate

Definition at line 51522 of file Item.cs.

51523 {
51524 //IL_01b3: Unknown result type (might be due to invalid IL or missing references)
51525 //IL_0222: Unknown result type (might be due to invalid IL or missing references)
51526 //IL_022c: Unknown result type (might be due to invalid IL or missing references)
51527 //IL_0231: Unknown result type (might be due to invalid IL or missing references)
51528 if (WorldGen.gen)
51529 {
51530 return 0;
51531 }
51532 if (Main.rand == null)
51533 {
51534 Main.rand = new UnifiedRandom();
51535 }
51536 if (NPCLoader.blockLoot.Contains(Type) || newItemDisabled)
51537 {
51538 return Main.maxItems;
51539 }
51540 if (Main.tenthAnniversaryWorld)
51541 {
51542 if (Type == 58)
51543 {
51544 Type = Main.rand.NextFromList(new short[3] { 1734, 1867, 58 });
51545 }
51546 if (Type == 184)
51547 {
51548 Type = Main.rand.NextFromList(new short[3] { 1735, 1868, 184 });
51549 }
51550 }
51551 if (Main.halloween)
51552 {
51553 if (Type == 58)
51554 {
51555 Type = 1734;
51556 }
51557 if (Type == 184)
51558 {
51559 Type = 1735;
51560 }
51561 }
51562 if (Main.xMas)
51563 {
51564 if (Type == 58)
51565 {
51566 Type = 1867;
51567 }
51568 if (Type == 184)
51569 {
51570 Type = 1868;
51571 }
51572 }
51573 if (itemToClone == null && Type > 0 && cachedItemSpawnsByType[Type] != -1)
51574 {
51576 return 400;
51577 }
51578 Main.item[400] = new Item();
51579 int num = 400;
51580 if (Main.netMode != 1)
51581 {
51583 }
51584 Main.timeItemSlotCannotBeReusedFor[num] = 0;
51585 Main.item[num] = new Item();
51586 Item item = Main.item[num];
51587 if (itemToClone != null)
51588 {
51589 Main.item[num] = itemToClone.Clone();
51590 item = Main.item[num];
51591 Type = itemToClone.type;
51592 }
51593 else
51594 {
51595 item.SetDefaults(Type);
51596 item.Prefix(pfix);
51597 item.stack = Stack;
51598 }
51599 item.position.X = X + Width / 2 - item.width / 2;
51600 item.position.Y = Y + Height / 2 - item.height / 2;
51601 item.wet = Collision.WetCollision(item.position, item.width, item.height);
51602 item.velocity.X = (float)Main.rand.Next(-30, 31) * 0.1f;
51603 item.velocity.Y = (float)Main.rand.Next(-40, -15) * 0.1f;
51604 if (Type == 859 || Type == 4743)
51605 {
51606 Item item2 = item;
51607 item2.velocity *= 0f;
51608 }
51609 if (Type == 520 || Type == 521 || (item.type >= 0 && ItemID.Sets.NebulaPickup[item.type]))
51610 {
51611 item.velocity.X = (float)Main.rand.Next(-30, 31) * 0.1f;
51612 item.velocity.Y = (float)Main.rand.Next(-30, 31) * 0.1f;
51613 }
51614 item.active = true;
51615 item.timeSinceItemSpawned = ItemID.Sets.OverflowProtectionTimeOffset[item.type];
51617 if (ItemSlot.Options.HighlightNewItems && item.type >= 0 && !ItemID.Sets.NeverAppearsAsNewInInventory[item.type])
51618 {
51619 item.newAndShiny = true;
51620 }
51621 ItemLoader.OnSpawn(item, source);
51622 if (Main.netMode == 2 && !noBroadcast)
51623 {
51624 NetMessage.SendData(21, -1, -1, null, num, noGrabDelay.ToInt());
51625 }
51626 else if (Main.netMode == 0)
51627 {
51628 item.playerIndexTheItemIsReservedFor = Main.myPlayer;
51629 }
51630 return num;
51631 }
static bool[] NeverAppearsAsNewInInventory
If true for a given item type (F:Terraria.Item.type), then that item will never be highlighted (F:Ter...
Definition ItemID.cs:1325
static int[] OverflowProtectionTimeOffset
If != 0 for a given item type (F:Terraria.Item.type), then that item will spawn with F:Terraria....
Definition ItemID.cs:165
static bool[] NebulaPickup
Do not add items to this set. If true for a given item type (F:Terraria.Item.type),...
Definition ItemID.cs:1380
static int numberOfNewItems
Definition Item.cs:777
static int PickAnItemSlotToSpawnItemOn(bool reverseLookup, int nextItem)
Definition Item.cs:51633
static int[] cachedItemSpawnsByType
The number of cached item spawns by type. A value of -1 means that an item type is not being cached....
Definition Item.cs:102
static bool newItemDisabled
Definition Item.cs:797
int IEntityWithGlobals< GlobalItem >. Type
Definition Item.cs:1019
int noGrabDelay
The delay, in ticks, before players can pick up this item. Usually set to 100 (approximately 1....
Definition Item.cs:183
static void OnSpawn(Item item, IEntitySource source)
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26
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...
Definition NPCLoader.cs:108
This serves as the central class from which NPC-related functions are carried out....
Definition NPCLoader.cs:26
static bool HighlightNewItems
Definition ItemSlot.cs:30

References Terraria.Item.Item(), Terraria.ModLoader.NPCLoader.blockLoot, Terraria.Item.cachedItemSpawnsByType, Terraria.WorldGen.gen, Terraria.Main.halloween, Terraria.Entity.height, Terraria.UI.ItemSlot.Options.HighlightNewItems, Terraria.Main.item, Terraria.Main.maxItems, Terraria.Main.myPlayer, Terraria.ID.ItemID.Sets.NebulaPickup, Terraria.Main.netMode, Terraria.ID.ItemID.Sets.NeverAppearsAsNewInInventory, Terraria.Item.newItemDisabled, Terraria.Item.noGrabDelay, Terraria.Item.numberOfNewItems, Terraria.ModLoader.ItemLoader.OnSpawn(), Terraria.ID.ItemID.Sets.OverflowProtectionTimeOffset, Terraria.Item.PickAnItemSlotToSpawnItemOn(), Terraria.Entity.position, Terraria.Item.Prefix(), Terraria.Main.rand, Terraria.NetMessage.SendData(), Terraria.Item.SetDefaults(), Terraria.Main.tenthAnniversaryWorld, Terraria.Main.timeItemSlotCannotBeReusedFor, Terraria.Item.type, Terraria.Item.Type, Terraria.Collision.WetCollision(), Terraria.Entity.width, and Terraria.Main.xMas.

Referenced by Terraria.Item.NewItem(), and Terraria.Item.NewItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: