Guest User

Untitled

a guest
Dec 16th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. package com.TheRPGAdventurer.ROTD.client.handler;
  2.  
  3. import com.TheRPGAdventurer.ROTD.RealmOfTheDragons;
  4. import com.TheRPGAdventurer.ROTD.client.blocks.BlockDragonBreedEgg;
  5. import com.TheRPGAdventurer.ROTD.client.init.ModArmour;
  6. import com.TheRPGAdventurer.ROTD.client.init.ModBlocks;
  7. import com.TheRPGAdventurer.ROTD.client.init.ModItems;
  8. import com.TheRPGAdventurer.ROTD.client.init.ModTools;
  9. import com.TheRPGAdventurer.ROTD.client.items.ItemDragonBreedEgg;
  10. import com.TheRPGAdventurer.ROTD.server.entity.breeds.EnumDragonBreed;
  11. import com.TheRPGAdventurer.ROTD.util.Utils;
  12.  
  13. import net.minecraft.block.Block;
  14. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  15. import net.minecraft.item.Item;
  16. import net.minecraft.item.ItemBlock;
  17. import net.minecraft.util.ResourceLocation;
  18. import net.minecraftforge.client.event.ModelRegistryEvent;
  19. import net.minecraftforge.client.model.ModelLoader;
  20. import net.minecraftforge.event.RegistryEvent;
  21. import net.minecraftforge.fml.common.Mod;
  22. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  23.  
  24. @Mod.EventBusSubscriber
  25. public class RegistryEventHandler {
  26.  
  27. @SubscribeEvent
  28. public static void registerBlocks(RegistryEvent.Register<Block> event) {
  29. event.getRegistry().registerAll(ModBlocks.BLOCKS);
  30. Utils.getLogger().info("Block Registries Successfully Registered!");
  31. }
  32.  
  33. @SubscribeEvent
  34. public static void registerItems(RegistryEvent.Register<Item> event) {
  35. event.getRegistry().registerAll(ModItems.ITEMS);
  36. event.getRegistry().registerAll(ModTools.TOOLS);
  37. event.getRegistry().registerAll(ModArmour.ARMOR);
  38.  
  39. for (Block block : ModBlocks.BLOCKS) {
  40. event.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
  41. }
  42.  
  43. Utils.getLogger().info("Item Registries Successfully Registered!");
  44. }
  45.  
  46. @SubscribeEvent
  47. public static void registerDragonEggItem(RegistryEvent.Register<Item> event) {
  48. event.getRegistry().register(ItemDragonBreedEgg.DRAGON_BREED_EGG.setRegistryName("dragon_egg"));
  49. }
  50.  
  51. @SubscribeEvent
  52. public static void registerDragonnEggBlock(RegistryEvent.Register<Block> event) {
  53. event.getRegistry().register(BlockDragonBreedEgg.DRAGON_BREED_EGG.setRegistryName("dragon_egg"));
  54. }
  55.  
  56. @SubscribeEvent
  57. public static void registerModels(ModelRegistryEvent event) {
  58. for (Block block: ModBlocks.BLOCKS) {
  59. ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
  60.  
  61. for (Item item: ModItems.ITEMS) {
  62. ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
  63. }
  64.  
  65. for (Item item: ModTools.TOOLS) {
  66. ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
  67. }
  68.  
  69. for (Item item: ModArmour.ARMOR) {
  70. ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName().toString(), "inventory"));
  71. }
  72.  
  73. for (Item itemegg: ItemDragonBreedEgg.ITEM_EGG) {
  74. // register item renderer for dragon egg block variants
  75. ResourceLocation eggModelItemLoc = new ResourceLocation(RealmOfTheDragons.MODID, "dragon_egg");
  76. Item itemBlockDragonEgg = Item.REGISTRY.getObject(eggModelItemLoc);
  77. EnumDragonBreed.META_MAPPING.forEach((breed, meta) -> {
  78. ModelResourceLocation eggModelLoc = new ModelResourceLocation(RealmOfTheDragons.MODID + ":dragon_egg", "breed=" + breed.getName());
  79. ModelLoader.setCustomModelResourceLocation(itemBlockDragonEgg, meta, eggModelLoc);
  80. });
  81. }
  82.  
  83. for (Block blockegg: BlockDragonBreedEgg.BLOCK_EGG) {
  84. // register item renderer for dragon egg block variants
  85. ResourceLocation eggModelItemLoc = new ResourceLocation(RealmOfTheDragons.MODID, "dragon_egg");
  86. Item itemBlockDragonEgg = Item.REGISTRY.getObject(eggModelItemLoc);
  87. EnumDragonBreed.META_MAPPING.forEach((breed, meta) -> {
  88. ModelResourceLocation eggModelLoc = new ModelResourceLocation(RealmOfTheDragons.MODID + ":dragon_egg", "breed=" + breed.getName());
  89. ModelLoader.setCustomModelResourceLocation(itemBlockDragonEgg, meta, eggModelLoc);
  90. });
  91. }
  92.  
  93. Utils.getLogger().info("Models Sucessfully Registered");
  94. }
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment