use of forestry.api.arboriculture.IFruitProvider 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.IFruitProvider 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.IFruitProvider in project ForestryMC by ForestryMC.
the class TreeRoot method getFruitProvidersForFruitFamily.
@Override
public Collection<IFruitProvider> getFruitProvidersForFruitFamily(IFruitFamily fruitFamily) {
if (providersForFamilies.isEmpty()) {
@SuppressWarnings("unchecked") Collection<IAlleleFruit> fruitAlleles = (Collection<IAlleleFruit>) (Object) AlleleManager.alleleRegistry.getRegisteredAlleles(EnumTreeChromosome.FRUITS);
for (IAlleleFruit alleleFruit : fruitAlleles) {
IFruitProvider fruitProvider = alleleFruit.getProvider();
Collection<IFruitProvider> fruitProviders = providersForFamilies.computeIfAbsent(fruitProvider.getFamily(), k -> new ArrayList<>());
fruitProviders.add(fruitProvider);
}
}
return providersForFamilies.computeIfAbsent(fruitFamily, k -> new ArrayList<>());
}
use of forestry.api.arboriculture.IFruitProvider 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();
}
use of forestry.api.arboriculture.IFruitProvider 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