diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 6ed0f8de..d587515c 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -130,6 +130,7 @@ namespace TShockAPI { PacketTypes.NumberOfAnglerQuestsCompleted, HandleNumberOfAnglerQuestsCompleted }, { PacketTypes.PlaceObject, HandlePlaceObject }, { PacketTypes.LoadNetModule, HandleLoadNetModule }, + { PacketTypes.ForceItemIntoNearestChest, HandleForceItemIntoNearestChest }, { PacketTypes.PlaceTileEntity, HandlePlaceTileEntity }, { PacketTypes.PlaceItemFrame, HandlePlaceItemFrame }, { PacketTypes.UpdateItemDrop, HandleItemDrop }, @@ -1790,6 +1791,30 @@ namespace TShockAPI return args.Handled; } + /// For use in a ForceItemIntoNearestChest event. + public class ForceItemIntoNearestChestEventArgs : GetDataHandledEventArgs + { + /// The slot index of the item being attempted to put into a chest. + public short Slot { get; set; } + + } + + /// Fired when a ForceItemIntoNearestChest event occurs. + public static HandlerList ForceItemIntoNearestChest = new HandlerList(); + private static bool OnForceItemIntoNearest(TSPlayer player, MemoryStream data, short slot) + { + + var args = new ForceItemIntoNearestChestEventArgs + { + Player = player, + Data = data, + Slot = slot + }; + + ForceItemIntoNearestChest.Invoke(null, args); + return args.Handled; + } + /// For use in a PlaceTileEntity event. public class PlaceTileEntityEventArgs : GetDataHandledEventArgs { @@ -4088,6 +4113,18 @@ namespace TShockAPI return false; } + private static bool HandleForceItemIntoNearestChest(GetDataHandlerArgs args) + { + var slot = args.Data.ReadInt16(); + + if (OnForceItemIntoNearest(args.Player, args.Data, slot)) + { + return true; + } + + return false; + } + private static bool HandlePlaceTileEntity(GetDataHandlerArgs args) { var x = args.Data.ReadInt16();