aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r--src/main/java/gregtech/api/enums/ItemList.java1
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java54
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java2
3 files changed, 56 insertions, 1 deletions
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java
index ed3aea00c4..518663e8ec 100644
--- a/src/main/java/gregtech/api/enums/ItemList.java
+++ b/src/main/java/gregtech/api/enums/ItemList.java
@@ -631,6 +631,7 @@ public enum ItemList implements IItemContainer {
Machine_LV_Hammer, Machine_MV_Hammer, Machine_HV_Hammer, Machine_EV_Hammer, Machine_IV_Hammer,
Machine_LV_FluidHeater, Machine_MV_FluidHeater, Machine_HV_FluidHeater, Machine_EV_FluidHeater, Machine_IV_FluidHeater,
Machine_Multi_LargeChemicalReactor,
+ Machine_LV_Miner, Machine_MV_Miner,
Neutron_Reflector,
Reactor_Coolant_He_1, Reactor_Coolant_He_3, Reactor_Coolant_He_6, Reactor_Coolant_NaK_1, Reactor_Coolant_NaK_3, Reactor_Coolant_NaK_6,neutroniumHeatCapacitor,
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index f4038e2d90..4c75abddcd 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -120,6 +120,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
aNBT.setBoolean("mInputDisabled", mInputDisabled);
aNBT.setBoolean("mOutputDisabled", mOutputDisabled);
aNBT.setTag("GT.CraftingComponents", mRecipeStuff);
+ aNBT.setInteger("nbtVersion", GT_Mod.TOTAL_VERSION);
} catch (Throwable e) {
GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err);
@@ -188,6 +189,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mCoverData = aNBT.getIntArray("mCoverData");
mSidedRedstone = aNBT.getByteArray("mRedstoneSided");
mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents");
+ int nbtVersion = aNBT.getInteger("nbtVersion");
if (mCoverData.length != 6) mCoverData = new int[]{0, 0, 0, 0, 0, 0};
if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
@@ -203,6 +205,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
for (int i = 0; i < tItemList.tagCount(); i++) {
NBTTagCompound tTag = tItemList.getCompoundTagAt(i);
int tSlot = tTag.getInteger("IntSlot");
+ tSlot = shiftInventoryIndex(tSlot, nbtVersion);
if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) {
mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag);
}
@@ -1907,4 +1910,55 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) {
mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider);
}
+
+ /**
+ * 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
+ */
+ private int shiftInventoryIndex(int slotIndex, int nbtVersion){
+ int oldInputSize, newInputSize, oldOutputSize, newOutputSize;
+ int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31);
+ if (mID >= 211 && mID <= 218) {//Assembler
+ if (nbtVersion < chemistryUpdateVersion) {
+ oldInputSize = 2;
+ oldOutputSize = 1;
+ } else {
+ return slotIndex;
+ }
+ newInputSize = 6;
+ newOutputSize = 1;
+ } else if (mID >= 421 && mID <= 428){//Chemical Reactor
+ if (nbtVersion < chemistryUpdateVersion) {
+ oldInputSize = 2;
+ oldOutputSize = 1;
+ } else {
+ return slotIndex;
+ }
+ newInputSize = 2;
+ newOutputSize = 2;
+ } else if (mID >= 531 && mID <= 538) {//Distillery
+ if (nbtVersion < chemistryUpdateVersion) {
+ oldInputSize = 1;
+ oldOutputSize = 0;
+ } else {
+ return slotIndex;
+ }
+ newInputSize = 1;
+ newOutputSize = 1;
+ } else {
+ return slotIndex;
+ }
+ int indexShift = 0;
+ if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize) {indexShift += newInputSize - oldInputSize;
+ }
+ if (slotIndex >= GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT + oldInputSize + oldOutputSize) {
+ indexShift += newOutputSize - oldOutputSize;
+ }
+ return slotIndex + indexShift;
+ }
}
+
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
index 9670a765ee..45e96a5318 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
@@ -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;