Fixed rejection check inside of HandlePaintTile to account for the

Paint Sprayer (or Architect Gizmo Pack) being inside your inventory,
rather than on an accessory slot.
This commit is contained in:
James Puleo 2021-12-07 02:41:17 -05:00
parent f3b1a84821
commit fe3a59f84a
No known key found for this signature in database
GPG key ID: 3E16C7EFA34FB15D
3 changed files with 22 additions and 2 deletions

View file

@ -12,6 +12,9 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Do not forget to sign every line you change with your name. (@hakusaro) * Do not forget to sign every line you change with your name. (@hakusaro)
* If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. * If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change.
## Upcoming changes
* Fixed rejection check inside of `HandlePaintTile` to account for the Paint Sprayer (or Architect Gizmo Pack) being inside your inventory, rather than on an accessory slot. (@drunderscore)
## TShock 4.5.12 ## TShock 4.5.12
* Fixed the ability to spawn Zenith projectile with non-original items. (@AgaSpace) * Fixed the ability to spawn Zenith projectile with non-original items. (@AgaSpace)
* Added hook `GetDataHandlers.OnNpcTalk` for NpcTalk and a handler for it that stops unregistered and logged out players from interacting with NPCs, preventing them from smuggling or duplicating items via NPC item slots. (@tru321) * Added hook `GetDataHandlers.OnNpcTalk` for NpcTalk and a handler for it that stops unregistered and logged out players from interacting with NPCs, preventing them from smuggling or duplicating items via NPC item slots. (@tru321)

View file

@ -3549,6 +3549,11 @@ namespace TShockAPI
return true; return true;
} }
bool hasPaintSprayerAbilities(Item item) =>
item != null
&& item.stack > 0
&& (item.type == ItemID.PaintSprayer || item.type == ItemID.ArchitectGizmoPack);
// Not selecting paintbrush or paint scraper or the spectre versions? Hacking. // Not selecting paintbrush or paint scraper or the spectre versions? Hacking.
if (args.Player.SelectedItem.type != ItemID.PaintRoller && if (args.Player.SelectedItem.type != ItemID.PaintRoller &&
args.Player.SelectedItem.type != ItemID.PaintScraper && args.Player.SelectedItem.type != ItemID.PaintScraper &&
@ -3556,8 +3561,8 @@ namespace TShockAPI
args.Player.SelectedItem.type != ItemID.SpectrePaintRoller && args.Player.SelectedItem.type != ItemID.SpectrePaintRoller &&
args.Player.SelectedItem.type != ItemID.SpectrePaintScraper && args.Player.SelectedItem.type != ItemID.SpectrePaintScraper &&
args.Player.SelectedItem.type != ItemID.SpectrePaintbrush && args.Player.SelectedItem.type != ItemID.SpectrePaintbrush &&
!args.Player.Accessories.Any(i => i != null && i.stack > 0 && !args.Player.Accessories.Any(hasPaintSprayerAbilities) &&
(i.type == ItemID.PaintSprayer || i.type == ItemID.ArchitectGizmoPack))) !args.Player.Inventory.Any(hasPaintSprayerAbilities))
{ {
TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected select consistency {0}", args.Player.Name); TShock.Log.ConsoleDebug("GetDataHandlers / HandlePaintTile rejected select consistency {0}", args.Player.Name);
args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color()); args.Player.SendData(PacketTypes.PaintTile, "", x, y, Main.tile[x, y].color());

View file

@ -898,6 +898,18 @@ namespace TShockAPI
} }
} }
/// <summary>
/// Gets the player's inventory (first 5 rows)
/// </summary>
public IEnumerable<Item> Inventory
{
get
{
for (int i = 0; i < 50; i++)
yield return TPlayer.inventory[i];
}
}
/// <summary> /// <summary>
/// Gets the player's accessories. /// Gets the player's accessories.
/// </summary> /// </summary>