By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,044 Members | 1,720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,044 IT Pros & Developers. It's quick & easy.

Minecraft Forge Problem

P: 8
Hythere! so far i've got another problem. the code does not have any compile errors, but i can't find the block in the game( ; _ ; )/~~~
Code:
Expand|Select|Wrap|Line Numbers
  1. package xyz.zhc.elements;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.block.material.Material;
  5. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  6. import net.minecraft.creativetab.CreativeTabs;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemBlock;
  9. import net.minecraftforge.client.event.ModelRegistryEvent;
  10. import net.minecraftforge.client.model.ModelLoader;
  11. import net.minecraftforge.event.RegistryEvent;
  12. import net.minecraftforge.fml.common.Mod;
  13. import net.minecraftforge.fml.common.Mod.EventHandler;
  14. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  15. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  16. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  17.  
  18. @Mod(modid = Elements.MODID, name = Elements.NAME, version = Elements.VERSION)
  19. public class Elements {
  20.     public static final String MODID = "elements";
  21.     public static final String NAME = "Elements";
  22.     public static final String DESCRIPTION = "The elements and chemical mod.";
  23.     public static final String VERSION = "0.2.0";    
  24.  
  25.     public static Block hydrogen = new Block(Material.ROCK),
  26.                         helium = new Block(Material.ROCK);
  27.     public static ItemBlock ihydrogen = new ItemBlock(hydrogen),
  28.                             ihelium = new ItemBlock(helium);
  29.  
  30.     @SubscribeEvent
  31.     public static void registerBlocks(RegistryEvent.Register<Block> event) {
  32.         event.getRegistry().registerAll(hydrogen, helium);
  33.     }
  34.     @SubscribeEvent
  35.     public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
  36.         event.getRegistry().registerAll(ihydrogen, ihelium);
  37.     }
  38.     @SubscribeEvent
  39.     public static void registerRenders(ModelRegistryEvent event) {
  40.         registerRender(ihydrogen);
  41.         registerRender(ihelium);
  42.     }
  43.     @SubscribeEvent
  44.     public static void registerRender(Item itemEvent) {
  45.         ModelLoader.setCustomModelResourceLocation(itemEvent, 0, new ModelResourceLocation( itemEvent.getRegistryName(), null)); 
  46.     }
  47.  
  48.  
  49.     @EventHandler
  50.     public static void preInit(FMLPreInitializationEvent event) {
  51.         //
  52.     }
  53.     @EventHandler
  54.     public static void init(FMLInitializationEvent event) {
  55.         hydrogen.setUnlocalizedName("hydrogen");
  56.         hydrogen.setRegistryName("hydrogen");
  57.         hydrogen.setCreativeTab(CreativeTabs.MISC);
  58.         hydrogen.setHardness((float) 0.1);
  59.         ihydrogen.setRegistryName("hydrogen");
  60.         ihydrogen.setUnlocalizedName("hydrogen");
  61.         helium.setUnlocalizedName("helium");
  62.         helium.setRegistryName("helium");
  63.         helium.setCreativeTab(CreativeTabs.MISC);
  64.         helium.setHardness((float) 0.1);
  65.         ihelium.setRegistryName("helium");
  66.         ihelium.setUnlocalizedName("helium");
  67.     }
  68.  
  69. }
  70.  
  71.  
Attachments are hydrogen.png and helium.png - textures of block hydrogen & helium.
Attached Images
File Type: png hydrogen.png (986 Bytes, 6 views)
File Type: png helium.png (915 Bytes, 6 views)
1 Week Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.