tentative fix for #1826
This commit is contained in:
parent
b63fb22db4
commit
2eb8e868f2
2 changed files with 16 additions and 11 deletions
|
@ -278,15 +278,18 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
private double getPowerToExtract() {
|
private double getPowerToExtract() {
|
||||||
TileEntity tile = getTileBuffer(orientation).getTile();
|
TileEntity tile = getTileBuffer(orientation).getTile();
|
||||||
|
|
||||||
if (tile instanceof IPowerReceptor) {
|
IBatteryObject battery = MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite());
|
||||||
|
|
||||||
|
if (battery != null) {
|
||||||
|
return extractEnergy(0, battery.getEnergyRequested(), false);
|
||||||
|
} else if (tile instanceof IPowerReceptor) {
|
||||||
PowerReceiver receptor = ((IPowerReceptor) tile)
|
PowerReceiver receptor = ((IPowerReceptor) tile)
|
||||||
.getPowerReceiver(orientation.getOpposite());
|
.getPowerReceiver(orientation.getOpposite());
|
||||||
|
|
||||||
return extractEnergy(receptor.getMinEnergyReceived(),
|
return extractEnergy(receptor.getMinEnergyReceived(),
|
||||||
receptor.getMaxEnergyReceived(), false);
|
receptor.getMaxEnergyReceived(), false);
|
||||||
} else {
|
} else {
|
||||||
return extractEnergy(0, MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite())
|
return 0;
|
||||||
.getEnergyRequested(), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +298,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
if (isPoweredTile(tile, orientation)) {
|
if (isPoweredTile(tile, orientation)) {
|
||||||
double extracted = getPowerToExtract();
|
double extracted = getPowerToExtract();
|
||||||
|
|
||||||
if (tile instanceof IPowerReceptor) {
|
IBatteryObject battery = MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite());
|
||||||
|
|
||||||
|
if (battery != null) {
|
||||||
|
battery.addEnergy(extractEnergy(0, battery.maxReceivedPerCycle(),
|
||||||
|
true));
|
||||||
|
} else if (tile instanceof IPowerReceptor) {
|
||||||
PowerReceiver receptor = ((IPowerReceptor) tile)
|
PowerReceiver receptor = ((IPowerReceptor) tile)
|
||||||
.getPowerReceiver(orientation.getOpposite());
|
.getPowerReceiver(orientation.getOpposite());
|
||||||
|
|
||||||
|
@ -306,11 +314,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
|
|
||||||
extractEnergy(receptor.getMinEnergyReceived(), needed, true);
|
extractEnergy(receptor.getMinEnergyReceived(), needed, true);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
IBatteryObject battery = MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite());
|
|
||||||
|
|
||||||
battery.addEnergy(extractEnergy(0, battery.maxReceivedPerCycle(),
|
|
||||||
true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -519,10 +522,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
|
||||||
public boolean isPoweredTile(TileEntity tile, ForgeDirection side) {
|
public boolean isPoweredTile(TileEntity tile, ForgeDirection side) {
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()) != null) {
|
||||||
|
return true;
|
||||||
} else if (tile instanceof IPowerReceptor) {
|
} else if (tile instanceof IPowerReceptor) {
|
||||||
return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null;
|
return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null;
|
||||||
} else {
|
} else {
|
||||||
return MjAPI.getMjBattery(tile, MjAPI.DEFAULT_POWER_FRAMEWORK, orientation.getOpposite()) != null;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class PipeTransportPower extends PipeTransport {
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
TileEntity tile = tiles [dir.ordinal()];
|
TileEntity tile = tiles [dir.ordinal()];
|
||||||
|
|
||||||
if (!(tile instanceof TileGenericPipe)) {
|
if (!(tile instanceof TileGenericPipe && ((TileGenericPipe) tile).pipe.transport instanceof PipeTransportPower)) {
|
||||||
PowerReceiver prov = getReceiverOnSide(dir);
|
PowerReceiver prov = getReceiverOnSide(dir);
|
||||||
if (prov != null) {
|
if (prov != null) {
|
||||||
double request = prov.powerRequest();
|
double request = prov.powerRequest();
|
||||||
|
|
Loading…
Reference in a new issue