Search in sources :

Example 1 with FarmHarvestingTarget

use of crazypants.enderio.base.farming.harvesters.FarmHarvestingTarget in project EnderIO by SleepyTrousers.

the class TreeFarmer method harvestBlock.

@Override
public IHarvestResult harvestBlock(@Nonnull IFarmer farm, @Nonnull BlockPos bc, @Nonnull Block block, @Nonnull IBlockState meta) {
    setupHarvesting(farm, bc);
    if (!hasAxe) {
        farm.setNotification(FarmNotification.NO_AXE);
        return null;
    }
    final World world = farm.getWorld();
    final HarvestResult res = new HarvestResult();
    final IHarvestingTarget target = new FarmHarvestingTarget(this, farm);
    TreeHarvester.harvest(world, bc, res, target);
    Collections.sort(res.getHarvestedBlocks(), comp);
    List<BlockPos> actualHarvests = new ArrayList<BlockPos>();
    for (int i = 0; i < res.getHarvestedBlocks().size() && hasAxe; i++) {
        final BlockPos coord = res.getHarvestedBlocks().get(i);
        harvestSingleBlock(farm, world, res, coord);
        actualHarvests.add(coord);
    }
    res.getHarvestedBlocks().clear();
    res.getHarvestedBlocks().addAll(actualHarvests);
    tryReplanting(farm, world, bc, res);
    return res;
}
Also used : IHarvestResult(crazypants.enderio.api.farm.IHarvestResult) IHarvestingTarget(crazypants.enderio.base.farming.harvesters.IHarvestingTarget) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) FarmHarvestingTarget(crazypants.enderio.base.farming.harvesters.FarmHarvestingTarget)

Aggregations

IHarvestResult (crazypants.enderio.api.farm.IHarvestResult)1 FarmHarvestingTarget (crazypants.enderio.base.farming.harvesters.FarmHarvestingTarget)1 IHarvestingTarget (crazypants.enderio.base.farming.harvesters.IHarvestingTarget)1 ArrayList (java.util.ArrayList)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1