Skip to content

Commit

Permalink
Merge pull request #2945 from AgaSpace/netitem-changes
Browse files Browse the repository at this point in the history
NetItem changes
  • Loading branch information
hakusaro authored Jan 26, 2025
2 parents fdee582 + 18062c5 commit e1c41d0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
30 changes: 28 additions & 2 deletions TShockAPI/NetItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -155,13 +155,39 @@ public int Stack
/// <param name="netId">The net ID.</param>
/// <param name="stack">The stack.</param>
/// <param name="prefixId">The prefix ID.</param>
public NetItem(int netId, int stack, byte prefixId)
public NetItem(int netId, int stack = 1, byte prefixId = 0)
{
_netId = netId;
_stack = stack;
_prefixId = prefixId;
}

/// <summary>
/// Creates a new <see cref="NetItem"/>.
/// </summary>
/// <param name="item">Item in the game.</param>
public NetItem(Item item)
{
_netId = item.netID;
_stack = item.stack;
_prefixId = item.prefix;
}

/// <summary>
/// Creates <see cref="Terraria.Item"/> based on data from this structure.
/// </summary>
/// <returns>A copy of the item.</returns>
public Item ToItem()
{
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>
Expand Down
9 changes: 5 additions & 4 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit e1c41d0

Please sign in to comment.