Guest User

ModBlocks

a guest
Aug 4th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. package trolio.morethings.init;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import net.minecraft.block.Block;
  7. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  8. import net.minecraft.item.Item;
  9. import net.minecraft.item.ItemBlock;
  10. import net.minecraft.item.ItemSlab;
  11. import net.minecraftforge.client.model.ModelLoader;
  12. import net.minecraftforge.fml.common.registry.ForgeRegistries;
  13. import trolio.morethings.blocks.CopperBlock;
  14. import trolio.morethings.blocks.WhiteGlass.WhiteGlassDoubleSlab;
  15. import trolio.morethings.blocks.WhiteGlass.WhiteGlassHalfSlab;
  16.  
  17. public class ModBlocks
  18. {
  19. public static final List<Block> BLOCKS = new ArrayList<Block>();
  20.  
  21. //slabs
  22. public static WhiteGlassHalfSlab slabWhiteGlassHalf;
  23. public static WhiteGlassDoubleSlab slabWhiteGlassDouble;
  24.  
  25. public static Block blockCopper;
  26.  
  27. public static void init()
  28. {
  29. slabWhiteGlassHalf = new WhiteGlassHalfSlab("slab_whiteglass_half");
  30. slabWhiteGlassDouble = new WhiteGlassDoubleSlab("slab_whiteglass_double");
  31.  
  32. blockCopper = new CopperBlock("block_copper");
  33. }
  34.  
  35. public static void register()
  36. {
  37. registerBlock(slabWhiteGlassHalf, new ItemSlab(slabWhiteGlassHalf, slabWhiteGlassHalf, slabWhiteGlassDouble));
  38.  
  39. registerBlock(blockCopper);
  40. }
  41.  
  42. public static void registerBlock (Block block)
  43. {
  44. ForgeRegistries.BLOCKS.register(block);
  45. ItemBlock item = new ItemBlock(block);
  46. item.setRegistryName(block.getRegistryName());
  47. ForgeRegistries.ITEMS.register(item);
  48.  
  49. ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
  50. }
  51.  
  52. public static void registerBlock (Block block, ItemBlock itemblock)
  53. {
  54. ForgeRegistries.BLOCKS.register(block);
  55. itemblock.setRegistryName(block.getRegistryName());
  56. ForgeRegistries.ITEMS.register(itemblock);
  57.  
  58. ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment