Merge pull request #1037 from yueh/fix-1030

Fixes #1030 IndexOutOfBoundsException caused by using wrong index
This commit is contained in:
yueh
2015-03-16 11:23:49 +01:00
@@ -195,23 +195,26 @@ public class PacketNEIRecipe extends AppEngPacket
// If that doesn't work, grab from the player's inventory // If that doesn't work, grab from the player's inventory
if ( whichItem == null && playerInventory != null ) if ( whichItem == null && playerInventory != null )
{ {
ItemStack playerItemStack = null; for ( int y = 0; y < this.recipe[x].length; y++ )
for ( int y = 0; y < playerInventory.getSizeInventory(); y++ )
{ {
// check if the item in slot y matches the required item. ItemStack playerItemStack = null;
playerItemStack = playerInventory.getStackInSlot( y ); for ( int i = 0; i < playerInventory.getSizeInventory(); i++ )
if ( playerItemStack != null && playerItemStack.getItem() == this.recipe[x][y].getItem() )
{ {
if ( realForFake == Actionable.SIMULATE ) // check if the item in slot y matches the required item.
playerItemStack = playerInventory.getStackInSlot( i );
if ( playerItemStack != null && playerItemStack.getItem() == this.recipe[x][y].getItem() )
{ {
whichItem = playerInventory.getStackInSlot( y ).copy(); if ( realForFake == Actionable.SIMULATE )
whichItem.stackSize = 1; {
whichItem = playerInventory.getStackInSlot( i ).copy();
whichItem.stackSize = 1;
}
else
{
whichItem = playerInventory.decrStackSize( i, 1 );
}
break;
} }
else
{
whichItem = playerInventory.decrStackSize( y, 1 );
}
break;
} }
} }
} }