Made the IPowerReceptor direction aware

This commit is contained in:
Krapht 2013-03-27 21:47:45 +01:00
parent 5703c85549
commit 4438947cab
12 changed files with 15 additions and 12 deletions

View file

@ -9,6 +9,8 @@
package buildcraft.api.power;
import net.minecraftforge.common.ForgeDirection;
public interface IPowerReceptor {
public void setPowerProvider(IPowerProvider provider);
@ -17,6 +19,6 @@ public interface IPowerReceptor {
public void doWork();
public int powerRequest();
public int powerRequest(ForgeDirection validDirections);
}

View file

@ -561,7 +561,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
if ((bluePrintBuilder != null || currentPathIterator != null) && !done)
return powerProvider.getMaxEnergyReceived();
else

View file

@ -356,7 +356,7 @@ public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowe
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
if (isActive())
return powerProvider.getMaxEnergyReceived();
else

View file

@ -389,7 +389,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
return 0;
}

View file

@ -9,6 +9,7 @@
package buildcraft.factory;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.core.IMachine;
import buildcraft.core.TileBuildCraft;
@ -16,7 +17,7 @@ import buildcraft.core.TileBuildCraft;
public abstract class TileMachine extends TileBuildCraft implements IMachine, IPowerReceptor {
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
if (isActive())
return (int) Math.ceil(Math.min(getPowerProvider().getMaxEnergyReceived(), getPowerProvider().getMaxEnergyStored()
- getPowerProvider().getEnergyStored()));

View file

@ -235,7 +235,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor {
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
if (powerProvider.getEnergyStored() < 200 || laser != null)
return 25;
else

View file

@ -161,7 +161,7 @@ public class PipeTransportPower extends PipeTransport {
for (int i = 0; i < 6; ++i) {
if (tiles[i] instanceof IPowerReceptor && !(tiles[i] instanceof TileGenericPipe)) {
IPowerReceptor receptor = (IPowerReceptor) tiles[i];
int request = receptor.powerRequest();
int request = receptor.powerRequest(ForgeDirection.VALID_DIRECTIONS[i]);
if (request > 0) {
requestEnergy(ForgeDirection.VALID_DIRECTIONS[i], request);

View file

@ -406,7 +406,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
return getPowerProvider().getMaxEnergyReceived();
}

View file

@ -295,7 +295,7 @@ public class PipeItemsObsidian extends Pipe implements IPowerReceptor {
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
return getPowerProvider().getMaxEnergyReceived();
}
}

View file

@ -229,7 +229,7 @@ public class PipeItemsWood extends Pipe implements IPowerReceptor {
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
return getPowerProvider().getMaxEnergyReceived();
}

View file

@ -145,7 +145,7 @@ public class PipeLiquidsWood extends Pipe implements IPowerReceptor {
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
return getPowerProvider().getMaxEnergyReceived();
}

View file

@ -123,7 +123,7 @@ public class PipePowerWood extends Pipe implements IPowerReceptor {
}
@Override
public int powerRequest() {
public int powerRequest(ForgeDirection from) {
return getPowerProvider().getMaxEnergyReceived();
}