Electrolytic Separators are now super server friendly
This commit is contained in:
parent
43b71cb8cc
commit
13f27b6732
1 changed files with 60 additions and 64 deletions
|
@ -77,6 +77,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
/** Type type of gas this block is dumping. */
|
||||
public GasMode dumpRight = GasMode.IDLE;
|
||||
|
||||
public boolean clientDumpLeft = false;
|
||||
public boolean clientDumpRight = false;
|
||||
|
||||
public double BASE_ENERGY_USAGE;
|
||||
|
||||
public double energyPerTick;
|
||||
|
@ -175,6 +178,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
|
||||
int dumpAmount = 8*(int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED));
|
||||
|
||||
boolean dumpedLeft = false;
|
||||
boolean dumpedRight = false;
|
||||
|
||||
if(leftTank.getGas() != null)
|
||||
{
|
||||
if(dumpLeft != GasMode.DUMPING)
|
||||
|
@ -195,20 +201,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
{
|
||||
leftTank.draw(dumpAmount, true);
|
||||
|
||||
if(worldObj.rand.nextInt(3) == 2)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
dumpedLeft = true;
|
||||
}
|
||||
|
||||
if(dumpLeft == GasMode.DUMPING_EXCESS && leftTank.getNeeded() < output)
|
||||
{
|
||||
leftTank.draw(output-leftTank.getNeeded(), true);
|
||||
|
||||
if(worldObj.rand.nextInt(3) == 2)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
dumpedLeft = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,21 +232,34 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
{
|
||||
rightTank.draw(dumpAmount, true);
|
||||
|
||||
if(worldObj.rand.nextInt(3) == 2)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(1, new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
dumpedRight = true;
|
||||
}
|
||||
|
||||
if(dumpRight == GasMode.DUMPING_EXCESS && rightTank.getNeeded() < output)
|
||||
{
|
||||
rightTank.draw(output-rightTank.getNeeded(), true);
|
||||
|
||||
if(worldObj.rand.nextInt(3) == 2)
|
||||
dumpedRight = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(clientDumpLeft != dumpedLeft || clientDumpRight != dumpedRight)
|
||||
{
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(1, new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
clientDumpLeft = dumpedLeft;
|
||||
clientDumpRight = dumpedRight;
|
||||
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(clientDumpLeft)
|
||||
{
|
||||
spawnParticle(0);
|
||||
}
|
||||
|
||||
if(clientDumpRight)
|
||||
{
|
||||
spawnParticle(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -418,10 +431,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
int type = dataStream.readInt();
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
if(dataStream.readBoolean())
|
||||
{
|
||||
fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt()));
|
||||
|
@ -448,22 +457,17 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
|
||||
dumpLeft = GasMode.values()[dataStream.readInt()];
|
||||
dumpRight = GasMode.values()[dataStream.readInt()];
|
||||
clientDumpLeft = dataStream.readBoolean();
|
||||
clientDumpRight = dataStream.readBoolean();
|
||||
isActive = dataStream.readBoolean();
|
||||
clientEnergyUsed = dataStream.readDouble();
|
||||
}
|
||||
else if(type == 1)
|
||||
{
|
||||
spawnParticle(dataStream.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(0);
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
data.add(true);
|
||||
|
@ -496,22 +500,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
|
||||
data.add(dumpLeft.ordinal());
|
||||
data.add(dumpRight.ordinal());
|
||||
data.add(clientDumpLeft);
|
||||
data.add(clientDumpRight);
|
||||
data.add(isActive);
|
||||
data.add(clientEnergyUsed);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public ArrayList getParticlePacket(int type, ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(1);
|
||||
data.add(type);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetFacing(int side)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue