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
@@ -194,27 +194,30 @@ 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 )
{
for ( int y = 0; y < this.recipe[x].length; y++ )
{ {
ItemStack playerItemStack = null; ItemStack playerItemStack = null;
for ( int y = 0; y < playerInventory.getSizeInventory(); y++ ) for ( int i = 0; i < playerInventory.getSizeInventory(); i++ )
{ {
// check if the item in slot y matches the required item. // check if the item in slot y matches the required item.
playerItemStack = playerInventory.getStackInSlot( y ); playerItemStack = playerInventory.getStackInSlot( i );
if ( playerItemStack != null && playerItemStack.getItem() == this.recipe[x][y].getItem() ) if ( playerItemStack != null && playerItemStack.getItem() == this.recipe[x][y].getItem() )
{ {
if ( realForFake == Actionable.SIMULATE ) if ( realForFake == Actionable.SIMULATE )
{ {
whichItem = playerInventory.getStackInSlot( y ).copy(); whichItem = playerInventory.getStackInSlot( i ).copy();
whichItem.stackSize = 1; whichItem.stackSize = 1;
} }
else else
{ {
whichItem = playerInventory.decrStackSize( y, 1 ); whichItem = playerInventory.decrStackSize( i, 1 );
} }
break; break;
} }
} }
} }
}
craftMatrix.setInventorySlotContents( x, whichItem ); craftMatrix.setInventorySlotContents( x, whichItem );
} }