Search in sources :

Example 11 with EnumTemperature

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

the class ClimateGrowthProvider method isBiomeValid.

@Override
public boolean isBiomeValid(ITree tree, Biome biome) {
    EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome);
    EnumHumidity biomeHumidity = EnumHumidity.getFromValue(biome.getRainfall());
    ITreeGenome genome = tree.getGenome();
    if (temperature == null) {
        temperature = genome.getPrimary().getTemperature();
    }
    if (humidity == null) {
        humidity = genome.getPrimary().getHumidity();
    }
    return AlleleManager.climateHelper.isWithinLimits(biomeTemperature, biomeHumidity, temperature, temperatureTolerance, humidity, humidityTolerance);
}
Also used : EnumHumidity(forestry.api.core.EnumHumidity) ITreeGenome(forestry.api.arboriculture.ITreeGenome) EnumTemperature(forestry.api.core.EnumTemperature)

Example 12 with EnumTemperature

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

the class AlleleEffectSnowing 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 = getModifiedArea(genome, housing);
    Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
    for (int i = 0; i < 1; i++) {
        BlockPos randomPos = VectUtil.getRandomPositionInArea(world.rand, area);
        BlockPos posBlock = randomPos.add(housing.getCoordinates()).add(offset);
        // Put snow on the ground
        if (world.isBlockLoaded(posBlock) && world.isSideSolid(posBlock.down(), EnumFacing.UP, false)) {
            IBlockState state = world.getBlockState(posBlock);
            Block block = state.getBlock();
            if (block == Blocks.SNOW_LAYER) {
                Integer layers = state.getValue(BlockSnow.LAYERS);
                if (layers < 7) {
                    IBlockState moreSnow = state.withProperty(BlockSnow.LAYERS, layers + 1);
                    world.setBlockState(posBlock, moreSnow);
                } else {
                    world.setBlockState(posBlock, Blocks.SNOW.getDefaultState());
                }
            } else if (block.isReplaceable(world, posBlock)) {
                world.setBlockState(posBlock, Blocks.SNOW_LAYER.getDefaultState());
            }
        }
    }
    return storedData;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EnumTemperature(forestry.api.core.EnumTemperature)

Example 13 with EnumTemperature

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

the class ClimateLedger method draw.

@Override
public void draw(int x, int y) {
    EnumTemperature temperature = tile.getTemperature();
    // Draw background
    drawBackground(x, y);
    // Draw icon
    drawSprite(temperature.getSprite(), x + 3, y + 4);
    if (!isFullyOpened()) {
        return;
    }
    drawHeader(Translator.translateToLocal("for.gui.climate"), x + 22, y + 8);
    drawSubheader(Translator.translateToLocal("for.gui.temperature") + ':', x + 22, y + 20);
    drawText(AlleleManager.climateHelper.toDisplay(temperature) + ' ' + StringUtil.floatAsPercent(tile.getExactTemperature()), x + 22, y + 32);
    drawSubheader(Translator.translateToLocal("for.gui.humidity") + ':', x + 22, y + 44);
    drawText(AlleleManager.climateHelper.toDisplay(tile.getHumidity()) + ' ' + StringUtil.floatAsPercent(tile.getExactHumidity()), x + 22, y + 56);
}
Also used : EnumTemperature(forestry.api.core.EnumTemperature)

Example 14 with EnumTemperature

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

the class GardeningManager method canTolerate.

@Override
public boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos) {
    if (flower == null) {
        return false;
    }
    IBlockState soil = world.getBlockState(pos.down());
    Biome biome = world.getBiome(pos);
    EnumAcidity acidity = soil.getValue(BlockSoil.ACIDITY);
    EnumMoisture moisture = soil.getValue(BlockSoil.MOISTURE);
    EnumTemperature temperature = EnumTemperature.getFromValue(biome.getTemperature());
    return canTolerate(flower, acidity, moisture, temperature);
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) IBlockState(net.minecraft.block.state.IBlockState) Biome(net.minecraft.world.biome.Biome) EnumAcidity(binnie.botany.api.gardening.EnumAcidity) 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