Search in sources :

Example 1 with IClimateSource

use of forestry.greenhouse.api.climate.IClimateSource in project ForestryMC by ForestryMC.

the class WallBlock method onCreate.

@Override
public void onCreate() {
    IClimateContainer container = provider.getClimateContainer();
    for (IClimateSourceOwner sourceOwner : GreenhouseManager.climateManager.getSources(provider.getWorld(), new Position2D(pos))) {
        IClimateSource source = sourceOwner.getClimateSource();
        sources.add(source);
        container.addClimateSource(source);
        source.onAdded(container);
    }
}
Also used : IClimateSourceOwner(forestry.greenhouse.api.climate.IClimateSourceOwner) IClimateContainer(forestry.greenhouse.api.climate.IClimateContainer) Position2D(forestry.greenhouse.api.greenhouse.Position2D) IClimateSource(forestry.greenhouse.api.climate.IClimateSource)

Example 2 with IClimateSource

use of forestry.greenhouse.api.climate.IClimateSource in project ForestryMC by ForestryMC.

the class CircuitClimateSource method onRemoval.

@Override
public void onRemoval(int slot, Object tile) {
    IClimateSourceOwner owner = getCircuitable(tile);
    if (owner == null) {
        return;
    }
    IClimateSource source = owner.getClimateSource();
    if (!(source instanceof IClimateSourceCircuitable)) {
        return;
    }
    ((IClimateSourceCircuitable) source).changeSourceConfig(type, -changeChange, -rangeChange, -energyChange);
}
Also used : IClimateSourceOwner(forestry.greenhouse.api.climate.IClimateSourceOwner) IClimateSource(forestry.greenhouse.api.climate.IClimateSource) IClimateSourceCircuitable(forestry.greenhouse.api.climate.IClimateSourceCircuitable)

Example 3 with IClimateSource

use of forestry.greenhouse.api.climate.IClimateSource in project ForestryMC by ForestryMC.

the class CircuitClimateSource method onInsertion.

@Override
public void onInsertion(int slot, Object tile) {
    IClimateSourceOwner owner = getCircuitable(tile);
    if (owner == null) {
        return;
    }
    IClimateSource source = owner.getClimateSource();
    if (!(source instanceof IClimateSourceCircuitable)) {
        return;
    }
    ((IClimateSourceCircuitable) source).changeSourceConfig(type, changeChange, rangeChange, energyChange);
}
Also used : IClimateSourceOwner(forestry.greenhouse.api.climate.IClimateSourceOwner) IClimateSource(forestry.greenhouse.api.climate.IClimateSource) IClimateSourceCircuitable(forestry.greenhouse.api.climate.IClimateSourceCircuitable)

Example 4 with IClimateSource

use of forestry.greenhouse.api.climate.IClimateSource in project ForestryMC by ForestryMC.

the class ClimateContainer method recalculateBoundaries.

@Override
public void recalculateBoundaries() {
    sizeModifier = Math.max(parent.getSize() / Config.climateSourceRange, 1.0D);
    float temperatureBoundaryUp = 0.0F;
    float humidityBoundaryUp = 0.0F;
    float temperatureBoundaryDown = 0.0F;
    float humidityBoundaryDown = 0.0F;
    for (IClimateSource source : sources) {
        if (source.affectClimateType(ClimateType.HUMIDITY)) {
            humidityBoundaryUp += source.getBoundaryModifier(ClimateType.HUMIDITY, true);
            humidityBoundaryDown += source.getBoundaryModifier(ClimateType.HUMIDITY, false);
        }
        if (source.affectClimateType(ClimateType.TEMPERATURE)) {
            temperatureBoundaryUp += source.getBoundaryModifier(ClimateType.TEMPERATURE, true);
            temperatureBoundaryDown += source.getBoundaryModifier(ClimateType.TEMPERATURE, false);
        }
    }
    if (temperatureBoundaryUp != 0) {
        temperatureBoundaryUp /= sizeModifier;
    }
    if (temperatureBoundaryDown != 0) {
        temperatureBoundaryDown /= sizeModifier;
    }
    if (humidityBoundaryUp != 0) {
        humidityBoundaryUp /= sizeModifier;
    }
    if (humidityBoundaryDown != 0) {
        humidityBoundaryDown /= sizeModifier;
    }
    boundaryUp = parent.getDefaultClimate().add(ClimateStates.of(temperatureBoundaryUp, humidityBoundaryUp));
    boundaryDown = parent.getDefaultClimate().remove(ClimateStates.of(temperatureBoundaryDown, humidityBoundaryDown));
}
Also used : IClimateSource(forestry.greenhouse.api.climate.IClimateSource)

Example 5 with IClimateSource

use of forestry.greenhouse.api.climate.IClimateSource in project ForestryMC by ForestryMC.

the class WallBlock method onRemove.

@Override
public void onRemove() {
    IClimateContainer container = provider.getClimateContainer();
    Iterator<IClimateSource> iterator = sources.iterator();
    while (iterator.hasNext()) {
        IClimateSource source = iterator.next();
        source.onRemoved(container);
        container.removeClimateSource(source);
        iterator.remove();
    }
}
Also used : IClimateContainer(forestry.greenhouse.api.climate.IClimateContainer) IClimateSource(forestry.greenhouse.api.climate.IClimateSource)

Aggregations

IClimateSource (forestry.greenhouse.api.climate.IClimateSource)6 IClimateSourceOwner (forestry.greenhouse.api.climate.IClimateSourceOwner)3 IClimateContainer (forestry.greenhouse.api.climate.IClimateContainer)2 IClimateSourceCircuitable (forestry.greenhouse.api.climate.IClimateSourceCircuitable)2 IClimateState (forestry.api.climate.IClimateState)1 Position2D (forestry.greenhouse.api.greenhouse.Position2D)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1