Skip to content

Commit

Permalink
Prevent ArrayOutOfBounds exceptions
Browse files Browse the repository at this point in the history
Should fix Vswe#38
  • Loading branch information
spacebuilder2020 committed Apr 20, 2017
1 parent eff4721 commit ae1813f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/java/vswe/production/page/unit/UnitCrafting.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,13 @@ public int getFullSize() {

@Override
public ItemStack getStackInSlot(int id) {
return items[id];
return id < items.length ? items[id] : null;
}

@Override
public void setInventorySlotContents(int id, ItemStack item) {
items[id] = item;
if (id < items.length)
items[id] = item;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/vswe/production/tileentity/TileEntityTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public PageUpgrades getUpgradePage() {

@Override
public ItemStack getStackInSlot(int id) {
return items[id];
return id < items.length ? items[id] : null;
}

@Override
Expand Down Expand Up @@ -160,7 +160,8 @@ public ItemStack getStackInSlotOnClosing(int id) {

@Override
public void setInventorySlotContents(int id, ItemStack item) {
items[id] = item;
if (id < items.length)
items[id] = item;
}

@Override
Expand Down

0 comments on commit ae1813f

Please sign in to comment.