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));
}
}
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();
}
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());
}
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;
}
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;
}
Aggregations