use of crazypants.enderio.base.farming.farmers.HarvestResult in project EnderIO by SleepyTrousers.
the class ItemDarkSteelAxe method onBlockStartBreak.
@Override
public boolean onBlockStartBreak(@Nonnull ItemStack itemstack, @Nonnull BlockPos pos, @Nonnull EntityPlayer player) {
if (!player.world.isRemote && !player.isSneaking() && EnergyUpgradeManager.itemHasAnyPowerUpgrade(itemstack)) {
IBlockState bs = player.world.getBlockState(pos);
Block block = bs.getBlock();
if (FarmersRegistry.isLog(block)) {
int powerStored = EnergyUpgradeManager.getEnergyStored(itemstack);
HarvestResult res = new HarvestResult();
final IHarvestingTarget target = new AxeHarvestingTarget(bs, pos);
TreeHarvester.harvest(player.world, pos, res, target);
NNList<BlockPos> sortedTargets = new NNList<BlockPos>(res.getHarvestedBlocks());
harvestComparator.refPoint = pos;
Collections.sort(sortedTargets, harvestComparator);
int maxBlocks = powerStored / Config.darkSteelAxePowerUsePerDamagePointMultiHarvest;
int numUsedPower = 0;
for (int i = 0; numUsedPower < maxBlocks && i < sortedTargets.size(); i++) {
if (doMultiHarvest(player, player.world, sortedTargets.get(i), block)) {
numUsedPower++;
}
}
return numUsedPower != 0;
}
}
return false;
}
use of crazypants.enderio.base.farming.farmers.HarvestResult in project EnderIO by SleepyTrousers.
the class NaturaBerryFarmer method harvestBlock.
@Override
public IHarvestResult harvestBlock(@Nonnull IFarmer farm, @Nonnull BlockPos bc, @Nonnull Block block, @Nonnull IBlockState meta) {
if (block != getPlantedBlock()) {
return null;
}
if (!farm.hasTool(FarmingTool.HOE)) {
farm.setNotification(FarmNotification.NO_HOE);
return null;
}
IHarvestResult res = new HarvestResult();
BlockPos checkBlock = bc;
while (checkBlock != null && checkBlock.getY() <= 255 && farm.hasTool(FarmingTool.HOE)) {
meta = farm.getBlockState(checkBlock);
block = meta.getBlock();
if (block != getPlantedBlock()) {
checkBlock = null;
} else {
if (getFullyGrownBlockMeta() == block.getMetaFromState(meta)) {
IHarvestResult blockRes = super.harvestBlock(farm, checkBlock, block, meta);
if (blockRes != null) {
res.getHarvestedBlocks().add(checkBlock);
res.getDrops().addAll(blockRes.getDrops());
}
}
checkBlock = checkBlock.up();
}
}
if (res.getHarvestedBlocks().isEmpty()) {
return null;
}
return res;
}
Aggregations