Search in sources :

Example 1 with EnumHumidity

use of forestry.api.core.EnumHumidity in project ForestryMC by ForestryMC.

the class ItemHabitatLocator method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, @Nullable World world, List<String> list, ITooltipFlag flag) {
    super.addInformation(itemstack, world, list, flag);
    Minecraft minecraft = Minecraft.getMinecraft();
    if (world != null && minecraft.player != null) {
        EntityPlayerSP player = minecraft.player;
        Biome currentBiome = player.world.getBiome(player.getPosition());
        float temperatureValue = ClimateUtil.getTemperature(world, player.getPosition());
        EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
        EnumHumidity humidity = EnumHumidity.getFromValue(ClimateUtil.getHumidity(world, player.getPosition()));
        list.add(Translator.translateToLocal("for.gui.currentBiome") + ": " + currentBiome.getBiomeName());
        list.add(Translator.translateToLocal("for.gui.temperature") + ": " + AlleleManager.climateHelper.toDisplay(temperature));
        list.add(Translator.translateToLocal("for.gui.humidity") + ": " + AlleleManager.climateHelper.toDisplay(humidity));
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) EnumHumidity(forestry.api.core.EnumHumidity) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) EnumTemperature(forestry.api.core.EnumTemperature) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with EnumHumidity

use of forestry.api.core.EnumHumidity in project ForestryMC by ForestryMC.

the class JubilanceDefault method isJubilant.

@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
    EnumTemperature temperature = housing.getTemperature();
    EnumHumidity humidity = housing.getHumidity();
    return temperature == species.getTemperature() && humidity == species.getHumidity();
}
Also used : EnumHumidity(forestry.api.core.EnumHumidity) EnumTemperature(forestry.api.core.EnumTemperature)

Example 3 with EnumHumidity

use of forestry.api.core.EnumHumidity in project ForestryMC by ForestryMC.

the class Butterfly method isAcceptedEnvironment.

private boolean isAcceptedEnvironment(World world, int x, int y, int z) {
    BlockPos pos = new BlockPos(x, y, z);
    Biome biome = world.getBiome(pos);
    EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, world, pos);
    EnumHumidity biomeHumidity = EnumHumidity.getFromValue(ClimateUtil.getHumidity(world, pos));
    return AlleleManager.climateHelper.isWithinLimits(biomeTemperature, biomeHumidity, getGenome().getPrimary().getTemperature(), getGenome().getToleranceTemp(), getGenome().getPrimary().getHumidity(), getGenome().getToleranceHumid());
}
Also used : Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos) EnumHumidity(forestry.api.core.EnumHumidity) EnumTemperature(forestry.api.core.EnumTemperature)

Example 4 with EnumHumidity

use of forestry.api.core.EnumHumidity in project ForestryMC by ForestryMC.

the class Butterfly method getCanGrow.

@Override
public Set<IErrorState> getCanGrow(IButterflyNursery nursery, @Nullable IButterflyCocoon cocoon) {
    World world = nursery.getWorldObj();
    Set<IErrorState> errorStates = new HashSet<>();
    // / And finally climate check
    IAlleleButterflySpecies species = genome.getPrimary();
    EnumTemperature actualTemperature = nursery.getTemperature();
    EnumTemperature baseTemperature = species.getTemperature();
    EnumTolerance toleranceTemperature = genome.getToleranceTemp();
    EnumHumidity actualHumidity = nursery.getHumidity();
    EnumHumidity baseHumidity = species.getHumidity();
    EnumTolerance toleranceHumidity = genome.getToleranceHumid();
    ClimateUtil.addClimateErrorStates(actualTemperature, actualHumidity, baseTemperature, toleranceTemperature, baseHumidity, toleranceHumidity, errorStates);
    return errorStates;
}
Also used : IErrorState(forestry.api.core.IErrorState) EnumTolerance(forestry.api.genetics.EnumTolerance) EnumHumidity(forestry.api.core.EnumHumidity) World(net.minecraft.world.World) HashSet(java.util.HashSet) IAlleleButterflySpecies(forestry.api.lepidopterology.IAlleleButterflySpecies) EnumTemperature(forestry.api.core.EnumTemperature)

Example 5 with EnumHumidity

