From c3f5994451b02a0b93230b41519f34fa97ac9a9a Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sun, 14 May 2023 10:08:02 +0700
Subject: [PATCH 1/9] Added optional arguments `stack` and `prefixId` to the
`NetItem` constructor
---
TShockAPI/NetItem.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs
index 278fda1cd..03596a1f2 100644
--- a/TShockAPI/NetItem.cs
+++ b/TShockAPI/NetItem.cs
@@ -155,7 +155,7 @@ public int Stack
/// The net ID.
/// The stack.
/// The prefix ID.
- public NetItem(int netId, int stack, byte prefixId)
+ public NetItem(int netId, int stack = 1, byte prefixId = 0)
{
_netId = netId;
_stack = stack;
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 2/9] 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 03596a1f2..095d3f1c0 100644
--- a/TShockAPI/NetItem.cs
+++ b/TShockAPI/NetItem.cs
@@ -162,6 +162,24 @@ public NetItem(int netId, int stack = 1, byte prefixId = 0)
_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.
///
From 86be1738ccc2f6d8930d4fe3dea411acc310dd49 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sun, 14 May 2023 10:13:59 +0700
Subject: [PATCH 3/9] Added a constructor with arguments taking
`Terraria.Item`.
---
TShockAPI/NetItem.cs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs
index 095d3f1c0..86fe82a72 100644
--- a/TShockAPI/NetItem.cs
+++ b/TShockAPI/NetItem.cs
@@ -162,6 +162,17 @@ public NetItem(int netId, int stack = 1, byte prefixId = 0)
_prefixId = prefixId;
}
+ ///
+ /// Creates a new .
+ ///
+ /// Item in the game.
+ public NetItem(Item item)
+ {
+ _netId = item.netID;
+ _stack = item.stack;
+ _prefixId = item.prefix;
+ }
+
///
/// Creates based on data from this structure.
///
From 7ab05707869366b884cce0680efee356cfc6ea7e Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Sun, 14 May 2023 10:22:39 +0700
Subject: [PATCH 4/9] Update changelog.md
---
docs/changelog.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index 3f64f3554..54e6ff668 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -78,7 +78,10 @@ Use past tense when adding new entries; sign your name off when you add or chang
* If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. -->
## Upcoming changes
-Your changes could be here!
+* Updated `TShockAPI.NetItem` (@AgaSpace):
+ * Added constructor overload with parameter `Terraria.Item`.
+ * Added the `Build` method to get a copy of `Terraria.Item`.
+ * In the constructor I added optional parameters `stack` and `prefix`.
## TShock 5.2
* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)
From 914d7432646080ab7eae8d0ccebd4c375f7c7439 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Tue, 6 Jun 2023 19:15:58 +0700
Subject: [PATCH 5/9] Changed the method from `NetItem.Build` to
`NetItem.ToItem`.
---
TShockAPI/NetItem.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs
index 86fe82a72..0a3e0c998 100644
--- a/TShockAPI/NetItem.cs
+++ b/TShockAPI/NetItem.cs
@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
- using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -178,7 +178,7 @@ public NetItem(Item item)
///
/// A copy of the item.
/// If the item ID is 0.
- public Item Build()
+ public Item ToItem()
{
if (_netId == 0)
throw new Exception("It is impossible to create an item whose ID is 0.");
From 3a90029d5199e724baeaf04a1aea010b9be3e103 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Thu, 8 Jun 2023 16:33:32 +0700
Subject: [PATCH 6/9] Allowed to receive an item if it is 0.
---
TShockAPI/NetItem.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs
index 0a3e0c998..13f3f49da 100644
--- a/TShockAPI/NetItem.cs
+++ b/TShockAPI/NetItem.cs
@@ -180,8 +180,6 @@ public NetItem(Item item)
/// If the item ID is 0.
public Item ToItem()
{
- if (_netId == 0)
- throw new Exception("It is impossible to create an item whose ID is 0.");
Item item = new Item();
item.netDefaults(_netId);
From b3f314985070afc450da441524698c1640d6dccc Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Thu, 8 Jun 2023 16:34:06 +0700
Subject: [PATCH 7/9] Update changelog.md
---
docs/changelog.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index 54e6ff668..e02dcbdc5 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -80,7 +80,7 @@ Use past tense when adding new entries; sign your name off when you add or chang
## Upcoming changes
* Updated `TShockAPI.NetItem` (@AgaSpace):
* Added constructor overload with parameter `Terraria.Item`.
- * Added the `Build` method to get a copy of `Terraria.Item`.
+ * Added the `ToItem` method to get a copy of `Terraria.Item`.
* In the constructor I added optional parameters `stack` and `prefix`.
## TShock 5.2
From 4eb2aa49de40e5c64b4dc09acacdf554634737c6 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Thu, 8 Jun 2023 18:11:26 +0700
Subject: [PATCH 8/9] Removed unnecessary documentation
---
TShockAPI/NetItem.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs
index 13f3f49da..0f0dc6e35 100644
--- a/TShockAPI/NetItem.cs
+++ b/TShockAPI/NetItem.cs
@@ -177,7 +177,6 @@ public NetItem(Item item)
/// Creates based on data from this structure.
///
/// A copy of the item.
- /// If the item ID is 0.
public Item ToItem()
{
Item item = new Item();
From 5498f84942c5487b651214db20a331c7f7b87dc6 Mon Sep 17 00:00:00 2001
From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com>
Date: Thu, 8 Jun 2023 18:12:25 +0700
Subject: [PATCH 9/9] Update changelog.md
---
docs/changelog.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/changelog.md b/docs/changelog.md
index e02dcbdc5..d1f486b26 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -81,7 +81,7 @@ Use past tense when adding new entries; sign your name off when you add or chang
* Updated `TShockAPI.NetItem` (@AgaSpace):
* Added constructor overload with parameter `Terraria.Item`.
* Added the `ToItem` method to get a copy of `Terraria.Item`.
- * In the constructor I added optional parameters `stack` and `prefix`.
+ * In the constructor `stack` and `prefix` are now optional parameters.
## TShock 5.2
* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)