aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2022-08-31 10:43:06 +0200
committerGitHub <noreply@github.com>2022-08-31 10:43:06 +0200
commit0c50a48fc4d4448c084ca3535af37b4981dd2d7c (patch)
tree28077f6375f883a15cc91276677c857e616d83aa /src/main/java/gregtech/api/metatileentity
parent4927a8885381ca48479be71e7cdb37aae9cbf5fd (diff)
downloadGT5-Unofficial-0c50a48fc4d4448c084ca3535af37b4981dd2d7c.tar.gz
GT5-Unofficial-0c50a48fc4d4448c084ca3535af37b4981dd2d7c.tar.bz2
GT5-Unofficial-0c50a48fc4d4448c084ca3535af37b4981dd2d7c.zip
Two slots wiremill (#1324)
* add a circuit slot to wiremil * add circuits to wire recipes * add 2 input slots to Wiremil * exchange circuit and material slot * add 2x-16x wires to wiremil * add missing 12x wires * add slot migration code (#1326) * spotlessApply (#1327) Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: GitHub GTNH Actions <> Co-authored-by: Glease <4586901+Glease@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java14
-rw-r--r--src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java11
2 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 911c1cabcb..76a6d3237e 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -2270,13 +2270,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity
* @param nbtVersion The GregTech version in which the original Inventory Index was saved.
* @return The corrected Inventory index
*/
- private int migrateInventoryIndex(int slotIndex, int nbtVersion) {
+ @Override
+ protected int migrateInventoryIndex(int slotIndex, int nbtVersion) {
final int oldInputSize;
final int newInputSize;
final int oldOutputSize;
final int newOutputSize;
final int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31);
final int configCircuitAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 40);
+ final int wireAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 41);
// 4 is old GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT
if (nbtVersion < configCircuitAdditionVersion
&& getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine
@@ -2320,6 +2322,16 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity
newInputSize = 6;
newOutputSize = 1;
+ } else if (mID >= 351 && mID <= 355 || mID >= 11050 && mID <= 11056) { // wire mill
+ if (nbtVersion < wireAdditionVersion) {
+ oldInputSize = 1;
+ oldOutputSize = 1;
+ } else {
+ return slotIndex;
+ }
+ newInputSize = 2;
+ newOutputSize = 1;
+
} else {
return slotIndex;
}
diff --git a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java
index 7e35f2e2c1..bf835b51bb 100644
--- a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java
@@ -59,11 +59,12 @@ public abstract class CommonMetaTileEntity extends CoverableTileEntity implement
}
protected void loadMetaTileNBT(NBTTagCompound aNBT) {
+ final int nbtVersion = aNBT.getInteger("nbtVersion");
if (mID != 0 && createNewMetatileEntity(mID)) {
final NBTTagList tItemList = aNBT.getTagList("Inventory", 10);
for (int i = 0; i < tItemList.tagCount(); i++) {
final NBTTagCompound tTag = tItemList.getCompoundTagAt(i);
- final int tSlot = tTag.getInteger("IntSlot");
+ final int tSlot = migrateInventoryIndex(tTag.getInteger("IntSlot"), nbtVersion);
if (tSlot >= 0 && tSlot < getMetaTileEntity().getRealInventory().length) {
getMetaTileEntity().getRealInventory()[tSlot] = GT_Utility.loadItem(tTag);
}
@@ -78,6 +79,14 @@ public abstract class CommonMetaTileEntity extends CoverableTileEntity implement
}
}
+ /**
+ * Shifts the machine Inventory index according to the change in Input/Output Slots.
+ * Default implementation does not do anything to the slotIndex.
+ */
+ protected int migrateInventoryIndex(int slotIndex, int nbtVersion) {
+ return slotIndex;
+ }
+
@Override
public void markDirty() {
super.markDirty();