Search in sources :

Example 6 with IBeeModifier

use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.

the class BeeMutation method getChance.

@Override
public float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1) {
    World world = housing.getWorldObj();
    BlockPos housingPos = housing.getCoordinates();
    float processedChance = super.getChance(world, housingPos, allele0, allele1, genome0, genome1, housing);
    if (processedChance <= 0) {
        return 0;
    }
    IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
    IBeeModifier beeModeModifier = BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier();
    processedChance *= beeHousingModifier.getMutationModifier(genome0, genome1, processedChance);
    processedChance *= beeModeModifier.getMutationModifier(genome0, genome1, processedChance);
    return processedChance;
}
Also used : IBeeModifier(forestry.api.apiculture.IBeeModifier) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 7 with IBeeModifier

use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.

the class Bee method age.

@Override
public void age(World world, float housingLifespanModifier) {
    IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
    IBeeModifier beeModifier = mode.getBeeModifier();
    float finalModifier = housingLifespanModifier * beeModifier.getLifespanModifier(genome, mate, housingLifespanModifier);
    super.age(world, finalModifier);
}
Also used : IBeeModifier(forestry.api.apiculture.IBeeModifier) IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode)

Example 8 with IBeeModifier

use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.

the class TileApiary method getBeeModifiers.

@Override
public Collection<IBeeModifier> getBeeModifiers() {
    List<IBeeModifier> beeModifiers = new ArrayList<>();
    beeModifiers.add(beeModifier);
    for (Tuple<IHiveFrame, ItemStack> frame : inventory.getFrames()) {
        IHiveFrame hiveFrame = frame.getFirst();
        ItemStack stack = frame.getSecond();
        IBeeModifier beeModifier = hiveFrame.getBeeModifier(stack);
        beeModifiers.add(beeModifier);
    }
    return beeModifiers;
}
Also used : IHiveFrame(forestry.api.apiculture.IHiveFrame) IBeeModifier(forestry.api.apiculture.IBeeModifier) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 9 with IBeeModifier

use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.

the class AlvearyController method getTemperature.

@Override
public EnumTemperature getTemperature() {
    IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(this);
    Biome biome = getBiome();
    if (beeModifier.isHellish() || BiomeHelper.isBiomeHellish(biome)) {
        if (tempChange >= 0) {
            return EnumTemperature.HELLISH;
        }
    }
    return EnumTemperature.getFromValue(getExactTemperature());
}
Also used : IBeeModifier(forestry.api.apiculture.IBeeModifier) Biome(net.minecraft.world.biome.Biome)

Example 10 with IBeeModifier

use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.

the class Bee method pollinateRandom.

@Override
public boolean pollinateRandom(IBeeHousing housing, IIndividual pollen) {
    IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
    int chance = (int) (genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
    World world = housing.getWorldObj();
    Random random = world.rand;
    // Correct speed
    if (random.nextInt(100) >= chance) {
        return false;
    }
    Vec3i area = getArea(genome, beeModifier);
    Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
    BlockPos housingPos = housing.getCoordinates();
    for (int i = 0; i < 30; i++) {
        BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area);
        BlockPos posBlock = VectUtil.add(housingPos, randomPos, offset);
        ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock);
        if (checkPollinatable == null) {
            continue;
        }
        if (!genome.getFlowerProvider().isAcceptedPollinatable(world, checkPollinatable)) {
            continue;
        }
        if (!checkPollinatable.canMateWith(pollen)) {
            continue;
        }
        IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwner(), world, posBlock, Config.pollinateVanillaTrees);
        if (realPollinatable != null) {
            realPollinatable.mateWith(pollen);
            return true;
        }
    }
    return false;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) ICheckPollinatable(forestry.api.genetics.ICheckPollinatable) IBeeModifier(forestry.api.apiculture.IBeeModifier) Random(java.util.Random) IPollinatable(forestry.api.genetics.IPollinatable) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Aggregations

IBeeModifier (forestry.api.apiculture.IBeeModifier)16 BlockPos (net.minecraft.util.math.BlockPos)7 World (net.minecraft.world.World)7 Vec3i (net.minecraft.util.math.Vec3i)6 Random (java.util.Random)3 ItemStack (net.minecraft.item.ItemStack)3 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)2 IBeeListener (forestry.api.apiculture.IBeeListener)2 IBeekeepingMode (forestry.api.apiculture.IBeekeepingMode)2 IHiveFrame (forestry.api.apiculture.IHiveFrame)2 ICheckPollinatable (forestry.api.genetics.ICheckPollinatable)2 IAlvearyComponent (forestry.api.multiblock.IAlvearyComponent)2 AlvearyBeeModifier (forestry.apiculture.AlvearyBeeModifier)2 ArrayList (java.util.ArrayList)2 EnumHumidity (forestry.api.core.EnumHumidity)1 EnumTemperature (forestry.api.core.EnumTemperature)1 IErrorState (forestry.api.core.IErrorState)1 EnumTolerance (forestry.api.genetics.EnumTolerance)1 IFlowerProvider (forestry.api.genetics.IFlowerProvider)1 IIndividual (forestry.api.genetics.IIndividual)1