Hopefully fix some RF problems with pseudo-acceptors.

This commit is contained in:
Ben Spiers 2015-04-17 17:44:02 +01:00
parent 32a0e0ff4e
commit d8c26c3ed0
2 changed files with 8 additions and 13 deletions

View file

@ -211,7 +211,7 @@ public class EnergyNetwork extends DynamicNetwork<EnergyAcceptorWrapper, EnergyN
{ {
for(ForgeDirection side : sides) for(ForgeDirection side : sides)
{ {
if(acceptor.canReceiveEnergy(side) && acceptor.getNeeded() > 0) if(acceptor.canReceiveEnergy(side) && acceptor.needsEnergy(side))
{ {
toReturn.add(acceptor); toReturn.add(acceptor);
break; break;

View file

@ -46,7 +46,7 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor
return wrapper; return wrapper;
} }
public abstract double getNeeded(); public abstract boolean needsEnergy(ForgeDirection side);
public static class MekanismAcceptor extends EnergyAcceptorWrapper public static class MekanismAcceptor extends EnergyAcceptorWrapper
{ {
@ -88,9 +88,9 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor
} }
@Override @Override
public double getNeeded() public boolean needsEnergy(ForgeDirection side)
{ {
return acceptor.getMaxEnergy() - acceptor.getEnergy(); return acceptor.getMaxEnergy() - acceptor.getEnergy() > 0;
} }
} }
@ -136,9 +136,9 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor
} }
@Override @Override
public double getNeeded() public boolean needsEnergy(ForgeDirection side)
{ {
return fromRF(acceptor.getMaxEnergyStored(ForgeDirection.UNKNOWN) - acceptor.getEnergyStored(ForgeDirection.UNKNOWN)); return acceptor.getMaxEnergyStored(side) - acceptor.getEnergyStored(side) > 0 || acceptor.receiveEnergy(side, 1, true) > 0;
} }
public int toRF(double joules) public int toRF(double joules)
@ -192,19 +192,14 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor
} }
@Override @Override
public double getNeeded() public boolean needsEnergy(ForgeDirection side)
{ {
return fromEU(acceptor.getDemandedEnergy()); return acceptor.getDemandedEnergy() > 0;
} }
public double toEU(double joules) public double toEU(double joules)
{ {
return joules * general.TO_IC2; return joules * general.TO_IC2;
} }
public double fromEU(double eu)
{
return eu * general.FROM_IC2;
}
} }
} }