Search in sources :

Example 1 with IFactoryHarvestable

use of powercrystals.minefactoryreloaded.api.IFactoryHarvestable in project MineFactoryReloaded by powercrystals.

the class TileEntityHarvester method getNextHarvest.

private BlockPosition getNextHarvest() {
    BlockPosition bp = _areaManager.getNextBlock();
    int searchId = worldObj.getBlockId(bp.x, bp.y, bp.z);
    if (!MFRRegistry.getHarvestables().containsKey(new Integer(searchId))) {
        _lastTree = null;
        return null;
    }
    IFactoryHarvestable harvestable = MFRRegistry.getHarvestables().get(new Integer(searchId));
    if (harvestable.canBeHarvested(worldObj, _settings, bp.x, bp.y, bp.z)) {
        if (harvestable.getHarvestType() == HarvestType.Normal) {
            _lastTree = null;
            return bp;
        } else if (harvestable.getHarvestType() == HarvestType.Column) {
            _lastTree = null;
            return getNextVertical(bp.x, bp.y, bp.z, 0);
        } else if (harvestable.getHarvestType() == HarvestType.LeaveBottom) {
            _lastTree = null;
            return getNextVertical(bp.x, bp.y, bp.z, 1);
        } else if (harvestable.getHarvestType() == HarvestType.Tree) {
            BlockPosition temp = getNextTreeSegment(bp.x, bp.y, bp.z, false);
            if (temp != null) {
                _areaManager.rewindBlock();
            }
            return temp;
        } else if (harvestable.getHarvestType() == HarvestType.TreeFlipped) {
            BlockPosition temp = getNextTreeSegment(bp.x, bp.y, bp.z, true);
            if (temp != null) {
                _areaManager.rewindBlock();
            }
            return temp;
        }
    }
    _lastTree = null;
    return null;
}
Also used : IFactoryHarvestable(powercrystals.minefactoryreloaded.api.IFactoryHarvestable) BlockPosition(powercrystals.core.position.BlockPosition)

Example 2 with IFactoryHarvestable

use of powercrystals.minefactoryreloaded.api.IFactoryHarvestable in project MineFactoryReloaded by powercrystals.

the class TileEntityHarvester method activateMachine.

@Override
public boolean activateMachine() {
    BlockPosition targetCoords = getNextHarvest();
    if (targetCoords == null) {
        setIdleTicks(getIdleTicksMax());
        return false;
    }
    int harvestedBlockId = worldObj.getBlockId(targetCoords.x, targetCoords.y, targetCoords.z);
    int harvestedBlockMetadata = worldObj.getBlockMetadata(targetCoords.x, targetCoords.y, targetCoords.z);
    IFactoryHarvestable harvestable = MFRRegistry.getHarvestables().get(new Integer(harvestedBlockId));
    List<ItemStack> drops = harvestable.getDrops(worldObj, _rand, ImmutableMap.copyOf(_settings), targetCoords.x, targetCoords.y, targetCoords.z);
    harvestable.preHarvest(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);
    doDrop(drops);
    if (harvestable.breakBlock()) {
        if (MFRConfig.playSounds.getBoolean(true)) {
            worldObj.playAuxSFXAtEntity(null, 2001, targetCoords.x, targetCoords.y, targetCoords.z, harvestedBlockId + (harvestedBlockMetadata << 12));
        }
        worldObj.setBlockToAir(targetCoords.x, targetCoords.y, targetCoords.z);
    }
    harvestable.postHarvest(worldObj, targetCoords.x, targetCoords.y, targetCoords.z);
    _tank.fill(LiquidDictionary.getLiquid("sludge", 10), true);
    return true;
}
Also used : IFactoryHarvestable(powercrystals.minefactoryreloaded.api.IFactoryHarvestable) BlockPosition(powercrystals.core.position.BlockPosition) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BlockPosition (powercrystals.core.position.BlockPosition)2 IFactoryHarvestable (powercrystals.minefactoryreloaded.api.IFactoryHarvestable)2 ItemStack (net.minecraft.item.ItemStack)1