Skip to content

Commit

Permalink
v0.3.1, fix fishing trash destination
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Aug 5, 2018
1 parent 1babcde commit 0b73c46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions AutoTrashPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ public override bool ShiftClickSlot(Item[] inventory, int context, int slot)
{
if (Main.keyState.IsKeyDown(Keys.LeftControl) || Main.keyState.IsKeyDown(Keys.RightControl))
{
var autoTrashPlayer = Main.LocalPlayer.GetModPlayer<AutoTrashPlayer>();
if (autoTrashPlayer.AutoTrashEnabled && !autoTrashPlayer.AutoTrashItems.Any(x => x.type == inventory[slot].type))
if (AutoTrashEnabled && !AutoTrashItems.Any(x => x.type == inventory[slot].type))
{
Main.PlaySound(7, -1, -1, 1, 1f, 0f);

Item newItem = new Item();
newItem.SetDefaults(inventory[slot].type);
autoTrashPlayer.AutoTrashItems.Add(newItem);
AutoTrashItems.Add(newItem);

autoTrashPlayer.LastAutoTrashItem = inventory[slot].Clone();
LastAutoTrashItem = inventory[slot].Clone();

inventory[slot].SetDefaults();

Expand All @@ -78,15 +77,16 @@ public override void PreUpdate()
// Fishing uses player.GetItem bypassing AutoTrash.
if (Main.myPlayer == player.whoAmI)
{
if(caughtFish > 0)
if(caughtFish > 0 && AutoTrashItems.Where(x => x.type == caughtFish).Any())
{
for (int i = 0; i < 59; i++)
{
if (!player.inventory[i].IsAir && player.inventory[i].type == caughtFish)
{
// TODO: Analyze performance impact? do every 60 frames only?
player.trashItem = player.inventory[i].Clone();
LastAutoTrashItem = player.inventory[i].Clone();
player.inventory[i].TurnToAir();
break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = jopojelly
version = 0.3
version = 0.3.1
displayName = Auto Trash
homepage = https://forums.terraria.org/index.php?threads/auto-trash.53592/
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*
Expand Down

0 comments on commit 0b73c46

Please sign in to comment.