From 62b8e5067ce3d97055ff7ed8063d9994909816c4 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sun, 14 May 2023 10:13:25 +0700
Subject: [PATCH] Added the `NetItem.Build' method.
The method will create a Terraria.Item instance based on the data from the structure.
---
TShockAPI/NetItem.cs | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs
index 03596a1f..095d3f1c 100644
--- a/TShockAPI/NetItem.cs
+++ b/TShockAPI/NetItem.cs
@@ -162,6 +162,24 @@ namespace TShockAPI
_prefixId = prefixId;
}
+ ///
+ /// Creates based on data from this structure.
+ ///
+ /// A copy of the item.
+ /// If the item ID is 0.
+ 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;
+ }
+
///
/// Converts the to a string.
///