Ejemplo n.º 1
0
  public static Item createPipe(
      int defaultID,
      Class<? extends Pipe> clas,
      String descr,
      Object ingredient1,
      Object ingredient2,
      Object ingredient3) {
    String name =
        Character.toLowerCase(clas.getSimpleName().charAt(0)) + clas.getSimpleName().substring(1);

    Property prop = BuildCraftCore.mainConfiguration.getItem(name + ".id", defaultID);

    int id = prop.getInt(defaultID);
    ItemPipe res = BlockGenericPipe.registerPipe(id, clas);
    res.setItemName(clas.getSimpleName());
    LanguageRegistry.addName(res, descr);

    // Add appropriate recipe to temporary list
    PipeRecipe recipe = new PipeRecipe();

    if (ingredient1 != null && ingredient2 != null && ingredient3 != null) {
      recipe.result = new ItemStack(res, 8);
      recipe.input =
          new Object[] {
            "ABC",
            Character.valueOf('A'),
            ingredient1,
            Character.valueOf('B'),
            ingredient2,
            Character.valueOf('C'),
            ingredient3
          };

      pipeRecipes.add(recipe);
    } else if (ingredient1 != null && ingredient2 != null) {
      recipe.isShapeless = true;
      recipe.result = new ItemStack(res, 1);
      recipe.input = new Object[] {ingredient1, ingredient2};

      pipeRecipes.add(recipe);
    }

    return res;
  }
  private static ItemPipe createPipe(int defaultID, Class<? extends Pipe> clazz, String descr) {
    String name =
        Character.toLowerCase(clazz.getSimpleName().charAt(0)) + clazz.getSimpleName().substring(1);

    Property prop = aboConfiguration.getItem(name + ".id", defaultID);

    int id = prop.getInt(defaultID);

    try {
      // search for free id
      while (BlockGenericPipe.isPipeRegistered(id)) ++id;

      prop.set(id);
    } catch (NoSuchMethodError e) {
      // e.printStackTrace();
    }

    ItemPipe pipe = BlockGenericPipe.registerPipe(id, clazz);
    pipe.setUnlocalizedName(clazz.getSimpleName());
    LanguageRegistry.addName(pipe, descr);
    GameRegistry.registerItem(pipe, pipe.getUnlocalizedName().replace("item.", ""));

    return pipe;
  }
 private static Item createPipe(Class<? extends Pipe<?>> clas) {
   Item res = BlockGenericPipe.registerPipe(clas, CreativeTabBuildCraft.PIPES);
   res.setUnlocalizedName(clas.getSimpleName());
   proxy.registerPipeRendering(res);
   return res;
 }