Skip to content

Commit

Permalink
Add safeguard against drops not being the same as capturedrops. Moved…
Browse files Browse the repository at this point in the history
… capturing of drops out of armor and knapsack stuff.
  • Loading branch information
Qowyn committed Oct 5, 2014
1 parent 03755be commit 312fd47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main/java/tconstruct/armor/player/ArmorExtended.java
Expand Up @@ -241,7 +241,7 @@ public void readFromNBT (NBTTagCompound tagCompound)
public void dropItems ()
{
EntityPlayer player = parent.get();
player.captureDrops = true;

for (int i = 0; i < 4; ++i)
{
if (this.inventory[i] != null)
Expand All @@ -250,7 +250,6 @@ public void dropItems ()
this.inventory[i] = null;
}
}
player.captureDrops = false;
}

@Override
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/tconstruct/armor/player/KnapsackInventory.java
Expand Up @@ -161,7 +161,7 @@ public void readFromNBT (NBTTagCompound tagCompound)
public void dropItems ()
{
EntityPlayer player = parent.get();
player.captureDrops = true;

for (int i = 0; i < inventory.length; ++i)
{
if (this.inventory[i] != null)
Expand All @@ -170,7 +170,6 @@ public void dropItems ()
this.inventory[i] = null;
}
}
player.captureDrops = false;
}

public void unequipItems ()
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/tconstruct/armor/player/TPlayerHandler.java
Expand Up @@ -261,8 +261,20 @@ public void playerDrops (PlayerDropsEvent evt)
else
stats.hunger = evt.entityPlayer.getFoodStats().getFoodLevel();

if (evt.entityPlayer.capturedDrops != evt.drops)
{
evt.entityPlayer.capturedDrops.clear();
}

evt.entityPlayer.captureDrops = true;
stats.armor.dropItems();
stats.knapsack.dropItems();
evt.entityPlayer.captureDrops = false;

if (evt.entityPlayer.capturedDrops != evt.drops)
{
evt.drops.addAll(evt.entityPlayer.capturedDrops);
}

playerStats.put(evt.entityPlayer.getPersistentID(), stats);
}
Expand Down

0 comments on commit 312fd47

Please sign in to comment.