From 791a6be8319fb14310585c33a5e6ed3424880395 Mon Sep 17 00:00:00 2001 From: Patrikkk <58985873+Patrikkk@users.noreply.github.com> Date: Sat, 30 May 2020 09:39:40 +0200 Subject: [PATCH] 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 --- TShockAPI/Bouncer.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs index 68089abc..edf05800 100644 --- a/TShockAPI/Bouncer.cs +++ b/TShockAPI/Bouncer.cs @@ -2072,7 +2072,7 @@ namespace TShockAPI /// 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;