Search in sources :

Example 11 with IBeeModifier

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

the class Bee method retrievePollen.

/* FLOWERS */
@Override
@Nullable
public IIndividual retrievePollen(IBeeHousing housing) {
    IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
    int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
    World world = housing.getWorldObj();
    Random random = world.rand;
    // Correct speed
    if (random.nextInt(100) >= chance) {
        return null;
    }
    Vec3i area = getArea(genome, beeModifier);
    Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
    BlockPos housingPos = housing.getCoordinates();
    IIndividual pollen = null;
    for (int i = 0; i < 20; i++) {
        BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area);
        BlockPos blockPos = VectUtil.add(housingPos, randomPos, offset);
        ICheckPollinatable pitcher = TileUtil.getTile(world, blockPos, ICheckPollinatable.class);
        if (pitcher != null) {
            if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) {
                pollen = pitcher.getPollen();
            }
        } else {
            pollen = GeneticsUtil.getPollen(world, blockPos);
        }
        if (pollen != null) {
            return pollen;
        }
    }
    return null;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) ICheckPollinatable(forestry.api.genetics.ICheckPollinatable) IBeeModifier(forestry.api.apiculture.IBeeModifier) Random(java.util.Random) IIndividual(forestry.api.genetics.IIndividual) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Nullable(javax.annotation.Nullable)

Example 12 with IBeeModifier

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

the class FlowerRegistry method getAreaIterator.

@Override
public Iterator<BlockPos.MutableBlockPos> getAreaIterator(IBeeHousing beeHousing, IBee bee) {
    IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
    Vec3i area = getArea(bee.getGenome(), beeModifier);
    BlockPos minPos = beeHousing.getCoordinates().add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2);
    BlockPos maxPos = minPos.add(area);
    World world = beeHousing.getWorldObj();
    return VectUtil.getAllInBoxFromCenterMutable(world, minPos, beeHousing.getCoordinates(), maxPos);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBeeModifier(forestry.api.apiculture.IBeeModifier) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 13 with IBeeModifier

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

the class Bee method produceStacks.

@Override
public NonNullList<ItemStack> produceStacks(IBeeHousing housing) {
    World world = housing.getWorldObj();
    IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
    NonNullList<ItemStack> products = NonNullList.create();
    IAlleleBeeSpecies primary = genome.getPrimary();
    IAlleleBeeSpecies secondary = genome.getSecondary();
    IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
    IBeeModifier beeModeModifier = mode.getBeeModifier();
    // Bee genetic speed * beehousing * beekeeping mode
    float speed = genome.getSpeed() * beeHousingModifier.getProductionModifier(genome, 1f) * beeModeModifier.getProductionModifier(genome, 1f);
    // / Primary Products
    for (Map.Entry<ItemStack, Float> entry : primary.getProductChances().entrySet()) {
        if (world.rand.nextFloat() < entry.getValue() * speed) {
            products.add(entry.getKey().copy());
        }
    }
    // / Secondary Products
    for (Map.Entry<ItemStack, Float> entry : secondary.getProductChances().entrySet()) {
        if (world.rand.nextFloat() < Math.round(entry.getValue() / 2) * speed) {
            products.add(entry.getKey().copy());
        }
    }
    // / Specialty products
    if (primary.isJubilant(genome, housing) && secondary.isJubilant(genome, housing)) {
        for (Map.Entry<ItemStack, Float> entry : primary.getSpecialtyChances().entrySet()) {
            if (world.rand.nextFloat() < entry.getValue() * speed) {
                products.add(entry.getKey().copy());
            }
        }
    }
    BlockPos housingCoordinates = housing.getCoordinates();
    return genome.getFlowerProvider().affectProducts(world, this, housingCoordinates, products);
}
Also used : IAlleleBeeSpecies(forestry.api.apiculture.IAlleleBeeSpecies) IBeeModifier(forestry.api.apiculture.IBeeModifier) IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map)

Example 14 with IBeeModifier

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

the class AlleleEffect method getBounding.

public static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing) {
    IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
    float territoryModifier = beeModifier.getTerritoryModifier(genome, 1.0f);
    Vec3i area = VectUtil.scale(genome.getTerritory(), territoryModifier);
    Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
    BlockPos min = housing.getCoordinates().add(offset);
    BlockPos max = min.add(area);
    return new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ());
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) IBeeModifier(forestry.api.apiculture.IBeeModifier) BlockPos(net.minecraft.util.math.BlockPos)

Example 15 with IBeeModifier

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

the class EntityMinecartApiary 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)

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