diff options
| author | Andrey <timeconqueror999@gmail.com> | 2021-08-01 13:40:42 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-01 13:40:42 +0300 |
| commit | 01bad48a4cc564725277c93ed1f004db8048bdc2 (patch) | |
| tree | 2eff9d12b13fc6db5682c31c7dd3253fdaf1ec4f /src/main/java/gregtech/common/tileentities/automation | |
| parent | 352e16cceb3e419f1ea63af2384b0aced76f9451 (diff) | |
| parent | 827a47c3cf0c26d81403f718dc3654a367436c2b (diff) | |
| download | GT5-Unofficial-01bad48a4cc564725277c93ed1f004db8048bdc2.tar.gz GT5-Unofficial-01bad48a4cc564725277c93ed1f004db8048bdc2.tar.bz2 GT5-Unofficial-01bad48a4cc564725277c93ed1f004db8048bdc2.zip | |
Merge branch 'experimental' into code-improvements
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/automation')
2 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java index 3830cd3497..9da0eace39 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java @@ -125,9 +125,11 @@ public class GT_MetaTileEntity_ChestBuffer extends GT_MetaTileEntity_Buffer { protected void fillStacksIntoFirstSlots() { sortStacks(); // Merge small stacks together - for (int i = 0; i < this.mInventory.length-1;) { + // The last slot of mInventory is invalid, so we need to avoid iterating over it. + // Thus all max indices are reduced by 1 here. + for (int i = 0; i < this.mInventory.length - 2;) { //GT_FML_LOGGER.info( (this.mInventory[i] == null) ? "Slot empty " + i : "Slot " + i + " holds " + this.mInventory[i].getDisplayName()); - for (int j = i + 1; j < this.mInventory.length; j++) { + for (int j = i + 1; j < this.mInventory.length - 1; j++) { if ((this.mInventory[j] != null) && ((GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) { GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); //GT_FML_LOGGER.info( "Moving slot " + j + " into slot " + i ); diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java index d3b124b79f..3cf5adff99 100644 --- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java +++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java @@ -51,7 +51,9 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer @Override protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < this.mInventory.length - 1; i++) { + // The last slot of mInventory is invalid, so we need to avoid iterating over it. + // Thus all max indices are reduced by 1 here. + for (int i = 0; i < this.mInventory.length - 2; i++) { for (int j = i + 1; j < this.mInventory.length - 1; j++) { if ((this.mInventory[j] != null) && ((this.mInventory[i] == null) || (GT_Utility.areStacksEqual(this.mInventory[i], this.mInventory[j])))) { |
