Пример #1
0
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (isPowered()
        && currentRecipe != null
        && cookTime > 0
        && (getStackInSlot(9) == null
            || this.getStackInSlot(9).getItem().equals(currentRecipe.getResult().getItem()))) {
      cookTime--;
      if (cookTime == 1) {
        ItemStack result = currentRecipe.getResult().copy();
        for (int i = 0; i < 9; i++) {
          ItemStack item = this.getStackInSlot(i);
          if (item != null && item.stackSize == 1 && !(item.getItem() instanceof ItemKitchenTool))
            this.setInventorySlotContents(i, null);
          else if (item != null && item.stackSize > 1) {
            item.stackSize--;
          }
        }
        if (getStackInSlot(9) != null
            && getStackInSlot(9).getItem().equals(currentRecipe.getResult().getItem())) {
          getStackInSlot(9).stackSize++;
        } else {
          this.setInventorySlotContents(9, result);
        }
        cookTime = 0;
        currentRecipe = null;
        setWorking(false);
        checkRecipes();
      }
    }
  }
Пример #2
0
  public void checkRecipes() {
    OvenRecipe newRecipe = RecipeManager.getOvenRecipe(this);
    if (newRecipe != null) {
      if (currentRecipe == null || !currentRecipe.equals(newRecipe)) {
        currentRecipe = newRecipe;
        setCookTime(200);
        setWorking(true);
      }

    } else if (getCookTime() > 0 && newRecipe == null) {
      setCookTime(0);
      currentRecipe = null;
      setWorking(false);
    }
  }