Killed off color and fluid restriction for networks
This commit is contained in:
parent
44d5e57116
commit
6029de9407
8 changed files with 24 additions and 153 deletions
|
@ -15,20 +15,20 @@ import dark.core.prefab.tilenetwork.NetworkTileEntities;
|
|||
/** 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
|
||||
* Liquids
|
||||
*
|
||||
*
|
||||
* @author Rseifert */
|
||||
public class NetworkFluidContainers extends NetworkFluidTiles
|
||||
{
|
||||
|
||||
public NetworkFluidContainers(ColorCode color, INetworkPart... parts)
|
||||
public NetworkFluidContainers(INetworkPart... parts)
|
||||
{
|
||||
super(color, parts);
|
||||
super(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTileEntities newInstance()
|
||||
{
|
||||
return new NetworkFluidContainers(this.color);
|
||||
return new NetworkFluidContainers();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,21 +22,19 @@ public class NetworkFluidTiles extends NetworkTileEntities
|
|||
/** Collective storage of all fluid tiles */
|
||||
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 */
|
||||
protected boolean loadedLiquids = false;
|
||||
|
||||
public NetworkFluidTiles(ColorCode color, INetworkPart... parts)
|
||||
public NetworkFluidTiles(INetworkPart... parts)
|
||||
{
|
||||
super(parts);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTileEntities newInstance()
|
||||
{
|
||||
return new NetworkFluidTiles(this.color);
|
||||
return new NetworkFluidTiles();
|
||||
}
|
||||
|
||||
/** Gets the collective tank of the network */
|
||||
|
@ -204,7 +202,7 @@ public class NetworkFluidTiles extends NetworkTileEntities
|
|||
@Override
|
||||
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)
|
||||
{
|
||||
|
@ -264,7 +262,7 @@ public class NetworkFluidTiles extends NetworkTileEntities
|
|||
@Override
|
||||
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
|
||||
|
|
|
@ -19,152 +19,32 @@ import dark.core.prefab.tilenetwork.NetworkTileEntities;
|
|||
/** 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
|
||||
* Liquids
|
||||
*
|
||||
*
|
||||
* @author Rseifert */
|
||||
public class NetworkPipes extends NetworkFluidTiles
|
||||
{
|
||||
private boolean processingRequest;
|
||||
public float pressureProduced;
|
||||
|
||||
/* MACHINES THAT USE THE PRESSURE SYSTEM TO DO WORK ** */
|
||||
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)
|
||||
public NetworkPipes(INetworkPart... parts)
|
||||
{
|
||||
super(color, parts);
|
||||
super(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkTileEntities newInstance()
|
||||
{
|
||||
return new NetworkPipes(this.color);
|
||||
}
|
||||
|
||||
@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;
|
||||
return new NetworkPipes();
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
*
|
||||
*
|
||||
* @param source - Were this liquid came from
|
||||
* @param stack - LiquidStack to be sent
|
||||
* @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
|
||||
*
|
||||
*
|
||||
* @param source - Were this liquid came from
|
||||
* @param stack - LiquidStack to be sent
|
||||
* @param doFill - actually fill the tank or just check numbers
|
||||
|
|
|
@ -56,7 +56,7 @@ public class BlockRenderHelper implements ISimpleBlockRenderingHandler
|
|||
}
|
||||
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);
|
||||
tank.render(0.0625F, false, false, false, false);
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
|
|
|
@ -97,13 +97,6 @@ public class BlockTank extends BlockFM
|
|||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
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
|
||||
|
|
|
@ -188,7 +188,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand
|
|||
@Override
|
||||
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;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public class TileEntityTank extends TileEntityFluidStorage implements IFluidHand
|
|||
{
|
||||
if (this.fluidNetwork == null)
|
||||
{
|
||||
this.setTileNetwork(new NetworkFluidContainers(this.getColor(), this));
|
||||
this.setTileNetwork(new NetworkFluidContainers(this));
|
||||
}
|
||||
return this.fluidNetwork;
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
|
|||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null || !FluidHelper.isValidLiquid(this.getColor(), resource.getFluid()))
|
||||
if (resource == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements IFluidHandler,
|
|||
{
|
||||
if (this.pipeNetwork == null)
|
||||
{
|
||||
this.setTileNetwork(new NetworkPipes(this.getColor(), this));
|
||||
this.setTileNetwork(new NetworkPipes(this));
|
||||
}
|
||||
return this.pipeNetwork;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public abstract class TileEntityFluidStorage extends TileEntityFluidDevice imple
|
|||
@Override
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue