Search in sources :

Example 1 with ITreekeepingMode

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());
}
Also used : IAlleleTreeSpecies(forestry.api.arboriculture.IAlleleTreeSpecies) IBlockState(net.minecraft.block.state.IBlockState) ITreekeepingMode(forestry.api.arboriculture.ITreekeepingMode) ILeafTickHandler(forestry.api.arboriculture.ILeafTickHandler) ITree(forestry.api.arboriculture.ITree) ITreeGenome(forestry.api.arboriculture.ITreeGenome)

Example 2 with ITreekeepingMode

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;
}
Also used : ITreekeepingMode(forestry.api.arboriculture.ITreekeepingMode) IArboristTracker(forestry.api.arboriculture.IArboristTracker)

Example 3 with ITreekeepingMode

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);
}
Also used : ITreekeepingMode(forestry.api.arboriculture.ITreekeepingMode)

Example 4 with ITreekeepingMode

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]);
}
Also used : ITreekeepingMode(forestry.api.arboriculture.ITreekeepingMode) ArrayList(java.util.ArrayList)

Aggregations

ITreekeepingMode (forestry.api.arboriculture.ITreekeepingMode)4 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)1 IArboristTracker (forestry.api.arboriculture.IArboristTracker)1 ILeafTickHandler (forestry.api.arboriculture.ILeafTickHandler)1 ITree (forestry.api.arboriculture.ITree)1 ITreeGenome (forestry.api.arboriculture.ITreeGenome)1 ArrayList (java.util.ArrayList)1 IBlockState (net.minecraft.block.state.IBlockState)1