use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class TileEntityFlower method mateWith.
@Override
public void mateWith(IIndividual individual) {
if (getFlower() == null || !(individual instanceof IFlower)) {
return;
}
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) individual.getGenome().getPrimary();
IAlleleFlowerSpecies primary2 = getFlower().getGenome().getPrimary();
if (primary == primary2 || world.rand.nextInt(4) == 0) {
getFlower().mate((IFlower) individual);
world.markBlockRangeForRenderUpdate(pos, pos);
}
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class ModuleFlowers method plantVanilla.
@SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
Block block = world.getBlockState(pos.down()).getBlock();
if (!BotanyCore.getGardening().isSoil(block)) {
return;
}
EntityPlayer player = event.getPlayer();
ItemStack heldItem = player.getHeldItem(event.getHand());
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
IFlower flower = flowerRoot.getConversion(heldItem);
if (flower != null) {
flowerRoot.plant(world, pos, flower, player.getGameProfile());
}
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class Flower method copy.
@Override
public IFlower copy() {
NBTTagCompound compound = new NBTTagCompound();
writeToNBT(compound);
return new Flower(compound);
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class Flower method getOffspring.
@Override
public IFlower getOffspring(World world, BlockPos pos) {
if (mate != null) {
IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
IChromosome[] parentFirst = mutateSpecies(world, pos, genome, mate);
IChromosome[] parentSecond = mutateSpecies(world, pos, mate, genome);
for (int i = 0; i < parentFirst.length; ++i) {
if (parentFirst[i] != null && parentSecond[i] != null) {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parentFirst[i], parentSecond[i]);
}
}
return new Flower(new FlowerGenome(chromosomes), 0);
}
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new Flower(nbt);
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class ItemFlowerGE method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
IFlower individual = (IFlower) getIndividual(itemStack);
if (individual == null) {
list.add(TextFormatting.DARK_RED + I18N.localise("item.botany.flower.destroy"));
return;
}
IFlowerGenome genome = individual.getGenome();
// Colors
String primaryColor = genome.getPrimaryColor().getColorName();
String secondaryColor = genome.getSecondaryColor().getColorName();
String stemColor = genome.getStemColor().getColorName();
String colorInfo;
if (!primaryColor.equals(secondaryColor)) {
colorInfo = I18N.localise("item.botany.grammar.flower.secondary", primaryColor, secondaryColor, stemColor);
} else {
colorInfo = I18N.localise("item.botany.grammar.flower", primaryColor, stemColor);
}
list.add(TextFormatting.YELLOW + colorInfo);
if (individual.isAnalyzed()) {
if (GuiScreen.isShiftKeyDown()) {
individual.addTooltip(list);
} else {
list.add(TextFormatting.ITALIC + "<" + I18N.localise("for.gui.tooltip.tmi") + '>');
}
} else {
list.add('<' + I18N.localise("for.gui.unknown") + '>');
}
}
Aggregations