Search in sources :

Example 1 with EnumTemperature

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

the class AlleleEffectGlacial method doEffectThrottled.

@Override
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    World world = housing.getWorldObj();
    EnumTemperature temp = housing.getTemperature();
    switch(temp) {
        case HELLISH:
        case HOT:
        case WARM:
            return storedData;
        default:
    }
    Vec3i area = genome.getTerritory();
    Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
    BlockPos housingCoords = housing.getCoordinates();
    for (int i = 0; i < 10; i++) {
        BlockPos randomPos = VectUtil.getRandomPositionInArea(world.rand, area);
        BlockPos posBlock = VectUtil.add(randomPos, housingCoords, offset);
        // Freeze water
        if (world.isBlockLoaded(posBlock)) {
            Block block = world.getBlockState(posBlock).getBlock();
            if (block == Blocks.WATER) {
                if (world.isAirBlock(new BlockPos(posBlock.getX(), posBlock.getY() + 1, posBlock.getZ()))) {
                    world.setBlockState(posBlock, Blocks.ICE.getDefaultState());
                }
            }
        }
    }
    return storedData;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EnumTemperature(forestry.api.core.EnumTemperature)

Example 2 with EnumTemperature

use of forestry.api.core.EnumTemperature 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 3 with EnumTemperature

use of forestry.api.core.EnumTemperature 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 4 with EnumTemperature

use of forestry.api.core.EnumTemperature 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 5 with EnumTemperature

use of forestry.api.core.EnumTemperature 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)

Aggregations

EnumTemperature (forestry.api.core.EnumTemperature)14 EnumHumidity (forestry.api.core.EnumHumidity)9 World (net.minecraft.world.World)5 Biome (net.minecraft.world.biome.Biome)5 BlockPos (net.minecraft.util.math.BlockPos)4 IErrorState (forestry.api.core.IErrorState)3 EnumTolerance (forestry.api.genetics.EnumTolerance)3 HashSet (java.util.HashSet)3 IAlleleButterflySpecies (forestry.api.lepidopterology.IAlleleButterflySpecies)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 Vec3i (net.minecraft.util.math.Vec3i)2 EnumAcidity (binnie.botany.api.gardening.EnumAcidity)1 EnumMoisture (binnie.botany.api.gardening.EnumMoisture)1 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