Example #1
0
 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);
   }
 }
Example #2
0
 int addVillager(String name, ResourceLocation skin) {
   int id = config.getVillager(name);
   VSBinding b = new VSBinding();
   b.id = id;
   b.object = skin;
   registeredVillagers.add(b);
   return id;
 }
Example #3
0
 void preallocateBlockIDs(boolean[] configMarkers) {
   ConfigCategory items = config.getCategory(config.CATEGORY_BLOCK);
   for (Property prop : items.getValues().values()) {
     int id = prop.getInt();
     if (id != -1) {
       // System.out.printf("BaseMod.preallocateItemIDs: Marking block id %d as in use\n", id);
       configMarkers[id] = true;
     }
   }
 }
Example #4
0
 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);
   }
 }
Example #5
0
 void saveConfig() {
   if (config.extended) config.save();
 }