mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Make engines more compatible with other RF mods
This commit is contained in:
1 parent
ee46f4fee1
commit
fb7bf6d9fb
2 files changed
+14
-8
No files matched your search
@@ -169,6 +169,13 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
|
||||
return energyStorage.getEnergyStored() >= energyPerWork;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this can send energy to the target tile
|
||||
*/
|
||||
public boolean canSendEnergy(ForgeDirection orientation, TileEntity tile) {
|
||||
return sendEnergy(orientation, tile, Integer.MAX_VALUE, true) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends as much energy as it can to the tile at orientation.
|
||||
* For power sources. Ignores canExtract()
|
||||
@@ -176,7 +183,7 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
|
||||
* @return amount sent
|
||||
*/
|
||||
public int sendEnergy(ForgeDirection orientation, TileEntity tile) {
|
||||
return sendEnergy(orientation, tile, Integer.MAX_VALUE);
|
||||
return sendEnergy(orientation, tile, Integer.MAX_VALUE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,15 +192,15 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
|
||||
*
|
||||
* @return amount sent
|
||||
*/
|
||||
public int sendEnergy(ForgeDirection orientation, TileEntity tile, int amount) {
|
||||
public int sendEnergy(ForgeDirection orientation, TileEntity tile, int amount, boolean simulate) {
|
||||
int sent = 0;
|
||||
if (BlockUtil.isEnergyReceiver(orientation.getOpposite(), tile)) {
|
||||
IEnergyReceiver receptor = (IEnergyReceiver) tile;
|
||||
|
||||
int extractable = energyStorage.extractEnergy(amount, true);
|
||||
if (extractable > 0) {
|
||||
sent = receptor.receiveEnergy(orientation.getOpposite(), extractable, false);
|
||||
energyStorage.extractEnergy(sent, false);
|
||||
sent = receptor.receiveEnergy(orientation.getOpposite(), extractable, simulate);
|
||||
energyStorage.extractEnergy(sent, simulate);
|
||||
}
|
||||
}
|
||||
return sent;
|
||||
|
||||
Reference in new issue
Block a user