mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +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
@@ -129,17 +129,16 @@ public abstract class Engine extends TileBase implements IEnergyConnection, IAct
|
||||
|
||||
progress += pistonSpeedServer;
|
||||
|
||||
energyManager.sendEnergy(getOrientation(), tile);
|
||||
|
||||
if (progress > 0.25 && stagePiston == 1) {
|
||||
stagePiston = 2;
|
||||
|
||||
energyManager.sendEnergy(getOrientation(), tile);
|
||||
|
||||
} else if (progress >= 0.5) {
|
||||
progress = 0;
|
||||
stagePiston = 0;
|
||||
}
|
||||
} else if (enabledRedstone && BlockUtil.isEnergyReceiver(getOrientation().getOpposite(), tile)) {
|
||||
if (energyManager.getEnergyStored(getOrientation()) > 0) {
|
||||
if (energyManager.canSendEnergy(getOrientation(), tile)) {
|
||||
stagePiston = 1; // If we can transfer energy, start running
|
||||
setActive(true);
|
||||
} else {
|
||||
|
||||
@@ -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