EnergyNetwork now only distributes demanded energy to acceptors instead of forcing transfer, should fix interaction issues

This commit is contained in:
aidancbrady 2016-03-06 13:51:11 -05:00
parent 1eff6ad6b8
commit 2db6fde118
2 changed files with 7 additions and 3 deletions

View file

@ -128,6 +128,7 @@ public class EnergyNetwork extends DynamicNetwork<EnergyAcceptorWrapper, EnergyN
} while(tryAgain); } while(tryAgain);
joulesTransmitted = sent; joulesTransmitted = sent;
return sent; return sent;
} }

View file

@ -103,7 +103,10 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor
@Override @Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount) public double transferEnergyToAcceptor(ForgeDirection side, double amount)
{ {
return fromRF(acceptor.receiveEnergy(side, toRF(amount), false)); int needed = acceptor.getMaxEnergyStored(side)-acceptor.getEnergyStored(side);
int transferred = acceptor.receiveEnergy(side, Math.min(needed, toRF(amount)), false);
return fromRF(transferred);
} }
@Override @Override
@ -135,7 +138,7 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor
@Override @Override
public boolean needsEnergy(ForgeDirection side) public boolean needsEnergy(ForgeDirection side)
{ {
return acceptor.getMaxEnergyStored(side) - acceptor.getEnergyStored(side) > 0 || acceptor.receiveEnergy(side, 1, true) > 0; return acceptor.receiveEnergy(side, 1, true) > 0;
} }
public int toRF(double joules) public int toRF(double joules)
@ -161,7 +164,7 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor
@Override @Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount) public double transferEnergyToAcceptor(ForgeDirection side, double amount)
{ {
return amount - fromEU(acceptor.injectEnergy(side, toEU(amount), 0)); return amount - fromEU(acceptor.injectEnergy(side, Math.min(acceptor.getDemandedEnergy(), toEU(amount)), 0));
} }
@Override @Override