use of forestry.api.genetics.IFruitFamily in project ForestryMC by ForestryMC.
the class Tree method allowsFruitBlocks.
@Override
public boolean allowsFruitBlocks() {
IFruitProvider provider = getGenome().getFruitProvider();
if (!provider.requiresFruitBlocks()) {
return false;
}
Collection<IFruitFamily> suitable = genome.getPrimary().getSuitableFruit();
return suitable.contains(provider.getFamily());
}
use of forestry.api.genetics.IFruitFamily in project ForestryMC by ForestryMC.
the class Tree method trySpawnFruitBlock.
@Override
public boolean trySpawnFruitBlock(World world, Random rand, BlockPos pos) {
IFruitProvider provider = getGenome().getFruitProvider();
Collection<IFruitFamily> suitable = genome.getPrimary().getSuitableFruit();
return suitable.contains(provider.getFamily()) && provider.trySpawnFruitBlock(getGenome(), world, rand, pos);
}
use of forestry.api.genetics.IFruitFamily in project Binnie by ForestryMC.
the class TreeBreedingSystem method getTreesThatCanBearFruit.
@Override
public Collection<IAlleleSpecies> getTreesThatCanBearFruit(final ItemStack fruit, final boolean master, final World world, final GameProfile player) {
final Collection<IAlleleSpecies> set = master ? this.getAllSpecies() : this.getDiscoveredSpecies(world, player);
final List<IAlleleSpecies> found = new ArrayList<>();
final Set<IFruitFamily> providers = new HashSet<>();
for (final IAlleleSpecies species : set) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
for (final ItemStack fruit2 : genome.getFruitProvider().getProducts().keySet()) {
if (fruit2.isItemEqual(fruit)) {
providers.add(genome.getFruitProvider().getFamily());
}
}
}
for (final IAlleleSpecies species : set) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
for (final IFruitFamily family : providers) {
if (tSpecies.getSuitableFruit().contains(family)) {
found.add(species);
break;
}
}
}
return found;
}
use of forestry.api.genetics.IFruitFamily in project ForestryMC by ForestryMC.
the class TreeDatabaseTab method createElements.
@Override
public void createElements(IGuiElementHelper elementHelper, ITree tree, ItemStack itemStack) {
IAlleleTreeSpecies primarySpecies = tree.getGenome().getPrimary();
boolean active = tab == EnumDatabaseTab.ACTIVE_SPECIES;
IAlleleTreeSpecies species = active ? primarySpecies : tree.getGenome().getSecondary();
int speciesColor = elementHelper.factory().getColorCoding(species.isDominant());
elementHelper.addText(Translator.translateToLocal("for.gui.database.tab." + tab.name().toLowerCase() + ".name"), GuiElementAlignment.CENTER, 0xcfb53b);
elementHelper.addAllele(Translator.translateToLocal("for.gui.species"), tree, EnumTreeChromosome.SPECIES, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.saplings"), tree, EnumTreeChromosome.FERTILITY, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.maturity"), tree, EnumTreeChromosome.MATURATION, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.height"), tree, EnumTreeChromosome.HEIGHT, active);
IAlleleInteger girth = (IAlleleInteger) (active ? tree.getGenome().getActiveAllele(EnumTreeChromosome.GIRTH) : tree.getGenome().getInactiveAllele(EnumTreeChromosome.GIRTH));
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.girth"), GuiElementAlignment.CENTER);
elementHelper.addText(String.format("%sx%s", girth.getValue(), girth.getValue()), GuiElementAlignment.CENTER, elementHelper.factory().getColorCoding(girth.isDominant()));
elementHelper.addAllele(Translator.translateToLocal("for.gui.yield"), tree, EnumTreeChromosome.YIELD, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.sappiness"), tree, EnumTreeChromosome.SAPPINESS, active);
elementHelper.addAllele(Translator.translateToLocal("for.gui.effect"), tree, EnumTreeChromosome.EFFECT, active);
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.native"), GuiElementAlignment.CENTER);
elementHelper.addText(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiElementAlignment.CENTER, speciesColor);
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.supports"), GuiElementAlignment.CENTER);
List<IFruitFamily> families = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
for (IFruitFamily fruitFamily : families) {
elementHelper.addText(fruitFamily.getName(), GuiElementAlignment.CENTER, speciesColor);
}
IAlleleFruit fruit = (IAlleleFruit) (active ? tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS) : tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS));
int colorCoding = elementHelper.factory().getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.fruits"), GuiElementAlignment.CENTER);
String strike = "";
if (!species.getSuitableFruit().contains(fruit.getProvider().getFamily()) && fruit != AlleleFruits.fruitNone) {
strike = TextFormatting.STRIKETHROUGH.toString();
}
elementHelper.addText(strike + fruit.getProvider().getDescription(), GuiElementAlignment.CENTER, colorCoding);
IFruitFamily family = fruit.getProvider().getFamily();
if (family != null && !family.getUID().equals(EnumFruitFamily.NONE.getUID())) {
elementHelper.addText(TextFormatting.UNDERLINE + Translator.translateToLocal("for.gui.family"), GuiElementAlignment.CENTER);
elementHelper.addText(family.getName(), GuiElementAlignment.CENTER, colorCoding);
}
}
use of forestry.api.genetics.IFruitFamily in project ForestryMC by ForestryMC.
the class AlleleTreeSpecies method getResearchSuitability.
@Override
public float getResearchSuitability(ItemStack itemstack) {
if (itemstack.isEmpty()) {
return 0f;
}
List<IFruitFamily> suitableFruit = getSuitableFruit();
for (IFruitFamily fruitFamily : suitableFruit) {
Collection<IFruitProvider> fruitProviders = TreeManager.treeRoot.getFruitProvidersForFruitFamily(fruitFamily);
for (IFruitProvider fruitProvider : fruitProviders) {
Map<ItemStack, Float> products = fruitProvider.getProducts();
for (ItemStack stack : products.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
}
Map<ItemStack, Float> specialtyChances = fruitProvider.getSpecialty();
for (ItemStack stack : specialtyChances.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
}
}
}
return super.getResearchSuitability(itemstack);
}
Aggregations