Add ItemDrop hook

This commit is contained in:
Lucas Nicodemus 2012-01-01 01:57:18 -07:00
parent 5c9639c9c1
commit 439efac901

View file

@ -520,6 +520,35 @@ namespace TShockAPI
return args.Handled;
}
public class ItemDropEventArgs : HandledEventArgs
{
public short ID { get; set; }
public Vector2 Position { get; set; }
public Vector2 Velocity { get; set; }
public byte Stacks { get; set; }
public byte Prefix { get; set; }
public short Type { get; set; }
}
public static HandlerList<ItemDropEventArgs> ItemDrop;
private static bool OnItemDrop(short id, Vector2 pos, Vector2 vel, byte stacks, byte prefix, short type)
{
if (ItemDrop == null)
return false;
var args = new ItemDropEventArgs
{
ID = id,
Position = pos,
Velocity = vel,
Stacks = stacks,
Prefix = prefix,
Type = type,
};
ItemDrop.Invoke(null, args);
return args.Handled;
}
#endregion
public static void InitGetDataHandler()
{
@ -1834,6 +1863,9 @@ namespace TShockAPI
var prefix = args.Data.ReadInt8();
var type = args.Data.ReadInt16();
if (OnItemDrop(id, pos, vel, stacks, prefix, type))
return true;
if (type == 0) //Item removed, let client do this to prevent item duplication client side
{
return false;