merged IPsiMachine with IFluidPipe
They are now known as ILiquidNetworkPart since any tileEntity can act as a conveyor of liquids in the network as long as they use that interface and its methods right. This allows for pipes, as well as guages, fluid motors, and other things to exist in the network without its spliting or changing the over all network.
This commit is contained in:
parent
8c110124e4
commit
2d41e3031d
6 changed files with 60 additions and 46 deletions
18
resources/mcmod.info
Normal file
18
resources/mcmod.info
Normal file
|
@ -0,0 +1,18 @@
|
|||
[
|
||||
{
|
||||
"modid" : "FluidMechanics",
|
||||
"name" : "Fluid Mechanics",
|
||||
"version" : "0.3.0",
|
||||
"url" : "http://calclavia.com/universalelectricity/?m=18",
|
||||
"credits" : "",
|
||||
"authors": [
|
||||
"Darkguardsman"
|
||||
],
|
||||
"description": "A basic fluid and mechanics support system for other mods to work off of",
|
||||
"logoFile" : "/fm_logo.png",
|
||||
"updateUrl" : "http://universalelectricity.com/?m=fluid_mechanics",
|
||||
"parent" : "",
|
||||
"screenshots": [
|
||||
]
|
||||
}
|
||||
]
|
|
@ -6,18 +6,22 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
/**
|
||||
* Must be applied to all tile entities that are conductors.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
* A machine that acts as one with the liquid network using the networks pressure for some function
|
||||
*/
|
||||
public interface IFluidPipe extends IColorCoded
|
||||
public interface ILiquidNetworkPart
|
||||
{
|
||||
/**
|
||||
* The Fluid network that this pipe is part of
|
||||
* gets the devices pressure from a given side for input
|
||||
*/
|
||||
public double getMaxPressure(ForgeDirection side);
|
||||
|
||||
/**
|
||||
* The Fluid network that this machine is part of
|
||||
*/
|
||||
public HydraulicNetwork getNetwork();
|
||||
|
||||
/**
|
||||
* sets the machines network
|
||||
*/
|
||||
public void setNetwork(HydraulicNetwork network);
|
||||
|
||||
/**
|
||||
|
@ -32,10 +36,6 @@ public interface IFluidPipe extends IColorCoded
|
|||
*/
|
||||
public int getMaxFlowRate(LiquidStack stack);
|
||||
|
||||
/**
|
||||
* gets the pipe's max pressure before bursting
|
||||
*/
|
||||
public double getMaxPressure();
|
||||
|
||||
/**
|
||||
* Called when the pressure on the pipe passes max
|
||||
|
@ -53,7 +53,7 @@ public interface IFluidPipe extends IColorCoded
|
|||
public void refreshConnectedBlocks();
|
||||
|
||||
/**
|
||||
* Adds a connection between this conductor and a UE unit
|
||||
* Adds a connection between this machine and another machine
|
||||
*
|
||||
* @param tileEntity - Must be either a producer, consumer or a conductor
|
||||
* @param side - side in which the connection is coming from
|
||||
|
@ -61,4 +61,5 @@ public interface IFluidPipe extends IColorCoded
|
|||
public void updateConnection(TileEntity tileEntity, ForgeDirection side);
|
||||
|
||||
public void updateConnectionWithoutSplit(TileEntity connectorFromSide, ForgeDirection orientation);
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package hydraulic.api;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IPsiMachine
|
||||
{
|
||||
/**
|
||||
* gets the devices pressure from a given side
|
||||
*/
|
||||
public double getMaxPressure(ForgeDirection side);
|
||||
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package hydraulic.api;
|
||||
|
||||
public interface IPsiReciever extends IPsiMachine
|
||||
public interface IPsiReciever
|
||||
{
|
||||
/**
|
||||
* Called when this machine receives pressure/Fluid
|
||||
* Too get force take pressure x Surface area of you machine
|
||||
* @param pressure - input pressure. make sure to output a pressure later on, plus remaining liquid
|
||||
* Called when this machine receives pressure/Fluid Too get force take pressure x Surface area
|
||||
* of you machine
|
||||
*
|
||||
* @param pressure - input pressure. make sure to output a pressure later on, plus remaining
|
||||
* liquid
|
||||
*/
|
||||
public void onReceivePressure(double pressure);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package hydraulic.core.liquidNetwork;
|
||||
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.api.IFluidPipe;
|
||||
import hydraulic.api.IPsiCreator;
|
||||
import hydraulic.api.IPsiMachine;
|
||||
import hydraulic.api.ILiquidNetworkPart;
|
||||
import hydraulic.helpers.connectionHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -18,17 +17,17 @@ import net.minecraftforge.liquids.LiquidStack;
|
|||
public class HydraulicNetwork
|
||||
{
|
||||
/* BLOCK THAT ACT AS FLUID CONVEYORS ** */
|
||||
public final List<IFluidPipe> conductors = new ArrayList<IFluidPipe>();
|
||||
public final List<ILiquidNetworkPart> conductors = new ArrayList<ILiquidNetworkPart>();
|
||||
|
||||
/* MACHINES THAT USE THE FORGE LIQUID API TO RECEIVE LIQUID ** */
|
||||
public final List<TileEntity> receivers = new ArrayList<TileEntity>();
|
||||
|
||||
public ColorCode color = ColorCode.NONE;
|
||||
|
||||
public HydraulicNetwork(IFluidPipe conductor)
|
||||
public HydraulicNetwork(ILiquidNetworkPart conductor, ColorCode color)
|
||||
{
|
||||
this.addConductor(conductor);
|
||||
this.color = conductor.getColor();
|
||||
this.addConductor(conductor, color);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +65,7 @@ public class HydraulicNetwork
|
|||
TileEntity[] surroundings = connectionHelper.getSurroundingTileEntities((TileEntity) tank);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (surroundings[i] instanceof IFluidPipe && ((IFluidPipe) surroundings[i]).getNetwork() == this)
|
||||
if (surroundings[i] instanceof ILiquidNetworkPart && ((ILiquidNetworkPart) surroundings[i]).getNetwork() == this)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i).getOpposite();
|
||||
ILiquidTank storage = tank.getTank(dir, stack);
|
||||
|
@ -125,7 +124,7 @@ public class HydraulicNetwork
|
|||
public int getMaxFlow(LiquidStack stack)
|
||||
{
|
||||
int flow = 1000;
|
||||
for (IFluidPipe conductor : this.conductors)
|
||||
for (ILiquidNetworkPart conductor : this.conductors)
|
||||
{
|
||||
int cFlow = conductor.getMaxFlowRate(stack);
|
||||
if (cFlow < flow)
|
||||
|
@ -159,17 +158,17 @@ public class HydraulicNetwork
|
|||
*/
|
||||
public void addEntity(TileEntity ent)
|
||||
{
|
||||
if(!receivers.contains(ent) && (ent instanceof ITankContainer || ent instanceof IPsiMachine || ent instanceof IPsiCreator))
|
||||
if(!receivers.contains(ent) && (ent instanceof ITankContainer || ent instanceof ILiquidNetworkPart || ent instanceof IPsiCreator))
|
||||
{
|
||||
receivers.add(ent);
|
||||
}
|
||||
}
|
||||
|
||||
public void addConductor(IFluidPipe newConductor)
|
||||
public void addConductor(ILiquidNetworkPart newConductor, ColorCode code)
|
||||
{
|
||||
this.cleanConductors();
|
||||
|
||||
if (newConductor.getColor() == this.color && !conductors.contains(newConductor))
|
||||
if (code == this.color && !conductors.contains(newConductor))
|
||||
{
|
||||
conductors.add(newConductor);
|
||||
newConductor.setNetwork(this);
|
||||
|
@ -203,7 +202,7 @@ public class HydraulicNetwork
|
|||
{
|
||||
this.cleanConductors();
|
||||
|
||||
for (IFluidPipe conductor : this.conductors)
|
||||
for (ILiquidNetworkPart conductor : this.conductors)
|
||||
{
|
||||
conductor.setNetwork(this);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package hydraulic.core.liquidNetwork;
|
||||
|
||||
import hydraulic.api.IFluidPipe;
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.api.ILiquidNetworkPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
@ -23,15 +24,20 @@ public class HydraulicNetworkManager
|
|||
private List<HydraulicNetwork> hydraulicNetworks = new ArrayList<HydraulicNetwork>();
|
||||
|
||||
/**
|
||||
* Registers a conductor into the UE electricity net.
|
||||
* Registers a pipe into the network, if not using a specific color give ColorCode.NONE
|
||||
*/
|
||||
public void registerConductor(IFluidPipe newConductor)
|
||||
public void registerConductor(ILiquidNetworkPart newConductor, ColorCode color)
|
||||
{
|
||||
this.cleanUpNetworks();
|
||||
HydraulicNetwork newNetwork = new HydraulicNetwork(newConductor);
|
||||
HydraulicNetwork newNetwork = new HydraulicNetwork(newConductor, color);
|
||||
this.hydraulicNetworks.add(newNetwork);
|
||||
}
|
||||
|
||||
/**
|
||||
* unregisters a tileEntity from the network
|
||||
*
|
||||
* @param tileEntity
|
||||
*/
|
||||
public void unregister(TileEntity tileEntity)
|
||||
{
|
||||
for (HydraulicNetwork network : this.hydraulicNetworks)
|
||||
|
@ -73,7 +79,7 @@ public class HydraulicNetworkManager
|
|||
* @param conductorA - existing conductor
|
||||
* @param conductorB - broken/invalid conductor
|
||||
*/
|
||||
public void splitConnection(IFluidPipe conductorA, IFluidPipe conductorB)
|
||||
public void splitConnection(ILiquidNetworkPart conductorA, ILiquidNetworkPart conductorB)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -88,7 +94,7 @@ public class HydraulicNetworkManager
|
|||
|
||||
while (it.hasNext())
|
||||
{
|
||||
IFluidPipe conductor = (IFluidPipe) it.next();
|
||||
ILiquidNetworkPart conductor = (ILiquidNetworkPart) it.next();
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue