Added the `NetItem.Build' method.
The method will create a Terraria.Item instance based on the data from the structure.
This commit is contained in:
parent
c3f5994451
commit
62b8e5067c
1 changed files with 18 additions and 0 deletions
|
|
@ -162,6 +162,24 @@ namespace TShockAPI
|
|||
_prefixId = prefixId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates <see cref="Terraria.Item"/> based on data from this structure.
|
||||
/// </summary>
|
||||
/// <returns>A copy of the item.</returns>
|
||||
/// <exception cref="Exception">If the item ID is 0.</exception>
|
||||
public Item Build()
|
||||
{
|
||||
if (_netId == 0)
|
||||
throw new Exception("It is impossible to create an item whose ID is 0.");
|
||||
Item item = new Item();
|
||||
|
||||
item.netDefaults(_netId);
|
||||
item.stack = _stack;
|
||||
item.prefix = _prefixId;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the <see cref="NetItem"/> to a string.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue