feat(GetDataHandler): add ForceItemIntoNearestChest
This commit is contained in:
parent
5d17f82d18
commit
939d1582f5
1 changed files with 37 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/// <summary>For use in a ForceItemIntoNearestChest event.</summary>
|
||||
public class ForceItemIntoNearestChestEventArgs : GetDataHandledEventArgs
|
||||
{
|
||||
/// <summary>The slot index of the item being attempted to put into a chest.</summary>
|
||||
public short Slot { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Fired when a ForceItemIntoNearestChest event occurs.</summary>
|
||||
public static HandlerList<ForceItemIntoNearestChestEventArgs> ForceItemIntoNearestChest = new HandlerList<ForceItemIntoNearestChestEventArgs>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>For use in a PlaceTileEntity event.</summary>
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue