Search in sources :

Example 6 with IClimateState

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);
    }
}
Also used : IClimateState(forestry.api.climate.IClimateState)

Example 7 with IClimateState

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;
}
Also used : IClimateState(forestry.api.climate.IClimateState) World(net.minecraft.world.World)

Example 8 with IClimateState

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()));
    }
}
Also used : PacketSelectClimateTargeted(forestry.greenhouse.network.packets.PacketSelectClimateTargeted) IClimateState(forestry.api.climate.IClimateState) BlockPos(net.minecraft.util.math.BlockPos)

Example 9 with IClimateState

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);
}
Also used : IClimateState(forestry.api.climate.IClimateState)

Example 10 with IClimateState

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());
        }
    }
}
Also used : IClimateModifier(forestry.greenhouse.api.climate.IClimateModifier) PacketUpdateClimate(forestry.core.network.packets.PacketUpdateClimate) IClimateState(forestry.api.climate.IClimateState) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

IClimateState (forestry.api.climate.IClimateState)16 IClimateContainer (forestry.greenhouse.api.climate.IClimateContainer)4 BlockPos (net.minecraft.util.math.BlockPos)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 IGreenhouseBlock (forestry.greenhouse.api.greenhouse.IGreenhouseBlock)2 IGreenhouseControllerInternal (forestry.greenhouse.multiblock.IGreenhouseControllerInternal)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 IGreenhouseComponent (forestry.api.multiblock.IGreenhouseComponent)1 IColoredBlock (forestry.core.blocks.IColoredBlock)1 PacketUpdateClimate (forestry.core.network.packets.PacketUpdateClimate)1 IClimateModifier (forestry.greenhouse.api.climate.IClimateModifier)1 IClimateSource (forestry.greenhouse.api.climate.IClimateSource)1 IGreenhouseClimateManager (forestry.greenhouse.api.climate.IGreenhouseClimateManager)1 IGreenhouseProvider (forestry.greenhouse.api.greenhouse.IGreenhouseProvider)1 GuiGreenhouse (forestry.greenhouse.gui.GuiGreenhouse)1 PacketSelectClimateTargeted (forestry.greenhouse.network.packets.PacketSelectClimateTargeted)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockColors (net.minecraft.client.renderer.color.BlockColors)1 ItemStack (net.minecraft.item.ItemStack)1