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;
}
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);
}
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);
}
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]);
}
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);
}
}
}
}
Aggregations