Add additional FoodPlatter event check. Update range check. (#1941)

This is a combination of 3 commits:

* @Olink was right. Adding additional check. Modifying range check.

There are two ways to place food into a plate. One is by having it in hand (mouse) and right clicking, the other is by having the item selected in the... "inventory bar"(?) and right clicking the plate.

Tested range, if player is outside the range, they should not get their item back.

* FoodPlatterHotfix - Update IsInRange range value.

To suggestion of Olink, to consider player lag and increase the range check.

Co-authored-by: Lucas Nicodemus <shank@shanked.me>
This commit is contained in:
Patrikkk 2020-05-30 09:39:40 +02:00 committed by GitHub
parent b6ab552d50
commit 791a6be831
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2072,7 +2072,7 @@ namespace TShockAPI
/// <param name="args"></param>
internal void OnFoodPlatterTryPlacing(object sender, GetDataHandlers.FoodPlatterTryPlacingEventArgs args)
{
if (args.Player.ItemInHand.type != args.ItemID)
if ((args.Player.SelectedItem.type != args.ItemID && args.Player.ItemInHand.type != args.ItemID))
{
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected item not placed by hand from {0}", args.Player.Name);
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
@ -2101,12 +2101,9 @@ namespace TShockAPI
return;
}
if (!args.Player.IsInRange(args.TileX, args.TileY))
if (!args.Player.IsInRange(args.TileX, args.TileY, range: 13)) // To my knowledge, max legit tile reach with accessories.
{
TShock.Log.ConsoleDebug("Bouncer / OnFoodPlatterTryPlacing rejected range checks from {0}", args.Player.Name);
Item item = new Item();
item.netDefaults(args.ItemID);
args.Player.GiveItemCheck(args.ItemID, item.Name, args.Stack, args.Prefix);
args.Player.SendTileSquare(args.TileX, args.TileY, 1);
args.Handled = true;
return;