Changes for new network code (untested)(Broken)
Most likely i will have to do tons of bug fixes after this. As well the code for the tank is unfinished so this will not even compile.
This commit is contained in:
parent
ab1d6a3a81
commit
5a08ed4b1c
13 changed files with 383 additions and 442 deletions
|
@ -357,17 +357,17 @@ public class ModelLiquidTank extends ModelBase
|
|||
|
||||
public void renderMeter(TileEntity tee, float f5)
|
||||
{
|
||||
TileEntity[] conenctedTiles = new TileEntity[6];
|
||||
int[] conenctedTiles = new int[6];
|
||||
if (tee instanceof TileEntityTank)
|
||||
{
|
||||
conenctedTiles = ((TileEntityTank) tee).connectedBlocks;
|
||||
conenctedTiles = ((TileEntityTank) tee).renderConnection;
|
||||
}
|
||||
// Front
|
||||
if (conenctedTiles[3] instanceof TileEntityPipe)
|
||||
if (conenctedTiles[3] == 1)
|
||||
{
|
||||
CCFront.render(f5);
|
||||
}
|
||||
else
|
||||
else if (conenctedTiles[3] == 0)
|
||||
{
|
||||
GuageT.render(f5);
|
||||
GuageB.render(f5);
|
||||
|
@ -377,11 +377,11 @@ public class ModelLiquidTank extends ModelBase
|
|||
GuageL.render(f5);
|
||||
}
|
||||
// back
|
||||
if (conenctedTiles[2] instanceof TileEntityPipe)
|
||||
if (conenctedTiles[2] == 1)
|
||||
{
|
||||
CCBack.render(f5);
|
||||
}
|
||||
else
|
||||
else if (conenctedTiles[2] == 0)
|
||||
{
|
||||
GuageT3.render(f5);
|
||||
Guage3.render(f5);
|
||||
|
@ -391,11 +391,11 @@ public class ModelLiquidTank extends ModelBase
|
|||
GuageL3.render(f5);
|
||||
}
|
||||
// right
|
||||
if (conenctedTiles[4] instanceof TileEntityPipe)
|
||||
if (conenctedTiles[4] == 1)
|
||||
{
|
||||
CCRight.render(f5);
|
||||
}
|
||||
else
|
||||
else if (conenctedTiles[4] == 0)
|
||||
{
|
||||
GuageT4.render(f5);
|
||||
Guage4.render(f5);
|
||||
|
@ -405,11 +405,11 @@ public class ModelLiquidTank extends ModelBase
|
|||
GuageL4.render(f5);
|
||||
}
|
||||
// left
|
||||
if (conenctedTiles[5] instanceof TileEntityPipe)
|
||||
if (conenctedTiles[5] == 1)
|
||||
{
|
||||
CCLeft.render(f5);
|
||||
}
|
||||
else
|
||||
else if (conenctedTiles[3] == 1)
|
||||
{
|
||||
GuageT2.render(f5);
|
||||
Guage2.render(f5);
|
||||
|
|
|
@ -2,9 +2,10 @@ package dark.fluid.common.machines;
|
|||
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.api.IColorCoded;
|
||||
import hydraulic.api.IPipeConnection;
|
||||
import hydraulic.api.INetworkPipe;
|
||||
import hydraulic.api.ITileConnector;
|
||||
import hydraulic.api.IReadOut;
|
||||
import hydraulic.fluidnetwork.IFluidNetworkPart;
|
||||
import hydraulic.network.PipeNetwork;
|
||||
import hydraulic.prefab.tile.TileEntityFluidDevice;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,12 +20,12 @@ import net.minecraftforge.liquids.LiquidContainerRegistry;
|
|||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import dark.library.helpers.ConnectionHelper;
|
||||
|
||||
public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPipeConnection, IReadOut
|
||||
public class TileEntityReleaseValve extends TileEntityFluidDevice implements ITileConnector, IReadOut
|
||||
{
|
||||
public boolean[] allowed = new boolean[ColorCode.values().length - 1];
|
||||
public TileEntity[] connected = new TileEntity[6];
|
||||
|
||||
private List<IFluidNetworkPart> output = new ArrayList<IFluidNetworkPart>();
|
||||
private List<INetworkPipe> output = new ArrayList<INetworkPipe>();
|
||||
private ITankContainer[] input = new ITankContainer[6];
|
||||
|
||||
public boolean isPowered = false;
|
||||
|
@ -65,10 +66,10 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi
|
|||
LiquidStack stack = drainedTank.drain(dir.getOpposite(), LiquidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (stack != null && stack.amount > 0)
|
||||
{
|
||||
IFluidNetworkPart inputPipe = this.findValidPipe(stack);
|
||||
INetworkPipe inputPipe = this.findValidPipe(stack);
|
||||
if (inputPipe != null)
|
||||
{
|
||||
int ammountFilled = inputPipe.getNetwork().addFluidToNetwork((TileEntity) drainedTank, stack, true);
|
||||
int ammountFilled = ((PipeNetwork)inputPipe.getTileNetwork()).addFluidToNetwork((TileEntity) drainedTank, stack, true);
|
||||
drainedTank.drain(ForgeDirection.UNKNOWN, ammountFilled, true);
|
||||
}
|
||||
}
|
||||
|
@ -79,10 +80,10 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi
|
|||
}
|
||||
|
||||
/** used to find a valid pipe for filling of the liquid type */
|
||||
public IFluidNetworkPart findValidPipe(LiquidStack stack)
|
||||
public INetworkPipe findValidPipe(LiquidStack stack)
|
||||
{
|
||||
// find normal color selective pipe first
|
||||
for (IFluidNetworkPart pipe : output)
|
||||
for (INetworkPipe pipe : output)
|
||||
{
|
||||
if (pipe.fill(ForgeDirection.UNKNOWN, stack, false) > 0)
|
||||
{
|
||||
|
@ -140,9 +141,9 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi
|
|||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = connected[dir.ordinal()];
|
||||
if (tileEntity instanceof IFluidNetworkPart)
|
||||
if (tileEntity instanceof INetworkPipe)
|
||||
{
|
||||
IFluidNetworkPart pipe = (IFluidNetworkPart) tileEntity;
|
||||
INetworkPipe pipe = (INetworkPipe) tileEntity;
|
||||
if (this.canConnect(pipe.getColor()))
|
||||
{
|
||||
this.output.add(pipe);
|
||||
|
@ -168,9 +169,9 @@ public class TileEntityReleaseValve extends TileEntityFluidDevice implements IPi
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return entity != null && entity instanceof IColorCoded && this.canConnect(((IColorCoded) entity).getColor());
|
||||
return entity != null && entity instanceof ITankContainer && entity instanceof IColorCoded && this.canConnect(((IColorCoded) entity).getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,263 +2,394 @@ package dark.fluid.common.machines;
|
|||
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.api.IColorCoded;
|
||||
import hydraulic.api.INetworkPipe;
|
||||
import hydraulic.api.ITileConnector;
|
||||
import hydraulic.api.IReadOut;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
import hydraulic.network.PipeNetwork;
|
||||
import hydraulic.prefab.tile.TileEntityFluidStorage;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.block.IConnectionProvider;
|
||||
import net.minecraftforge.liquids.LiquidTank;
|
||||
|
||||
import org.bouncycastle.util.Arrays;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.core.vector.VectorHelper;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.fluid.common.FluidMech;
|
||||
import dark.fluid.common.pipes.TileEntityPipe;
|
||||
|
||||
public class TileEntityTank extends TileEntityFluidStorage implements IPacketReceiver, ITankContainer, IColorCoded, IConnectionProvider
|
||||
public class TileEntityTank extends TileEntityFluidStorage implements ITankContainer, IReadOut, IColorCoded, INetworkPipe, IPacketReceiver
|
||||
{
|
||||
public TileEntity[] connectedBlocks = { null, null, null, null, null, null };
|
||||
/* TANK TO FAKE OTHER TILES INTO BELIVING THIS HAS AN INTERNAL STORAGE */
|
||||
protected LiquidTank fakeTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
|
||||
/* CURRENTLY CONNECTED TILE ENTITIES TO THIS */
|
||||
private TileEntity[] connectedBlocks = new TileEntity[6];
|
||||
public int[] renderConnection = new int[6];
|
||||
/* RANDOM INSTANCE USED BY THE UPDATE TICK */
|
||||
private Random random = new Random();
|
||||
/* NETWORK INSTANCE THAT THIS PIPE USES */
|
||||
private PipeNetwork pipeNetwork;
|
||||
|
||||
private boolean shouldAutoDrain = false;
|
||||
|
||||
public enum PacketID
|
||||
{
|
||||
PIPE_CONNECTIONS, EXTENTION_CREATE, EXTENTION_UPDATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate()
|
||||
{
|
||||
this.updateAdjacentConnections();
|
||||
this.updateNetworkConnections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (this.ticks % (random.nextInt(10) * 4 + 20) == 0)
|
||||
{
|
||||
updateAdjacentConnections();
|
||||
}
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
int originalVolume = 0;
|
||||
|
||||
if (this.tank.getLiquid() != null)
|
||||
if (ticks % ((int) random.nextInt(5) * 40 + 20) == 0)
|
||||
{
|
||||
originalVolume = this.tank.getLiquid().amount;
|
||||
|
||||
if (ticks % (random.nextInt(4) * 5 + 10) >= 0)
|
||||
{
|
||||
this.fillTanksAround();
|
||||
this.tank.drain(this.fillSide(this.getStoredLiquid(), ForgeDirection.DOWN, true), true);
|
||||
}
|
||||
|
||||
if ((this.tank.getLiquid() == null && originalVolume != 0) || (this.tank.getLiquid() != null && this.tank.getLiquid().amount != originalVolume))
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
this.updateNetworkConnections();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ticks % (random.nextInt(5) * 10 + 20) == 0)
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.getTileNetwork().splitNetwork(this.worldObj, this);
|
||||
}
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
PacketID id = PacketID.values()[dataStream.readInt()];
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (id == PacketID.PIPE_CONNECTIONS)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.renderConnection[0] = dataStream.readInt();
|
||||
this.renderConnection[1] = dataStream.readInt();
|
||||
this.renderConnection[2] = dataStream.readInt();
|
||||
this.renderConnection[3] = dataStream.readInt();
|
||||
this.renderConnection[4] = dataStream.readInt();
|
||||
this.renderConnection[5] = dataStream.readInt();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
if (this.getStoredLiquid() != null)
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, PacketID.PIPE_CONNECTIONS.ordinal(), this.renderConnection[0], this.renderConnection[1], this.renderConnection[2], this.renderConnection[3], this.renderConnection[4], this.renderConnection[5]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
LiquidStack liquid = LiquidStack.loadLiquidStackFromNBT(nbt.getCompoundTag("tank"));
|
||||
if (liquid != null)
|
||||
{
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, this.getStoredLiquid().itemID, this.getStoredLiquid().amount, this.getStoredLiquid().itemMeta);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PacketManager.getPacket(FluidMech.CHANNEL, this, 0, 0, 0);
|
||||
this.fakeTank.setLiquid(liquid);
|
||||
}
|
||||
}
|
||||
|
||||
public LiquidStack getStoredLiquid()
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
return tank.getLiquid();
|
||||
super.writeToNBT(nbt);
|
||||
if (this.fakeTank.containsValidLiquid())
|
||||
{
|
||||
nbt.setTag("stored", this.fakeTank.getLiquid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the current color mark of the pipe
|
||||
*/
|
||||
@Override
|
||||
public ColorCode getColor()
|
||||
{
|
||||
if (this.worldObj == null)
|
||||
{
|
||||
return ColorCode.NONE;
|
||||
}
|
||||
return ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the current color mark of the pipe
|
||||
*/
|
||||
@Override
|
||||
public void setColor(Object cc)
|
||||
{
|
||||
ColorCode code = ColorCode.get(cc);
|
||||
if (!worldObj.isRemote && code != this.getColor())
|
||||
{
|
||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, code.ordinal(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput data)
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
try
|
||||
/* DEBUG CODE ACTIVATERS */
|
||||
boolean testConnections = false;
|
||||
boolean testNetwork = false;
|
||||
boolean testSubs = false;
|
||||
|
||||
/* NORMAL OUTPUT */
|
||||
String string = this.getTileNetwork().pressureProduced + "p " + this.getTileNetwork().getNetworkFluid() + " Extra";
|
||||
|
||||
/* DEBUG CODE */
|
||||
if (testConnections)
|
||||
{
|
||||
this.tank.setLiquid(new LiquidStack(data.readInt(), data.readInt(), data.readInt()));
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
string += ":" + this.renderConnection[i] + (this.getNetworkConnections()[i] != null ? "T" : "F");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
if (testNetwork)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.out.print("Fail reading data for Storage tank \n");
|
||||
string += " " + this.getTileNetwork().toString();
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null || !this.getColor().isValidLiquid(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
TileEntity tile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), from);
|
||||
return this.getTileNetwork().addFluidToNetwork(tile, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if (!this.getColor().isValidLiquid(resource))
|
||||
if (tankIndex != 0 || resource == null || !this.getColor().isValidLiquid(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (this.isFull())
|
||||
{
|
||||
TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
if (tank instanceof TileEntityTank)
|
||||
{
|
||||
return ((TileEntityTank) tank).fill(tankIndex, resource, doFill);
|
||||
}
|
||||
}
|
||||
return super.fill(tankIndex, resource, doFill);
|
||||
return this.getTileNetwork().addFluidToNetwork(this, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (from != ForgeDirection.DOWN)
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[] { this.fakeTank };
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
if (this.getColor().isValidLiquid(type))
|
||||
{
|
||||
return super.drain(from, maxDrain, doDrain);
|
||||
return this.fakeTank;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Cause this TE to trade liquid with the Tanks around it to level off */
|
||||
public void fillTanksAround()
|
||||
/**
|
||||
* Checks to make sure the connection is valid to the tileEntity
|
||||
*
|
||||
* @param tileEntity - the tileEntity being checked
|
||||
* @param side - side the connection is too
|
||||
*/
|
||||
public void validateConnectionSide(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0)
|
||||
if (!this.worldObj.isRemote && tileEntity != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity[] ents = this.getAdjacentConnections();
|
||||
|
||||
/* SUM VOLUME UP FOR ALL CONNECTED TANKS */
|
||||
int commonVol = this.tank.getLiquid().amount;
|
||||
int equalVol = commonVol;
|
||||
int tanks = 1;
|
||||
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
if (ents[i] instanceof TileEntityTank && ((TileEntityTank) ents[i]).getColor() == this.getColor())
|
||||
if (tileEntity instanceof ITileConnector)
|
||||
{
|
||||
tanks++;
|
||||
if (((TileEntityTank) ents[i]).tank.getLiquid() != null)
|
||||
if (((ITileConnector) tileEntity).canPipeConnect(this, side))
|
||||
{
|
||||
commonVol += ((TileEntityTank) ents[i]).tank.getLiquid().amount;
|
||||
if (tileEntity instanceof INetworkPipe)
|
||||
{
|
||||
if (((INetworkPipe) tileEntity).getColor() == this.getColor())
|
||||
{
|
||||
this.getTileNetwork().merge(((INetworkPipe) tileEntity).getTileNetwork());
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
equalVol = commonVol / tanks;
|
||||
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= equalVol)
|
||||
else if (tileEntity instanceof IColorCoded)
|
||||
{
|
||||
break;
|
||||
if (this.getColor() == ColorCode.NONE || this.getColor() == ((IColorCoded) tileEntity).getColor())
|
||||
{
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if (ents[i] instanceof TileEntityTank && ((TileEntityTank) ents[i]).getColor() == this.getColor() && !((TileEntityTank) ents[i]).isFull())
|
||||
else if (tileEntity instanceof ITankContainer)
|
||||
{
|
||||
LiquidStack target = ((TileEntityTank) ents[i]).tank.getLiquid();
|
||||
LiquidStack filling = this.tank.getLiquid();
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
filling = FluidHelper.getStack(this.tank.getLiquid(), equalVol);
|
||||
}
|
||||
else if (target.amount < equalVol)
|
||||
{
|
||||
filling = FluidHelper.getStack(this.tank.getLiquid(), equalVol - target.amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
filling = null;
|
||||
}
|
||||
int f = ((TileEntityTank) ents[i]).tank.fill(filling, true);
|
||||
this.tank.drain(f, true);
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Object obj)
|
||||
public void updateNetworkConnections()
|
||||
{
|
||||
ColorCode code = ColorCode.get(obj);
|
||||
if (!worldObj.isRemote && code != this.getColor() && (this.tank != null || code.isValidLiquid(this.tank.getLiquid())))
|
||||
|
||||
if (this.worldObj != null && !this.worldObj.isRemote)
|
||||
{
|
||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, code.ordinal() & 15, 3);
|
||||
this.updateAdjacentConnections();
|
||||
|
||||
int[] previousConnections = this.renderConnection.clone();
|
||||
this.connectedBlocks = new TileEntity[6];
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(i);
|
||||
this.validateConnectionSide(this.worldObj.getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ), dir);
|
||||
|
||||
this.renderConnection[i] = this.connectedBlocks[i] instanceof TileEntityTank ? 2 : (this.connectedBlocks[i] instanceof INetworkPipe ? 1 : this.connectedBlocks[i] != null ? 3 : 0);
|
||||
|
||||
if (this.connectedBlocks[i] instanceof TileEntityTank)
|
||||
{
|
||||
ITankContainer tankContainer = (ITankContainer) this.connectedBlocks[i];
|
||||
this.getTileNetwork().addEntity(tankContainer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only send packet updates if visuallyConnected changed.
|
||||
*/
|
||||
if (!Arrays.areEqual(previousConnections, this.renderConnection))
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorCode getColor()
|
||||
{
|
||||
return ColorCode.get(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
TileEntity entity = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord);
|
||||
|
||||
return entity != null && entity.getClass() == this.getClass() && ((IColorCoded) entity).getColor() == this.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return entity != null && entity instanceof IColorCoded && (((IColorCoded) entity).getColor() == ColorCode.NONE || ((IColorCoded) entity).getColor() == this.getColor());
|
||||
return entity != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
public double getMaxPressure(ForgeDirection side)
|
||||
{
|
||||
return 350;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PipeNetwork getTileNetwork()
|
||||
{
|
||||
if (this.pipeNetwork == null)
|
||||
{
|
||||
this.setNetwork(new PipeNetwork(this.getColor(), this));
|
||||
}
|
||||
return this.pipeNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(PipeNetwork network)
|
||||
{
|
||||
this.pipeNetwork = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side)
|
||||
{
|
||||
return FluidHelper.getDefaultFlowRate(stack) * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOverPressure(Boolean damageAllowed)
|
||||
{
|
||||
if (damageAllowed)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, yCoord, 0, 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity[] getNetworkConnections()
|
||||
{
|
||||
return this.connectedBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAdjacentConnections()
|
||||
public int getTankSize()
|
||||
{
|
||||
TileEntity[] originalConnection = this.connectedBlocks;
|
||||
this.connectedBlocks = new TileEntity[6];
|
||||
for (int side = 0; side < 6; side++)
|
||||
{
|
||||
ForgeDirection direction = ForgeDirection.getOrientation(side);
|
||||
TileEntity entity = worldObj.getBlockTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
||||
if (entity != null && !(entity instanceof IConductor))
|
||||
{
|
||||
if (!(entity instanceof IColorCoded) || (entity instanceof IColorCoded && (((IColorCoded) entity).getColor() == ColorCode.NONE || ((IColorCoded) entity).getColor() == this.getColor())))
|
||||
{
|
||||
if (entity instanceof IConnectionProvider && ((IConnectionProvider) entity).canConnect(direction))
|
||||
{
|
||||
connectedBlocks[side] = entity;
|
||||
}
|
||||
else if (entity instanceof ITankContainer)
|
||||
{
|
||||
connectedBlocks[side] = entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!originalConnection.equals(this.connectedBlocks))
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
return LiquidContainerRegistry.BUCKET_VOLUME * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankSize()
|
||||
public ILiquidTank getTank()
|
||||
{
|
||||
return (LiquidContainerRegistry.BUCKET_VOLUME * 4);
|
||||
return this.fakeTank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTankContent(LiquidStack stack)
|
||||
{
|
||||
this.fakeTank.setLiquid(stack);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package dark.fluid.common.pipes;
|
||||
|
||||
import hydraulic.api.FluidRestrictionHandler;
|
||||
import hydraulic.fluidnetwork.IFluidNetworkPart;
|
||||
import hydraulic.api.INetworkPipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -61,9 +61,9 @@ public class BlockPipe extends BlockAdvanced
|
|||
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity instanceof IFluidNetworkPart)
|
||||
if (tileEntity instanceof INetworkPipe)
|
||||
{
|
||||
((IFluidNetworkPart) tileEntity).updateAdjacentConnections();
|
||||
((INetworkPipe) tileEntity).updateNetworkConnections();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,9 @@ public class BlockPipe extends BlockAdvanced
|
|||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity instanceof IFluidNetworkPart)
|
||||
if (tileEntity instanceof INetworkPipe)
|
||||
{
|
||||
((IFluidNetworkPart) tileEntity).updateAdjacentConnections();
|
||||
((INetworkPipe) tileEntity).updateNetworkConnections();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package dark.fluid.common.pipes;
|
|||
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
import hydraulic.network.PipeNetwork;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
|
@ -20,7 +21,7 @@ public class TileEntityGenericPipe extends TileEntityPipe
|
|||
return 0;
|
||||
}
|
||||
TileEntity tile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), from);
|
||||
return this.getNetwork().addFluidToNetwork(tile, resource, doFill);
|
||||
return ((PipeNetwork) this.getTileNetwork()).addFluidToNetwork(tile, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,7 +31,7 @@ public class TileEntityGenericPipe extends TileEntityPipe
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
return this.getNetwork().addFluidToNetwork(this, resource, doFill);
|
||||
return ((PipeNetwork) this.getTileNetwork()).addFluidToNetwork(this, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,24 +41,18 @@ public class TileEntityGenericPipe extends TileEntityPipe
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
Vector3 vec = new Vector3(entity);
|
||||
int meta = vec.getBlockMetadata(this.worldObj);
|
||||
int blockID = vec.getBlockID(this.worldObj);
|
||||
|
||||
|
||||
if (entity instanceof TileEntityPipe && blockID == this.getBlockType().blockID)
|
||||
{
|
||||
return meta == this.getBlockMetadata();
|
||||
}
|
||||
|
||||
return super.canPipeConnect(entity, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankSize()
|
||||
{
|
||||
return LiquidContainerRegistry.BUCKET_VOLUME;
|
||||
return super.canTileConnect(entity, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,11 +2,12 @@ package dark.fluid.common.pipes;
|
|||
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.api.IColorCoded;
|
||||
import hydraulic.api.IPipeConnection;
|
||||
import hydraulic.api.INetworkPipe;
|
||||
import hydraulic.api.ITileConnector;
|
||||
import hydraulic.api.IReadOut;
|
||||
import hydraulic.fluidnetwork.HydraulicNetwork;
|
||||
import hydraulic.fluidnetwork.IFluidNetworkPart;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
import hydraulic.network.PipeNetwork;
|
||||
import hydraulic.network.TileNetwork;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
@ -40,7 +41,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import dark.fluid.common.FluidMech;
|
||||
import dark.fluid.common.pipes.addon.IPipeExtention;
|
||||
|
||||
public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer, IReadOut, IColorCoded, IFluidNetworkPart, IPacketReceiver
|
||||
public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer, IReadOut, IColorCoded, INetworkPipe, IPacketReceiver
|
||||
{
|
||||
|
||||
/* TANK TO FAKE OTHER TILES INTO BELIVING THIS HAS AN INTERNAL STORAGE */
|
||||
|
@ -52,7 +53,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
/* RANDOM INSTANCE USED BY THE UPDATE TICK */
|
||||
private Random random = new Random();
|
||||
/* NETWORK INSTANCE THAT THIS PIPE USES */
|
||||
private HydraulicNetwork pipeNetwork;
|
||||
private PipeNetwork pipeNetwork;
|
||||
|
||||
private boolean shouldAutoDrain = false;
|
||||
|
||||
|
@ -64,7 +65,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
@Override
|
||||
public void initiate()
|
||||
{
|
||||
this.updateAdjacentConnections();
|
||||
this.updateNetworkConnections();
|
||||
if (this.subEntities[0] == null)
|
||||
{
|
||||
// this.addNewExtention(0, TileEntityPipeWindow.class);
|
||||
|
@ -95,7 +96,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
{
|
||||
if (ticks % ((int) random.nextInt(5) * 40 + 20) == 0)
|
||||
{
|
||||
this.updateAdjacentConnections();
|
||||
this.updateNetworkConnections();
|
||||
}
|
||||
if (ticks % ((int) random.nextInt(5) * 60 + 20) == 0)
|
||||
{
|
||||
|
@ -139,7 +140,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.getNetwork().splitNetwork(this.worldObj, this);
|
||||
this.getTileNetwork().splitNetwork(this.worldObj, this);
|
||||
}
|
||||
|
||||
super.invalidate();
|
||||
|
@ -326,7 +327,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
@Override
|
||||
public ColorCode getColor()
|
||||
{
|
||||
if(this.worldObj == null)
|
||||
if (this.worldObj == null)
|
||||
{
|
||||
return ColorCode.NONE;
|
||||
}
|
||||
|
@ -355,19 +356,19 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
boolean testSubs = false;
|
||||
|
||||
/* NORMAL OUTPUT */
|
||||
String string = this.getNetwork().pressureProduced + "p " + this.getNetwork().getStorageFluid() + " Extra";
|
||||
String string = ((PipeNetwork)this.getTileNetwork()).pressureProduced + "p " + ((PipeNetwork)this.getTileNetwork()).getNetworkFluid() + " Extra";
|
||||
|
||||
/* DEBUG CODE */
|
||||
if (testConnections)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
string += ":" + (this.renderConnection[i] ? "T" : "F") + (this.getAdjacentConnections()[i] != null ? "T" : "F");
|
||||
string += ":" + (this.renderConnection[i] ? "T" : "F") + (this.getNetworkConnections()[i] != null ? "T" : "F");
|
||||
}
|
||||
}
|
||||
if (testNetwork)
|
||||
{
|
||||
string += " " + this.getNetwork().toString();
|
||||
string += " " + this.getTileNetwork().toString();
|
||||
}
|
||||
if (testSubs)
|
||||
{
|
||||
|
@ -397,7 +398,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
return 0;
|
||||
}
|
||||
TileEntity tile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), from);
|
||||
return this.getNetwork().addFluidToNetwork(tile, resource, doFill);
|
||||
return ((PipeNetwork)this.getTileNetwork()).addFluidToNetwork(tile, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -407,7 +408,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
return this.getNetwork().addFluidToNetwork(this, resource, doFill);
|
||||
return ((PipeNetwork)this.getTileNetwork()).addFluidToNetwork(this, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -453,15 +454,15 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
connectedBlocks[side.ordinal()] = null;
|
||||
return;
|
||||
}
|
||||
if (tileEntity instanceof IPipeConnection)
|
||||
if (tileEntity instanceof ITileConnector)
|
||||
{
|
||||
if (((IPipeConnection) tileEntity).canPipeConnect(this, side))
|
||||
if (((ITileConnector) tileEntity).canTileConnect(this, side))
|
||||
{
|
||||
if (tileEntity instanceof IFluidNetworkPart)
|
||||
if (tileEntity instanceof INetworkPipe)
|
||||
{
|
||||
if (((IFluidNetworkPart) tileEntity).getColor() == this.getColor())
|
||||
if (((INetworkPipe) tileEntity).getColor() == this.getColor())
|
||||
{
|
||||
this.getNetwork().mergeNetworks(((IFluidNetworkPart) tileEntity).getNetwork());
|
||||
this.getTileNetwork().merge(((INetworkPipe) tileEntity).getTileNetwork());
|
||||
connectedBlocks[side.ordinal()] = tileEntity;
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +487,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateAdjacentConnections()
|
||||
public void updateNetworkConnections()
|
||||
{
|
||||
|
||||
if (this.worldObj != null && !this.worldObj.isRemote)
|
||||
|
@ -502,17 +503,17 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
|
||||
this.renderConnection[i] = this.connectedBlocks[i] != null;
|
||||
|
||||
if (this.renderConnection[i] && this.connectedBlocks[i] instanceof ITankContainer && !(this.connectedBlocks[i] instanceof IFluidNetworkPart))
|
||||
if (this.renderConnection[i] && this.connectedBlocks[i] instanceof ITankContainer && !(this.connectedBlocks[i] instanceof INetworkPipe))
|
||||
{
|
||||
ITankContainer tankContainer = (ITankContainer) this.connectedBlocks[i];
|
||||
this.getNetwork().addEntity(tankContainer);
|
||||
this.getTileNetwork().addEntity(this.connectedBlocks[i], false);
|
||||
|
||||
/* LITTLE TRICK TO AUTO DRAIN TANKS ON EACH CONNECTION UPDATE */
|
||||
|
||||
LiquidStack stack = tankContainer.drain(dir, LiquidContainerRegistry.BUCKET_VOLUME, false);
|
||||
if (stack != null && stack.amount > 0)
|
||||
{
|
||||
int fill = this.getNetwork().addFluidToNetwork((TileEntity) tankContainer, stack, true);
|
||||
int fill = ((PipeNetwork)this.getTileNetwork()).addFluidToNetwork((TileEntity) tankContainer, stack, true);
|
||||
tankContainer.drain(dir, fill, true);
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +530,7 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return entity != null && this.subEntities[dir.ordinal()] == null;
|
||||
}
|
||||
|
@ -541,19 +542,22 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public HydraulicNetwork getNetwork()
|
||||
public TileNetwork getTileNetwork()
|
||||
{
|
||||
if (this.pipeNetwork == null)
|
||||
{
|
||||
this.setNetwork(new HydraulicNetwork(this.getColor(), this));
|
||||
this.setTileNetwork(new PipeNetwork(this.getColor(), this));
|
||||
}
|
||||
return this.pipeNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(HydraulicNetwork network)
|
||||
public void setTileNetwork(TileNetwork network)
|
||||
{
|
||||
this.pipeNetwork = network;
|
||||
if (network instanceof PipeNetwork)
|
||||
{
|
||||
this.pipeNetwork = (PipeNetwork) network;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -580,19 +584,13 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
public TileEntity[] getNetworkConnections()
|
||||
{
|
||||
return this.connectedBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankSize()
|
||||
{
|
||||
return LiquidContainerRegistry.BUCKET_VOLUME * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank()
|
||||
public LiquidTank getTank()
|
||||
{
|
||||
return this.fakeTank;
|
||||
}
|
||||
|
@ -600,8 +598,11 @@ public class TileEntityPipe extends TileEntityAdvanced implements ITankContainer
|
|||
@Override
|
||||
public void setTankContent(LiquidStack stack)
|
||||
{
|
||||
if(this.fakeTank == null)
|
||||
{
|
||||
this.fakeTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
this.fakeTank.setLiquid(stack);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dark.fluid.common.pipes.addon;
|
||||
|
||||
import hydraulic.network.PipeNetwork;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
|
@ -11,7 +12,6 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
import dark.fluid.client.render.pipe.RenderPipeWindow;
|
||||
import dark.fluid.common.pipes.TileEntityPipe;
|
||||
|
||||
|
||||
public class TileEntityPipeWindow extends TileEntityPipeExtention
|
||||
{
|
||||
|
||||
|
@ -23,13 +23,14 @@ public class TileEntityPipeWindow extends TileEntityPipeExtention
|
|||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
// TODO replace the updateEntity method with updateAddon(TileEntityPipe pipe)
|
||||
super.updateEntity();
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (pipe != null)
|
||||
{
|
||||
stack = pipe.getNetwork().getTank().getLiquid();
|
||||
stack = ((PipeNetwork) pipe.getTileNetwork()).getNetworkTank().getLiquid();
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, yCoord, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ public class TileEntityPipeWindow extends TileEntityPipeExtention
|
|||
@Override
|
||||
public boolean canBePlacedOnPipe(TileEntityPipe pipe, int side)
|
||||
{
|
||||
if(pipe != null && pipe.subEntities[side] == null)
|
||||
if (pipe != null && pipe.subEntities[side] == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package dark.fluid.common.pipes.tele;
|
||||
|
||||
import hydraulic.fluidnetwork.IFluidNetworkPart;
|
||||
import hydraulic.api.INetworkPipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
* cause that network to seak out all other connected network and try to merge them
|
||||
*
|
||||
*/
|
||||
public interface INetworkConnector extends IFluidNetworkPart
|
||||
public interface INetworkConnector extends INetworkPipe
|
||||
{
|
||||
/**
|
||||
* gets the pipes frequency
|
||||
|
|
|
@ -1,192 +0,0 @@
|
|||
package dark.fluid.common.pipes.tele;
|
||||
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.fluidnetwork.HydraulicNetwork;
|
||||
import hydraulic.prefab.tile.TileEntityFluidDevice;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
public class TileEntityEndPipe extends TileEntityFluidDevice implements INetworkConnector
|
||||
{
|
||||
public static HashMap<TileEntityEndPipe, Integer> linkMap = new HashMap<TileEntityEndPipe, Integer>();
|
||||
|
||||
private HydraulicNetwork network;
|
||||
@Override
|
||||
public String getMeterReading(EntityPlayer user, ForgeDirection side)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPressure(ForgeDirection side)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFlowRate(LiquidStack stack, ForgeDirection side)
|
||||
{
|
||||
return LiquidContainerRegistry.BUCKET_VOLUME * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HydraulicNetwork getNetwork()
|
||||
{
|
||||
if(network == null)
|
||||
{
|
||||
network = new HydraulicNetwork(this.getColor(), this);
|
||||
}
|
||||
return network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(HydraulicNetwork network)
|
||||
{
|
||||
this.network = network;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOverPressure(Boolean damageAllowed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTankSize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTankContent(LiquidStack stack)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorCode getColor()
|
||||
{
|
||||
return ColorCode.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Object obj)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAdjacentConnections()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFrequency()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrequency(int id)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(String username)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<INetworkConnector> getConnectedParts()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package dark.fluid.common.pump;
|
||||
|
||||
import hydraulic.fluidnetwork.HydraulicNetworkHelper;
|
||||
import hydraulic.network.HydraulicNetworkHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package dark.fluid.common.pump;
|
||||
|
||||
import hydraulic.api.IPipeConnection;
|
||||
import hydraulic.fluidnetwork.HydraulicNetworkHelper;
|
||||
import hydraulic.fluidnetwork.IFluidNetworkPart;
|
||||
import hydraulic.api.INetworkPipe;
|
||||
import hydraulic.api.ITileConnector;
|
||||
import hydraulic.network.FluidNetwork;
|
||||
import hydraulic.network.HydraulicNetworkHelper;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ILiquidTank;
|
||||
|
@ -16,7 +17,7 @@ import universalelectricity.core.vector.VectorHelper;
|
|||
import dark.library.helpers.MetaGroup;
|
||||
import dark.library.machine.TileEntityRunnableMachine;
|
||||
|
||||
public class TileEntityConstructionPump extends TileEntityRunnableMachine implements ITankContainer, IPipeConnection
|
||||
public class TileEntityConstructionPump extends TileEntityRunnableMachine implements ITankContainer, ITileConnector
|
||||
{
|
||||
/* ENERGY PER TICK TO TRY TO PUMP */
|
||||
public static final double WATTS_PER_TICK = 100;
|
||||
|
@ -35,7 +36,7 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
|
|||
|
||||
public ForgeDirection getFacing(boolean input)
|
||||
{
|
||||
int meta = 0;
|
||||
int meta = 0;
|
||||
if (worldObj != null)
|
||||
{
|
||||
meta = MetaGroup.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
@ -57,11 +58,13 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
|
|||
super.updateEntity();
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (this.ticks % 10 == 0 && this.wattsReceived >= this.WATTS_PER_TICK) // TODO add electric Drain
|
||||
if (this.ticks % 10 == 0 && this.wattsReceived >= this.WATTS_PER_TICK) // TODO add
|
||||
// electric
|
||||
// Drain
|
||||
{
|
||||
this.wattsReceived -= this.WATTS_PER_TICK;
|
||||
this.rotation += 1;
|
||||
if(rotation >= 7)
|
||||
if (rotation >= 7)
|
||||
{
|
||||
rotation = 0;
|
||||
}
|
||||
|
@ -69,11 +72,11 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
|
|||
|
||||
TileEntity inputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), getFacing(true));
|
||||
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), getFacing(false));
|
||||
if (inputTile instanceof IFluidNetworkPart)
|
||||
if (inputTile instanceof INetworkPipe && ((INetworkPipe) inputTile).getTileNetwork() instanceof FluidNetwork)
|
||||
{
|
||||
if (outputTile instanceof ITankContainer)
|
||||
{
|
||||
for (ITankContainer tank : ((IFluidNetworkPart) inputTile).getNetwork().fluidTanks)
|
||||
for (ITankContainer tank : ((FluidNetwork) ((INetworkPipe) inputTile).getTileNetwork()).fluidTanks)
|
||||
{
|
||||
if (tank instanceof TileEntityDrain)
|
||||
{
|
||||
|
@ -160,9 +163,9 @@ public class TileEntityConstructionPump extends TileEntityRunnableMachine implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return dir == this.getFacing(false) || dir == this.getFacing(true);
|
||||
return entity instanceof ITankContainer && (dir == this.getFacing(false) || dir == this.getFacing(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package dark.fluid.common.pump;
|
||||
|
||||
import hydraulic.api.IDrain;
|
||||
import hydraulic.fluidnetwork.IFluidNetworkPart;
|
||||
import hydraulic.api.INetworkPipe;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
import hydraulic.prefab.tile.TileEntityFluidDevice;
|
||||
|
||||
|
@ -13,6 +13,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -213,7 +214,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
{
|
||||
requests.remove();
|
||||
}
|
||||
else if (pipe instanceof IFluidNetworkPart && !((IFluidNetworkPart) pipe).getNetwork().isConnected(entry.getKey()))
|
||||
else if (pipe instanceof INetworkPipe && !((INetworkPipe) pipe).getTileNetwork().isPartOfNetwork(entry.getKey()))
|
||||
{
|
||||
requests.remove();
|
||||
}
|
||||
|
@ -439,7 +440,7 @@ public class TileEntityDrain extends TileEntityFluidDevice implements ITankConta
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
return dir == this.getFacing();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package dark.fluid.common.pump;
|
|||
|
||||
import hydraulic.api.ColorCode;
|
||||
import hydraulic.api.IColorCoded;
|
||||
import hydraulic.api.IPipeConnection;
|
||||
import hydraulic.api.ITileConnector;
|
||||
import hydraulic.api.IReadOut;
|
||||
import hydraulic.helpers.FluidHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -23,7 +23,7 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
import dark.library.helpers.MetaGroup;
|
||||
import dark.library.machine.TileEntityRunnableMachine;
|
||||
|
||||
public class TileEntityStarterPump extends TileEntityRunnableMachine implements IPacketReceiver, IReadOut, IPipeConnection
|
||||
public class TileEntityStarterPump extends TileEntityRunnableMachine implements IPacketReceiver, IReadOut, ITileConnector
|
||||
{
|
||||
public final double WATTS_PER_TICK = (400 / 20);
|
||||
private double percentPumped = 0.0;
|
||||
|
@ -198,9 +198,9 @@ public class TileEntityStarterPump extends TileEntityRunnableMachine implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canPipeConnect(TileEntity entity, ForgeDirection dir)
|
||||
public boolean canTileConnect(TileEntity entity, ForgeDirection dir)
|
||||
{
|
||||
if (dir == this.pipeConnection.getOpposite())
|
||||
if (dir == this.pipeConnection.getOpposite() && entity instanceof ITankContainer)
|
||||
{
|
||||
return entity != null && entity instanceof IColorCoded && (((IColorCoded) entity).getColor() == ColorCode.NONE || ((IColorCoded) entity).getColor() == this.color);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue