Partly fixed pipes
This commit is contained in:
parent
9bb6098362
commit
09484b5ee2
6 changed files with 51 additions and 83 deletions
|
@ -1,11 +1,14 @@
|
||||||
package dark.core.prefab.tilenetwork.fluid;
|
package dark.core.prefab.tilenetwork.fluid;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTank;
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
|
@ -21,7 +24,7 @@ import dark.core.prefab.tilenetwork.NetworkUpdateHandler;
|
||||||
public class NetworkFluidTiles extends NetworkTileEntities
|
public class NetworkFluidTiles extends NetworkTileEntities
|
||||||
{
|
{
|
||||||
/** Fluid Tanks that are connected to the network but not part of the network's main body */
|
/** Fluid Tanks that are connected to the network but not part of the network's main body */
|
||||||
public final Set<IFluidHandler> connectedTanks = new HashSet<IFluidHandler>();
|
public HashMap<IFluidHandler, EnumSet<ForgeDirection>> connctedFluidHandlers = new HashMap<IFluidHandler, EnumSet<ForgeDirection>>();
|
||||||
/** Collective storage tank of all fluid tile that make up this networks main body */
|
/** Collective storage tank of all fluid tile that make up this networks main body */
|
||||||
protected FluidTank sharedTank;
|
protected FluidTank sharedTank;
|
||||||
protected FluidTankInfo sharedTankInfo;
|
protected FluidTankInfo sharedTankInfo;
|
||||||
|
@ -186,24 +189,29 @@ public class NetworkFluidTiles extends NetworkTileEntities
|
||||||
@Override
|
@Override
|
||||||
public boolean removeTile(TileEntity ent)
|
public boolean removeTile(TileEntity ent)
|
||||||
{
|
{
|
||||||
return super.removeTile(ent) || this.connectedTanks.remove(ent);
|
return super.removeTile(ent) || this.connctedFluidHandlers.remove(ent) != null;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addTile(TileEntity ent, boolean member)
|
|
||||||
{
|
|
||||||
if (!(super.addTile(ent, member)) && ent instanceof IFluidHandler && !connectedTanks.contains(ent))
|
|
||||||
{
|
|
||||||
connectedTanks.add((IFluidHandler) ent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks too see if the tileEntity is part of or connected too the network */
|
/** Checks too see if the tileEntity is part of or connected too the network */
|
||||||
public boolean isConnected(TileEntity tileEntity)
|
public boolean isConnected(TileEntity tileEntity)
|
||||||
{
|
{
|
||||||
return this.connectedTanks.contains(tileEntity);
|
return this.connctedFluidHandlers.containsKey(tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTank(ForgeDirection side, IFluidHandler tank)
|
||||||
|
{
|
||||||
|
if (this.connctedFluidHandlers.containsKey(tank))
|
||||||
|
{
|
||||||
|
EnumSet<ForgeDirection> d = this.connctedFluidHandlers.get(tank);
|
||||||
|
d.add(side);
|
||||||
|
this.connctedFluidHandlers.put(tank, d);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EnumSet<ForgeDirection> d = EnumSet.noneOf(ForgeDirection.class);
|
||||||
|
d.add(side);
|
||||||
|
this.connctedFluidHandlers.put(tank, d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package dark.core.prefab.tilenetwork.fluid;
|
package dark.core.prefab.tilenetwork.fluid;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
@ -57,76 +60,38 @@ public class NetworkPipes extends NetworkFluidTiles
|
||||||
public int addFluidToNetwork(TileEntity source, FluidStack sta, boolean doFill, boolean allowStore)
|
public int addFluidToNetwork(TileEntity source, FluidStack sta, boolean doFill, boolean allowStore)
|
||||||
{
|
{
|
||||||
int used = 0;
|
int used = 0;
|
||||||
FluidStack prevCombined = this.getNetworkTank().getFluid();
|
|
||||||
FluidStack stack = sta.copy();
|
FluidStack stack = sta.copy();
|
||||||
|
|
||||||
if (!this.processingRequest && stack != null)
|
if (!this.processingRequest && stack != null)
|
||||||
{
|
{
|
||||||
this.processingRequest = true;
|
this.processingRequest = true;
|
||||||
|
|
||||||
if (this.getNetworkTank().getFluid() != null && !stack.isFluidEqual(this.getNetworkTank().getFluid()))
|
|
||||||
{
|
|
||||||
//this.causingMixing(null, this.combinedStorage().getFluid(), stack);
|
|
||||||
}
|
|
||||||
if (stack.amount > this.getMaxFlow(stack))
|
if (stack.amount > this.getMaxFlow(stack))
|
||||||
{
|
{
|
||||||
stack = FluidHelper.getStack(stack, this.getMaxFlow(stack));
|
stack = FluidHelper.getStack(stack, this.getMaxFlow(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Main fill target to try to fill with the stack */
|
|
||||||
IFluidHandler primaryFill = null;
|
|
||||||
int volume = Integer.MAX_VALUE;
|
|
||||||
ForgeDirection fillDir = ForgeDirection.UNKNOWN;
|
|
||||||
|
|
||||||
/* Secondary fill target if the main target is not found */
|
/* Secondary fill target if the main target is not found */
|
||||||
IFluidHandler secondayFill = null;
|
IFluidHandler tankToFill = null;
|
||||||
int mostFill = 0;
|
int mostFill = 0;
|
||||||
ForgeDirection otherFillDir = ForgeDirection.UNKNOWN;
|
ForgeDirection fillDir = ForgeDirection.UNKNOWN;
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
/* FIND THE FILL TARGET FROM THE LIST OF FLUID RECIEVERS */
|
/* FIND THE FILL TARGET FROM THE LIST OF FLUID RECIEVERS */
|
||||||
for (IFluidHandler tankContainer : connectedTanks)
|
for (Entry<IFluidHandler, EnumSet<ForgeDirection>> entry : this.connctedFluidHandlers.entrySet())
|
||||||
{
|
{
|
||||||
|
IFluidHandler tankContainer = entry.getKey();
|
||||||
if (tankContainer instanceof TileEntity && tankContainer != source && !(tankContainer instanceof INetworkPipe))
|
if (tankContainer instanceof TileEntity && tankContainer != source && !(tankContainer instanceof INetworkPipe))
|
||||||
{
|
{
|
||||||
TileEntity[] connectedTiles = ConnectionHelper.getSurroundingTileEntities((TileEntity) tankContainer);
|
for (ForgeDirection dir : entry.getValue())
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
{
|
||||||
if (connectedTiles[i] instanceof INetworkPipe && ((INetworkPipe) connectedTiles[i]).getTileNetwork() == this)
|
|
||||||
{
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(i).getOpposite();
|
|
||||||
FluidTankInfo[] targetTank = tankContainer.getTankInfo(dir);
|
|
||||||
int fill = tankContainer.fill(dir, stack, false);
|
int fill = tankContainer.fill(dir, stack, false);
|
||||||
|
|
||||||
/* USE GET TANK FROM SIDE METHOD FIRST */
|
if (fill > 0 && fill > mostFill)
|
||||||
if (targetTank != null)
|
|
||||||
{
|
{
|
||||||
for (int t = 0; t < targetTank.length; t++)
|
tankToFill = tankContainer;
|
||||||
{
|
|
||||||
FluidStack stackStored = targetTank[t].fluid;
|
|
||||||
int tankCap = targetTank[t].capacity;
|
|
||||||
if (stackStored == null)
|
|
||||||
{
|
|
||||||
primaryFill = tankContainer;
|
|
||||||
found = true;
|
|
||||||
fillDir = dir;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (stackStored.isFluidEqual(sta) && stackStored.amount < tankCap && stackStored.amount < volume)
|
|
||||||
{
|
|
||||||
primaryFill = tankContainer;
|
|
||||||
volume = stackStored.amount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}/* USE FILL METHOD IF GET TANK == NULL */
|
|
||||||
else if (fill > 0 && fill > mostFill)
|
|
||||||
{
|
|
||||||
secondayFill = tankContainer;
|
|
||||||
mostFill = fill;
|
mostFill = fill;
|
||||||
otherFillDir = dir;
|
fillDir = dir;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,14 +102,9 @@ public class NetworkPipes extends NetworkFluidTiles
|
||||||
}// End of tank finder
|
}// End of tank finder
|
||||||
|
|
||||||
boolean filledMain = false;
|
boolean filledMain = false;
|
||||||
if (primaryFill != null)
|
if (tankToFill != null)
|
||||||
{
|
{
|
||||||
used = primaryFill.fill(fillDir, stack, doFill);
|
used = tankToFill.fill(fillDir, stack, doFill);
|
||||||
// System.out.println("Primary Target " + used + doFill);
|
|
||||||
}
|
|
||||||
else if (secondayFill != null)
|
|
||||||
{
|
|
||||||
used = secondayFill.fill(fillDir, stack, doFill);
|
|
||||||
// System.out.println("Seconday Target " + used + doFill);
|
// System.out.println("Seconday Target " + used + doFill);
|
||||||
}
|
}
|
||||||
else if (allowStore)
|
else if (allowStore)
|
||||||
|
|
|
@ -75,6 +75,7 @@ public class TileEntityPipe extends TileEntityFluidNetworkTile implements IColor
|
||||||
{
|
{
|
||||||
connectedBlocks.add(tileEntity);
|
connectedBlocks.add(tileEntity);
|
||||||
this.renderConnection[side.ordinal()] = true;
|
this.renderConnection[side.ordinal()] = true;
|
||||||
|
this.getTileNetwork().addTank(side.getOpposite(), (IFluidHandler) tileEntity);
|
||||||
}
|
}
|
||||||
else if (tileEntity instanceof ITileConnector && ((ITileConnector) tileEntity).canTileConnect(Connection.FLUIDS, side.getOpposite()))
|
else if (tileEntity instanceof ITileConnector && ((ITileConnector) tileEntity).canTileConnect(Connection.FLUIDS, side.getOpposite()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -299,12 +299,13 @@ public abstract class TileEntityFluidNetworkTile extends TileEntityFluidDevice i
|
||||||
{
|
{
|
||||||
if (fluid.getFluid().isGaseous(fluid) && !mat.canSupportGas)
|
if (fluid.getFluid().isGaseous(fluid) && !mat.canSupportGas)
|
||||||
{
|
{
|
||||||
//TODO lose 25% of the gas, and render the lost
|
//TODO lose 25% of the gas, and render the escaping gas as a particle effect
|
||||||
|
this.getTileNetwork().drainNetworkTank(this.worldObj, (int) (fluid.amount * .25), true);
|
||||||
}
|
}
|
||||||
else if (FluidMasterList.isMolten(fluid.getFluid()) && !mat.canSupportMoltenFluids)
|
else if (FluidMasterList.isMolten(fluid.getFluid()) && !mat.canSupportMoltenFluids)
|
||||||
{
|
{
|
||||||
//TODO start to heat up the pipe to melting point. When it hits melting point turn the pipe to its molten metal equal
|
//TODO start to heat up the pipe to melting point. When it hits melting point turn the pipe to its molten metal equal
|
||||||
//TODO also once it reaches a set heat level start burning up blocks around the pipe. Eg wood
|
//TODO also once it reaches a set heat level start burning up blocks around the pipe such as wood
|
||||||
this.heat += FluidMasterList.getHeatPerPass(fluid.getFluid());
|
this.heat += FluidMasterList.getHeatPerPass(fluid.getFluid());
|
||||||
if (heat >= this.maxHeat)
|
if (heat >= this.maxHeat)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package dark.fluid.common.pump;
|
package dark.fluid.common.pump;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -85,11 +87,12 @@ public class TileEntityConstructionPump extends TileEntityStarterPump implements
|
||||||
{
|
{
|
||||||
if (outputTile instanceof IFluidHandler)
|
if (outputTile instanceof IFluidHandler)
|
||||||
{
|
{
|
||||||
for (IFluidHandler tank : ((NetworkFluidTiles) ((INetworkPipe) inputTile).getTileNetwork()).connectedTanks)
|
for (Entry<IFluidHandler, EnumSet<ForgeDirection>> entry : ((NetworkFluidTiles) ((INetworkPipe) inputTile).getTileNetwork()).connctedFluidHandlers.entrySet())
|
||||||
{
|
{
|
||||||
if (tank instanceof IDrain && !ignoreList.contains(tank))
|
|
||||||
|
if (entry.getKey() instanceof IDrain && !ignoreList.contains(entry.getKey()))
|
||||||
{
|
{
|
||||||
drain = (IDrain) tank;
|
drain = (IDrain) entry.getKey();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,9 +175,9 @@ public class TileEntityConstructionPump extends TileEntityStarterPump implements
|
||||||
if (inputTile instanceof INetworkPipe && ((INetworkPipe) inputTile).getTileNetwork() instanceof NetworkFluidTiles)
|
if (inputTile instanceof INetworkPipe && ((INetworkPipe) inputTile).getTileNetwork() instanceof NetworkFluidTiles)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (IFluidHandler tank : ((NetworkFluidTiles) ((INetworkPipe) inputTile).getTileNetwork()).connectedTanks)
|
for (Entry<IFluidHandler, EnumSet<ForgeDirection>> entry : ((NetworkFluidTiles) ((INetworkPipe) inputTile).getTileNetwork()).connctedFluidHandlers.entrySet())
|
||||||
{
|
{
|
||||||
if (tank instanceof IDrain)
|
if (entry.getKey() instanceof IDrain)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,11 +141,6 @@ public class TileEntityStarterPump extends TileEntityEnergyMachine implements IT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExternalModHandler.isBCFluidPipe(drain))
|
|
||||||
{
|
|
||||||
//TODO add resource pathfinder
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drainList == null)
|
if (drainList == null)
|
||||||
{
|
{
|
||||||
if (this.getLiquidFinder().results.size() < MAX_WORLD_EDITS_PER_PROCESS + 10)
|
if (this.getLiquidFinder().results.size() < MAX_WORLD_EDITS_PER_PROCESS + 10)
|
||||||
|
|
Loading…
Reference in a new issue