コード例 #1
0
ファイル: BaseMod.java プロジェクト: nevercast/SGCraft
 public <BLOCK extends Block> BLOCK newBlock(
     String name, Class<BLOCK> cls, Class itemClass, String title) {
   try {
     int id = config.getBlock(name, 4095).getInt();
     Constructor<BLOCK> ctor = cls.getConstructor(int.class);
     BLOCK block = ctor.newInstance(id);
     String qualName = assetKey + ":" + name;
     block.setUnlocalizedName(qualName);
     // block.func_111022_d(qualName.toLowerCase()); // Set default icon name
     // block.func_111022_d(qualName); // Set default icon name
     block.setTextureName(qualName); // Set default icon name
     GameRegistry.registerBlock(block, itemClass);
     if (title != null) {
       LanguageRegistry.addName(block, title);
       if (clientSide) {
         // System.out.printf("%s: BaseMod.newBlock: %s: creative tab = %s\n",
         //	this, block.getUnlocalizedName(), block.getCreativeTabToDisplayOn());
         if (block.getCreativeTabToDisplayOn() == null && !title.startsWith("["))
           block.setCreativeTab(CreativeTabs.tabMisc);
       }
     }
     if (block instanceof IBlock) registeredBlocks.add((IBlock) block);
     return block;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
コード例 #2
0
ファイル: BaseMod.java プロジェクト: nevercast/SGCraft
 public <ITEM extends Item> ITEM newItem(String name, Class<ITEM> cls, String title) {
   try {
     int id = config.getItem(name, 31743).getInt();
     Constructor<ITEM> ctor = cls.getConstructor(int.class);
     ITEM item = ctor.newInstance(id);
     String qualName = assetKey + ":" + name;
     item.setUnlocalizedName(qualName);
     // item.func_111206_d(qualName.toLowerCase()); // Set default icon name
     // item.func_111206_d(qualName); // Set default icon name
     item.setTextureName(qualName); // Set default icon name
     LanguageRegistry.addName(item, title);
     if (clientSide) {
       if (item.getCreativeTab() == null) item.setCreativeTab(CreativeTabs.tabMisc);
     }
     // System.out.printf("BaseMod.newItem: %s unlocalizedName = %s title = %s\n",
     //	item, item.getUnlocalizedName(), title);
     return item;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }