use of forestry.api.greenhouse.IClimateHousing in project ForestryMC by ForestryMC.
the class AltitudeModifier method modifyTarget.
@Override
public IClimateState modifyTarget(IClimateContainer container, IClimateState newState, IClimateState oldState, NBTTagCompound data) {
World world = container.getWorld();
IClimateHousing parent = container.getParent();
if (world.provider.isSurfaceWorld()) {
BlockPos position = parent.getCoordinates();
float modifier = (64 - position.getY()) / 64F;
float altitudeChange = modifier * TEMPERATURE_CHANGE;
data.setFloat("altitudeChange", altitudeChange);
newState = newState.addTemperature(altitudeChange);
}
return newState;
}
use of forestry.api.greenhouse.IClimateHousing in project ForestryMC by ForestryMC.
the class ClimateContainer method equals.
@Override
public boolean equals(Object obj) {
if (!(obj instanceof IClimateContainer)) {
return false;
}
IClimateContainer container = (IClimateContainer) obj;
IClimateHousing parent = container.getParent();
if (parent.getCoordinates() == null || this.parent.getCoordinates() == null) {
return false;
}
return this.parent.getCoordinates().equals(parent.getCoordinates());
}
use of forestry.api.greenhouse.IClimateHousing 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.api.greenhouse.IClimateHousing in project ForestryMC by ForestryMC.
the class GreenhouseProviderServer method create.
public void create() {
if (ready) {
GreenhouseState oldState = this.state;
storage.removeProviderFromChunks();
storage.clearBlocks(false);
createBlocks();
storage.addProviderToChunks();
if (!world.isRemote) {
IClimateHousing region = container.getParent();
BlockPos pos = region.getCoordinates();
if (pos != null) {
needReload = oldState != state;
NetworkUtil.sendNetworkPacket(new PacketGreenhouseData(pos, this), pos, world);
}
}
}
}
use of forestry.api.greenhouse.IClimateHousing 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);
}
}
Aggregations