use of forestry.api.climate.IClimateState in project ForestryMC by ForestryMC.
the class ClimateSourceWindow method beforeWork.
@Override
protected void beforeWork() {
IClimateState currentState = container.getState();
IClimateState biomeState = ForestryAPI.climateManager.getBiomeState(owner.getWorld(), owner.getPos());
if (biomeState.getTemperature() > currentState.getTemperature()) {
setTemperatureMode(ClimateSourceMode.POSITIVE);
} else if (biomeState.getTemperature() < currentState.getTemperature()) {
setTemperatureMode(ClimateSourceMode.NEGATIVE);
} else {
setTemperatureMode(ClimateSourceMode.NONE);
}
if (biomeState.getHumidity() > currentState.getHumidity()) {
setHumidityMode(ClimateSourceMode.POSITIVE);
} else if (biomeState.getHumidity() < currentState.getHumidity()) {
setHumidityMode(ClimateSourceMode.NEGATIVE);
} else {
setHumidityMode(ClimateSourceMode.NONE);
}
}
use of forestry.api.climate.IClimateState in project ForestryMC by ForestryMC.
the class WeatherModifier method modifyTarget.
@Override
public IClimateState modifyTarget(IClimateContainer container, IClimateState newState, IClimateState oldState, NBTTagCompound data) {
World world = container.getWorld();
IClimateState defaultClimate = container.getParent().getDefaultClimate();
int rainTime = data.getInteger("raintime");
if (world.isRaining()) {
if (rainTime < RAIN_TIME) {
rainTime++;
}
} else {
if (rainTime > 0) {
rainTime--;
}
}
if (rainTime > 0) {
float rainModifier = (float) rainTime / (float) RAIN_TIME;
float temperatureChange = rainModifier * RAIN_TEMPERATURE_CHANGE;
if (defaultClimate.getTemperature() <= 0.35F) {
temperatureChange *= SNOW_MODIFIER;
}
float humidityChange = rainModifier * RAIN_HUMIDITY_CHANGE;
data.setFloat("rainTemperatureChange", temperatureChange);
data.setFloat("rainHumidityChange", humidityChange);
newState = newState.addHumidity(humidityChange);
newState = newState.addTemperature(temperatureChange);
}
data.setInteger("raintime", rainTime);
return newState;
}
use of forestry.api.climate.IClimateState in project ForestryMC by ForestryMC.
the class GuiGreenhouse method sendNetworkUpdate.
public void sendNetworkUpdate() {
IClimateState climateState = container.getTargetedState();
if (climateState.isPresent()) {
BlockPos pos = controller.getCoordinates();
float temp = temperaturePanel.parseValue();
float hum = humidityPanel.parseValue();
setClimate(container, temp, hum);
NetworkUtil.sendToServer(new PacketSelectClimateTargeted(pos, container.getTargetedState()));
}
}
use of forestry.api.climate.IClimateState in project Binnie by ForestryMC.
the class GardeningManager method getBiomePH.
@Override
public float getBiomePH(World world, BlockPos pos) {
IClimateState info = ForestryAPI.climateManager.getClimateState(world, pos);
double humidity = info.getHumidity();
double temperature = info.getTemperature();
return (float) (-3.0 * (humidity - 0.5) + 0.5 * (temperature - 0.699999988079071) * (temperature - 0.699999988079071) + 0.02f * (pos.getY() - 64) - 0.15000000596046448);
}
use of forestry.api.climate.IClimateState in project ForestryMC by ForestryMC.
the class ClimateContainer method updateClimate.
@Override
public void updateClimate(int ticks) {
if (ticks % getTickDelay() == 0) {
IClimateState oldState = state.copy(ClimateStateType.DEFAULT);
state = parent.getDefaultClimate().copy(ClimateStateType.EXTENDED);
for (IClimateModifier modifier : GreenhouseClimateManager.getInstance().getModifiers()) {
state = modifier.modifyTarget(this, state, oldState, modifierData).copy(ClimateStateType.EXTENDED);
}
if (!state.equals(oldState)) {
BlockPos coordinates = parent.getCoordinates();
NetworkUtil.sendNetworkPacket(new PacketUpdateClimate(coordinates, this), coordinates, parent.getWorldObj());
}
}
}
Aggregations