Add ItemDrop hook
This commit is contained in:
parent
5c9639c9c1
commit
439efac901
1 changed files with 32 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue