From 2945a120efce12cb1aeba52678fefaef979aebb4 Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Mon, 13 Jan 2014 00:19:02 -0500 Subject: [PATCH] Started on new fluid network interfaces --- .../api/fluid/FluidMasterList.java | 71 ------------------- .../api/fluid/IFluidNetwork.java | 42 +++++++++++ .../api/fluid/IFluidPart.java | 15 ++++ .../api/fluid/IFluidPipe.java | 13 ++++ .../api/fluid/INetworkFluidPart.java | 32 --------- .../api/fluid/INetworkPipe.java | 37 ---------- .../api/fluid/IPressureInput.java | 13 ++++ .../api/fluid/IPressureOutput.java | 11 +++ .../prefab/NetworkResourceSupply.java | 31 -------- .../fluid/{pipe => prefab}/EnumTankTypes.java | 4 +- 10 files changed, 97 insertions(+), 172 deletions(-) delete mode 100644 src/main/java/resonantinduction/api/fluid/FluidMasterList.java create mode 100644 src/main/java/resonantinduction/api/fluid/IFluidNetwork.java create mode 100644 src/main/java/resonantinduction/api/fluid/IFluidPart.java create mode 100644 src/main/java/resonantinduction/api/fluid/IFluidPipe.java delete mode 100644 src/main/java/resonantinduction/api/fluid/INetworkFluidPart.java delete mode 100644 src/main/java/resonantinduction/api/fluid/INetworkPipe.java create mode 100644 src/main/java/resonantinduction/api/fluid/IPressureInput.java create mode 100644 src/main/java/resonantinduction/api/fluid/IPressureOutput.java delete mode 100644 src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkResourceSupply.java rename src/main/java/resonantinduction/mechanical/fluid/{pipe => prefab}/EnumTankTypes.java (91%) diff --git a/src/main/java/resonantinduction/api/fluid/FluidMasterList.java b/src/main/java/resonantinduction/api/fluid/FluidMasterList.java deleted file mode 100644 index 25423ed54..000000000 --- a/src/main/java/resonantinduction/api/fluid/FluidMasterList.java +++ /dev/null @@ -1,71 +0,0 @@ -package resonantinduction.api.fluid; - -import java.util.HashMap; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import com.builtbroken.common.Pair; - -public class FluidMasterList -{ - public static HashMap moltenFluids = new HashMap(); - /** - * Map containing items to FluidStack for melting down. Anything not in the list will be turned - * into slag. - */ - public static HashMap, FluidStack> meltDownMap = new HashMap(); - - public static final Fluid WATER = FluidRegistry.WATER; - public static final Fluid LAVA = FluidRegistry.LAVA; - - static - { - // http://www.engineeringtoolbox.com/melting-temperature-metals-d_860.html - moltenFluids.put("lava", 1200f); - moltenFluids.put("molten-iron", 1200f); - moltenFluids.put("molten-gold", 1063f); - moltenFluids.put("molten-silver", 1000f); - } - - /** - * Registers a fluid, by fluid name, as a molten fluids so pipes will interact with it different - * - * @param name - fluid name - * @param heatValue - temperature of the fluid - */ - public static void registerMoltenFluid(String name, float heatValue) - { - if (name != null && heatValue > 0) - { - moltenFluids.put(name, heatValue); - } - } - - /** - * Try to only register very simple items as a reverse recipe system will be used to get to the - * items used to craft the object - * - * @param id - item id - * @param meta - item meta - * @param stack - fluid stack to return - */ - public static void registerMeltDown(int id, int meta, FluidStack stack) - { - if (id > 0 && stack != null) - { - meltDownMap.put(new Pair(id, meta), stack); - } - } - - public static boolean isMolten(Fluid fluid) - { - return fluid != null && moltenFluids.containsKey(fluid.getName()); - } - - public static float getHeatPerPass(Fluid fluid) - { - return moltenFluids.get(fluid.getName()); - } -} diff --git a/src/main/java/resonantinduction/api/fluid/IFluidNetwork.java b/src/main/java/resonantinduction/api/fluid/IFluidNetwork.java new file mode 100644 index 000000000..a70baa78e --- /dev/null +++ b/src/main/java/resonantinduction/api/fluid/IFluidNetwork.java @@ -0,0 +1,42 @@ +package resonantinduction.api.fluid; + +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import universalelectricity.api.net.INetwork; + +/** Interface version of the fluid network. + * + * @author DarkGuardsman */ +public interface IFluidNetwork extends INetwork +{ + /** Called to build the network when something changes such as addition of a pipe */ + void reconstruct(); + + /** Called to add fluid into the network + * + * @param source - part that is receiving the fluid for the network + * @param from - direction of this connection + * @param resource - fluid stack that is being filled into the network + * @param doFill - true causes the action to be taken, false simulates the action + * @return amount of fluid filled into the network */ + int fill(IFluidPart source, ForgeDirection from, FluidStack resource, boolean doFill); + + /** Called to remove fluid from a network, not supported by all networks + * + * @param source - part that is receiving the fluid for the network + * @param from - direction of this connection + * @param resource - fluid stack that is being filled into the network + * @param doDrain - true causes the action to be taken, false simulates the action + * @return FluidStack that contains the fluid drained from the network */ + FluidStack drain(IFluidPart source, ForgeDirection from, FluidStack resource, boolean doDrain); + + /** Fluid tank that represents the entire network */ + FluidTank getTank(); + + /** Information about the network's tank */ + FluidTankInfo[] getTankInfo(); + +} diff --git a/src/main/java/resonantinduction/api/fluid/IFluidPart.java b/src/main/java/resonantinduction/api/fluid/IFluidPart.java new file mode 100644 index 000000000..b8c20affd --- /dev/null +++ b/src/main/java/resonantinduction/api/fluid/IFluidPart.java @@ -0,0 +1,15 @@ +package resonantinduction.api.fluid; + +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.IFluidHandler; +import universalelectricity.api.net.IConnector; + +/** Generic interface for any tile that acts as part of a fluid network. Generally network assume + * that each part can only support one fluid tank internally + * + * @author DarkGuardsman */ +public interface IFluidPart extends IConnector, IFluidHandler +{ + /** FluidTank that the network will have access to fill or drain */ + public FluidTank getInternalTank(); +} diff --git a/src/main/java/resonantinduction/api/fluid/IFluidPipe.java b/src/main/java/resonantinduction/api/fluid/IFluidPipe.java new file mode 100644 index 000000000..f200f4a55 --- /dev/null +++ b/src/main/java/resonantinduction/api/fluid/IFluidPipe.java @@ -0,0 +1,13 @@ +package resonantinduction.api.fluid; + +/** Applied to tiles that are pipes and support pressure + * + * @author DarkGuardsman */ +public interface IFluidPipe extends IFluidPart, IPressureInput +{ + /** Max pressure this pipe can support */ + int getMaxPressure(); + + /** Max flow rate of fluid this pipe can support */ + int getMaxFlowRate(); +} diff --git a/src/main/java/resonantinduction/api/fluid/INetworkFluidPart.java b/src/main/java/resonantinduction/api/fluid/INetworkFluidPart.java deleted file mode 100644 index bcf0ef6b0..000000000 --- a/src/main/java/resonantinduction/api/fluid/INetworkFluidPart.java +++ /dev/null @@ -1,32 +0,0 @@ -package resonantinduction.api.fluid; - -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; -import resonantinduction.core.tilenetwork.INetworkPart; - -/** - * Interface used by part that are members of a fluid tile network. Parts in the network will act as - * one entity and will be controlled by the network. This means the network need the part to access - * the parts in a set way to function correctly - * - * @author DarkGuardsman - */ -public interface INetworkFluidPart extends IFluidHandler, INetworkPart -{ - - /** Gets information about the tanks internal storage that the network has access to. */ - public FluidTankInfo[] getTankInfo(); - - /** - * Fills the pipe in the same way that fill method is called in IFluidHandler. This is used so - * the network has a direct method to access the pipes internal fluid storage - */ - public int fillTankContent(int index, FluidStack stack, boolean doFill); - - /** - * Removes from from the pipe in the same way that drain method is called in IFluidHandler. This - * is used so the network has a direct method to access the pipes internal fluid storage - */ - public FluidStack drainTankContent(int index, int volume, boolean doDrain); -} diff --git a/src/main/java/resonantinduction/api/fluid/INetworkPipe.java b/src/main/java/resonantinduction/api/fluid/INetworkPipe.java deleted file mode 100644 index 991d52f1c..000000000 --- a/src/main/java/resonantinduction/api/fluid/INetworkPipe.java +++ /dev/null @@ -1,37 +0,0 @@ -package resonantinduction.api.fluid; - -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -/** - * A machine that acts as one with the liquid network using the networks pressure for some function - * that doesn't change the over all network pressure. So pipes, gauges, tubes, buffers, decor - * blocks. - */ -public interface INetworkPipe extends INetworkFluidPart -{ - /** - * Gets the parts max pressure limit it can handle - * - * Note this is not recommended max limit by rather actual breaking point of the part - */ - public double getMaxPressure(ForgeDirection side); - - /** - * Max flow rate of liquid flow this part from the side for the liquid type that his part will - * allow - * - * @return limit in bucket parts(1/1000 of a bucket) - */ - public int getMaxFlowRate(FluidStack stack, ForgeDirection side); - - /** - * Called when the pressure on the machine goes beyond max limits. Suggest doing random chance - * of damage or break too simulate real chances of pipe going beyond designed limits - * - * @param damageAllowed - can this tileEntity cause grief damage - * @return true if the device over pressured and destroyed itself - */ - public boolean onOverPressure(Boolean damageAllowed); - -} diff --git a/src/main/java/resonantinduction/api/fluid/IPressureInput.java b/src/main/java/resonantinduction/api/fluid/IPressureInput.java new file mode 100644 index 000000000..5700661cd --- /dev/null +++ b/src/main/java/resonantinduction/api/fluid/IPressureInput.java @@ -0,0 +1,13 @@ +package resonantinduction.api.fluid; + +import net.minecraftforge.common.ForgeDirection; + +/** Applied to tiles that work with pressure for there inputs + * + * @author DarkGaurdsman */ +public interface IPressureInput +{ + public int getPressureIn(ForgeDirection side); + + public void onWrongPressure(ForgeDirection side, int pressure); +} diff --git a/src/main/java/resonantinduction/api/fluid/IPressureOutput.java b/src/main/java/resonantinduction/api/fluid/IPressureOutput.java new file mode 100644 index 000000000..b7be91756 --- /dev/null +++ b/src/main/java/resonantinduction/api/fluid/IPressureOutput.java @@ -0,0 +1,11 @@ +package resonantinduction.api.fluid; + +import net.minecraftforge.common.ForgeDirection; + +/** Applied to tiles that are a source of pressure in a fluid network + * + * @author Darkguardsman */ +public interface IPressureOutput +{ + public int getPressureOut(ForgeDirection side); +} diff --git a/src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkResourceSupply.java b/src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkResourceSupply.java deleted file mode 100644 index 5ac6a8014..000000000 --- a/src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkResourceSupply.java +++ /dev/null @@ -1,31 +0,0 @@ -package resonantinduction.core.tilenetwork.prefab; - -import java.util.HashMap; -import java.util.List; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import resonantinduction.core.tilenetwork.INetworkPart; - -/** - * Network that supplies resources to tiles that demand a set resource - * - * @param C - Storage class used to handle what the network transports - * @param I - Base acceptor class - * @author DarkGuardsman - */ -public class NetworkResourceSupply extends NetworkTileEntities -{ - protected C storage; - protected HashMap> acceptors = new HashMap(); - - public NetworkResourceSupply(INetworkPart... parts) - { - super(parts); - } - - public boolean isValidAcceptor(TileEntity entity) - { - return entity != null && !entity.isInvalid(); - } -} diff --git a/src/main/java/resonantinduction/mechanical/fluid/pipe/EnumTankTypes.java b/src/main/java/resonantinduction/mechanical/fluid/prefab/EnumTankTypes.java similarity index 91% rename from src/main/java/resonantinduction/mechanical/fluid/pipe/EnumTankTypes.java rename to src/main/java/resonantinduction/mechanical/fluid/prefab/EnumTankTypes.java index bad5cb908..e8901b125 100644 --- a/src/main/java/resonantinduction/mechanical/fluid/pipe/EnumTankTypes.java +++ b/src/main/java/resonantinduction/mechanical/fluid/prefab/EnumTankTypes.java @@ -1,5 +1,7 @@ -package resonantinduction.mechanical.fluid.pipe; +package resonantinduction.mechanical.fluid.prefab; +import resonantinduction.mechanical.fluid.pipe.EnumPipeType; +import resonantinduction.mechanical.fluid.pipe.IPipeType; import dark.lib.helpers.ColorCode; import dark.lib.helpers.ColorCode.IColoredId;