Pipe capacity stuff + packet tweaks

Should completely fix addon pipes with different capacities.

Might also fix some issues people are seeing with pipes not renderering,
see #473
This commit is contained in:
CovertJaguar 2012-12-02 18:47:33 -08:00
parent 3088a588f7
commit 97caa8f3ad
3 changed files with 43 additions and 35 deletions

View file

@ -40,8 +40,8 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
//Tracks how much is currently available (has spent it's inbound delaytime)
public PipeSection() {
super(null, PipeTransportLiquids.LIQUID_IN_PIPE);
public PipeSection(int capacity) {
super(null, capacity);
}
@Override
@ -153,13 +153,17 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
public PipeTransportLiquids() {
for (ForgeDirection direction : orientations) {
internalTanks[direction.ordinal()] = new PipeSection();
internalTanks[direction.ordinal()] = new PipeSection(getCapacity());
if (direction != ForgeDirection.UNKNOWN){
transferState[direction.ordinal()] = TransferState.None;
}
}
}
public int getCapacity() {
return LIQUID_IN_PIPE;
}
public boolean canReceiveLiquid(ForgeDirection o) {
TileEntity entity = container.getTile(o);
@ -193,9 +197,11 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
BitSet delta = new BitSet(21);
if (initClient > 0) {
changed = true;
initClient--;
delta.set(0, 21);
if (initClient == 1) {
changed = true;
delta.set(0, 21);
}
}
for (ForgeDirection dir : orientations) {
@ -236,11 +242,11 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
delta.set(dir.ordinal() * 3 + 1);
}
int displayQty = (renderCache[dir.ordinal()].amount * 4 + current.amount) / 5;
int displayQty = (prev.amount * 4 + current.amount) / 5;
if (displayQty == 0 && current.amount > 0) {
displayQty = current.amount;
}
displayQty = Math.min(PipeTransportLiquids.LIQUID_IN_PIPE, displayQty);
displayQty = Math.min(getCapacity(), displayQty);
if (prev.amount != displayQty) {
changed = true;
@ -253,8 +259,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
PacketLiquidUpdate packet = new PacketLiquidUpdate(xCoord, yCoord, zCoord);
packet.renderCache = this.renderCache;
packet.delta = delta;
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord,
DefaultProps.PIPE_CONTENTS_RENDER_DIST);
CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST);
}
}
}
@ -266,7 +271,7 @@ public class PipeTransportLiquids extends PipeTransport implements ITankContaine
public void sendDescriptionPacket() {
super.sendDescriptionPacket();
initClient = 2;
initClient = 6;
}
@Override

View file

@ -49,8 +49,10 @@ public class PacketLiquidUpdate extends PacketCoordinates {
if (!(pipe.pipe.transport instanceof PipeTransportLiquids)) {
return;
}
PipeTransportLiquids transLiq = ((PipeTransportLiquids) pipe.pipe.transport);
renderCache = ((PipeTransportLiquids) pipe.pipe.transport).renderCache;
renderCache = transLiq.renderCache;
byte[] dBytes = new byte[3];
data.read(dBytes);
@ -70,7 +72,7 @@ public class PacketLiquidUpdate extends PacketCoordinates {
renderCache[dir.ordinal()].itemMeta = data.readShort();
}
if (delta.get(dir.ordinal() * 3 + 2)) {
renderCache[dir.ordinal()].amount = data.readShort();
renderCache[dir.ordinal()].amount = Math.min(transLiq.getCapacity(), data.readShort());
}
}
}

View file

@ -48,7 +48,7 @@ import buildcraft.transport.PipeTransportPower;
import buildcraft.transport.TileGenericPipe;
public class RenderPipe extends TileEntitySpecialRenderer {
final static private int maxPower = 1000;
final static private int displayLiquidStages = 40;
@ -269,9 +269,10 @@ public class RenderPipe extends TileEntitySpecialRenderer {
if (pow.displayPower[i] >= 1.0) {
int stage = 0;
for (; stage < displayPowerStages; ++stage)
for (; stage < displayPowerStages; ++stage) {
if (displayPowerLimits[stage] > pow.displayPower[i])
break;
}
if (stage < displayPowerList.length)
GL11.glCallList(displayPowerList[stage]);
@ -311,30 +312,30 @@ public class RenderPipe extends TileEntitySpecialRenderer {
if (d == null)
continue;
int stage = (int) ((float) liquid.amount / (float) (liq.getTanks(ForgeDirection.UNKNOWN)[0].getCapacity()) * (displayLiquidStages - 1));
int stage = (int) ((float) liquid.amount / (float) (liq.getCapacity()) * (displayLiquidStages - 1));
GL11.glPushMatrix();
int list = 0;
switch (ForgeDirection.values()[i]) {
case UP:
above = true;
list = d.sideVertical[stage];
break;
case DOWN:
GL11.glTranslatef(0, -0.75F, 0);
list = d.sideVertical[stage];
break;
case EAST:
case WEST:
case SOUTH:
case NORTH:
sides = true;
GL11.glRotatef(angleY[i], 0, 1, 0);
GL11.glRotatef(angleZ[i], 0, 0, 1);
list = d.sideHorizontal[stage];
break;
default:
switch (ForgeDirection.VALID_DIRECTIONS[i]) {
case UP:
above = true;
list = d.sideVertical[stage];
break;
case DOWN:
GL11.glTranslatef(0, -0.75F, 0);
list = d.sideVertical[stage];
break;
case EAST:
case WEST:
case SOUTH:
case NORTH:
sides = true;
GL11.glRotatef(angleY[i], 0, 1, 0);
GL11.glRotatef(angleZ[i], 0, 0, 1);
list = d.sideHorizontal[stage];
break;
default:
}
GL11.glCallList(list);
@ -353,7 +354,7 @@ public class RenderPipe extends TileEntitySpecialRenderer {
DisplayLiquidList d = getListFromBuffer(liquid, pipe.worldObj);
if (d != null) {
int stage = (int) ((float) liquid.amount / (float) (liq.getTanks(ForgeDirection.UNKNOWN)[0].getCapacity()) * (displayLiquidStages - 1));
int stage = (int) ((float) liquid.amount / (float) (liq.getCapacity()) * (displayLiquidStages - 1));
if (above)
GL11.glCallList(d.centerVertical[stage]);