mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Simulate amount the network has room for, rather than the amount that rate it can transfer at (#5513)
* Simulate amount the network has room for, rather than the amount that rate it can transfer at. Fixes #5512 * Double check the insert to the pipe/tube with a simulation
This commit is contained in:
1 parent
180183fcbd
commit
c9a9acbb81
2 files changed
+18
-4
No files matched your search
@@ -57,8 +57,8 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
|
||||
if (connectedAcceptors[side.ordinal()] != null) {
|
||||
IFluidHandler container = connectedAcceptors[side.ordinal()];
|
||||
if (container != null) {
|
||||
FluidStack received = container.drain(getPullAmount(), false);
|
||||
if (received != null && received.amount != 0) {
|
||||
FluidStack received = container.drain(getAvailablePull(), false);
|
||||
if (received != null && received.amount != 0 && takeFluid(received, false) == received.amount) {
|
||||
container.drain(takeFluid(received, true), true);
|
||||
}
|
||||
}
|
||||
@@ -253,6 +253,13 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getAvailablePull() {
|
||||
if (getTransmitter().hasTransmitterNetwork()) {
|
||||
return Math.min(getPullAmount(), getTransmitter().getTransmitterNetwork().getFluidNeeded());
|
||||
}
|
||||
return Math.min(getPullAmount(), buffer.getCapacity() - buffer.getFluidAmount());
|
||||
}
|
||||
|
||||
public int takeFluid(FluidStack fluid, boolean doEmit) {
|
||||
if (getTransmitter().hasTransmitterNetwork()) {
|
||||
return getTransmitter().getTransmitterNetwork().emit(fluid, doEmit);
|
||||
|
||||
@@ -82,8 +82,8 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
|
||||
if (connectedAcceptors[side.ordinal()] != null) {
|
||||
IGasHandler container = connectedAcceptors[side.ordinal()];
|
||||
if (container != null) {
|
||||
GasStack received = container.drawGas(side.getOpposite(), tier.getTubePullAmount(), false);
|
||||
if (received != null && received.amount != 0) {
|
||||
GasStack received = container.drawGas(side.getOpposite(), getAvailablePull(), false);
|
||||
if (received != null && received.amount != 0 && takeGas(received, false) == received.amount) {
|
||||
container.drawGas(side.getOpposite(), takeGas(received, true), true);
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,13 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
|
||||
super.update();
|
||||
}
|
||||
|
||||
public int getAvailablePull() {
|
||||
if (getTransmitter().hasTransmitterNetwork()) {
|
||||
return Math.min(tier.getTubePullAmount(), getTransmitter().getTransmitterNetwork().getGasNeeded());
|
||||
}
|
||||
return Math.min(tier.getTubePullAmount(), buffer.getNeeded());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateShare() {
|
||||
if (getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetworkSize() > 0) {
|
||||
|
||||
Reference in new issue
Block a user