Advertisement
WitherDoggie

Block Renderer

May 22nd, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. package com.wither.withermod.blocks;
  2.  
  3. import com.wither.withermod.Main;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.client.Minecraft;
  7. import net.minecraft.client.resources.model.ModelBakery;
  8. import net.minecraft.client.resources.model.ModelResourceLocation;
  9. import net.minecraft.item.Item;
  10. import net.minecraft.util.ResourceLocation;
  11.  
  12. public class BlockRender {
  13.    
  14.     //Sets render method for blocks
  15.     public static void registerBlock(Block block){
  16.  
  17.         Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(Main.MODID + ":" + block.getUnlocalizedName().substring(5), "inventory"));
  18.     }
  19.        
  20.    
  21.     public static void registerBlock(){
  22.        
  23.         //Ores
  24.         registerBlock(BlockRegistry.Garium_Ore);
  25.         registerBlock(BlockRegistry.Radium_Ore);
  26.         registerBlock(BlockRegistry.LavaGemOre);
  27.        
  28.         //Crops
  29.         registerBlock(BlockRegistry.cornPlant);
  30.         registerBlock(BlockRegistry.tomatoPlant);
  31.         registerBlock(BlockRegistry.lettucePlant);
  32.  
  33.         //PaneBlocks
  34.         registerBlock(BlockRegistry.testpane);
  35.        
  36.         //Blocks
  37.         registerBlock(BlockRegistry.Smooth_slab);
  38.         registerBlock(BlockRegistry.GariumBlock);
  39.         registerBlock(BlockRegistry.RadiumBlock);
  40.        
  41.         //WoodWall
  42.         reg(BlockRegistry.woodWall, 0, "woodWall_oak");
  43.         reg(BlockRegistry.woodWall, 1, "woodWall_spruce");
  44.         reg(BlockRegistry.woodWall, 2, "woodWall_birch");
  45.         reg(BlockRegistry.woodWall, 3, "woodWall_jungle");
  46.         reg(BlockRegistry.woodWall, 4, "woodWall_acacia");
  47.         reg(BlockRegistry.woodWall, 5, "woodWall_dark_oak");
  48.        
  49.         //Registers inventory models for woodWall
  50.         final String types[] = {"oak", "spruce", "birch", "jungle", "acacia", "dark_oak"};
  51.         ResourceLocation[] resLoc = new ResourceLocation[6];
  52.         for (int i=0; i < 6; i++)
  53.         resLoc[i] = new ResourceLocation("withermod:woodWall_" + types[i]);
  54.         ModelBakery.registerItemVariants(Item.getItemFromBlock(BlockRegistry.woodWall), resLoc);
  55.     }
  56.    
  57.     public static void reg(Block block, int meta, String name) {
  58.         Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), meta, new ModelResourceLocation(Main.MODID + ":" + name, "inventory"));
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement