Search in sources :

Example 1 with IClimateHousing

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;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) IClimateHousing(forestry.api.greenhouse.IClimateHousing)

Example 2 with IClimateHousing

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

Example 3 with IClimateHousing

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;
}
Also used : EnergyManager(forestry.energy.EnergyManager) IGreenhouseControllerInternal(forestry.greenhouse.multiblock.IGreenhouseControllerInternal) IErrorLogic(forestry.api.core.IErrorLogic) IClimateHousing(forestry.api.greenhouse.IClimateHousing)

Example 4 with IClimateHousing

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

Example 5 with IClimateHousing

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);
    }
}
Also used : EnergyManager(forestry.energy.EnergyManager) IGreenhouseControllerInternal(forestry.greenhouse.multiblock.IGreenhouseControllerInternal) IClimateHousing(forestry.api.greenhouse.IClimateHousing)

Aggregations

IClimateHousing (forestry.api.greenhouse.IClimateHousing)6 BlockPos (net.minecraft.util.math.BlockPos)3 EnergyManager (forestry.energy.EnergyManager)2 IGreenhouseControllerInternal (forestry.greenhouse.multiblock.IGreenhouseControllerInternal)2 IErrorLogic (forestry.api.core.IErrorLogic)1 IGreenhouseController (forestry.api.multiblock.IGreenhouseController)1 GreenhouseState (forestry.greenhouse.api.climate.GreenhouseState)1 IClimateContainer (forestry.greenhouse.api.climate.IClimateContainer)1 Position2D (forestry.greenhouse.api.greenhouse.Position2D)1 PacketGreenhouseData (forestry.greenhouse.network.packets.PacketGreenhouseData)1 World (net.minecraft.world.World)1