Пример #1
0
  public void careForInventorySlot(int i, float startTemp) {
    NBTTagCompound inputCompound;
    float mod = 1;
    if (i == 0) {
      if (fireItemStacks[5] != null) {
        mod = 0.8F;
      } else {
        mod = 0.6F;
        if (fireItemStacks[6] == null) {
          mod = 0.3F;
        }
      }
    } else if (i == 1) {
      if (fireItemStacks[6] != null) {
        mod = 0.9F;
      } else {
        mod = 0.7F;
        if (fireItemStacks[7] == null) {
          mod = 0.4F;
        }
      }
    } else if (i == 2) {
      if (fireItemStacks[7] != null) {
        mod = 1.0F;
      } else {
        mod = 0.5F;
      }
    } else if (i == 3) {
      if (fireItemStacks[8] != null) {
        mod = 0.9F;
      } else {
        mod = 0.7F;
        if (fireItemStacks[7] == null) {
          mod = 0.4F;
        }
      }
    } else if (i == 4) {
      if (fireItemStacks[9] != null) {
        mod = 0.8F;
      } else {
        mod = 0.6F;
        if (fireItemStacks[8] == null) {
          mod = 0.3F;
        }
      }
    }

    HeatRegistry manager = HeatRegistry.getInstance();

    if (fireItemStacks[i] != null && fireItemStacks[i].hasTagCompound()) {
      HeatIndex index = manager.findMatchingIndex(fireItemStacks[i]);

      inputCompound = fireItemStacks[i].getTagCompound();

      if (inputCompound.hasKey("temperature")) {
        inputItemTemps[i] = inputCompound.getFloat("temperature");
      } else {
        inputItemTemps[i] = ambientTemp;
      }

      if (fireTemperature * mod > inputItemTemps[i]) {
        float increase =
            TFC_ItemHeat.getTempIncrease(fireItemStacks[i], fireTemperature * mod, MaxFireTemp);
        inputItemTemps[i] += increase;
      } else if (fireTemperature * mod < inputItemTemps[i]) {
        float increase = TFC_ItemHeat.getTempDecrease(fireItemStacks[i]);
        inputItemTemps[i] -= increase;
      }
      inputCompound.setFloat("temperature", inputItemTemps[i]);
      fireItemStacks[i].setTagCompound(inputCompound);

      if (inputItemTemps[i] <= ambientTemp) {
        Collection C = fireItemStacks[i].getTagCompound().getTags();
        Iterator itr = C.iterator();
        while (itr.hasNext()) {
          Object tag = itr.next();
          if (TFC_ItemHeat.canRemoveTag(tag, "temperature", NBTTagFloat.class)) {
            itr.remove();
            break;
          }
        }
        // fireItemStacks[i].stackTagCompound = null;
      }
    } else if (fireItemStacks[i] != null && !fireItemStacks[i].hasTagCompound()) {
      if (TFC_ItemHeat.getMeltingPoint(fireItemStacks[i]) != -1) {
        inputCompound = new NBTTagCompound();
        inputCompound.setFloat("temperature", startTemp);
        fireItemStacks[i].setTagCompound(inputCompound);
        inputItemTemps[i] = startTemp;
      }
    } else if (fireItemStacks[i] == null) {
      inputItemTemps[i] = 0;
    }
  }
Пример #2
0
  public void CookItemsNew(int i) {
    HeatRegistry manager = HeatRegistry.getInstance();
    Random R = new Random();
    if (fireItemStacks[i] != null) {
      HeatIndex index = manager.findMatchingIndex(fireItemStacks[i]);
      ItemStack inputCopy = fireItemStacks[i].copy();
      if (index != null && inputItemTemps[i] > index.meltTemp) {
        int dam = fireItemStacks[i].getItemDamage();
        ItemStack is = fireItemStacks[i].copy();
        // Morph the input
        if (!(fireItemStacks[i].getItem() instanceof ItemMeltedMetal))
          fireItemStacks[i] = index.getMorph();

        if (fireItemStacks[i] != null) {
          HeatIndex index2 = manager.findMatchingIndex(fireItemStacks[i]);
          if (index2 != null) {
            // if the input is a new item, then apply the old temperature to it
            NBTTagCompound nbt = new NBTTagCompound();
            nbt.setFloat("temperature", inputItemTemps[i]);
            fireItemStacks[i].stackTagCompound = nbt;
          }
        } else if (index.hasOutput()) {
          ItemStack output = index.getOutput(inputCopy, R);
          int count = 1;
          Boolean useCount = false;
          if (output.getItem() instanceof ItemMeltedMetal) {
            if (output.stackSize >= 1) {
              count = 0;
              int c = output.stackSize;
              for (int iterations = 0; c > 0 && iterations <= 20; iterations++) {
                if (fireItemStacks[10] != null
                    && fireItemStacks[10].getItem().itemID == TFCItems.CeramicMold.itemID) {
                  fireItemStacks[10].stackSize--;
                  if (fireItemStacks[10].stackSize == 0) fireItemStacks[10] = null;
                  c--;
                  count++;
                } else if (fireItemStacks[11] != null
                    && fireItemStacks[11].getItem().itemID == TFCItems.CeramicMold.itemID) {
                  fireItemStacks[11].stackSize--;
                  if (fireItemStacks[11].stackSize == 0) fireItemStacks[11] = null;
                  c--;
                  count++;
                } else if (fireItemStacks[12] != null
                    && fireItemStacks[12].getItem().itemID == TFCItems.CeramicMold.itemID) {
                  fireItemStacks[12].stackSize--;
                  if (fireItemStacks[12].stackSize == 0) fireItemStacks[12] = null;
                  c--;
                  count++;
                } else if (fireItemStacks[13] != null
                    && fireItemStacks[13].getItem().itemID == TFCItems.CeramicMold.itemID) {
                  fireItemStacks[13].stackSize--;
                  if (fireItemStacks[13].stackSize == 0) fireItemStacks[13] = null;
                  c--;
                  count++;
                }
              }
            }
            useCount = true;
          }
          fireItemStacks[i] = output;
          if (useCount) {
            if (count > 0) fireItemStacks[i].stackSize = count;
            else fireItemStacks[i] = null;
          }

          HeatIndex index2 = manager.findMatchingIndex(fireItemStacks[i]);
          if (index2 != null) {
            // if the input is a new item, then apply the old temperature to it
            NBTTagCompound nbt = new NBTTagCompound();
            nbt.setFloat("temperature", inputItemTemps[i]);
            fireItemStacks[i].stackTagCompound = nbt;
          }
          if (fireItemStacks[i] != null
              && fireItemStacks[i].getItem() instanceof ItemMeltedMetal
              && is.getItem() instanceof ItemMeltedMetal) {
            fireItemStacks[i].setItemDamage(dam);
          }
        }
      }
    }
  }