Tweak energynet logic a bit to safeguard against overly high tiers of IC2 acceptor and things that implement everything but with only one working.
Should fix AE2 EU P2P tunnel support.
This commit is contained in:
parent
3d1b256632
commit
1d61c3d4e8
1 changed files with 23 additions and 10 deletions
|
@ -201,21 +201,26 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
if(acceptor instanceof IStrictEnergyAcceptor)
|
||||
{
|
||||
sent += ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending);
|
||||
double used = ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending);
|
||||
sent += used;
|
||||
if(used > 0) continue;
|
||||
}
|
||||
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
|
||||
if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
|
||||
{
|
||||
IEnergyHandler handler = (IEnergyHandler)acceptor;
|
||||
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(currentSending*Mekanism.TO_TE), false);
|
||||
sent += used*Mekanism.FROM_TE;
|
||||
if(used > 0) continue;
|
||||
}
|
||||
else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink)
|
||||
if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink)
|
||||
{
|
||||
double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(((IEnergySink) acceptor).getSinkTier())*Mekanism.FROM_IC2);
|
||||
double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(Math.min(((IEnergySink) acceptor).getSinkTier(), 8))*Mekanism.FROM_IC2);
|
||||
toSend = Math.min(toSend, ((IEnergySink)acceptor).getDemandedEnergy()*Mekanism.FROM_IC2);
|
||||
sent += (toSend - (((IEnergySink)acceptor).injectEnergy(side.getOpposite(), toSend*Mekanism.TO_IC2, 0)*Mekanism.FROM_IC2));
|
||||
double used = toSend - (((IEnergySink)acceptor).injectEnergy(side.getOpposite(), toSend*Mekanism.TO_IC2, 0)*Mekanism.FROM_IC2);
|
||||
sent += used;
|
||||
if(used > 0) continue;
|
||||
}
|
||||
else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor)
|
||||
if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor)
|
||||
{
|
||||
PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite());
|
||||
|
||||
|
@ -223,6 +228,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
double toSend = receiver.receiveEnergy(Type.PIPE, (float)(Math.min(receiver.powerRequest(), currentSending*Mekanism.TO_BC)), side.getOpposite());
|
||||
sent += toSend*Mekanism.FROM_BC;
|
||||
if(toSend > 0) continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,10 +266,11 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
if(handler.getMaxEnergy() - handler.getEnergy() > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
|
||||
if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
|
||||
{
|
||||
IEnergyHandler handler = (IEnergyHandler)acceptor;
|
||||
|
||||
|
@ -272,22 +279,27 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0 || handler.receiveEnergy(side.getOpposite(), 1, true) > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink)
|
||||
if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink)
|
||||
{
|
||||
IEnergySink handler = (IEnergySink)acceptor;
|
||||
|
||||
if(handler.acceptsEnergyFrom(null, side.getOpposite()))
|
||||
{
|
||||
if(Math.min((handler.getDemandedEnergy()*Mekanism.FROM_IC2), (EnergyNet.instance.getPowerFromTier(handler.getSinkTier())*Mekanism.FROM_IC2)) > 0)
|
||||
double demanded = handler.getDemandedEnergy()*Mekanism.FROM_IC2;
|
||||
int tier = Math.min(handler.getSinkTier(), 8);
|
||||
double max = EnergyNet.instance.getPowerFromTier(tier)*Mekanism.FROM_IC2;
|
||||
if(Math.min(demanded, max) > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor)
|
||||
if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor)
|
||||
{
|
||||
IPowerReceptor handler = (IPowerReceptor)acceptor;
|
||||
|
||||
|
@ -301,6 +313,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
}
|
||||
|
||||
toReturn.add(acceptor);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue