From 16890312198713c45c30d3d4a1af56a4b1bda711 Mon Sep 17 00:00:00 2001 From: jmongeon Date: Tue, 15 Jul 2014 23:40:33 -0400 Subject: [PATCH 1/6] Fix Gas Generator not accepting Buildcraft fuels. --- src/main/java/mekanism/api/gas/FuelHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/mekanism/api/gas/FuelHandler.java b/src/main/java/mekanism/api/gas/FuelHandler.java index 452c6b696..ff3537dc4 100644 --- a/src/main/java/mekanism/api/gas/FuelHandler.java +++ b/src/main/java/mekanism/api/gas/FuelHandler.java @@ -27,7 +27,7 @@ public class FuelHandler return fuels.get(gas.getName()); } - if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuel") && gas.hasFluid()) + if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") && gas.hasFluid()) { Fuel bcFuel = IronEngineFuel.getFuelForFluid(gas.getFluid()); From f768dabd5fcf69e24dd141984e10f8ccbfad22cd Mon Sep 17 00:00:00 2001 From: fewizz Date: Fri, 25 Jul 2014 12:44:54 +0400 Subject: [PATCH 2/6] Update ru_RU.lang --- .../resources/assets/mekanism/lang/ru_RU.lang | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/resources/assets/mekanism/lang/ru_RU.lang b/src/main/resources/assets/mekanism/lang/ru_RU.lang index 9aa7fbd04..a401b5248 100644 --- a/src/main/resources/assets/mekanism/lang/ru_RU.lang +++ b/src/main/resources/assets/mekanism/lang/ru_RU.lang @@ -137,6 +137,7 @@ tile.OreBlock.OsmiumOre.name=Осмиевая руда tile.OreBlock.CopperOre.name=Медная руда tile.OreBlock.TinOre.name=Оловянная руда +//Transmitters item.MultipartTransmitter.PressurizedTube.name=Герметичная труба item.MultipartTransmitter.BasicUniversalCable.name=Основной универсальный провод item.MultipartTransmitter.AdvancedUniversalCable.name=Продвинутый универсальный провод @@ -268,6 +269,7 @@ fluid.sulfuricAcid=Жидкая серная кислота fluid.hydrogenChloride=Жидкий хлороводород fluid.brine=Рапа fluid.ethene=Жидкий этилен +fluid.sodium=Жидкий натрий //OreGas names oregas.iron=Железная руда @@ -291,6 +293,10 @@ update.outdated=Используется устаревшая версия од key.mode=Переключить режим key.voice=Голос +//Config Gui +mekanism.configgui.ctgy.general.tooltip=Общие настройки, касающиеся Mekanism и всех его модулей +mekanism.configgui.ctgy.usage.tooltip=Настройки, касающиеся машин, и использования ими же энергии + //Gui text gui.removeSpeedUpgrade=Удалить улучшение скорости gui.removeEnergyUpgrade=Удалить улучшение энергии @@ -383,12 +389,6 @@ gui.materialFilter.details=Используется материал gui.portableTeleporter=Переносной телепортер -gui.teleporter.notReady=Не готов -gui.teleporter.ready=Готов -gui.teleporter.needsEnergy=Нужна энергия -gui.teleporter.linksCapacity=Соединения > 2 -gui.teleporter.noLink=Соединение не найдено - gui.robit=«Робит» entity.Robit.name=«Робит» gui.robit.smelting=«Робит»: Плавка @@ -417,6 +417,13 @@ gui.logisticalSorter.roundRobin=Цикл gui.electricChest.editPassword=Редактировать пароль +gui.teleporter.notReady=Не готов +gui.teleporter.ready=Готов +gui.teleporter.noFrame=Нет рамки +gui.teleporter.noLink=Нет ссылки +gui.teleporter.exceeds=Ссылок больше двух +gui.teleporter.needsEnergy=Требуется энергия + gui.digitalMinerConfig=Настройки цифрового шахтёра gui.digitalMiner.autoPull=Авто-тяга @@ -535,6 +542,8 @@ tooltip.PrecisionSawmill=Этот механизм используется дл tooltip.ChemicalDissolutionChamber=Максимальный механизм используется для !nхимического растворения всех примесей !nруды, оставляя необработанный расплав. tooltip.ChemicalWasher=Максимальный механизм, который очищает необработанные !nрасплавленные руды и подготавливает их для кристаллизации. tooltip.ChemicalCrystalizer=Максимальный механизм, который используется для кристаллизации !nочищенной расплавленной руды в кристаллы. +tooltip.ChemicalOxidizer=Механизм, который окисляет !nтвердые материалы в газ. +tooltip.ChemicalInfuser=Механизм, который производит !nновый газ, путём инфузии двух других газов. tooltip.SeismicVibrator=Механизм, который использует сейсмические колебания, чтобы !nпредоставить информацию о различных слоях мира. tooltip.PressurizedReactionChamber=Продвинутый механизм, который обрабатывает твёрдые, жидкие и газообразные смеси и создаёт как газообразный, так и твёрдый продукт. tooltip.PortableTank=Удобный, переносной резервуар, который позволяет переносить 14 !nвёдер жидкости, где бы Вы !nне были. Также служит в качестве ведра! @@ -559,6 +568,11 @@ control.disabled.desc=Всегда активен control.high.desc=Активен по сигналу control.low.desc=Активен без сигнала +//Container edit modes +fluidedit.both=Both +fluidedit.fill=Заполнять +fluidedit.empty=Выливать + //Colors color.black=Чёрный color.darkBlue=Тёмно-синий From ba289ced25fc59cf8eb6da00b2719c43d8845460 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 26 Jul 2014 17:37:25 -0400 Subject: [PATCH 3/6] Added sustained fluid and gas tanks to PRC and Electrolytic Separator, fixed Gas Generator losing energy when being picked up --- .../mekanism/common/block/BlockMachine.java | 41 ++++++++++++++++++- .../common/item/ItemBlockMachine.java | 22 ++++++++++ .../common/block/BlockGenerator.java | 2 +- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index f565a5a14..367abe760 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -73,7 +73,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; @@ -1168,6 +1167,46 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer itemStack.stackTagCompound.setTag("leftTank", infuser.centerTank.getGas().write(new NBTTagCompound())); } } + + if(tileEntity instanceof TileEntityElectrolyticSeparator) + { + TileEntityElectrolyticSeparator separator = (TileEntityElectrolyticSeparator)tileEntity; + + if(separator.fluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("fluidTank", separator.fluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(separator.leftTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("leftTank", separator.leftTank.getGas().write(new NBTTagCompound())); + } + + if(separator.rightTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("rightTank", separator.rightTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityPRC) + { + TileEntityPRC prc = (TileEntityPRC)tileEntity; + + if(prc.inputFluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("inputFluidTank", prc.inputFluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(prc.inputGasTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputGasTank", prc.inputGasTank.getGas().write(new NBTTagCompound())); + } + + if(prc.outputGasTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputGasTank", prc.outputGasTank.getGas().write(new NBTTagCompound())); + } + } return itemStack; } diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index ea5223597..5dbde0970 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -34,8 +34,10 @@ import mekanism.common.tile.TileEntityChemicalOxidizer; import mekanism.common.tile.TileEntityDigitalMiner; import mekanism.common.tile.TileEntityElectricBlock; import mekanism.common.tile.TileEntityElectricChest; +import mekanism.common.tile.TileEntityElectrolyticSeparator; import mekanism.common.tile.TileEntityFactory; import mekanism.common.tile.TileEntityLogisticalSorter; +import mekanism.common.tile.TileEntityPRC; import mekanism.common.tile.TileEntityPortableTank; import mekanism.common.tile.TileEntityRotaryCondensentrator; import mekanism.common.transporter.TransporterFilter; @@ -378,6 +380,26 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec ((TileEntityChemicalInfuser)tileEntity).centerTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("centerTank"))); } } + + if(tileEntity instanceof TileEntityElectrolyticSeparator) + { + if(stack.stackTagCompound != null) + { + ((TileEntityElectrolyticSeparator)tileEntity).fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("fluidTank"))); + ((TileEntityElectrolyticSeparator)tileEntity).leftTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("leftTank"))); + ((TileEntityElectrolyticSeparator)tileEntity).rightTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("rightTank"))); + } + } + + if(tileEntity instanceof TileEntityPRC) + { + if(stack.stackTagCompound != null) + { + ((TileEntityPRC)tileEntity).inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("inputFluidTank"))); + ((TileEntityPRC)tileEntity).inputGasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputGasTank"))); + ((TileEntityPRC)tileEntity).outputGasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputGasTank"))); + } + } ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index f4adedd7d..cc31bc86d 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -526,7 +526,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds { HEAT_GENERATOR(0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true), SOLAR_GENERATOR(1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, true), - GAS_GENERATOR(3, "GasGenerator", 3, 40000, TileEntityGasGenerator.class, true), + GAS_GENERATOR(3, "GasGenerator", 3, Mekanism.FROM_H2*100, TileEntityGasGenerator.class, true), BIO_GENERATOR(4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true), ADVANCED_SOLAR_GENERATOR(5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator.class, true), WIND_TURBINE(6, "WindTurbine", 5, 200000, TileEntityWindTurbine.class, true); From 7ac7fbc5ccd59781799ed2cf24eb5cf3e14523c9 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 26 Jul 2014 17:59:43 -0400 Subject: [PATCH 4/6] Sustained gas and fluid support for Chemical Washer, Chemical Crystallizer and Chemical Infuser --- .../mekanism/common/block/BlockMachine.java | 53 +++++++++++++++++-- .../common/item/ItemBlockMachine.java | 30 +++++++++++ 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 367abe760..6a4519704 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1140,11 +1140,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer if(tileEntity instanceof TileEntityChemicalOxidizer) { - TileEntityChemicalOxidizer formulator = (TileEntityChemicalOxidizer)tileEntity; + TileEntityChemicalOxidizer oxidizer = (TileEntityChemicalOxidizer)tileEntity; - if(formulator.gasTank.getGas() != null) + if(oxidizer.gasTank.getGas() != null) { - itemStack.stackTagCompound.setTag("gasTank", formulator.gasTank.getGas().write(new NBTTagCompound())); + itemStack.stackTagCompound.setTag("gasTank", oxidizer.gasTank.getGas().write(new NBTTagCompound())); } } @@ -1164,7 +1164,52 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer if(infuser.centerTank.getGas() != null) { - itemStack.stackTagCompound.setTag("leftTank", infuser.centerTank.getGas().write(new NBTTagCompound())); + itemStack.stackTagCompound.setTag("centerTank", infuser.centerTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalDissolutionChamber) + { + TileEntityChemicalDissolutionChamber chamber = (TileEntityChemicalDissolutionChamber)tileEntity; + + if(chamber.injectTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("injectTank", chamber.injectTank.getGas().write(new NBTTagCompound())); + } + + if(chamber.outputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputTank", chamber.outputTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalWasher) + { + TileEntityChemicalWasher washer = (TileEntityChemicalWasher)tileEntity; + + if(washer.fluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("fluidTank", washer.fluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(washer.inputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputTank", washer.inputTank.getGas().write(new NBTTagCompound())); + } + + if(washer.outputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputTank", washer.outputTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalCrystallizer) + { + TileEntityChemicalCrystallizer crystallizer = (TileEntityChemicalCrystallizer)tileEntity; + + if(crystallizer.inputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputTank", crystallizer.inputTank.getGas().write(new NBTTagCompound())); } } diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index 5dbde0970..868ea986a 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -29,8 +29,11 @@ import mekanism.common.miner.MinerFilter; import mekanism.common.network.PacketElectricChest.ElectricChestMessage; import mekanism.common.network.PacketElectricChest.ElectricChestPacketType; import mekanism.common.tile.TileEntityBasicBlock; +import mekanism.common.tile.TileEntityChemicalCrystallizer; +import mekanism.common.tile.TileEntityChemicalDissolutionChamber; import mekanism.common.tile.TileEntityChemicalInfuser; import mekanism.common.tile.TileEntityChemicalOxidizer; +import mekanism.common.tile.TileEntityChemicalWasher; import mekanism.common.tile.TileEntityDigitalMiner; import mekanism.common.tile.TileEntityElectricBlock; import mekanism.common.tile.TileEntityElectricChest; @@ -381,6 +384,33 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } + if(tileEntity instanceof TileEntityChemicalDissolutionChamber) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalDissolutionChamber)tileEntity).injectTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("injectTank"))); + ((TileEntityChemicalDissolutionChamber)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank"))); + } + } + + if(tileEntity instanceof TileEntityChemicalWasher) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalWasher)tileEntity).fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("fluidTank"))); + ((TileEntityChemicalWasher)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank"))); + ((TileEntityChemicalWasher)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank"))); + } + } + + if(tileEntity instanceof TileEntityChemicalCrystallizer) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalCrystallizer)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank"))); + } + } + if(tileEntity instanceof TileEntityElectrolyticSeparator) { if(stack.stackTagCompound != null) From 94c3a6aa607c674b8cd6ed836f2d79f2f661b261 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 26 Jul 2014 18:16:00 -0400 Subject: [PATCH 5/6] Started work on a new system of managing sustained data --- .../java/mekanism/common/ISustainedData.java | 10 +++ .../mekanism/common/block/BlockMachine.java | 74 +------------------ .../common/item/ItemBlockMachine.java | 72 ++---------------- .../common/tile/TileEntityDigitalMiner.java | 65 +++++++++++++++- .../tile/TileEntityLogisticalSorter.java | 56 +++++++++++++- .../tile/TileEntityRotaryCondensentrator.java | 31 ++++---- 6 files changed, 155 insertions(+), 153 deletions(-) create mode 100644 src/main/java/mekanism/common/ISustainedData.java diff --git a/src/main/java/mekanism/common/ISustainedData.java b/src/main/java/mekanism/common/ISustainedData.java new file mode 100644 index 000000000..732735865 --- /dev/null +++ b/src/main/java/mekanism/common/ISustainedData.java @@ -0,0 +1,10 @@ +package mekanism.common; + +import net.minecraft.item.ItemStack; + +public interface ISustainedData +{ + public void writeSustainedData(ItemStack itemStack); + + public void readSustainedData(ItemStack itemStack); +} diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 6a4519704..d4fe9c324 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -14,12 +14,12 @@ import mekanism.common.IFactory.RecipeType; import mekanism.common.IInvConfiguration; import mekanism.common.IRedstoneControl; import mekanism.common.ISpecialBounds; +import mekanism.common.ISustainedData; import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedTank; import mekanism.common.IUpgradeManagement; import mekanism.common.ItemAttacher; import mekanism.common.Mekanism; -import mekanism.common.miner.MinerFilter; import mekanism.common.network.PacketElectricChest.ElectricChestMessage; import mekanism.common.network.PacketElectricChest.ElectricChestPacketType; import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage; @@ -1023,66 +1023,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer itemStack.stackTagCompound.setByte("config"+i, config.getConfiguration()[i]); } } - - if(tileEntity instanceof TileEntityDigitalMiner) + + if(tileEntity instanceof ISustainedData) { - TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity; - - itemStack.stackTagCompound.setBoolean("hasMinerConfig", true); - - itemStack.stackTagCompound.setInteger("radius", miner.radius); - itemStack.stackTagCompound.setInteger("minY", miner.minY); - itemStack.stackTagCompound.setInteger("maxY", miner.maxY); - itemStack.stackTagCompound.setBoolean("doEject", miner.doEject); - itemStack.stackTagCompound.setBoolean("doPull", miner.doPull); - itemStack.stackTagCompound.setBoolean("silkTouch", miner.silkTouch); - itemStack.stackTagCompound.setBoolean("inverse", miner.inverse); - - if(miner.replaceStack != null) - { - itemStack.stackTagCompound.setTag("replaceStack", miner.replaceStack.writeToNBT(new NBTTagCompound())); - } - - NBTTagList filterTags = new NBTTagList(); - - for(MinerFilter filter : miner.filters) - { - filterTags.appendTag(filter.write(new NBTTagCompound())); - } - - if(filterTags.tagCount() != 0) - { - itemStack.stackTagCompound.setTag("filters", filterTags); - } - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; - - itemStack.stackTagCompound.setBoolean("hasSorterConfig", true); - - if(sorter.color != null) - { - itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(sorter.color)); - } - - itemStack.stackTagCompound.setBoolean("autoEject", sorter.autoEject); - itemStack.stackTagCompound.setBoolean("roundRobin", sorter.roundRobin); - - NBTTagList filterTags = new NBTTagList(); - - for(TransporterFilter filter : sorter.filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } - - if(filterTags.tagCount() != 0) - { - itemStack.stackTagCompound.setTag("filters", filterTags); - } + ((ISustainedData)tileEntity).writeSustainedData(itemStack); } if(tileEntity instanceof IRedstoneControl) @@ -1128,16 +1072,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack); } - if(tileEntity instanceof TileEntityRotaryCondensentrator) - { - TileEntityRotaryCondensentrator condensentrator = (TileEntityRotaryCondensentrator)tileEntity; - - if(condensentrator.gasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("gasStack", condensentrator.gasTank.getGas().write(new NBTTagCompound())); - } - } - if(tileEntity instanceof TileEntityChemicalOxidizer) { TileEntityChemicalOxidizer oxidizer = (TileEntityChemicalOxidizer)tileEntity; diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index 868ea986a..565562b9b 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -18,6 +18,7 @@ import mekanism.common.IFactory; import mekanism.common.IInvConfiguration; import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl.RedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedTank; import mekanism.common.IUpgradeManagement; @@ -25,7 +26,6 @@ import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.integration.IC2ItemManager; import mekanism.common.inventory.InventoryElectricChest; -import mekanism.common.miner.MinerFilter; import mekanism.common.network.PacketElectricChest.ElectricChestMessage; import mekanism.common.network.PacketElectricChest.ElectricChestPacketType; import mekanism.common.tile.TileEntityBasicBlock; @@ -34,7 +34,6 @@ import mekanism.common.tile.TileEntityChemicalDissolutionChamber; import mekanism.common.tile.TileEntityChemicalInfuser; import mekanism.common.tile.TileEntityChemicalOxidizer; import mekanism.common.tile.TileEntityChemicalWasher; -import mekanism.common.tile.TileEntityDigitalMiner; import mekanism.common.tile.TileEntityElectricBlock; import mekanism.common.tile.TileEntityElectricChest; import mekanism.common.tile.TileEntityElectrolyticSeparator; @@ -270,61 +269,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } } - - if(tileEntity instanceof TileEntityDigitalMiner) + + if(tileEntity instanceof ISustainedData) { - TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity; - - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasMinerConfig")) + if(stack.stackTagCompound != null) { - miner.radius = stack.stackTagCompound.getInteger("radius"); - miner.minY = stack.stackTagCompound.getInteger("minY"); - miner.maxY = stack.stackTagCompound.getInteger("maxY"); - miner.doEject = stack.stackTagCompound.getBoolean("doEject"); - miner.doPull = stack.stackTagCompound.getBoolean("doPull"); - miner.silkTouch = stack.stackTagCompound.getBoolean("silkTouch"); - miner.inverse = stack.stackTagCompound.getBoolean("inverse"); - - if(stack.stackTagCompound.hasKey("replaceStack")) - { - miner.replaceStack = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("replaceStack")); - } - - if(stack.stackTagCompound.hasKey("filters")) - { - NBTTagList tagList = stack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - miner.filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; - - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSorterConfig")) - { - if(stack.stackTagCompound.hasKey("color")) - { - sorter.color = TransporterUtils.colors.get(stack.stackTagCompound.getInteger("color")); - } - - sorter.autoEject = stack.stackTagCompound.getBoolean("autoEject"); - sorter.roundRobin = stack.stackTagCompound.getBoolean("roundRobin"); - - if(stack.stackTagCompound.hasKey("filters")) - { - NBTTagList tagList = stack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - sorter.filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } + ((ISustainedData)tileEntity).readSustainedData(stack); } } @@ -357,15 +307,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec ((TileEntityElectricChest)tileEntity).password = getPassword(stack); } - if(tileEntity instanceof TileEntityRotaryCondensentrator) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("gasStack")) - { - GasStack gasStack = GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasStack")); - ((TileEntityRotaryCondensentrator)tileEntity).gasTank.setGas(gasStack); - } - } - if(tileEntity instanceof TileEntityChemicalOxidizer) { if(stack.stackTagCompound != null) @@ -878,8 +819,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec MachineType type = MachineType.get((ItemStack)data[0]); - return type == MachineType.ELECTRIC_PUMP || type == MachineType.ROTARY_CONDENSENTRATOR - || type == MachineType.PORTABLE_TANK || type == MachineType.FLUIDIC_PLENISHER; + return type == MachineType.ELECTRIC_PUMP || type == MachineType.PORTABLE_TANK || type == MachineType.FLUIDIC_PLENISHER; } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index f2fb6c3ab..205f4a3eb 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -15,6 +15,7 @@ import mekanism.common.IActiveState; import mekanism.common.IAdvancedBoundingBlock; import mekanism.common.ILogisticalTransporter; import mekanism.common.IRedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.IUpgradeTile; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; @@ -37,7 +38,6 @@ import mekanism.common.util.TransporterUtils; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -56,7 +56,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IPeripheral, IUpgradeTile, IRedstoneControl, IActiveState, IAdvancedBoundingBlock +public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IPeripheral, IUpgradeTile, IRedstoneControl, IActiveState, ISustainedData, IAdvancedBoundingBlock { public static int[] EJECT_INV; @@ -1369,4 +1369,65 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { return "tooltip.filterCard.digitalMiner"; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + itemStack.stackTagCompound.setBoolean("hasMinerConfig", true); + + itemStack.stackTagCompound.setInteger("radius", radius); + itemStack.stackTagCompound.setInteger("minY", minY); + itemStack.stackTagCompound.setInteger("maxY", maxY); + itemStack.stackTagCompound.setBoolean("doEject", doEject); + itemStack.stackTagCompound.setBoolean("doPull", doPull); + itemStack.stackTagCompound.setBoolean("silkTouch", silkTouch); + itemStack.stackTagCompound.setBoolean("inverse", inverse); + + if(replaceStack != null) + { + itemStack.stackTagCompound.setTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound())); + } + + NBTTagList filterTags = new NBTTagList(); + + for(MinerFilter filter : filters) + { + filterTags.appendTag(filter.write(new NBTTagCompound())); + } + + if(filterTags.tagCount() != 0) + { + itemStack.stackTagCompound.setTag("filters", filterTags); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + if(itemStack.stackTagCompound.hasKey("hasMinerConfig")) + { + radius = itemStack.stackTagCompound.getInteger("radius"); + minY = itemStack.stackTagCompound.getInteger("minY"); + maxY = itemStack.stackTagCompound.getInteger("maxY"); + doEject = itemStack.stackTagCompound.getBoolean("doEject"); + doPull = itemStack.stackTagCompound.getBoolean("doPull"); + silkTouch = itemStack.stackTagCompound.getBoolean("silkTouch"); + inverse = itemStack.stackTagCompound.getBoolean("inverse"); + + if(itemStack.stackTagCompound.hasKey("replaceStack")) + { + replaceStack = ItemStack.loadItemStackFromNBT(itemStack.stackTagCompound.getCompoundTag("replaceStack")); + } + + if(itemStack.stackTagCompound.hasKey("filters")) + { + NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); + + for(int i = 0; i < tagList.tagCount(); i++) + { + filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); + } + } + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index ff4cf5b26..36353828d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -12,6 +12,7 @@ import mekanism.common.HashList; import mekanism.common.IActiveState; import mekanism.common.ILogisticalTransporter; import mekanism.common.IRedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -33,7 +34,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState, IFilterAccess +public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState, IFilterAccess, ISustainedData { public HashList filters = new HashList(); @@ -620,4 +621,57 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen { return "tooltip.filterCard.logisticalSorter"; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + itemStack.stackTagCompound.setBoolean("hasSorterConfig", true); + + if(color != null) + { + itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(color)); + } + + itemStack.stackTagCompound.setBoolean("autoEject", autoEject); + itemStack.stackTagCompound.setBoolean("roundRobin", roundRobin); + + NBTTagList filterTags = new NBTTagList(); + + for(TransporterFilter filter : filters) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } + + if(filterTags.tagCount() != 0) + { + itemStack.stackTagCompound.setTag("filters", filterTags); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + if(itemStack.stackTagCompound.hasKey("hasSorterConfig")) + { + if(itemStack.stackTagCompound.hasKey("color")) + { + color = TransporterUtils.colors.get(itemStack.stackTagCompound.getInteger("color")); + } + + autoEject = itemStack.stackTagCompound.getBoolean("autoEject"); + roundRobin = itemStack.stackTagCompound.getBoolean("roundRobin"); + + if(itemStack.stackTagCompound.hasKey("filters")) + { + NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); + + for(int i = 0; i < tagList.tagCount(); i++) + { + filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); + } + } + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java index 4d70b8990..2449b4036 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -14,7 +14,7 @@ import mekanism.api.gas.IGasHandler; import mekanism.api.gas.ITubeConnection; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; -import mekanism.common.ISustainedTank; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -36,7 +36,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedTank, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl +public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedData, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl { public GasTank gasTank = new GasTank(MAX_FLUID); @@ -501,23 +501,26 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { return mode == 0 && side == MekanismUtils.getLeft(facing) ? gasTank.canReceive(type) : false; } - + @Override - public void setFluidStack(FluidStack fluidStack, Object... data) + public void writeSustainedData(ItemStack itemStack) { - fluidTank.setFluid(fluidStack); + if(fluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(gasTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("gasTank", gasTank.getGas().write(new NBTTagCompound())); + } } - + @Override - public FluidStack getFluidStack(Object... data) + public void readSustainedData(ItemStack itemStack) { - return fluidTank.getFluid(); - } - - @Override - public boolean hasTank(Object... data) - { - return true; + fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank"))); + gasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank"))); } @Override From ab34edc46aec8e01c17d5633d4ee474e845685ed Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 26 Jul 2014 18:44:24 -0400 Subject: [PATCH 6/6] Finished off new system of sustained data --- .../mekanism/common/block/BlockMachine.java | 115 ------------------ .../common/item/ItemBlockMachine.java | 65 ---------- .../tile/TileEntityChemicalCrystallizer.java | 18 ++- .../TileEntityChemicalDissolutionChamber.java | 24 +++- .../tile/TileEntityChemicalInfuser.java | 30 ++++- .../tile/TileEntityChemicalOxidizer.java | 18 ++- .../common/tile/TileEntityChemicalWasher.java | 30 ++++- .../tile/TileEntityElectrolyticSeparator.java | 33 +++-- .../mekanism/common/tile/TileEntityPRC.java | 30 ++++- 9 files changed, 165 insertions(+), 198 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index d4fe9c324..8cac64014 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1072,121 +1072,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack); } - if(tileEntity instanceof TileEntityChemicalOxidizer) - { - TileEntityChemicalOxidizer oxidizer = (TileEntityChemicalOxidizer)tileEntity; - - if(oxidizer.gasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("gasTank", oxidizer.gasTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityChemicalInfuser) - { - TileEntityChemicalInfuser infuser = (TileEntityChemicalInfuser)tileEntity; - - if(infuser.leftTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("leftTank", infuser.leftTank.getGas().write(new NBTTagCompound())); - } - - if(infuser.rightTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("rightTank", infuser.rightTank.getGas().write(new NBTTagCompound())); - } - - if(infuser.centerTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("centerTank", infuser.centerTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityChemicalDissolutionChamber) - { - TileEntityChemicalDissolutionChamber chamber = (TileEntityChemicalDissolutionChamber)tileEntity; - - if(chamber.injectTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("injectTank", chamber.injectTank.getGas().write(new NBTTagCompound())); - } - - if(chamber.outputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("outputTank", chamber.outputTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityChemicalWasher) - { - TileEntityChemicalWasher washer = (TileEntityChemicalWasher)tileEntity; - - if(washer.fluidTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("fluidTank", washer.fluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } - - if(washer.inputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("inputTank", washer.inputTank.getGas().write(new NBTTagCompound())); - } - - if(washer.outputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("outputTank", washer.outputTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityChemicalCrystallizer) - { - TileEntityChemicalCrystallizer crystallizer = (TileEntityChemicalCrystallizer)tileEntity; - - if(crystallizer.inputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("inputTank", crystallizer.inputTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityElectrolyticSeparator) - { - TileEntityElectrolyticSeparator separator = (TileEntityElectrolyticSeparator)tileEntity; - - if(separator.fluidTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("fluidTank", separator.fluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } - - if(separator.leftTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("leftTank", separator.leftTank.getGas().write(new NBTTagCompound())); - } - - if(separator.rightTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("rightTank", separator.rightTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityPRC) - { - TileEntityPRC prc = (TileEntityPRC)tileEntity; - - if(prc.inputFluidTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("inputFluidTank", prc.inputFluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } - - if(prc.inputGasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("inputGasTank", prc.inputGasTank.getGas().write(new NBTTagCompound())); - } - - if(prc.outputGasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("outputGasTank", prc.outputGasTank.getGas().write(new NBTTagCompound())); - } - } - return itemStack; } diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index 565562b9b..3c7e15a30 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -307,71 +307,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec ((TileEntityElectricChest)tileEntity).password = getPassword(stack); } - if(tileEntity instanceof TileEntityChemicalOxidizer) - { - if(stack.stackTagCompound != null) - { - ((TileEntityChemicalOxidizer)tileEntity).gasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasTank"))); - } - } - - if(tileEntity instanceof TileEntityChemicalInfuser) - { - if(stack.stackTagCompound != null) - { - ((TileEntityChemicalInfuser)tileEntity).leftTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("leftTank"))); - ((TileEntityChemicalInfuser)tileEntity).rightTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("rightTank"))); - ((TileEntityChemicalInfuser)tileEntity).centerTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("centerTank"))); - } - } - - if(tileEntity instanceof TileEntityChemicalDissolutionChamber) - { - if(stack.stackTagCompound != null) - { - ((TileEntityChemicalDissolutionChamber)tileEntity).injectTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("injectTank"))); - ((TileEntityChemicalDissolutionChamber)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank"))); - } - } - - if(tileEntity instanceof TileEntityChemicalWasher) - { - if(stack.stackTagCompound != null) - { - ((TileEntityChemicalWasher)tileEntity).fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("fluidTank"))); - ((TileEntityChemicalWasher)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank"))); - ((TileEntityChemicalWasher)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank"))); - } - } - - if(tileEntity instanceof TileEntityChemicalCrystallizer) - { - if(stack.stackTagCompound != null) - { - ((TileEntityChemicalCrystallizer)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank"))); - } - } - - if(tileEntity instanceof TileEntityElectrolyticSeparator) - { - if(stack.stackTagCompound != null) - { - ((TileEntityElectrolyticSeparator)tileEntity).fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("fluidTank"))); - ((TileEntityElectrolyticSeparator)tileEntity).leftTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("leftTank"))); - ((TileEntityElectrolyticSeparator)tileEntity).rightTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("rightTank"))); - } - } - - if(tileEntity instanceof TileEntityPRC) - { - if(stack.stackTagCompound != null) - { - ((TileEntityPRC)tileEntity).inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("inputFluidTank"))); - ((TileEntityPRC)tileEntity).inputGasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputGasTank"))); - ((TileEntityPRC)tileEntity).outputGasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputGasTank"))); - } - } - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); if(tileEntity instanceof TileEntityElectricBlock) diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index 505b41bdf..2b519c891 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -19,6 +19,7 @@ import mekanism.common.IActiveState; import mekanism.common.IEjector; import mekanism.common.IInvConfiguration; import mekanism.common.IRedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.IUpgradeTile; import mekanism.common.Mekanism; import mekanism.common.SideData; @@ -38,7 +39,7 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; -public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IInvConfiguration, IUpgradeTile +public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IInvConfiguration, IUpgradeTile, ISustainedData { public static final int MAX_GAS = 10000; public static final int MAX_FLUID = 10000; @@ -539,4 +540,19 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl { return upgradeComponent; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(inputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank"))); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index f30ac6670..05cb253b2 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -16,6 +16,7 @@ import mekanism.api.gas.ITubeConnection; import mekanism.client.sound.IHasSound; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.IUpgradeTile; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; @@ -31,7 +32,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IGasHandler, IUpgradeTile +public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IGasHandler, IUpgradeTile, ISustainedData { public GasTank injectTank = new GasTank(MAX_GAS); public GasTank outputTank = new GasTank(MAX_GAS); @@ -471,4 +472,25 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc { return upgradeComponent; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(injectTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("injectTank", injectTank.getGas().write(new NBTTagCompound())); + } + + if(outputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + injectTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("injectTank"))); + outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank"))); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index 3afa34029..c28dc2d8d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -16,6 +16,7 @@ import mekanism.api.gas.ITubeConnection; import mekanism.client.sound.IHasSound; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -30,7 +31,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalInfuser extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound +public class TileEntityChemicalInfuser extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, ISustainedData { public GasTank leftTank = new GasTank(MAX_GAS); public GasTank rightTank = new GasTank(MAX_GAS); @@ -476,4 +477,31 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return 1; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(leftTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("leftTank", leftTank.getGas().write(new NBTTagCompound())); + } + + if(rightTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("rightTank", rightTank.getGas().write(new NBTTagCompound())); + } + + if(centerTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("centerTank", centerTank.getGas().write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + leftTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank"))); + rightTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank"))); + centerTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("centerTank"))); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index 1525c86b9..720de13bf 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -15,6 +15,7 @@ import mekanism.api.gas.ITubeConnection; import mekanism.client.sound.IHasSound; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.IUpgradeTile; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; @@ -30,7 +31,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IUpgradeTile +public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IUpgradeTile, ISustainedData { public GasTank gasTank = new GasTank(MAX_GAS); @@ -397,4 +398,19 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen { return upgradeComponent; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(gasTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("gasTank", gasTank.getGas().write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + gasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank"))); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index 0fb6759eb..10dae7238 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -16,6 +16,7 @@ import mekanism.api.gas.ITubeConnection; import mekanism.client.sound.IHasSound; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -40,7 +41,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityChemicalWasher extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IFluidHandler +public class TileEntityChemicalWasher extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IFluidHandler, ISustainedData { public FluidTank fluidTank = new FluidTank(MAX_FLUID); public GasTank inputTank = new GasTank(MAX_GAS); @@ -587,4 +588,31 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements return PipeUtils.EMPTY; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(fluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(inputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound())); + } + + if(outputTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank"))); + inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank"))); + outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank"))); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index db661dfba..fac5b03e2 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -14,7 +14,7 @@ import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; -import mekanism.common.ISustainedTank; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity.TileEntityMessage; @@ -43,7 +43,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedTank, IGasHandler +public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedData, IGasHandler { /** This separator's water slot. */ public FluidTank fluidTank = new FluidTank(24000); @@ -575,21 +575,30 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public void setFluidStack(FluidStack fluidStack, Object... data) + public void writeSustainedData(ItemStack itemStack) { - fluidTank.setFluid(fluidStack); + if(fluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(leftTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("leftTank", leftTank.getGas().write(new NBTTagCompound())); + } + + if(rightTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("rightTank", rightTank.getGas().write(new NBTTagCompound())); + } } @Override - public FluidStack getFluidStack(Object... data) + public void readSustainedData(ItemStack itemStack) { - return fluidTank.getFluid(); - } - - @Override - public boolean hasTank(Object... data) - { - return true; + fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank"))); + leftTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank"))); + rightTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank"))); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityPRC.java b/src/main/java/mekanism/common/tile/TileEntityPRC.java index 5f2c5db08..39d72ce41 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPRC.java +++ b/src/main/java/mekanism/common/tile/TileEntityPRC.java @@ -15,6 +15,7 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.ITubeConnection; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.SideData; import mekanism.common.block.BlockMachine.MachineType; @@ -41,7 +42,7 @@ import cpw.mods.fml.common.Optional.Method; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandler, IGasHandler, ITubeConnection +public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandler, IGasHandler, ITubeConnection, ISustainedData { public FluidTank inputFluidTank = new FluidTank(10000); public GasTank inputGasTank = new GasTank(10000); @@ -438,4 +439,31 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl { return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing); } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(inputFluidTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("inputFluidTank", inputFluidTank.getFluid().writeToNBT(new NBTTagCompound())); + } + + if(inputGasTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("inputGasTank", inputGasTank.getGas().write(new NBTTagCompound())); + } + + if(outputGasTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("outputGasTank", outputGasTank.getGas().write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("inputFluidTank"))); + inputGasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputGasTank"))); + outputGasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputGasTank"))); + } }