use of forestry.api.arboriculture.ITreeGenome in project Binnie by ForestryMC.
the class TreeBreedingSystem method calculateArrays.
@Override
public final void calculateArrays() {
super.calculateArrays();
for (final IAlleleSpecies species : this.allActiveSpecies) {
final IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
final ITreeGenome genome = (ITreeGenome) this.getSpeciesRoot().templateAsGenome(this.getSpeciesRoot().getTemplate(tSpecies));
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
final ItemStack wood = treeSpecies.getWoodProvider().getWoodStack();
if (!wood.isEmpty()) {
this.allWoods.add(wood);
}
/*for (final ItemStack wood : tSpecies.getRoot().templateAsIndividual(getSpeciesRoot().getTemplate(tSpecies.getUID())).getProduceList()) {
this.allWoods.add(wood);
}*/
this.allFruits.addAll(genome.getFruitProvider().getProducts().keySet());
}
}
use of forestry.api.arboriculture.ITreeGenome in project Binnie by ForestryMC.
the class TreeBreedingSystem method getTreesThatBearFruit.
@Override
public Collection<IAlleleSpecies> getTreesThatBearFruit(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<>();
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)) {
found.add(species);
}
}
}
return found;
}
use of forestry.api.arboriculture.ITreeGenome 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.arboriculture.ITreeGenome in project Binnie by ForestryMC.
the class ModelETDecorativeLeaves method bakeBlock.
@Override
protected void bakeBlock(BlockETDecorativeLeaves block, ETTreeDefinition treeDefinition, IModelBaker baker, boolean inventory) {
TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
ITreeGenome genome = treeDefinition.getGenome();
IAlleleTreeSpecies species = genome.getPrimary();
ILeafSpriteProvider leafSpriteProvider = species.getLeafSpriteProvider();
ResourceLocation leafSpriteLocation = leafSpriteProvider.getSprite(false, Proxies.render.fancyGraphicsEnabled());
TextureAtlasSprite leafSprite = map.getAtlasSprite(leafSpriteLocation.toString());
// Render the plain leaf block.
baker.addBlockModel(null, leafSprite, 0);
// Render overlay for fruit leaves.
ResourceLocation fruitSpriteLocation = genome.getFruitProvider().getDecorativeSprite();
if (fruitSpriteLocation != null) {
TextureAtlasSprite fruitSprite = map.getAtlasSprite(fruitSpriteLocation.toString());
baker.addBlockModel(null, fruitSprite, 1);
}
// Set the particle sprite
baker.setParticleSprite(leafSprite);
}
use of forestry.api.arboriculture.ITreeGenome in project ForestryMC by ForestryMC.
the class TileLeaves method setTree.
@Override
public void setTree(ITree tree) {
super.setTree(tree);
ITreeGenome genome = tree.getGenome();
species = genome.getPrimary();
if (tree.canBearFruit()) {
IFruitProvider fruitProvider = genome.getFruitProvider();
isFruitLeaf = fruitProvider.isFruitLeaf(genome, world, getPos());
if (isFruitLeaf) {
// Hardcoded because vanilla oak trees don't show fruits.
if (species == TreeDefinition.Oak.getGenome().getPrimary() && fruitProvider == AlleleFruits.fruitApple.getProvider()) {
fruitSprite = null;
} else {
fruitSprite = fruitProvider.getSprite(genome, world, getPos(), getRipeningTime());
}
ripeningPeriod = (short) tree.getGenome().getFruitProvider().getRipeningPeriod();
}
} else {
isFruitLeaf = false;
fruitSprite = null;
}
markDirty();
}
Aggregations