Killed off color and fluid restriction for networks

This commit is contained in:
DarkGuardsman 2013-10-29 23:39:46 -04:00
parent 44d5e57116
commit 6029de9407
8 changed files with 24 additions and 153 deletions

View file

@ -15,20 +15,20 @@ import dark.core.prefab.tilenetwork.NetworkTileEntities;
/** Side note: the network should act like this when done {@link http /** Side note: the network should act like this when done {@link http
* ://www.e4training.com/hydraulic_calculators/B1.htm} as well as stay compatible with the forge * ://www.e4training.com/hydraulic_calculators/B1.htm} as well as stay compatible with the forge
* Liquids * Liquids
* *
* @author Rseifert */ * @author Rseifert */
public class NetworkFluidContainers extends NetworkFluidTiles public class NetworkFluidContainers extends NetworkFluidTiles
{ {
public NetworkFluidContainers(ColorCode color, INetworkPart... parts) public NetworkFluidContainers(INetworkPart... parts)
{ {
super(color, parts); super(parts);
} }
@Override @Override
public NetworkTileEntities newInstance() public NetworkTileEntities newInstance()
{ {
return new NetworkFluidContainers(this.color); return new NetworkFluidContainers();
} }
@Override @Override

View file

@ -22,21 +22,19 @@ public class NetworkFluidTiles extends NetworkTileEntities
/** Collective storage of all fluid tiles */ /** Collective storage of all fluid tiles */
public FluidTank sharedTank; public FluidTank sharedTank;
/** Color code of the network, mainly used for connection rules */
public ColorCode color = ColorCode.UNKOWN;
/** Has the collective tank been loaded yet */ /** Has the collective tank been loaded yet */
protected boolean loadedLiquids = false; protected boolean loadedLiquids = false;
public NetworkFluidTiles(ColorCode color, INetworkPart... parts) public NetworkFluidTiles(INetworkPart... parts)
{ {
super(parts); super(parts);
this.color = color;
} }
@Override @Override
public NetworkTileEntities newInstance() public NetworkTileEntities newInstance()
{ {
return new NetworkFluidTiles(this.color); return new NetworkFluidTiles();
} }
/** Gets the collective tank of the network */ /** Gets the collective tank of the network */
@ -204,7 +202,7 @@ public class NetworkFluidTiles extends NetworkTileEntities
@Override @Override
public boolean preMergeProcessing(NetworkTileEntities mergingNetwork, INetworkPart mergePoint) public boolean preMergeProcessing(NetworkTileEntities mergingNetwork, INetworkPart mergePoint)
{ {
if (mergingNetwork instanceof NetworkFluidTiles && ((NetworkFluidTiles) mergingNetwork).color == this.color) if (mergingNetwork instanceof NetworkFluidTiles && ((NetworkFluidTiles) mergingNetwork).getClass() == this.getClass())
{ {
if (!((NetworkFluidTiles) mergingNetwork).loadedLiquids) if (!((NetworkFluidTiles) mergingNetwork).loadedLiquids)
{ {
@ -264,7 +262,7 @@ public class NetworkFluidTiles extends NetworkTileEntities
@Override @Override
public boolean isValidMember(INetworkPart part) public boolean isValidMember(INetworkPart part)
{ {
return super.isValidMember(part) && part instanceof INetworkFluidPart && ((INetworkFluidPart) part).getColor() == this.color; return super.isValidMember(part) && part instanceof INetworkFluidPart;
} }
@Override @Override

View file

@ -19,152 +19,32 @@ import dark.core.prefab.tilenetwork.NetworkTileEntities;
/** Side note: the network should act like this when done {@link http /** Side note: the network should act like this when done {@link http
* ://www.e4training.com/hydraulic_calculators/B1.htm} as well as stay compatible with the forge * ://www.e4training.com/hydraulic_calculators/B1.htm} as well as stay compatible with the forge
* Liquids * Liquids
* *
* @author Rseifert */ * @author Rseifert */
public class NetworkPipes extends NetworkFluidTiles public class NetworkPipes extends NetworkFluidTiles
{ {
private boolean processingRequest;
public float pressureProduced;
/* MACHINES THAT USE THE PRESSURE SYSTEM TO DO WORK ** */ public NetworkPipes(INetworkPart... parts)
private final HashMap<TileEntity, FluidPressurePack> pressureProducers = new HashMap<TileEntity, FluidPressurePack>();
private final HashMap<TileEntity, FluidPressurePack> pressureLoads = new HashMap<TileEntity, FluidPressurePack>();
/* PRESSURE OF THE NETWORK AS A TOTAL. ZERO AS IN NO PRESSURE */
public double pressureProduced = 0, pressureLoad = 0;
/* IS IT PROCESSING AN ADD LIQUID EVENT */
private boolean processingRequest = false;
public NetworkPipes(ColorCode color, INetworkPart... parts)
{ {
super(color, parts); super(parts);
} }
@Override @Override
public NetworkTileEntities newInstance() public NetworkTileEntities newInstance()
{ {
return new NetworkPipes(this.color); return new NetworkPipes();
}
@Override
public boolean isPartOfNetwork(TileEntity ent)
{
return super.isPartOfNetwork(ent) || this.pressureLoads.containsKey(ent) || this.pressureProducers.containsKey(ent);
}
/** sets this tileEntity to produce a pressure and flow rate in the network */
public void startProducingPressure(TileEntity tileEntity, FluidPressurePack fluidPack)
{
if (tileEntity != null && fluidPack.liquidStack != null)
{
if ((this.combinedStorage().getFluid() == null || fluidPack.liquidStack.isFluidEqual(this.combinedStorage().getFluid())) && fluidPack.liquidStack.amount > 0)
{
this.pressureProducers.put(tileEntity, fluidPack);
}
}
}
/** sets this tileEntity to produce a pressure and flow rate in the network */
public void startProducingPressure(TileEntity tileEntity, FluidStack stack, double pressure)
{
this.startProducingPressure(tileEntity, new FluidPressurePack(stack, pressure));
}
/** is this tile entity producing a pressure */
public boolean isProducingPressure(TileEntity tileEntity)
{
return this.pressureProducers.containsKey(tileEntity);
}
/** Sets this tile entity to act as a load on the system */
public void addLoad(TileEntity tileEntity, FluidPressurePack fluidPack)
{
if (tileEntity != null && fluidPack.liquidStack != null && fluidPack.liquidStack.amount > 0)
{
this.pressureLoads.put(tileEntity, fluidPack);
}
}
/** Sets this tile entity to act as a load on the system */
public void addLoad(TileEntity tileEntity, FluidStack stack, double pressure)
{
this.addLoad(tileEntity, new FluidPressurePack(stack, pressure));
}
/** is this tileEntity a load in the network */
public boolean isLoad(TileEntity tileEntity)
{
return this.pressureLoads.containsKey(tileEntity);
}
/** @param ignoreTiles The TileEntities to ignore during this calculation. Null will make it not
* ignore any.
* @return The electricity produced in this electricity network */
public double getPressureProduced(TileEntity... ignoreTiles)
{
// TODO pressure is not added as a sum but rather as a collective sum of the largest
// pressures. IF the pressure is to small it will be ignored and stop producing pressure.
int totalPressure = 0;
Iterator it = this.pressureProducers.entrySet().iterator();
loop:
while (it.hasNext())
{
Map.Entry pairs = (Map.Entry) it.next();
if (pairs != null)
{
TileEntity tileEntity = (TileEntity) pairs.getKey();
if (tileEntity == null)
{
it.remove();
continue;
}
if (tileEntity.isInvalid())
{
it.remove();
continue;
}
if (tileEntity.worldObj.getBlockTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord) != tileEntity)
{
it.remove();
continue;
}
if (ignoreTiles != null)
{
for (TileEntity ignoreTile : ignoreTiles)
{
if (tileEntity == ignoreTile)
{
continue loop;
}
}
}
FluidPressurePack pack = (FluidPressurePack) pairs.getValue();
if (pairs.getKey() != null && pairs.getValue() != null && pack != null)
{
totalPressure += pack.pressure;
}
}
}
return totalPressure;
} }
@Override @Override
public boolean removeTile(TileEntity ent) public boolean removeTile(TileEntity ent)
{ {
return super.removeTile(ent) || this.pressureLoads.remove(ent) != null || this.pressureProducers.remove(ent) != null; return super.removeTile(ent);
} }
/** Adds FLuid to this network from one of the connected Pipes /** Adds FLuid to this network from one of the connected Pipes
* *
* @param source - Were this liquid came from * @param source - Were this liquid came from
* @param stack - LiquidStack to be sent * @param stack - LiquidStack to be sent
* @param doFill - actually fill the tank or just check numbers * @param doFill - actually fill the tank or just check numbers
@ -175,7 +55,7 @@ public class NetworkPipes extends NetworkFluidTiles
} }
/** Adds FLuid to this network from one of the connected Pipes /** Adds FLuid to this network from one of the connected Pipes
* *
* @param source - Were this liquid came from * @param source - Were this liquid came from
* @param stack - LiquidStack to be sent * @param stack - LiquidStack to be sent
* @param doFill - actually fill the tank or just check numbers * @param doFill - actually fill the tank or just check numbers

View file

@ -56,7 +56,7 @@ public class BlockRenderHelper implements ISimpleBlockRenderingHandler
} }
else if (FMRecipeLoader.blockTank != null && block.blockID == FMRecipeLoader.blockTank.blockID) else if (FMRecipeLoader.blockTank != null && block.blockID == FMRecipeLoader.blockTank.blockID)
{ {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(FluidMech.instance.getDomain(), metadata == 1 ? "/textures/blocks/obsidian.png" : "/textures/blocks/iron_block.png")); FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(FluidMech.instance.DOMAIN, metadata == 1 ? "textures/blocks/obsidian.png" : "textures/blocks/iron_block.png"));
GL11.glTranslatef(0.0F, -0.9F, 0.0F); GL11.glTranslatef(0.0F, -0.9F, 0.0F);
tank.render(0.0625F, false, false, false, false); tank.render(0.0625F, false, false, false, false);
GL11.glRotatef(90f, 0f, 1f, 0f); GL11.glRotatef(90f, 0f, 1f, 0f);

View file

@ -97,13 +97,6 @@ public class BlockTank extends BlockFM
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{ {
par3List.add(new ItemStack(par1, 1, 15)); par3List.add(new ItemStack(par1, 1, 15));
for (int i = 0; i < 16; i++)
{
if (FluidHelper.hasRestrictedStack(i))
{
par3List.add(new ItemStack(par1, 1, i));
}
}
} }
@Override @Override

View file

@ -188,7 +188,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {
if (resource == null || !FluidHelper.isValidLiquid(this.getColor(), resource.getFluid()) || this.worldObj.isRemote) if (resource == null || this.worldObj.isRemote)
{ {
return 0; return 0;
} }
@ -277,7 +277,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand
{ {
if (this.fluidNetwork == null) if (this.fluidNetwork == null)
{ {
this.setTileNetwork(new NetworkFluidContainers(this.getColor(), this)); this.setTileNetwork(new NetworkFluidContainers(this));
} }
return this.fluidNetwork; return this.fluidNetwork;
} }

View file

@ -169,7 +169,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {
if (resource == null || !FluidHelper.isValidLiquid(this.getColor(), resource.getFluid())) if (resource == null)
{ {
return 0; return 0;
} }
@ -330,7 +330,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
{ {
if (this.pipeNetwork == null) if (this.pipeNetwork == null)
{ {
this.setTileNetwork(new NetworkPipes(this.getColor(), this)); this.setTileNetwork(new NetworkPipes(this));
} }
return this.pipeNetwork; return this.pipeNetwork;
} }

View file

@ -41,7 +41,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{ {
if (resource == null || resource.getFluid() == null || !FluidHelper.isValidLiquid(this.getColor(), resource.getFluid())) if (resource == null || resource.getFluid() == null)
{ {
return 0; return 0;
} }