Example #1
0
  @Override
  public int[] getNextPosition() {
    int[] next = null;
    BlockPosition cleanBlockPos = blockPos.copy();
    cleanBlockPos.orientation = ForgeDirection.UP;
    cleanBlockPos.moveForwards(1);
    Block suspect = cleanBlockPos.getBlock(world);

    while (suspect == Blocks.brown_mushroom_block || suspect == Blocks.red_mushroom_block) {
      next = new int[] {cleanBlockPos.x, cleanBlockPos.y, cleanBlockPos.z};
      cleanBlockPos.moveForwards(1);
      suspect = cleanBlockPos.getBlock(world);
    }

    if (next != null) {
      return next;
    }

    cleanBlockPos = blockPos.copy();
    cleanBlockPos.orientation = ForgeDirection.DOWN;
    cleanBlockPos.moveForwards(1);
    suspect = cleanBlockPos.getBlock(world);

    while (suspect == Blocks.brown_mushroom_block || suspect == Blocks.red_mushroom_block) {
      next = new int[] {cleanBlockPos.x, cleanBlockPos.y, cleanBlockPos.z};
      cleanBlockPos.moveForwards(1);
      suspect = cleanBlockPos.getBlock(world);
    }
    return next;
  }