use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class TileLeaves method matureCaterpillar.
/* IBUTTERFLYNURSERY */
private void matureCaterpillar() {
if (caterpillar == null) {
return;
}
maturationTime++;
ITree tree = getTree();
boolean wasDestroyed = isDestroyed(tree, damage);
damage += caterpillar.getGenome().getMetabolism();
IButterflyGenome caterpillarGenome = caterpillar.getGenome();
int caterpillarMatureTime = Math.round((float) caterpillarGenome.getLifespan() / (caterpillarGenome.getFertility() * 2));
if (maturationTime >= caterpillarMatureTime) {
ButterflyManager.butterflyRoot.plantCocoon(world, pos.down(), getCaterpillar(), getOwnerHandler().getOwner(), 0, false);
setCaterpillar(null);
} else if (!wasDestroyed && isDestroyed(tree, damage)) {
sendNetworkUpdate();
}
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class TileLeaves method getFoliageColour.
@SideOnly(Side.CLIENT)
public int getFoliageColour(EntityPlayer player) {
final boolean showPollinated = isPollinatedState && GeneticsUtil.hasNaturalistEye(player);
final int baseColor = getLeafSpriteProvider().getColor(showPollinated);
ITree tree = getTree();
if (isDestroyed(tree, damage)) {
return ColourUtil.addRGBComponents(baseColor, 92, 61, 0);
} else if (caterpillar != null) {
return ColourUtil.multiplyRGBComponents(baseColor, 1.5f);
} else {
return baseColor;
}
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class TileSapling method tryGrow.
public void tryGrow(Random random, boolean bonemealed) {
ITree tree = getTree();
if (tree == null) {
return;
}
int maturity = getRequiredMaturity(world, tree);
if (timesTicked < maturity) {
if (bonemealed) {
timesTicked = maturity;
}
return;
}
WorldGenerator generator = tree.getTreeGenerator(world, getPos(), bonemealed);
final boolean generated;
if (generator instanceof WorldGenBase) {
generated = ((WorldGenBase) generator).generate(world, random, getPos(), false);
} else {
generated = generator.generate(world, random, getPos());
}
if (generated) {
IBreedingTracker breedingTracker = TreeManager.treeRoot.getBreedingTracker(world, getOwnerHandler().getOwner());
breedingTracker.registerBirth(tree);
}
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class TileSapling method canAcceptBoneMeal.
public boolean canAcceptBoneMeal(Random rand) {
ITree tree = getTree();
if (tree == null) {
return false;
}
int maturity = getRequiredMaturity(world, tree);
if (timesTicked < maturity) {
return true;
}
WorldGenerator generator = tree.getTreeGenerator(world, getPos(), true);
if (generator instanceof WorldGenArboriculture) {
WorldGenArboriculture arboricultureGenerator = (WorldGenArboriculture) generator;
arboricultureGenerator.preGenerate(world, rand, getPos());
return arboricultureGenerator.getValidGrowthPos(world, getPos()) != null;
} else {
return true;
}
}
use of forestry.api.arboriculture.ITree in project ForestryMC by ForestryMC.
the class ItemGermlingGE method getFermentationModifier.
@Override
public float getFermentationModifier(ItemStack itemstack) {
itemstack = GeneticsUtil.convertToGeneticEquivalent(itemstack);
ITree tree = TreeManager.treeRoot.getMember(itemstack);
if (tree == null) {
return 1.0f;
}
return tree.getGenome().getSappiness() * 10;
}
Aggregations