Started on new fluid network interfaces
This commit is contained in:
parent
c192cfdf54
commit
2945a120ef
10 changed files with 97 additions and 172 deletions
|
@ -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<String, Float> moltenFluids = new HashMap();
|
||||
/**
|
||||
* Map containing items to FluidStack for melting down. Anything not in the list will be turned
|
||||
* into slag.
|
||||
*/
|
||||
public static HashMap<Pair<Integer, Integer>, 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<Integer, Integer>(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());
|
||||
}
|
||||
}
|
42
src/main/java/resonantinduction/api/fluid/IFluidNetwork.java
Normal file
42
src/main/java/resonantinduction/api/fluid/IFluidNetwork.java
Normal file
|
@ -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<IFluidNetwork, IFluidPart, IFluidHandler>
|
||||
{
|
||||
/** 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();
|
||||
|
||||
}
|
15
src/main/java/resonantinduction/api/fluid/IFluidPart.java
Normal file
15
src/main/java/resonantinduction/api/fluid/IFluidPart.java
Normal file
|
@ -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<IFluidNetwork>, IFluidHandler
|
||||
{
|
||||
/** FluidTank that the network will have access to fill or drain */
|
||||
public FluidTank getInternalTank();
|
||||
}
|
13
src/main/java/resonantinduction/api/fluid/IFluidPipe.java
Normal file
13
src/main/java/resonantinduction/api/fluid/IFluidPipe.java
Normal file
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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<C, I> extends NetworkTileEntities
|
||||
{
|
||||
protected C storage;
|
||||
protected HashMap<I, List<ForgeDirection>> acceptors = new HashMap();
|
||||
|
||||
public NetworkResourceSupply(INetworkPart... parts)
|
||||
{
|
||||
super(parts);
|
||||
}
|
||||
|
||||
public boolean isValidAcceptor(TileEntity entity)
|
||||
{
|
||||
return entity != null && !entity.isInvalid();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
Loading…
Reference in a new issue