Package forestry.api.farming

Examples of forestry.api.farming.IFarmLogic


  public void onInsertion(int slot, TileEntity tile) {
    IFarmHousing housing = getCircuitable(tile);
    if (housing == null)
      return;

    IFarmLogic logic;
    try {
      logic = logicClass.getConstructor(new Class[] { IFarmHousing.class }).newInstance(housing);
    } catch (Exception ex) {
      throw new RuntimeException("Failed to instantiate logic of class " + logicClass.getName() + ": " + ex.getMessage());
    }

    try {
      logic.setManual(isManual);
    } catch (Throwable e) {
      // uses older version of the API that doesn't implement setManual
    }
    housing.setFarmLogic(ForgeDirection.values()[slot + 2], logic);
  }
View Full Code Here


      if (farmLogics.length <= entry.getKey().ordinal() - 2 || farmLogics[entry.getKey().ordinal() - 2] == null)
        continue;

      boolean didWork = false;

      IFarmLogic logic = farmLogics[entry.getKey().ordinal() - 2];

      // Allow listeners to cancel this cycle.
      for (IFarmListener listener : eventHandlers)
        if (listener.cancelTask(logic, entry.getKey()))
          continue cycle;

      // Always try to collect windfall first.
      if (doCollection(logic))
        didWork = true;
      else
        for (int i = 0; i < entry.getValue().length; i++) {

          FarmTarget target = entry.getValue()[i];
          if (target.getExtent() <= 0)
            continue;
          else
            hasFarmland = true;

          if (!stage) {

            // Check fertilizer and water
            if (!hasFertilizer(logic.getFertilizerConsumption()))
              continue;
            else
              hasFertilizer = true;

            FluidStack liquid = LiquidHelper.getLiquid(Defaults.LIQUID_WATER, logic.getWaterConsumption(getHydrationModifier()));
            if (liquid.amount > 0 && !hasLiquid(liquid))
              continue;
            else
              hasLiquid = true;

            if (doCultivationPhase(logic, target, entry.getKey())) {
              // Remove fertilizer and water
              removeFertilizer(logic.getFertilizerConsumption());
              removeLiquid(liquid);

              didWork = true;
            }
View Full Code Here

    protected IFarmLogic getFarmLogic(IFarmHousing housing) throws Throwable{
        ArrayList<IFarmable> origList = (ArrayList<IFarmable>)Farmables.farmables.get("farmVegetables");
        ArrayList<IFarmable> backup = new ArrayList<IFarmable>(origList);
        origList.clear();
        origList.add(new FarmablePlastic(getBlock()));
        IFarmLogic logic = getLogicClass("FarmLogicVegetable").getConstructor(IFarmHousing.class).newInstance(housing);
        origList.clear();
        origList.addAll(backup);
        return logic;
    }
View Full Code Here

TOP

Related Classes of forestry.api.farming.IFarmLogic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.