diff --git a/dependencies.gradle b/dependencies.gradle index 0435cd06..ce934d27 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -35,7 +35,7 @@ */ dependencies { api('com.github.GTNewHorizons:NotEnoughItems:2.8.6-GTNH:dev') - api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-711-GTNH:dev') + api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-717-GTNH:dev') api('curse.maven:cofh-core-69162:2388751') api('com.github.GTNewHorizons:waila:1.9.0:dev') api("com.github.GTNewHorizons:GTNHLib:0.7.0:dev") diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidP2PInterface.java b/src/main/java/com/glodblock/github/common/parts/PartFluidP2PInterface.java index c1de93be..80bef8e2 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidP2PInterface.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidP2PInterface.java @@ -35,6 +35,7 @@ import com.google.common.collect.ImmutableSet; import appeng.api.config.Actionable; import appeng.api.config.Upgrades; +import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.tiles.ITileStorageMonitorable; import appeng.api.networking.IGridNode; import appeng.api.networking.crafting.ICraftingLink; @@ -48,7 +49,6 @@ import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; -import appeng.api.parts.IPart; import appeng.api.storage.IMEMonitor; import appeng.api.storage.IStorageMonitorable; import appeng.api.storage.data.IAEFluidStack; @@ -307,9 +307,13 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic newTunnel, NBTTagCompound data) throws GridAccessException { - this.duality.getConfigManager().readFromNBT(data); - super.pasteMemoryCardData(newTunnel, data); + public PartP2PTunnel applyMemoryCard(EntityPlayer player, IMemoryCard memoryCard, ItemStack is) { + PartP2PTunnel newTunnel = super.applyMemoryCard(player, memoryCard, is); + NBTTagCompound data = memoryCard.getData(is); + if (newTunnel instanceof PartFluidP2PInterface p2PInterface) { + p2PInterface.duality.getConfigManager().readFromNBT(data); + } + return newTunnel; } @Override @@ -345,41 +349,7 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic drops = new ArrayList<>(); - for (int i = 0; i < patterns.getSizeInventory(); i++) { - if (patterns.getStackInSlot(i) == null) continue; - drops.add(patterns.getStackInSlot(i)); - } - - final IPart tile = this.getHost().getPart(this.getSide()); - if (tile instanceof PartFluidP2PInterface dualTile) { - DualityInterface newDuality = dualTile.duality; - // Copy interface storage, upgrades, and settings over - UpgradeInventory upgrades = (UpgradeInventory) duality.getInventoryByName("upgrades"); - dualTile.duality.getStorage(); - UpgradeInventory newUpgrade = (UpgradeInventory) newDuality.getInventoryByName("upgrades"); - for (int i = 0; i < upgrades.getSizeInventory(); ++i) { - newUpgrade.setInventorySlotContents(i, upgrades.getStackInSlot(i)); - } - - if (!duality.sharedInventory) { - IInventory storage = duality.getStorage(); - IInventory newStorage = newDuality.getStorage(); - for (int i = 0; i < storage.getSizeInventory(); ++i) { - newStorage.setInventorySlotContents(i, storage.getStackInSlot(i)); - } - } - - IConfigManager config = duality.getConfigManager(); - config.getSettings().forEach( - setting -> newDuality.getConfigManager().putSetting(setting, config.getSetting(setting))); - } - TileEntity te = getTileEntity(); - Platform.spawnDrops(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, drops); - return true; } @@ -399,6 +369,64 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic drops = new ArrayList<>(); + for (int i = 0; i < patterns.getSizeInventory(); i++) { + if (patterns.getStackInSlot(i) == null) continue; + drops.add(patterns.getStackInSlot(i)); + } + if (!drops.isEmpty()) { + final TileEntity te = p2p.getTileEntity(); + Platform.spawnDrops(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, drops); + } + } + + @Override + protected void copyContents(final PartP2PTunnel from) { + if (from instanceof PartFluidP2PInterface fromInterface) { + DualityInterface newDuality = this.duality; + // Copy interface storage, upgrades, and settings over + UpgradeInventory upgrades = (UpgradeInventory) fromInterface.duality.getInventoryByName("upgrades"); + UpgradeInventory newUpgrade = (UpgradeInventory) newDuality.getInventoryByName("upgrades"); + for (int i = 0; i < upgrades.getSizeInventory(); ++i) { + newUpgrade.setInventorySlotContents(i, upgrades.getStackInSlot(i)); + } + + if (!fromInterface.duality.sharedInventory) { + IInventory storage = fromInterface.duality.getStorage(); + IInventory newStorage = newDuality.getStorage(); + for (int i = 0; i < storage.getSizeInventory(); ++i) { + newStorage.setInventorySlotContents(i, storage.getStackInSlot(i)); + } + } + + AppEngInternalInventory patterns = fromInterface.duality.getPatterns(); + boolean drop = true; + if (!from.isOutput() && !this.isOutput()) { // input to input + for (int i = 0; i < patterns.getSizeInventory(); i++) { + newDuality.getPatterns().setInventorySlotContents(i, patterns.getStackInSlot(i)); + } + drop = false; + } + + if (drop) { + this.dropPatterns(fromInterface); + } + } + } + + @Override + protected void copySettings(final PartP2PTunnel from) { + if (from instanceof PartFluidP2PInterface fromInterface) { + DualityInterface newDuality = this.duality; + + IConfigManager config = fromInterface.duality.getConfigManager(); + config.getSettings() + .forEach(setting -> newDuality.getConfigManager().putSetting(setting, config.getSetting(setting))); + } + } + @Override public IIcon getBreakingTexture() { return this.getItemStack().getIconIndex();