use of forestry.api.arboriculture.ITreekeepingMode in project ForestryMC by ForestryMC.
the class TileLeaves method onBlockTick.
@Override
public void onBlockTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
ITree tree = getTree();
if (tree == null) {
return;
}
ITreeGenome genome = tree.getGenome();
IAlleleTreeSpecies primary = genome.getPrimary();
if (!checkedForConversionToDefaultLeaves) {
if (shouldConvertToDefaultLeaves()) {
IBlockState defaultLeaves = ModuleArboriculture.getBlocks().getDefaultLeaves(primary.getUID());
worldIn.setBlockState(getPos(), defaultLeaves);
return;
}
checkedForConversionToDefaultLeaves = true;
}
boolean isDestroyed = isDestroyed(tree, damage);
for (ILeafTickHandler tickHandler : primary.getRoot().getLeafTickHandlers()) {
if (tickHandler.onRandomLeafTick(tree, world, rand, getPos(), isDestroyed)) {
return;
}
}
if (isDestroyed) {
return;
}
if (damage > 0) {
damage--;
}
if (hasFruit() && getRipeningTime() < ripeningPeriod) {
ITreekeepingMode treekeepingMode = TreeManager.treeRoot.getTreekeepingMode(world);
float sappinessModifier = treekeepingMode.getSappinessModifier(genome, 1f);
float sappiness = genome.getSappiness() * sappinessModifier;
if (rand.nextFloat() < sappiness) {
ripeningTime++;
sendNetworkUpdateRipening();
}
}
if (caterpillar != null) {
matureCaterpillar();
}
effectData = tree.doEffect(effectData, world, getPos());
}
use of forestry.api.arboriculture.ITreekeepingMode in project ForestryMC by ForestryMC.
the class TreeRoot method getTreekeepingMode.
@Override
public ITreekeepingMode getTreekeepingMode(World world) {
if (activeTreekeepingMode != null) {
return activeTreekeepingMode;
}
// No Treekeeping mode yet, item it.
IArboristTracker tracker = getBreedingTracker(world, null);
String modeName = tracker.getModeName();
ITreekeepingMode mode = getTreekeepingMode(modeName);
Preconditions.checkNotNull(mode);
setTreekeepingMode(world, mode);
FMLCommonHandler.instance().getFMLLogger().debug("Set Treekeeping mode for a world to " + mode);
return activeTreekeepingMode;
}
use of forestry.api.arboriculture.ITreekeepingMode in project ForestryMC by ForestryMC.
the class TileSapling method getRequiredMaturity.
private static int getRequiredMaturity(World world, ITree tree) {
ITreekeepingMode treekeepingMode = TreeManager.treeRoot.getTreekeepingMode(world);
float maturationModifier = treekeepingMode.getMaturationModifier(tree.getGenome(), 1f);
return Math.round(tree.getRequiredMaturity() * maturationModifier);
}
use of forestry.api.arboriculture.ITreekeepingMode in project ForestryMC by ForestryMC.
the class TreeModeHelper method getModeNames.
@Override
public String[] getModeNames() {
List<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
int modeStringCount = treekeepingModes.size();
List<String> modeStrings = new ArrayList<>(modeStringCount);
for (ITreekeepingMode mode : treekeepingModes) {
modeStrings.add(mode.getName());
}
return modeStrings.toArray(new String[modeStringCount]);
}
Aggregations