use of forestry.energy.EnergyManager in project ForestryMC by ForestryMC.
the class ClimateSourceClimatiser method canWork.
@Override
public boolean canWork(IClimateState currentState, ClimateSourceType oppositeType) {
IClimateHousing region = container.getParent();
if (region instanceof IGreenhouseControllerInternal) {
IGreenhouseControllerInternal controller = (IGreenhouseControllerInternal) region;
IErrorLogic errorLogic = owner.getErrorLogic();
EnergyManager energyManager = controller.getEnergyManager();
if (energyManager.extractEnergy((int) (ENERGY_PER_OPERATION * getEnergyModifier(currentState, oppositeType)), true) > 0) {
owner.setActive(true);
errorLogic.setCondition(false, EnumErrorCode.NO_POWER);
return true;
} else {
owner.setActive(false);
errorLogic.setCondition(true, EnumErrorCode.NO_POWER);
return false;
}
}
if (owner.isActive()) {
owner.setActive(false);
}
return false;
}
use of forestry.energy.EnergyManager in project ForestryMC by ForestryMC.
the class ContainerTile method onGuiEnergy.
@SideOnly(Side.CLIENT)
public void onGuiEnergy(int energyStored) {
if (tile instanceof IPowerHandler) {
EnergyManager energyManager = ((IPowerHandler) tile).getEnergyManager();
energyManager.setEnergyStored(energyStored);
}
}
use of forestry.energy.EnergyManager in project ForestryMC by ForestryMC.
the class ClimateSourceClimatiser method removeResources.
@Override
protected void removeResources(IClimateState currentState, ClimateSourceType oppositeType) {
IClimateHousing region = container.getParent();
if (region instanceof IGreenhouseControllerInternal) {
IGreenhouseControllerInternal controller = (IGreenhouseControllerInternal) region;
EnergyManager energyManager = controller.getEnergyManager();
energyManager.extractEnergy((int) (ENERGY_PER_OPERATION * getEnergyModifier(currentState, oppositeType)), false);
}
}
use of forestry.energy.EnergyManager in project ForestryMC by ForestryMC.
the class ContainerTile method detectAndSendChanges.
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (tile instanceof IErrorLogicSource) {
IErrorLogicSource errorLogicSource = (IErrorLogicSource) tile;
ImmutableSet<IErrorState> errorStates = errorLogicSource.getErrorLogic().getErrorStates();
if (previousErrorStates == null || !errorStates.equals(previousErrorStates)) {
PacketErrorUpdate packet = new PacketErrorUpdate(tile, errorLogicSource);
sendPacketToListeners(packet);
}
previousErrorStates = errorStates;
}
if (tile instanceof IPowerHandler) {
EnergyManager energyManager = ((IPowerHandler) tile).getEnergyManager();
int energyManagerData = energyManager.getEnergyStored();
if (energyManagerData != previousEnergyManagerData) {
PacketGuiEnergy packet = new PacketGuiEnergy(windowId, energyManagerData);
sendPacketToListeners(packet);
previousEnergyManagerData = energyManagerData;
}
}
if (tile instanceof TilePowered) {
boolean guiNeedsUpdate = false;
TilePowered tilePowered = (TilePowered) tile;
int workCounter = tilePowered.getWorkCounter();
if (workCounter != previousWorkCounter) {
guiNeedsUpdate = true;
previousWorkCounter = workCounter;
}
int ticksPerWorkCycle = tilePowered.getTicksPerWorkCycle();
if (ticksPerWorkCycle != previousTicksPerWorkCycle) {
guiNeedsUpdate = true;
previousTicksPerWorkCycle = ticksPerWorkCycle;
}
if (guiNeedsUpdate) {
PacketGuiUpdate packet = new PacketGuiUpdate(tilePowered);
sendPacketToListeners(packet);
}
}
}
Aggregations