Search in sources :

Example 1 with IBeekeepingMode

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

the class BeeRoot method getBeekeepingMode.

@Override
public IBeekeepingMode getBeekeepingMode(World world) {
    if (activeBeekeepingMode != null) {
        return activeBeekeepingMode;
    }
    // No beekeeping mode yet, get it.
    IApiaristTracker tracker = getBreedingTracker(world, null);
    String modeName = tracker.getModeName();
    IBeekeepingMode mode = getBeekeepingMode(modeName);
    Preconditions.checkNotNull(mode);
    setBeekeepingMode(world, mode);
    FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode);
    return activeBeekeepingMode;
}
Also used : IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode) IApiaristTracker(forestry.api.apiculture.IApiaristTracker)

Example 2 with IBeekeepingMode

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

the class Bee method createOffspring.

private IBee createOffspring(IBeeHousing housing, IBeeGenome mate, int generation) {
    World world = housing.getWorldObj();
    IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
    IChromosome[] parent1 = genome.getChromosomes();
    IChromosome[] parent2 = mate.getChromosomes();
    // Check for mutation. Replace one of the parents with the mutation
    // template if mutation occurred.
    IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
    if (mutated1 != null) {
        parent1 = mutated1;
    }
    IChromosome[] mutated2 = mutateSpecies(housing, mate, genome);
    if (mutated2 != null) {
        parent2 = mutated2;
    }
    for (int i = 0; i < parent1.length; i++) {
        if (parent1[i] != null && parent2[i] != null) {
            chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
        }
    }
    IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
    return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
}
Also used : IBeeGenome(forestry.api.apiculture.IBeeGenome) IBee(forestry.api.apiculture.IBee) IChromosome(forestry.api.genetics.IChromosome) IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode) World(net.minecraft.world.World)

Example 3 with IBeekeepingMode

use of forestry.api.apiculture.IBeekeepingMode 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 4 with IBeekeepingMode

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

the class BeeModeHelper method getModeNames.

@Override
public String[] getModeNames() {
    List<IBeekeepingMode> beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
    int modeStringCount = beekeepingModes.size();
    List<String> modeStrings = new ArrayList<>(modeStringCount);
    for (IBeekeepingMode mode : beekeepingModes) {
        modeStrings.add(mode.getName());
    }
    return modeStrings.toArray(new String[modeStringCount]);
}
Also used : ArrayList(java.util.ArrayList) IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode)

Example 5 with IBeekeepingMode

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

the class InventoryApiary method wearOutFrames.

@Override
public void wearOutFrames(IBeeHousing beeHousing, int amount) {
    IBeekeepingMode beekeepingMode = BeeManager.beeRoot.getBeekeepingMode(beeHousing.getWorldObj());
    int wear = Math.round(amount * beekeepingMode.getWearModifier());
    for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
        ItemStack hiveFrameStack = getStackInSlot(i);
        Item hiveFrameItem = hiveFrameStack.getItem();
        if ((hiveFrameItem instanceof IHiveFrame)) {
            IHiveFrame hiveFrame = (IHiveFrame) hiveFrameItem;
            ItemStack queenStack = getQueen();
            IBee queen = BeeManager.beeRoot.getMember(queenStack);
            if (queen != null) {
                ItemStack usedFrame = hiveFrame.frameUsed(beeHousing, hiveFrameStack, queen, wear);
                setInventorySlotContents(i, usedFrame);
            }
        }
    }
}
Also used : IHiveFrame(forestry.api.apiculture.IHiveFrame) Item(net.minecraft.item.Item) IBeekeepingMode(forestry.api.apiculture.IBeekeepingMode) IBee(forestry.api.apiculture.IBee) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IBeekeepingMode (forestry.api.apiculture.IBeekeepingMode)7 ItemStack (net.minecraft.item.ItemStack)3 IBee (forestry.api.apiculture.IBee)2 IBeeModifier (forestry.api.apiculture.IBeeModifier)2 World (net.minecraft.world.World)2 IAlleleBeeSpecies (forestry.api.apiculture.IAlleleBeeSpecies)1 IApiaristTracker (forestry.api.apiculture.IApiaristTracker)1 IBeeGenome (forestry.api.apiculture.IBeeGenome)1 IHiveFrame (forestry.api.apiculture.IHiveFrame)1 IChromosome (forestry.api.genetics.IChromosome)1 BlockRegistryApiculture (forestry.apiculture.blocks.BlockRegistryApiculture)1 ItemRegistryApiculture (forestry.apiculture.items.ItemRegistryApiculture)1 LocalizedConfiguration (forestry.core.config.LocalizedConfiguration)1 VillagerTradeLists (forestry.core.utils.VillagerTradeLists)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Item (net.minecraft.item.Item)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockPos (net.minecraft.util.math.BlockPos)1