use of forestry.api.apiculture.IBeeGenome in project Binnie by ForestryMC.
the class PageSpeciesGenome method onValueChanged.
@Override
public void onValueChanged(IAlleleSpecies species) {
IAllele[] template = BeeManager.beeRoot.getTemplate(species.getUID());
if (template == null) {
return;
}
IBeeGenome genome = BeeManager.beeRoot.templateAsGenome(template);
IBee bee = BeeManager.beeRoot.getBee(genome);
speedText.setValue(rateSpeed(genome.getSpeed()));
lifespanText.setValue(rateLifespan(genome.getLifespan()));
fertilityText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".children", genome.getFertility()));
floweringText.setValue(rateFlowering(genome.getFlowering()));
Vec3i area = genome.getTerritory();
territoryText.setValue(area.getX() + "x" + area.getY() + 'x' + area.getZ());
String behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".daytime");
if (genome.getPrimary().isNocturnal()) {
behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".nighttime");
}
if (genome.getNeverSleeps()) {
behavior = I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".allDay");
}
nocturnalText.setValue(behavior);
if (genome.getCaveDwelling()) {
caveDwellingText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".notNeeded"));
} else {
caveDwellingText.setValue(I18N.localise(DatabaseConstants.BEE_GENOME_KEY + ".required"));
}
tolerantFlyerText.setValue(tolerated(genome.getToleratesRain()));
if (genome.getFlowerProvider() != null) {
flowerText.setValue(genome.getFlowerProvider().getDescription());
} else {
flowerText.setValue(AlleleHelper.toDisplay(EnumTolerance.NONE));
}
effectText.setValue(genome.getEffect().getAlleleName());
}
use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.
the class TileHive method getContainedBee.
public IBee getContainedBee() {
if (this.containedBee == null) {
IBeeGenome beeGenome = null;
ItemStack containedBee = contained.getStackInSlot(0);
if (!containedBee.isEmpty()) {
IBee bee = BeeManager.beeRoot.getMember(containedBee);
if (bee != null) {
beeGenome = bee.getGenome();
}
}
if (beeGenome == null) {
beeGenome = getGenomeFromBlock();
}
if (beeGenome == null) {
beeGenome = BeeDefinition.FOREST.getGenome();
}
this.containedBee = BeeManager.beeRoot.getBee(beeGenome);
}
return this.containedBee;
}
use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.
the class BeeRoot method registerTemplate.
@Override
public void registerTemplate(String identifier, IAllele[] template) {
IBeeGenome beeGenome = BeeManager.beeRoot.templateAsGenome(template);
IBee bee = new Bee(beeGenome);
beeTemplates.add(bee);
speciesTemplates.put(identifier, template);
}
use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.
the class Bee method mutateSpecies.
@Nullable
private static IChromosome[] mutateSpecies(IBeeHousing housing, IBeeGenome genomeOne, IBeeGenome genomeTwo) {
World world = housing.getWorldObj();
IChromosome[] parent1 = genomeOne.getChromosomes();
IChromosome[] parent2 = genomeTwo.getChromosomes();
IBeeGenome genome0;
IBeeGenome genome1;
IAlleleBeeSpecies allele0;
IAlleleBeeSpecies allele1;
if (world.rand.nextBoolean()) {
allele0 = (IAlleleBeeSpecies) parent1[EnumBeeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele1 = (IAlleleBeeSpecies) parent2[EnumBeeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeOne;
genome1 = genomeTwo;
} else {
allele0 = (IAlleleBeeSpecies) parent2[EnumBeeChromosome.SPECIES.ordinal()].getPrimaryAllele();
allele1 = (IAlleleBeeSpecies) parent1[EnumBeeChromosome.SPECIES.ordinal()].getSecondaryAllele();
genome0 = genomeTwo;
genome1 = genomeOne;
}
GameProfile playerProfile = housing.getOwner();
IApiaristTracker breedingTracker = BeeManager.beeRoot.getBreedingTracker(world, playerProfile);
List<IMutation> combinations = BeeManager.beeRoot.getCombinations(allele0, allele1, true);
for (IMutation mutation : combinations) {
IBeeMutation beeMutation = (IBeeMutation) mutation;
float chance = beeMutation.getChance(housing, allele0, allele1, genome0, genome1);
if (chance <= 0) {
continue;
}
// boost chance for researched mutations
if (breedingTracker.isResearched(beeMutation)) {
float mutationBoost = chance * (Config.researchMutationBoostMultiplier - 1.0f);
mutationBoost = Math.min(Config.maxResearchMutationBoostPercent, mutationBoost);
chance += mutationBoost;
}
if (chance > world.rand.nextFloat() * 100) {
breedingTracker.registerMutation(mutation);
return BeeManager.beeRoot.templateAsChromosomes(mutation.getTemplate());
}
}
return null;
}
use of forestry.api.apiculture.IBeeGenome in project ForestryMC by ForestryMC.
the class CommandBeeGive method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length < 2) {
printHelp(sender);
return;
}
IBeeGenome beeGenome = getBeeGenome(args[0]);
EnumBeeType beeType = getBeeType(args[1]);
if (beeType == null) {
printHelp(sender);
return;
}
EntityPlayer player;
if (args.length == 3) {
player = CommandBase.getPlayer(server, sender, args[2]);
} else {
player = CommandBase.getPlayer(server, sender, sender.getName());
}
IBee bee = BeeManager.beeRoot.getBee(beeGenome);
if (beeType == EnumBeeType.QUEEN) {
bee.mate(bee);
}
ItemStack beeStack = BeeManager.beeRoot.getMemberStack(bee, beeType);
player.dropItem(beeStack, false, true);
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getName(), bee.getGenome().getPrimary().getAlleleName(), beeType.getName());
}
Aggregations