diff --git a/TShockAPI/NetItem.cs b/TShockAPI/NetItem.cs index 278fda1cd..0f0dc6e35 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; @@ -155,13 +155,39 @@ 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; _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. + /// + /// A copy of the item. + public Item ToItem() + { + Item item = new Item(); + + item.netDefaults(_netId); + item.stack = _stack; + item.prefix = _prefixId; + + return item; + } + /// /// Converts the to a string. /// diff --git a/docs/changelog.md b/docs/changelog.md index 41fa28533..09e2254ba 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -82,6 +82,10 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added `ParryDamageBuff` (Striking Moment with Brand of the Inferno and shield) for player, updated `CursedInferno` buff for NPC (@sgkoishi, #3005) * Changed the use of `Player.active` to `TSPlayer.Active` for consistency. (@sgkoishi, #2939) * Fix typo in config for IP bans. (@redchess64) +* 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 `stack` and `prefix` are now optional parameters. * Fixed unable to transfer long response body for REST API. (@sgkoishi, #2925) * Fixed the `/wind` command not being very helpful. (@punchready) @@ -98,10 +102,7 @@ Use past tense when adding new entries; sign your name off when you add or chang * Added a property `TSPlayer.Hostile`, which gets pvp player mode. (@AgaSpace) * Fixed bug where when the `UseSqlLogs` config property is true, an empty log file would still get created. (@ZakFahey) * Fixed typo in `/gbuff`. (@sgkoishi, #2955) -* Rewrote the `.dockerignore` file into a denylist. (@timschumi) -* Added CI for Docker images. (@timschumi) -* Fixed Cursed Flares kicking players for invalid buff. (@Arthri) -* Added automatic publishing of Docker images to GHCR. (@timschumi) + ## TShock 5.2 * An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)