wasliebob

Untitled

May 19th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. package fmpintegration.main;
  2.  
  3. import java.util.HashSet;
  4.  
  5. import net.minecraft.block.Block;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.ItemStack;
  8. import codechicken.microblock.BlockMicroMaterial;
  9. import codechicken.microblock.MicroMaterialRegistry;
  10. import fmpintegration.api.FMPIntegration;
  11.  
  12. public class Micropart {
  13. public static void init()
  14. {
  15. initParts();
  16. initMicroparts();
  17. }
  18.  
  19. public static void initParts(){}
  20.  
  21. public static void initMicroparts()
  22. {
  23. for(Block b : Block.blocksList){
  24. if(b != null && MicroMaterialRegistry.getMaterial(b.getUnlocalizedName()) == null && !FMPIntegration.isBanned(b) && b != null && Item.itemsList[b.blockID] != null && acceptsFullCube(b)){
  25. HashSet<String> known = new HashSet<String>();
  26.  
  27. for(int meta = 0; meta < 16; meta++){
  28. String name ;
  29. try{
  30. name = new ItemStack(b, 1, meta).getUnlocalizedName();
  31. }catch(Exception e){
  32. continue;
  33. }
  34. if(name != null && known.add(name) && !containsNumber(name)){
  35. registerMultipart(b, meta);
  36. }
  37. };
  38. }
  39. }
  40. }
  41.  
  42. public static boolean acceptsFullCube(Block block)
  43. {
  44. if(!Config.fullCube)
  45. return true;
  46. else if(Config.fullCube)
  47. return block.renderAsNormalBlock();
  48. else
  49. return true;
  50. }
  51.  
  52. public static boolean containsNumber(String name)
  53. {
  54. String[] numb = new String[]{"2", "3", "4", "5", "6", "7", "8", "9", "11", "0"};
  55. for(int i = 0; i < numb.length; i++)
  56. if(name != null && numb != null && name.contains(numb[i]))
  57. return true;
  58.  
  59. return false;
  60. }
  61.  
  62. public static void registerMetadata(Block block, int maxMeta){
  63. for (int i = 0; i <= maxMeta; i ++)
  64. registerMultipart(block, i);
  65. }
  66.  
  67. private static void registerMultipart(Block block, int meta)
  68. {
  69. System.out.println("[FMPI] " + " registering multipart for " + block.getLocalizedName());
  70. MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(block, meta), block.getUnlocalizedName() + (meta == 0 ? "" : "_" + meta));
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment