private boolean canSmelt() {
   if (contents[0] == null) {
     return false;
   } else {
     ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(contents[0]);
     if (stack == null) return false;
     if (contents[2] == null) return true;
     if (!contents[2].isItemEqual(stack)) return false;
     int result = contents[2].stackSize + stack.stackSize;
     return result <= getInventoryStackLimit() && result <= contents[2].getMaxStackSize();
   }
 }
示例#2
0
  public void h() {
    if (!i()) {
      return;
    }
    ItemStack itemstack = FurnaceRecipes.a().a(h[0].a().ba);

    if (h[2] == null) {
      h[2] = itemstack.j();
    } else if (h[2].c == itemstack.c) {
      h[2].a++;
    }
    h[0].a--;
    if (h[0].a <= 0) {
      h[0] = null;
    }
  }
 public void smeltItem() {
   if (!canSmelt()) {
     return;
   }
   ItemStack itemstack =
       FurnaceRecipes.smelting().getSmeltingResult(furnaceItemStacks[0].getItem().shiftedIndex);
   if (furnaceItemStacks[2] == null) {
     furnaceItemStacks[2] = itemstack.copy();
   } else if (furnaceItemStacks[2].itemID == itemstack.itemID) {
     furnaceItemStacks[2].stackSize++;
   }
   furnaceItemStacks[0].stackSize--;
   if (furnaceItemStacks[0].stackSize <= 0) {
     furnaceItemStacks[0] = null;
   }
 }
  public void smeltItem() {
    if (canSmelt()) {
      ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(contents[0]);

      if (contents[2] == null) {
        contents[2] = stack.copy();
      } else if (contents[2].getItem() == stack.getItem()) {
        contents[2].stackSize += stack.stackSize;
      }

      contents[0].stackSize--;

      if (contents[0].stackSize <= 0) {
        contents[0] = null;
      }
    }
  }
示例#5
0
  private boolean i() {
    if (h[0] == null) {
      return false;
    }
    ItemStack itemstack = FurnaceRecipes.a().a(h[0].a().ba);

    if (itemstack == null) {
      return false;
    }
    if (h[2] == null) {
      return true;
    }
    if (!h[2].a(itemstack)) {
      return false;
    }
    if (h[2].a < c() && h[2].a < h[2].b()) {
      return true;
    }
    return h[2].a < itemstack.b();
  }
 private boolean canSmelt() {
   if (furnaceItemStacks[0] == null) {
     return false;
   }
   ItemStack itemstack =
       FurnaceRecipes.smelting().getSmeltingResult(furnaceItemStacks[0].getItem().shiftedIndex);
   if (itemstack == null) {
     return false;
   }
   if (furnaceItemStacks[2] == null) {
     return true;
   }
   if (!furnaceItemStacks[2].isItemEqual(itemstack)) {
     return false;
   }
   if (furnaceItemStacks[2].stackSize < getInventoryStackLimit()
       && furnaceItemStacks[2].stackSize < furnaceItemStacks[2].getMaxStackSize()) {
     return true;
   }
   return furnaceItemStacks[2].stackSize < itemstack.getMaxStackSize();
 }
