diff --git a/common/mekanism/api/gas/GasTransmission.java b/common/mekanism/api/gas/GasTransmission.java index e1d3aefbd..3eb7e5909 100644 --- a/common/mekanism/api/gas/GasTransmission.java +++ b/common/mekanism/api/gas/GasTransmission.java @@ -6,6 +6,7 @@ import java.util.Set; import mekanism.api.transmitters.ITransmitter; import mekanism.api.transmitters.TransmissionType; import mekanism.common.Object3D; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -101,4 +102,31 @@ public final class GasTransmission return 0; } + + public static GasStack removeGas(ItemStack itemStack, Gas type, int amount) + { + if(itemStack != null && itemStack.getItem() instanceof IGasItem) + { + IGasItem item = (IGasItem)itemStack.getItem(); + + if(type != null && item.getGas(itemStack) != null && item.getGas(itemStack).getGas() != type || !item.canProvideGas(itemStack, type)) + { + return null; + } + + return item.removeGas(itemStack, amount); + } + + return null; + } + + public static int addGas(ItemStack itemStack, GasStack stack) + { + if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas())) + { + return ((IGasItem)itemStack.getItem()).addGas(itemStack, stack.copy()); + } + + return 0; + } } diff --git a/common/mekanism/api/gas/GasUtils.java b/common/mekanism/api/gas/GasUtils.java deleted file mode 100644 index cdecd9491..000000000 --- a/common/mekanism/api/gas/GasUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package mekanism.api.gas; - -import net.minecraft.item.ItemStack; - -public final class GasUtils -{ - public static int addGas(ItemStack itemStack, GasStack stack) - { - if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas())) - { - return ((IGasItem)itemStack.getItem()).addGas(itemStack, stack.copy()); - } - - return 0; - } - - public static GasStack removeGas(ItemStack itemStack, Gas type, int amount) - { - if(itemStack != null && itemStack.getItem() instanceof IGasItem) - { - IGasItem item = (IGasItem)itemStack.getItem(); - - if(type != null && item.getGas(itemStack) != null && item.getGas(itemStack).getGas() != type || !item.canProvideGas(itemStack, type)) - { - return null; - } - - return item.removeGas(itemStack, amount); - } - - return null; - } -} diff --git a/common/mekanism/common/tileentity/TileEntityFactory.java b/common/mekanism/common/tileentity/TileEntityFactory.java index 38e9230d9..31dd6511e 100644 --- a/common/mekanism/common/tileentity/TileEntityFactory.java +++ b/common/mekanism/common/tileentity/TileEntityFactory.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasUtils; +import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasAcceptor; import mekanism.api.gas.IGasItem; import mekanism.api.gas.IGasStorage; @@ -260,7 +260,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { if(inventory[4].getItem() instanceof IGasItem) { - GasStack removed = GasUtils.removeGas(inventory[4], GasRegistry.getGas("oxygen"), getMaxSecondaryEnergy()-secondaryEnergyStored); + GasStack removed = GasTransmission.removeGas(inventory[4], GasRegistry.getGas("oxygen"), getMaxSecondaryEnergy()-secondaryEnergyStored); setSecondaryEnergy(secondaryEnergyStored + (removed != null ? removed.amount : 0)); return; diff --git a/common/mekanism/common/tileentity/TileEntityGasTank.java b/common/mekanism/common/tileentity/TileEntityGasTank.java index 748707e00..04949be02 100644 --- a/common/mekanism/common/tileentity/TileEntityGasTank.java +++ b/common/mekanism/common/tileentity/TileEntityGasTank.java @@ -6,7 +6,6 @@ import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTransmission; -import mekanism.api.gas.GasUtils; import mekanism.api.gas.IGasAcceptor; import mekanism.api.gas.IGasItem; import mekanism.api.gas.IGasStorage; @@ -46,17 +45,17 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS { if(inventory[0] != null && getGas() != null) { - setGas(new GasStack(getGas().getGas(), getGas().amount - GasUtils.addGas(inventory[0], getGas()))); + setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.addGas(inventory[0], getGas()))); } if(inventory[1] != null && (getGas() == null || getGas().amount < getMaxGas())) { if(getGas() == null) { - setGas(GasUtils.removeGas(inventory[1], null, getMaxGas())); + setGas(GasTransmission.removeGas(inventory[1], null, getMaxGas())); } else { - GasStack removed = GasUtils.removeGas(inventory[1], getGas().getGas(), getMaxGas()-getGas().amount); + GasStack removed = GasTransmission.removeGas(inventory[1], getGas().getGas(), getMaxGas()-getGas().amount); setGas(new GasStack(getGas().getGas(), getGas().amount + (removed != null ? removed.amount : 0))); } } diff --git a/common/mekanism/common/tileentity/TileEntityPurificationChamber.java b/common/mekanism/common/tileentity/TileEntityPurificationChamber.java index 75c51e90f..5033f1ccb 100644 --- a/common/mekanism/common/tileentity/TileEntityPurificationChamber.java +++ b/common/mekanism/common/tileentity/TileEntityPurificationChamber.java @@ -5,7 +5,7 @@ import java.util.Map; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasUtils; +import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasAcceptor; import mekanism.api.gas.IGasItem; import mekanism.api.gas.IGasStorage; @@ -101,7 +101,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac { if(inventory[1] != null && secondaryEnergyStored < MAX_SECONDARY_ENERGY) { - GasStack removed = GasUtils.removeGas(inventory[1], GasRegistry.getGas("oxygen"), MAX_SECONDARY_ENERGY-secondaryEnergyStored); + GasStack removed = GasTransmission.removeGas(inventory[1], GasRegistry.getGas("oxygen"), MAX_SECONDARY_ENERGY-secondaryEnergyStored); setSecondaryEnergy(secondaryEnergyStored + (removed != null ? removed.amount : 0)); } diff --git a/common/mekanism/common/tileentity/TileEntityRotaryCondensentrator.java b/common/mekanism/common/tileentity/TileEntityRotaryCondensentrator.java index be3cc3521..0008bba62 100644 --- a/common/mekanism/common/tileentity/TileEntityRotaryCondensentrator.java +++ b/common/mekanism/common/tileentity/TileEntityRotaryCondensentrator.java @@ -6,7 +6,6 @@ import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTransmission; -import mekanism.api.gas.GasUtils; import mekanism.api.gas.IGasAcceptor; import mekanism.api.gas.IGasStorage; import mekanism.api.gas.ITubeConnection; @@ -105,10 +104,10 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { if(getGas() == null) { - setGas(GasUtils.removeGas(inventory[1], null, getMaxGas())); + setGas(GasTransmission.removeGas(inventory[1], null, getMaxGas())); } else { - GasStack removed = GasUtils.removeGas(inventory[1], getGas().getGas(), getMaxGas()-getGas().amount); + GasStack removed = GasTransmission.removeGas(inventory[1], getGas().getGas(), getMaxGas()-getGas().amount); setGas(new GasStack(getGas().getGas(), getGas().amount + (removed != null ? removed.amount : 0))); } } @@ -167,7 +166,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { if(inventory[0] != null) { - setGas(new GasStack(getGas().getGas(), getGas().amount - GasUtils.addGas(inventory[0], getGas()))); + setGas(new GasStack(getGas().getGas(), getGas().amount - GasTransmission.addGas(inventory[0], getGas()))); } } diff --git a/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java b/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java index 2f2ca44b3..276d5a5ab 100644 --- a/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java +++ b/common/mekanism/generators/common/tileentity/TileEntityElectrolyticSeparator.java @@ -7,7 +7,6 @@ import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTransmission; -import mekanism.api.gas.GasUtils; import mekanism.api.gas.IGasAcceptor; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; @@ -111,13 +110,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { if(inventory[1] != null && hydrogenStored > 0) { - hydrogenStored -= GasUtils.addGas(inventory[1], new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored)); + hydrogenStored -= GasTransmission.addGas(inventory[1], new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored)); MekanismUtils.saveChunk(this); } if(inventory[2] != null && oxygenStored > 0) { - hydrogenStored -= GasUtils.addGas(inventory[2], new GasStack(GasRegistry.getGas("oxygen"), oxygenStored)); + hydrogenStored -= GasTransmission.addGas(inventory[2], new GasStack(GasRegistry.getGas("oxygen"), oxygenStored)); MekanismUtils.saveChunk(this); } } diff --git a/common/mekanism/generators/common/tileentity/TileEntityHydrogenGenerator.java b/common/mekanism/generators/common/tileentity/TileEntityHydrogenGenerator.java index cc0abb06f..1157bb1f3 100644 --- a/common/mekanism/generators/common/tileentity/TileEntityHydrogenGenerator.java +++ b/common/mekanism/generators/common/tileentity/TileEntityHydrogenGenerator.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasUtils; +import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasAcceptor; import mekanism.api.gas.IGasItem; import mekanism.api.gas.IGasStorage; @@ -47,7 +47,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements if(inventory[0] != null && hydrogenStored < MAX_HYDROGEN) { - GasStack removed = GasUtils.removeGas(inventory[0], GasRegistry.getGas("hydrogen"), getMaxGas()-hydrogenStored); + GasStack removed = GasTransmission.removeGas(inventory[0], GasRegistry.getGas("hydrogen"), getMaxGas()-hydrogenStored); setGas(new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored + (removed != null ? removed.amount : 0))); }