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:
AkjaHAsLk1IALk0MasH 2023-05-14 10:13:25 +07:00
parent c3f5994451
commit 62b8e5067c

View file

@ -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>