Fixed split energy calculations, fixed gas rendering
This commit is contained in:
parent
4d84386b8e
commit
31d9275c7a
2 changed files with 42 additions and 7 deletions
|
@ -97,21 +97,22 @@ public class PacketTransmitterUpdate implements IMekanismPacket
|
|||
|
||||
Gas gasType = GasRegistry.getGas(dataStream.readInt());
|
||||
int amount = dataStream.readInt();
|
||||
GasStack stack = null;
|
||||
didGasTransfer = dataStream.readBoolean();
|
||||
|
||||
if(gasType != null)
|
||||
{
|
||||
stack = new GasStack(gasType, amount);
|
||||
}
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
if(gasType != null)
|
||||
{
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().gasStored = new GasStack(gasType, amount);
|
||||
}
|
||||
else {
|
||||
if(((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().gasStored != null)
|
||||
{
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().gasStored.amount = amount;
|
||||
}
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().refGas = gasType;
|
||||
}
|
||||
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().gasStored = stack;
|
||||
((ITransmitter<GasNetwork>)tileEntity).getTransmitterNetwork().didTransfer = didGasTransfer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -211,6 +211,40 @@ public class ListUtils
|
|||
ret[i] = (int)Math.round(val*percent[i]);
|
||||
}
|
||||
|
||||
int newTotal = 0;
|
||||
for(int i : ret) newTotal += i;
|
||||
|
||||
int diff = val-newTotal;
|
||||
|
||||
if(diff != val)
|
||||
{
|
||||
for(int i = 0; i < ret.length; i++)
|
||||
{
|
||||
int num = ret[i];
|
||||
|
||||
if(diff < 0 && num == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(diff > 0)
|
||||
{
|
||||
ret[i]++;
|
||||
diff--;
|
||||
}
|
||||
else if(diff < 0)
|
||||
{
|
||||
ret[i]--;
|
||||
diff++;
|
||||
}
|
||||
|
||||
if(diff == 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue