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

◆ NewItem() [1/10]

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

Spawns an item into the game world with the given type and stack size. The X, Y, Width, and Height parameters dictate a rectangle, the item will be spawned centered within that rectangle. Other overloads support passing in a position directly, or just use 0 for Width and Height if the center is passed in a X and Y.
This method should not be called on multiplayer clients. If you need to spawn items from client code, use M:Terraria.Player.QuickSpawnItem(Terraria.DataStructures.IEntitySource,System.Int32,System.Int32) instead, it handles the multiplayer syncing code needed.
See the noBroadcast documentation if you need to customize attached ModItem or GlobalItem data prior to syncing.
The source represents the entity causing this item to spawn. The return value is the index of the spawned Item within the F:Terraria.Main.item array.

Parameters
source
X
Y
Width
Height
TypeEither an T:Terraria.ID.ItemID entry or M:Terraria.ModLoader.ModContent.ItemType``1, for example F:Terraria.ID.ItemID.IronskinPotion or ModContent.ItemType<MyModItem>()
StackItem stack
noBroadcastControls whether an item spawned on a server is synced using M:Terraria.NetMessage.SendData(System.Int32,System.Int32,System.Int32,Terraria.Localization.NetworkText,System.Int32,System.Single,System.Single,System.Single,System.Int32,System.Int32,System.Int32) and F:Terraria.ID.MessageID.SyncItem. If false, the item will be synced. If true, the calling code can modify the item instance and then sync the item with F:Terraria.ID.MessageID.SyncItem. Has no effect except on server. NewItem running on multiplayer clients always needs to manually sync, see M:Terraria.Player.QuickSpawnItem(Terraria.DataStructures.IEntitySource,System.Int32,System.Int32) source code for an example.
pfix
noGrabDelay
reverseLookup
Returns
The index of the item within F:Terraria.Main.item

Definition at line 51517 of file Item.cs.

51518 {
51519 return NewItem_Inner(source, X, Y, Width, Height, null, Type, Stack, noBroadcast, pfix, noGrabDelay, reverseLookup);
51520 }
int noGrabDelay
The delay, in ticks, before players can pick up this item. Usually set to 100 (approximately 1....
Definition Item.cs:183
static int 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)
Definition Item.cs:51522

References Terraria.Item.NewItem_Inner(), and Terraria.Item.noGrabDelay.

+ Here is the call graph for this function: