Pipes won't connect to a receptor with no provider
And a tweak to powerRequest()
This commit is contained in:
parent
1f8c9f78ee
commit
8d1b33b268
3 changed files with 7 additions and 7 deletions
|
@ -130,9 +130,8 @@ public final class PowerProvider {
|
|||
data.setCompoundTag(tag, nbt);
|
||||
}
|
||||
|
||||
public int powerRequest() {
|
||||
float needed = maxEnergyStored - energyStored;
|
||||
return (int) Math.ceil(Math.min(maxEnergyReceived, needed));
|
||||
public float powerRequest() {
|
||||
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
|
||||
}
|
||||
|
||||
public float receiveEnergy(float quantity, ForgeDirection from) {
|
||||
|
|
|
@ -15,5 +15,5 @@ public interface IPipeTransportPowerHook {
|
|||
|
||||
public double receiveEnergy(ForgeDirection from, double val);
|
||||
|
||||
public void requestEnergy(ForgeDirection from, int i);
|
||||
public void requestEnergy(ForgeDirection from, float amount);
|
||||
}
|
||||
|
|
|
@ -70,9 +70,10 @@ public class PipeTransportPower extends PipeTransport {
|
|||
Pipe pipe2 = ((TileGenericPipe) tile).pipe;
|
||||
if (BlockGenericPipe.isValid(pipe2) && !(pipe2.transport instanceof PipeTransportPower))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return tile instanceof TileGenericPipe || tile instanceof IMachine || tile instanceof IPowerReceptor;
|
||||
return tile instanceof IPowerReceptor && ((IPowerReceptor)tile).getPowerProvider(side) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -180,7 +181,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
IPowerReceptor receptor = (IPowerReceptor) tiles[i];
|
||||
PowerProvider prov = receptor.getPowerProvider(ForgeDirection.VALID_DIRECTIONS[i].getOpposite());
|
||||
if (prov != null && prov.canAcceptPowerFromPipes) {
|
||||
int request = prov.powerRequest();
|
||||
float request = prov.powerRequest();
|
||||
|
||||
if (request > 0) {
|
||||
requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request);
|
||||
|
@ -284,7 +285,7 @@ public class PipeTransportPower extends PipeTransport {
|
|||
return val;
|
||||
}
|
||||
|
||||
public void requestEnergy(ForgeDirection from, int amount) {
|
||||
public void requestEnergy(ForgeDirection from, float amount) {
|
||||
step();
|
||||
if (this.container.pipe instanceof IPipeTransportPowerHook) {
|
||||
((IPipeTransportPowerHook) this.container.pipe).requestEnergy(from, amount);
|
||||
|
|
Loading…
Reference in a new issue