Search in sources :

Example 1 with TreeHarvestManager

use of powercrystals.minefactoryreloaded.core.TreeHarvestManager in project MineFactoryReloaded by powercrystals.

the class TileEntityFruitPicker method getNextTreeSegment.

private BlockPosition getNextTreeSegment(int x, int y, int z, boolean treeFlipped) {
    int blockId;
    if (_lastTree == null || _lastTree.x != x || _lastTree.y != y || _lastTree.z != z) {
        int yTreeAreaLowerBound = (treeFlipped ? y - MFRConfig.fruitTreeSearchMaxVertical.getInt() : y);
        int yTreeAreaUpperBound = (treeFlipped ? y : y + MFRConfig.fruitTreeSearchMaxVertical.getInt());
        Area a = new Area(x - MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), x + MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), yTreeAreaLowerBound, yTreeAreaUpperBound, z - MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), z + MFRConfig.fruitTreeSearchMaxHorizontal.getInt());
        _treeManager = new TreeHarvestManager(a, treeFlipped ? TreeHarvestMode.HarvestInverted : TreeHarvestMode.Harvest);
        _lastTree = new BlockPosition(x, y, z);
    } else if (_treeManager.getIsDone()) {
        _treeManager.reset();
    }
    while (true) {
        if (_treeManager.getIsDone()) {
            return null;
        }
        BlockPosition bp = _treeManager.getNextBlock();
        blockId = worldObj.getBlockId(bp.x, bp.y, bp.z);
        if (MFRRegistry.getFruits().containsKey(new Integer(blockId)) && MFRRegistry.getFruits().get(new Integer(blockId)).canBePicked(worldObj, bp.x, bp.y, bp.z)) {
            return bp;
        }
        _treeManager.moveNext();
    }
}
Also used : Area(powercrystals.core.position.Area) BlockPosition(powercrystals.core.position.BlockPosition) TreeHarvestManager(powercrystals.minefactoryreloaded.core.TreeHarvestManager)

Example 2 with TreeHarvestManager

use of powercrystals.minefactoryreloaded.core.TreeHarvestManager in project MineFactoryReloaded by powercrystals.

the class TileEntityHarvester method getNextTreeSegment.

private BlockPosition getNextTreeSegment(int x, int y, int z, boolean treeFlipped) {
    int blockId;
    if (_lastTree == null || _lastTree.x != x || _lastTree.y != y || _lastTree.z != z) {
        int yTreeAreaLowerBound = (treeFlipped ? y - MFRConfig.treeSearchMaxVertical.getInt() : y);
        int yTreeAreaUpperBound = (treeFlipped ? y : y + MFRConfig.treeSearchMaxVertical.getInt());
        Area a = new Area(x - MFRConfig.treeSearchMaxHorizontal.getInt(), x + MFRConfig.treeSearchMaxHorizontal.getInt(), yTreeAreaLowerBound, yTreeAreaUpperBound, z - MFRConfig.treeSearchMaxHorizontal.getInt(), z + MFRConfig.treeSearchMaxHorizontal.getInt());
        _treeManager = new TreeHarvestManager(a, treeFlipped ? TreeHarvestMode.HarvestInverted : TreeHarvestMode.Harvest);
        _lastTree = new BlockPosition(x, y, z);
    } else if (_treeManager.getIsDone()) {
        _treeManager.reset();
    }
    while (true) {
        if (_treeManager.getIsDone()) {
            return null;
        }
        BlockPosition bp = _treeManager.getNextBlock();
        blockId = worldObj.getBlockId(bp.x, bp.y, bp.z);
        if (MFRRegistry.getHarvestables().containsKey(new Integer(blockId)) && MFRRegistry.getHarvestables().get(new Integer(blockId)).canBeHarvested(worldObj, _settings, bp.x, bp.y, bp.z)) {
            if (_treeManager.getIsLeafPass() && MFRRegistry.getHarvestables().get(new Integer(blockId)).getHarvestType() == HarvestType.TreeLeaf) {
                return bp;
            } else if (!_treeManager.getIsLeafPass() && (MFRRegistry.getHarvestables().get(new Integer(blockId)).getHarvestType() == HarvestType.Tree || MFRRegistry.getHarvestables().get(new Integer(blockId)).getHarvestType() == HarvestType.TreeFlipped)) {
                return bp;
            } else if (!_treeManager.getIsLeafPass() && MFRRegistry.getHarvestables().get(new Integer(blockId)).getHarvestType() == HarvestType.TreeLeaf) {
                _treeManager.reset();
                continue;
            }
        }
        _treeManager.moveNext();
    }
}
Also used : Area(powercrystals.core.position.Area) BlockPosition(powercrystals.core.position.BlockPosition) TreeHarvestManager(powercrystals.minefactoryreloaded.core.TreeHarvestManager)

Aggregations

Area (powercrystals.core.position.Area)2 BlockPosition (powercrystals.core.position.BlockPosition)2 TreeHarvestManager (powercrystals.minefactoryreloaded.core.TreeHarvestManager)2