use of forestry.api.arboriculture.ITreeGenome in project ForestryMC by ForestryMC.
the class BlockDecorativeLeaves method colorMultiplier.
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
TreeDefinition treeDefinition = state.getValue(getVariant());
ITreeGenome genome = treeDefinition.getGenome();
if (tintIndex == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
IFruitProvider fruitProvider = genome.getFruitProvider();
return fruitProvider.getDecorativeColor();
}
ILeafSpriteProvider spriteProvider = genome.getPrimary().getLeafSpriteProvider();
return spriteProvider.getColor(false);
}
use of forestry.api.arboriculture.ITreeGenome in project ForestryMC by ForestryMC.
the class BlockDefaultLeaves method getLeafDrop.
@Override
protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) {
ITree tree = getTree(world, pos);
if (tree == null) {
return;
}
// Add saplings
List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier);
for (ITree sapling : saplings) {
if (sapling != null) {
drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING));
}
}
// Add fruits
ITreeGenome genome = tree.getGenome();
IFruitProvider fruitProvider = genome.getFruitProvider();
if (fruitProvider.isFruitLeaf(genome, world, pos)) {
NonNullList<ItemStack> produceStacks = tree.produceStacks(world, pos, Integer.MAX_VALUE);
drops.addAll(produceStacks);
}
}
use of forestry.api.arboriculture.ITreeGenome in project ForestryMC by ForestryMC.
the class BlockDefaultLeaves method colorMultiplier.
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
TreeDefinition treeDefinition = getTreeDefinition(state);
if (treeDefinition == null) {
treeDefinition = TreeDefinition.Oak;
}
ITreeGenome genome = treeDefinition.getGenome();
if (tintIndex == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
IFruitProvider fruitProvider = genome.getFruitProvider();
return fruitProvider.getDecorativeColor();
}
ILeafSpriteProvider spriteProvider = genome.getPrimary().getLeafSpriteProvider();
return spriteProvider.getColor(false);
}
use of forestry.api.arboriculture.ITreeGenome in project Binnie by ForestryMC.
the class TreeBreedingSystem method getChance.
@Override
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies firstSpecies, final IAlleleSpecies secondSpecies) {
ISpeciesRoot speciesRoot = this.getSpeciesRoot();
final ITreeGenome genome0 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(firstSpecies));
final ITreeGenome genome2 = (ITreeGenome) speciesRoot.templateAsGenome(speciesRoot.getTemplate(secondSpecies));
return ((ITreeMutation) mutation).getChance(player.world, player.getPosition(), (IAlleleTreeSpecies) firstSpecies, (IAlleleTreeSpecies) secondSpecies, genome0, genome2);
}
use of forestry.api.arboriculture.ITreeGenome in project Binnie by ForestryMC.
the class TreeBreedingSystem method getTreesThatHaveWood.
@Override
public Collection<IAlleleSpecies> getTreesThatHaveWood(final ItemStack wood, 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) {
IAlleleTreeSpecies tSpecies = (IAlleleTreeSpecies) species;
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies));
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
if (woodStack.isItemEqual(wood)) {
found.add(species);
}
}
return found;
}
Aggregations