Accounted for misc slots when shifting machine inventory contents

This commit is contained in:
Johannes Gäßler 2017-07-02 17:12:30 +02:00
parent 5d8bcb0af3
commit 7d074d985f
2 changed files with 4 additions and 3 deletions

View file

@ -1911,6 +1911,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
/**
* Shifts the machine Inventory index according to the change in Input/Output Slots.
* This is NOT done automatically. If you want to change slot count for a machine this method needs to be adapted.
* Currently this method only works for GT_MetaTileEntity_BasicMachine
* @param slotIndex The original Inventory index
* @param nbtVersion The GregTech version in which the original Inventory Index was saved.
* @return The corrected Inventory index
@ -1949,10 +1950,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
return slotIndex;
}
int indexShift = 0;
if (slotIndex >= oldInputSize) {
if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize) {
indexShift += newInputSize - oldInputSize;
}
if (slotIndex >= oldInputSize + oldOutputSize) {
if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize + oldOutputSize) {
indexShift += newOutputSize - oldOutputSize;
}
return slotIndex + indexShift;

View file

@ -43,7 +43,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
DID_NOT_FIND_RECIPE = 0,
FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1,
FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2;
private static final int OTHER_SLOT_COUNT = 4;
public static final int OTHER_SLOT_COUNT = 4;
public final ItemStack[] mOutputItems;
public final int mInputSlotCount, mAmperage;
public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false;