Пример #1
0
void Furnace::smelt()
{
  // Check if we're cooking
  if(isCooking())
  {
    // Convert where applicable
    Slot inputSlot  = m_slots[SLOT_INPUT];
    Slot fuelSlot   = m_slots[SLOT_FUEL];
    Slot outputSlot = m_slots[SLOT_OUTPUT];
    int32_t creationID = 0;
    if(inputSlot.id == BLOCK_IRON_ORE)    { creationID = ITEM_IRON_INGOT; }
    if(inputSlot.id == BLOCK_GOLD_ORE)    { creationID = ITEM_GOLD_INGOT; }
    if(inputSlot.id == BLOCK_SAND)        { creationID = BLOCK_GLASS; }
    if(inputSlot.id == BLOCK_COBBLESTONE) { creationID = BLOCK_STONE; }
    if(inputSlot.id == ITEM_PORK)         { creationID = ITEM_GRILLED_PORK; }
    if(inputSlot.id == ITEM_CLAY_BALLS)   { creationID = ITEM_CLAY_BRICK; }
    if(inputSlot.id == ITEM_RAW_FISH)     { creationID = ITEM_COOKED_FISH; }

    // Update other params if we actually converted
    if(creationID != 0)
    {
      // Ok - now check if the current output slot contains the same stuff
      if(outputSlot.id != creationID)
      {
        // No so overwrite it
        outputSlot.id = creationID;
        outputSlot.count = 0;
      }

      // Increment output and decrememnt the input source
      outputSlot.count++;
      inputSlot.count--;
      outputSlot.damage = inputSlot.damage;

      // Bounds check all
      if(outputSlot.count > 64)
      {
        outputSlot.count = 64;
      }

      if(inputSlot.count < 0)
      {
        inputSlot.count = 0;
      }

      // Update the m_slots
      m_slots[SLOT_INPUT]  = inputSlot;
      m_slots[SLOT_FUEL]   = fuelSlot;
      m_slots[SLOT_OUTPUT] = outputSlot;
    }
  }

  // Reset our active cook durations
  m_activeCookDuration = 0;
}
Пример #2
0
void Furnace::smelt()
{
  // Check if we're cooking
  if (isCooking())
  {
    // Convert where applicable
    Item* inputSlot  = &slots()[SLOT_INPUT];
    Item* fuelSlot   = &slots()[SLOT_FUEL];
    Item* outputSlot = &slots()[SLOT_OUTPUT];
    int32_t creationID = createList[inputSlot->getType()].output;

    // Update other params if we actually converted
    if (creationID != -1 && outputSlot->getCount() != 64)
    {
      // Check if the outputSlot is empty
      if (outputSlot->getType() == -1)
      {
        outputSlot->setType(creationID);
        outputSlot->setCount(1);
        outputSlot->setHealth(createList[inputSlot->getType()].meta);
        inputSlot->setCount(inputSlot->getCount() - 1);
        m_data->cookTime = 0;
      }

      // Ok - now check if the current output slot contains the same stuff
      if (outputSlot->getType() == creationID && m_data->cookTime != 0)
      {
        // Increment output and decrememnt the input source
        outputSlot->setCount(outputSlot->getCount() + createList[inputSlot->getType()].count);
        inputSlot->setCount(inputSlot->getCount() - 1);
        outputSlot->setHealth(createList[inputSlot->getType()].meta);
        m_data->cookTime = 0;

        if (inputSlot->getCount() == 0)
        {
          *inputSlot = Item();
        }
      }
    }
  }
}
Пример #3
0
void Furnace::smelt()
{
  // Check if we're cooking
  if(isCooking())
  {
    // Convert where applicable
    Item* inputSlot  = &slots()[SLOT_INPUT];
    Item* fuelSlot   = &slots()[SLOT_FUEL];
    Item* outputSlot = &slots()[SLOT_OUTPUT];
    int32_t creationID = createList[inputSlot->type].output;
 
    // Update other params if we actually converted
    if(creationID != -1 && outputSlot->count != 64)
    {
      // Check if the outputSlot is empty
      if(outputSlot->type == -1)
      {
        outputSlot->type = creationID;
        outputSlot->count = 0;
      }

      // Ok - now check if the current output slot contains the same stuff
      if(outputSlot->type == creationID)
      {
        // Increment output and decrememnt the input source
        outputSlot->count+=createList[inputSlot->type].count;
        inputSlot->count--;
        outputSlot->health = createList[inputSlot->type].meta;
        data->cookTime = 0;

        if(inputSlot->count == 0)
        {
          *inputSlot = Item();
        }
      }
    }
  }
}