|
8 | 8 | import appeng.me.GridAccessException; |
9 | 9 | import appeng.util.Platform; |
10 | 10 | import github.kasuminova.mmce.common.tile.base.MEItemBus; |
| 11 | +import hellfirepvp.modularmachinery.ModularMachinery; |
11 | 12 | import hellfirepvp.modularmachinery.common.lib.ItemsMM; |
12 | 13 | import hellfirepvp.modularmachinery.common.machine.IOType; |
13 | 14 | import hellfirepvp.modularmachinery.common.machine.MachineComponent; |
|
22 | 23 | import java.util.WeakHashMap; |
23 | 24 | import java.util.concurrent.locks.ReadWriteLock; |
24 | 25 |
|
25 | | -public class MEItemInputBus extends MEItemBus { |
| 26 | +public class MEItemInputBus extends MEItemBus implements SettingsTransfer { |
| 27 | + |
| 28 | + private static final String CONFIG_TAG_KEY = "configInventory"; |
| 29 | + |
26 | 30 | // A simple cache for AEItemStack. |
27 | 31 | private static final Map<ItemStack, IAEItemStack> AE_STACK_CACHE = new WeakHashMap<>(); |
28 | 32 | private IOInventory configInventory = buildConfigInventory(); |
@@ -71,16 +75,16 @@ public IOInventory buildConfigInventory() { |
71 | 75 | public void readCustomNBT(final NBTTagCompound compound) { |
72 | 76 | super.readCustomNBT(compound); |
73 | 77 |
|
74 | | - if (compound.hasKey("configInventory")) { |
75 | | - readConfigInventoryNBT(compound.getCompoundTag("configInventory")); |
| 78 | + if (compound.hasKey(CONFIG_TAG_KEY)) { |
| 79 | + readConfigInventoryNBT(compound.getCompoundTag(CONFIG_TAG_KEY)); |
76 | 80 | } |
77 | 81 | } |
78 | 82 |
|
79 | 83 | @Override |
80 | 84 | public void writeCustomNBT(final NBTTagCompound compound) { |
81 | 85 | super.writeCustomNBT(compound); |
82 | 86 |
|
83 | | - compound.setTag("configInventory", configInventory.writeNBT()); |
| 87 | + compound.setTag(CONFIG_TAG_KEY, configInventory.writeNBT()); |
84 | 88 | } |
85 | 89 |
|
86 | 90 | public IOInventory getConfigInventory() { |
@@ -281,4 +285,21 @@ public void readConfigInventoryNBT(final NBTTagCompound compound) { |
281 | 285 | } |
282 | 286 | configInventory.setStackLimit(Integer.MAX_VALUE, slotIDs); |
283 | 287 | } |
| 288 | + |
| 289 | + @Override |
| 290 | + public NBTTagCompound downloadSettings() { |
| 291 | + NBTTagCompound tag = new NBTTagCompound(); |
| 292 | + tag.setTag(CONFIG_TAG_KEY, configInventory.writeNBT()); |
| 293 | + return tag; |
| 294 | + } |
| 295 | + |
| 296 | + @Override |
| 297 | + public void uploadSettings(NBTTagCompound settings) { |
| 298 | + readConfigInventoryNBT(settings.getCompoundTag(CONFIG_TAG_KEY)); |
| 299 | + try { |
| 300 | + proxy.getTick().alertDevice(proxy.getNode()); |
| 301 | + } catch (GridAccessException e) { |
| 302 | + ModularMachinery.log.warn("Error while uploading settings", e); |
| 303 | + } |
| 304 | + } |
284 | 305 | } |
0 commit comments