Ejemplo n.º 1
0
  private void getCookableFoodFromInventory() {
    for (int i = 0; i < owner.getInventory().getSizeInventory(); i++) {
      ItemStack stack = owner.getInventory().getStackInSlot(i);

      for (final CookableFood entry : RegistryMCA.getCookableFoodList()) {
        if (stack != null && stack.getItem() == entry.getFoodRaw()) {
          indexOfCookingFood = RegistryMCA.getCookableFoodList().indexOf(entry);
          hasCookableFood = true;
        }
      }
    }
  }
Ejemplo n.º 2
0
  private void doCookFood() {
    final double distanceToFurnace = RadixMath.getDistanceToXYZ(owner, furnacePos);

    if (distanceToFurnace <= 2.5D) {
      if (isCooking) {
        if (cookingTicks <= cookingInterval) {
          if (BlockHelper.getBlock(
                  owner.worldObj, furnacePos.iPosX, furnacePos.iPosY, furnacePos.iPosZ)
              != Blocks.lit_furnace) {
            BlockHelper.updateFurnaceState(
                true, owner.worldObj, furnacePos.iPosX, furnacePos.iPosY, furnacePos.iPosZ);
          }

          cookingTicks++;
        } else {
          CookableFood foodObj = RegistryMCA.getCookableFoodList().get(indexOfCookingFood);
          int rawFoodSlot = owner.getInventory().getFirstSlotContainingItem(foodObj.getFoodRaw());

          if (rawFoodSlot > -1) {
            owner.getInventory().decrStackSize(rawFoodSlot, 1);
            addItemStackToInventory(new ItemStack(foodObj.getFoodCooked(), 1, 0));
            owner.swingItem();
          } else {
            EntityPlayer player = getAssigningPlayer();

            if (player != null) {
              owner.sayRaw("I don't have any food to cook.", player); // TODO Translate.
            }

            reset();
          }

          isCooking = false;
          hasCookableFood = false;
          cookingTicks = 0;
          fuelUsesRemaining--;
          BlockHelper.updateFurnaceState(
              false, owner.worldObj, furnacePos.iPosX, furnacePos.iPosY, furnacePos.iPosZ);

          if (fuelUsesRemaining <= 0) {
            hasFuel = false;
          }
        }
      } else {
        owner.swingItem();
        isCooking = true;
      }
    }
  }
Ejemplo n.º 3
0
  private boolean hasCookableFood() {
    CookableFood foodObj = RegistryMCA.getCookableFoodList().get(indexOfCookingFood);
    int rawFoodSlot = owner.getInventory().getFirstSlotContainingItem(foodObj.getFoodRaw());

    return rawFoodSlot > -1;
  }