Skip to content

Commit 939d158

Browse files
committed
feat(GetDataHandler): add ForceItemIntoNearestChest
1 parent 5d17f82 commit 939d158

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

TShockAPI/GetDataHandlers.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public static void InitGetDataHandler()
130130
{ PacketTypes.NumberOfAnglerQuestsCompleted, HandleNumberOfAnglerQuestsCompleted },
131131
{ PacketTypes.PlaceObject, HandlePlaceObject },
132132
{ PacketTypes.LoadNetModule, HandleLoadNetModule },
133+
{ PacketTypes.ForceItemIntoNearestChest, HandleForceItemIntoNearestChest },
133134
{ PacketTypes.PlaceTileEntity, HandlePlaceTileEntity },
134135
{ PacketTypes.PlaceItemFrame, HandlePlaceItemFrame },
135136
{ PacketTypes.UpdateItemDrop, HandleItemDrop },
@@ -1790,6 +1791,30 @@ private static bool OnPlaceObject(TSPlayer player, MemoryStream data, short x, s
17901791
return args.Handled;
17911792
}
17921793

1794+
/// <summary>For use in a ForceItemIntoNearestChest event.</summary>
1795+
public class ForceItemIntoNearestChestEventArgs : GetDataHandledEventArgs
1796+
{
1797+
/// <summary>The slot index of the item being attempted to put into a chest.</summary>
1798+
public short Slot { get; set; }
1799+
1800+
}
1801+
1802+
/// <summary>Fired when a ForceItemIntoNearestChest event occurs.</summary>
1803+
public static HandlerList<ForceItemIntoNearestChestEventArgs> ForceItemIntoNearestChest = new HandlerList<ForceItemIntoNearestChestEventArgs>();
1804+
private static bool OnForceItemIntoNearest(TSPlayer player, MemoryStream data, short slot)
1805+
{
1806+
1807+
var args = new ForceItemIntoNearestChestEventArgs
1808+
{
1809+
Player = player,
1810+
Data = data,
1811+
Slot = slot
1812+
};
1813+
1814+
ForceItemIntoNearestChest.Invoke(null, args);
1815+
return args.Handled;
1816+
}
1817+
17931818
/// <summary>For use in a PlaceTileEntity event.</summary>
17941819
public class PlaceTileEntityEventArgs : GetDataHandledEventArgs
17951820
{
@@ -4088,6 +4113,18 @@ private static bool HandleLoadNetModule(GetDataHandlerArgs args)
40884113
return false;
40894114
}
40904115

4116+
private static bool HandleForceItemIntoNearestChest(GetDataHandlerArgs args)
4117+
{
4118+
var slot = args.Data.ReadInt16();
4119+
4120+
if (OnForceItemIntoNearest(args.Player, args.Data, slot))
4121+
{
4122+
return true;
4123+
}
4124+
4125+
return false;
4126+
}
4127+
40914128
private static bool HandlePlaceTileEntity(GetDataHandlerArgs args)
40924129
{
40934130
var x = args.Data.ReadInt16();

0 commit comments

Comments
 (0)