diff --git a/CHANGELOG.md b/CHANGELOG.md index 145d5933..3792c16b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin * Initial support for MonoMod hooks on Raspberry Pi (arm64). (@kevzhao2) ## Upcoming changes +* Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@gohjoseph) +* Only allow using Teleportation Potions, Magic Conch, and Demon Conch whilst holding them. (@drunderscore) ## TShock 4.5.17 * Fixed duplicate characters (twins) after repeatedly logging in as the same character due to connection not being immediately closed during `NetHooks_NameCollision`. (@gohjoseph) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 7d877dce..ace40b78 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3813,6 +3813,13 @@ namespace TShockAPI switch (type) { case 0: // Teleportation Potion + if (args.Player.ItemInHand.type != ItemID.TeleportationPotion && + args.Player.SelectedItem.type != ItemID.TeleportationPotion) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type); + return true; + } + if (!args.Player.HasPermission(Permissions.tppotion)) { Fail("Teleportation Potions"); @@ -3820,6 +3827,13 @@ namespace TShockAPI } break; case 1: // Magic Conch + if (args.Player.ItemInHand.type != ItemID.MagicConch && + args.Player.SelectedItem.type != ItemID.MagicConch) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type); + return true; + } + if (!args.Player.HasPermission(Permissions.magicconch)) { Fail("the Magic Conch"); @@ -3827,6 +3841,13 @@ namespace TShockAPI } break; case 2: // Demon Conch + if (args.Player.ItemInHand.type != ItemID.DemonConch && + args.Player.SelectedItem.type != ItemID.DemonConch) + { + TShock.Log.ConsoleDebug("GetDataHandlers / HandleTeleportationPotion rejected not holding the correct item {0} {1}", args.Player.Name, type); + return true; + } + if (!args.Player.HasPermission(Permissions.demonconch)) { Fail("the Demon Conch"); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 01dc05d0..f418176c 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1379,7 +1379,9 @@ namespace TShockAPI public virtual void GiveItem(int type, int stack, int prefix = 0) { int itemIndex = Item.NewItem(new EntitySource_DebugCommand(), (int)X, (int)Y, TPlayer.width, TPlayer.height, type, stack, true, prefix, true); - SendData(PacketTypes.ItemDrop, "", itemIndex); + Main.item[itemIndex].playerIndexTheItemIsReservedFor = this.Index; + SendData(PacketTypes.ItemDrop, "", itemIndex, 1); + SendData(PacketTypes.ItemOwner, null, itemIndex); } ///