示例#7
0
  public static void checkblock(String type, CustomBlockDesign item) {
    for (int rpc = 1; rpc < 10; ++rpc) {
      if (Configuration.block.contains(
          "Custom " + type + "." + item.getName() + ".shaped recipe" + rpc)) {
        int amount =
            Configuration.block.getInt(
                "Custom " + type + "." + item.getName() + ".shaped recipe" + rpc + ".amount");
        List list =
            Configuration.block.getList(
                "Custom " + type + "." + item.getName() + ".shaped recipe" + rpc + ".ingredients");
        int customId = 0;
        Iterator keys = list.iterator();
        String[] row1 = keys.next().toString().split(",");
        String[] row2 = keys.next().toString().split(",");
        String[] row3 = keys.next().toString().split(",");
        String srow1 = "";
        String srow2 = "";
        String srow3 = "";

        ItemStack result = new SpoutItemStack(item, amount);
        recipe = new SpoutShapedRecipe(result);
        recipe.shape("ghi", "def", "abc");

        char letter = 0;

        for (int count = 0; count < 3; count++) {
          if (row1[count].contains(":")) {
            if (count == 0) {
              row1dv1 = row1[count].split(":");
            } else if (count == 1) {
              row1dv2 = row1[count].split(":");
            } else if (count == 2) {
              row1dv3 = row1[count].split(":");
            }
          }
        }
        for (int count = 0; count < 3; count++) {
          if (row2[count].contains(":")) {
            if (count == 0) {
              row2dv1 = row2[count].split(":");
            } else if (count == 1) {
              row2dv2 = row2[count].split(":");
            } else if (count == 2) {
              row2dv3 = row2[count].split(":");
            }
          }
        }
        for (int count = 0; count < 3; count++) {
          if (row3[count].contains(":")) {
            if (count == 0) {
              row3dv1 = row3[count].split(":");
            } else if (count == 1) {
              row3dv2 = row3[count].split(":");
            } else if (count == 2) {
              row3dv3 = row3[count].split(":");
            }
          }
        }

        for (int rowi = 0; rowi < 3; ++rowi) {
          if (rowi == 0) {
            for (i = 0; i < 3; ) {
              if (i == 0) {
                letter = 'a';
                rowletter = "a";
              } else if (i == 1) {
                letter = 'b';
                rowletter = "b";
              } else if (i == 2) {
                letter = 'c';
                rowletter = "c";
              }
              if (row1[i] != "-") {
                try {
                  if (i == 0) {
                    if (row1dv1 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row1dv1[0]), Short.parseShort(row1dv1[1])));
                      srow1 = srow1 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row1[i])));
                      srow1 = srow1 + rowletter;
                    }
                  } else if (i == 1) {
                    if (row1dv2 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row1dv2[0]), Short.parseShort(row1dv2[1])));
                      srow1 = srow1 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row1[i])));
                      srow1 = srow1 + rowletter;
                    }
                  } else {
                    if (row1dv3 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row1dv3[0]), Short.parseShort(row1dv3[1])));
                      srow1 = srow1 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row1[i])));
                      srow1 = srow1 + rowletter;
                    }
                  }
                } catch (NumberFormatException e) {
                  for (GenericCustomItem itemcheck : Hashmaps.customitemsmap.values()) {
                    if (itemcheck.getName().equals(row1[i])) {
                      customId = itemcheck.getCustomId();
                      srow1 = srow1 + rowletter;
                    }
                  }
                  for (CustomOresDesign block : Hashmaps.customoresmap.values()) {
                    if (block.getName().equals(row1[i])) {
                      customId = block.getCustomId();
                      srow1 = srow1 + rowletter;
                    }
                  }
                  for (GenericCustomTool toolcheck : Hashmaps.customtoolsmap.values()) {
                    if (toolcheck.getName().equals(row1[i])) {
                      customId = toolcheck.getCustomId();
                      srow1 = srow1 + rowletter;
                    }
                  }
                  for (GenericCustomFood foodcheck : Hashmaps.customfoodmap.values()) {
                    if (foodcheck.getName().equals(row1[i])) {
                      customId = foodcheck.getCustomId();
                      srow1 = srow1 + rowletter;
                    }
                  }
                  recipe.setIngredient(letter, MaterialData.getCustomItem(customId));
                }
              } else {
                srow1 = srow1 + " ";
              }
              ++i;
            }
          } else if (rowi == 1) {
            for (int i = 0; i < 3; ) {
              if (i == 0) {
                letter = 'd';
                rowletter = "d";
              } else if (i == 1) {
                letter = 'e';
                rowletter = "e";
              } else if (i == 2) {
                letter = 'f';
                rowletter = "f";
              }
              if (row2[i] != "-") {
                try {
                  if (i == 0) {
                    if (row2dv1 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row2dv1[0]), Short.parseShort(row2dv1[1])));
                      srow2 = srow2 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row2[i])));
                      srow2 = srow2 + rowletter;
                    }
                  } else if (i == 1) {
                    if (row2dv2 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row2dv2[0]), Short.parseShort(row2dv2[1])));
                      srow2 = srow2 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row2[i])));
                      srow2 = srow2 + rowletter;
                    }
                  } else {
                    if (row2dv3 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row2dv3[0]), Short.parseShort(row2dv3[1])));
                      srow2 = srow2 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row2[i])));
                      srow2 = srow2 + rowletter;
                    }
                  }
                } catch (NumberFormatException e) {
                  for (GenericCustomItem itemcheck : Hashmaps.customitemsmap.values()) {
                    if (itemcheck.getName().equals(row2[i])) {
                      customId = itemcheck.getCustomId();
                      srow2 = srow2 + rowletter;
                    }
                  }
                  for (CustomOresDesign block : Hashmaps.customoresmap.values()) {
                    if (block.getName().equals(row2[i])) {
                      customId = block.getCustomId();
                      srow2 = srow2 + rowletter;
                    }
                  }
                  for (GenericCustomTool toolcheck : Hashmaps.customtoolsmap.values()) {
                    if (toolcheck.getName().equals(row2[i])) {
                      customId = toolcheck.getCustomId();
                      srow2 = srow2 + rowletter;
                    }
                  }
                  for (GenericCustomFood foodcheck : Hashmaps.customfoodmap.values()) {
                    if (foodcheck.getName().equals(row2[i])) {
                      customId = foodcheck.getCustomId();
                      srow2 = srow2 + rowletter;
                    }
                  }
                  recipe.setIngredient(letter, MaterialData.getCustomItem(customId));
                }
              } else {
                srow2 = srow2 + " ";
              }
              ++i;
            }
          } else if (rowi == 2) {
            for (int i = 0; i < 3; ) {
              if (i == 0) {
                letter = 'g';
                rowletter = "g";
              } else if (i == 1) {
                letter = 'h';
                rowletter = "h";
              } else if (i == 2) {
                letter = 'i';
                rowletter = "i";
              }
              if (row3[i] != "-") {
                try {
                  if (i == 0) {
                    if (row3dv1 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row3dv1[0]), Short.parseShort(row3dv1[1])));
                      srow3 = srow3 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row3[i])));
                      srow3 = srow3 + rowletter;
                    }
                  } else if (i == 1) {
                    if (row3dv2 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row3dv2[0]), Short.parseShort(row3dv2[1])));
                      srow3 = srow3 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row3[i])));
                      srow3 = srow3 + rowletter;
                    }
                  } else {
                    if (row3dv3 != null) {
                      recipe.setIngredient(
                          letter,
                          MaterialData.getMaterial(
                              Integer.parseInt(row3dv3[0]), Short.parseShort(row3dv3[1])));
                      srow3 = srow3 + rowletter;
                    } else {
                      recipe.setIngredient(
                          letter, MaterialData.getMaterial(Integer.parseInt(row3[i])));
                      srow3 = srow3 + rowletter;
                    }
                  }
                } catch (NumberFormatException e) {
                  for (GenericCustomItem itemcheck : Hashmaps.customitemsmap.values()) {
                    if (itemcheck.getName().equals(row3[i])) {
                      customId = itemcheck.getCustomId();
                      srow3 = srow3 + rowletter;
                    }
                  }
                  for (CustomOresDesign block : Hashmaps.customores) {
                    if (block.getName().equals(row3[i])) {
                      customId = block.getCustomId();
                      srow3 = srow3 + rowletter;
                    }
                  }
                  for (GenericCustomTool toolcheck : Hashmaps.customtoolsmap.values()) {
                    if (toolcheck.getName().equals(row3[i])) {
                      customId = toolcheck.getCustomId();
                      srow3 = srow3 + rowletter;
                    }
                  }
                  for (GenericCustomFood foodcheck : Hashmaps.customfoodmap.values()) {
                    if (foodcheck.getName().equals(row3[i])) {
                      customId = foodcheck.getCustomId();
                      srow3 = srow3 + rowletter;
                    }
                  }
                  recipe.setIngredient(letter, MaterialData.getCustomItem(customId));
                }
              } else {
                srow3 = srow3 + " ";
              }
              ++i;
            }
          }
        }
        recipe.shape(srow1, srow2, srow3);
        SpoutManager.getMaterialManager().registerSpoutRecipe(recipe);
        System.out.println(
            "[RpgEssentials] Added shaped recipe " + rpc + " for: " + item.getName());
      }
      if (Configuration.block.contains(
          "Custom " + type + "." + item.getName() + ".furnace recipe" + rpc)) {
        int amount =
            Configuration.block.getInt(
                "Custom " + type + "." + item.getName() + ".furnace recipe" + rpc + ".amount");
        String ingredientraw =
            Configuration.block.getString(
                "Custom " + type + "." + item.getName() + ".furnace recipe" + rpc + ".ingredient");
        int customId = 0;
        ItemStack result = new SpoutItemStack(item, amount);
        try {
          int ingredient = Integer.parseInt(ingredientraw);
          FurnaceRecipes.NewFurnaceRecipe(result, ingredient);
        } catch (NumberFormatException e) {
          CustomOresDesign test1 = Hashmaps.customoresmap.get(ingredientraw);
          GenericCustomItem test2 = Hashmaps.customitemsmap.get(ingredientraw);
          GenericCustomTool test3 = Hashmaps.customtoolsmap.get(ingredientraw);
          if (test1 != null) {
            FurnaceRecipes.CustomOreFurnaceRecipe(result, Material.STONE, test1);
          } else if (test2 != null) {
            FurnaceRecipes.CustomItemFurnaceRecipe(result, Material.FLINT, test2);
          } else {
            FurnaceRecipes.CustomToolFurnaceRecipe(result, Material.FLINT, test3);
          }
        }
      }
    }
  }