use of forestry.api.core.EnumHumidity in project ForestryMC by ForestryMC.

the class Bee method getCanWork.

@Override
public Set<IErrorState> getCanWork(IBeeHousing housing) {
    World world = housing.getWorldObj();
    Set<IErrorState> errorStates = new HashSet<>();
    IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
    // / Rain needs tolerant flyers
    if (housing.isRaining() && !canFlyInRain(beeModifier)) {
        errorStates.add(EnumErrorCode.IS_RAINING);
    }
    // / Night or darkness requires nocturnal species
    if (world.isDaytime()) {
        if (!canWorkDuringDay()) {
            errorStates.add(EnumErrorCode.NOT_NIGHT);
        }
    } else {
        if (!canWorkAtNight(beeModifier)) {
            errorStates.add(EnumErrorCode.NOT_DAY);
        }
    }
    if (housing.getBlockLightValue() > Constants.APIARY_MIN_LEVEL_LIGHT) {
        if (!canWorkDuringDay()) {
            errorStates.add(EnumErrorCode.NOT_GLOOMY);
        }
    } else {
        if (!canWorkAtNight(beeModifier)) {
            errorStates.add(EnumErrorCode.NOT_BRIGHT);
        }
    }
    // / Check for the sky, except if in hell
    if (!world.provider.isNether()) {
        if (!housing.canBlockSeeTheSky() && !canWorkUnderground(beeModifier)) {
            errorStates.add(EnumErrorCode.NO_SKY);
        }
    }
    // / And finally climate check
    IAlleleBeeSpecies species = genome.getPrimary();
    {
        EnumTemperature actualTemperature = housing.getTemperature();
        EnumTemperature beeBaseTemperature = species.getTemperature();
        EnumTolerance beeToleranceTemperature = genome.getToleranceTemp();
        if (!AlleleManager.climateHelper.isWithinLimits(actualTemperature, beeBaseTemperature, beeToleranceTemperature)) {
            if (beeBaseTemperature.ordinal() > actualTemperature.ordinal()) {
                errorStates.add(EnumErrorCode.TOO_COLD);
            } else {
                errorStates.add(EnumErrorCode.TOO_HOT);
            }
        }
    }
    {
        EnumHumidity actualHumidity = housing.getHumidity();
        EnumHumidity beeBaseHumidity = species.getHumidity();
        EnumTolerance beeToleranceHumidity = genome.getToleranceHumid();
        if (!AlleleManager.climateHelper.isWithinLimits(actualHumidity, beeBaseHumidity, beeToleranceHumidity)) {
            if (beeBaseHumidity.ordinal() > actualHumidity.ordinal()) {
                errorStates.add(EnumErrorCode.TOO_ARID);
            } else {
                errorStates.add(EnumErrorCode.TOO_HUMID);
            }
        }
    }
    return errorStates;
}
Also used : IAlleleBeeSpecies(forestry.api.apiculture.IAlleleBeeSpecies) IBeeModifier(forestry.api.apiculture.IBeeModifier) IErrorState(forestry.api.core.IErrorState) EnumTolerance(forestry.api.genetics.EnumTolerance) EnumHumidity(forestry.api.core.EnumHumidity) World(net.minecraft.world.World) HashSet(java.util.HashSet) EnumTemperature(forestry.api.core.EnumTemperature)

Aggregations

EnumHumidity (forestry.api.core.EnumHumidity)11 EnumTemperature (forestry.api.core.EnumTemperature)9 Biome (net.minecraft.world.biome.Biome)5 IErrorState (forestry.api.core.IErrorState)3 EnumTolerance (forestry.api.genetics.EnumTolerance)3 HashSet (java.util.HashSet)3 BlockPos (net.minecraft.util.math.BlockPos)3 World (net.minecraft.world.World)3 IAlleleButterflySpecies (forestry.api.lepidopterology.IAlleleButterflySpecies)2 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)1 IBeeGenome (forestry.api.apiculture.IBeeGenome)1 IBeeModifier (forestry.api.apiculture.IBeeModifier)1 ITreeGenome (forestry.api.arboriculture.ITreeGenome)1 ArrayList (java.util.ArrayList)1 Minecraft (net.minecraft.client.Minecraft)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1