change the tank to better work with the network

The  fluid network use the get tank side method to better find which
tank to fill first. However, i neglected to use this method correctly in
the tank and most likely something else but I'll get to that later.
This commit is contained in:
Rseifert 2013-03-29 16:14:05 -04:00
parent b9c64dff24
commit 6a2a2f8809
2 changed files with 30 additions and 11 deletions

View file

@ -148,7 +148,15 @@ public class TileEntityTank extends TileEntityAdvanced implements IPacketReceive
@Override @Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{ {
if (resource == null || (!getColor().getLiquidData().getStack().isLiquidEqual(resource) && this.getColor() != ColorCode.NONE)) if (resource == null || (this.getColor() != ColorCode.NONE && !getColor().getLiquidData().getStack().isLiquidEqual(resource)))
{
// TODO add if liquids are not equal but can still be accept cause mixing
return 0;
}
LiquidData data = LiquidHandler.get(resource);
if ((data.getCanFloat() && from == ForgeDirection.DOWN) || !data.getCanFloat() && from == ForgeDirection.UP)
{ {
return 0; return 0;
} }
@ -180,9 +188,7 @@ public class TileEntityTank extends TileEntityAdvanced implements IPacketReceive
} }
/** /**
* find out if this tank is actual full or not * is the tank full
*
* @return
*/ */
public boolean isFull() public boolean isFull()
{ {
@ -190,7 +196,7 @@ public class TileEntityTank extends TileEntityAdvanced implements IPacketReceive
{ {
return false; return false;
} }
if (this.tank.getLiquid().amount > 0 && this.tank.getLiquid().amount < this.tank.getCapacity()) if (this.tank.getLiquid().amount < this.tank.getCapacity())
{ {
return false; return false;
} }
@ -224,26 +230,39 @@ public class TileEntityTank extends TileEntityAdvanced implements IPacketReceive
@Override @Override
public ILiquidTank[] getTanks(ForgeDirection direction) public ILiquidTank[] getTanks(ForgeDirection direction)
{ {
return new ILiquidTank[] { tank }; return new ILiquidTank[] { tank };
} }
@Override @Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) public ILiquidTank getTank(ForgeDirection direction, LiquidStack resource)
{ {
return null; if (getColor().isValidLiquid(resource))
{
LiquidData data = LiquidHandler.get(resource);
if ((data.getCanFloat() && direction == ForgeDirection.DOWN) || !data.getCanFloat() && direction == ForgeDirection.UP)
{
return null;
}
}
return tank;
} }
@Override @Override
public int getPressureOut(LiquidStack type, ForgeDirection dir) public int getPressureOut(LiquidStack type, ForgeDirection dir)
{ {
if (getColor().isValidLiquid(type) || type.isLiquidEqual(LiquidHandler.unkown.getStack())) if (getColor().isValidLiquid(type))
{ {
LiquidData data = LiquidHandler.get(type); LiquidData data = LiquidHandler.get(type);
if (data.getCanFloat() && dir == ForgeDirection.DOWN) if (data.getCanFloat() && dir == ForgeDirection.DOWN)
{
return data.getPressure(); return data.getPressure();
}
if (!data.getCanFloat() && dir == ForgeDirection.UP) if (!data.getCanFloat() && dir == ForgeDirection.UP)
{
return data.getPressure(); return data.getPressure();
}
} }
return 0; return 0;
} }

View file

@ -203,7 +203,7 @@ public class HydraulicNetwork
*/ */
public void addEntity(ITankContainer ent) public void addEntity(ITankContainer ent)
{ {
if (ent == null) if (ent == null || ent instanceof IFluidNetworkPart)
{ {
return; return;
} }
@ -213,7 +213,7 @@ public class HydraulicNetwork
} }
} }
public void addConductor(IFluidNetworkPart newConductor, ColorCode code) public void addNetworkPart(IFluidNetworkPart newConductor, ColorCode code)
{ {
this.cleanConductors(); this.cleanConductors();