private Item createPipeSpecial(Class<? extends Pipe<?>> clas) {
    ItemPipe item = new ItemPipeAP();
    item.setUnlocalizedName(clas.getSimpleName());
    proxy.registerPipeRendering(item);
    BlockGenericPipe.pipes.put(item, clas);

    GameRegistry.registerItem(item, item.getUnlocalizedName());

    proxy.createPipeSpecial(item, clas);

    return item;
  }
Пример #2
0
  public static ItemPipe registerPipe(int key, Class<? extends Pipe> clas) {
    ItemPipe item = new ItemPipe(key);
    item.setUnlocalizedName("buildcraftPipe." + clas.getSimpleName().toLowerCase(Locale.ENGLISH));
    GameRegistry.registerItem(item, item.getUnlocalizedName());

    pipes.put(item.itemID, clas);

    Pipe dummyPipe = createPipe(item.itemID);
    if (dummyPipe != null) {
      item.setPipeIconIndex(dummyPipe.getIconIndexForItem());
      TransportProxy.proxy.setIconProviderFromPipe(item, dummyPipe);
    }
    return item;
  }
  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;
  }