コード例 #1
0
  private BlockPosition getNextTreeSegment(BlockPosition pos) {
    Block block;

    if (_treeManager.getIsDone() || !_treeManager.getOrigin().equals(pos)) {
      int lowerBound = 0;
      int upperBound = MFRConfig.fruitTreeSearchMaxVertical.getInt();

      Area a =
          new Area(
              pos.copy(), MFRConfig.fruitTreeSearchMaxHorizontal.getInt(), lowerBound, upperBound);

      _treeManager.reset(worldObj, a, HarvestMode.FruitTree, null);
    }

    Map<Block, IFactoryFruit> fruits = MFRRegistry.getFruits();
    while (!_treeManager.getIsDone()) {
      BlockPosition bp = _treeManager.getNextBlock();
      block = worldObj.getBlock(bp.x, bp.y, bp.z);
      IFactoryFruit fruit = fruits.containsKey(block) ? fruits.get(block) : null;

      if (fruit != null && fruit.canBePicked(worldObj, bp.x, bp.y, bp.z)) return bp;

      _treeManager.moveNext();
    }
    return null;
  }
コード例 #2
0
  private BlockPosition getNextTree() {
    BlockPosition bp = _areaManager.getNextBlock();
    if (!worldObj.blockExists(bp.x, bp.y, bp.z)) {
      return null;
    }

    Block search = worldObj.getBlock(bp.x, bp.y, bp.z);

    if (!MFRRegistry.getFruitLogBlocks().contains(search)) {
      IFactoryFruit f = MFRRegistry.getFruits().get(search);
      return f != null && f.canBePicked(worldObj, bp.x, bp.y, bp.z) ? bp : null;
    }

    BlockPosition temp = getNextTreeSegment(bp);
    if (temp != null) _areaManager.rewindBlock();

    return temp;
  }