SHARE
TWEET

Untitled

a guest Oct 18th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.harry.customgems.init;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6.  
  7. import mod.akrivus.kagic.items.ItemGem;
  8. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  9. import net.minecraft.item.Item;
  10. import net.minecraft.util.ResourceLocation;
  11. import net.minecraftforge.client.model.ModelLoader;
  12. import net.minecraftforge.event.RegistryEvent;
  13. import net.minecraftforge.fml.common.FMLCommonHandler;
  14. import net.minecraftforge.fml.relauncher.Side;
  15. import net.minecraftforge.oredict.OreDictionary;
  16.  
  17. public class ModItems
  18. {
  19.  
  20.     public static final HashMap<ItemGem, ItemGem> GEM_TABLE = new HashMap<ItemGem, ItemGem>();
  21.     public static final ItemGem FORT_GEM = new ItemGem("fort");
  22.     public static final ItemGem CRACKED_FORT_GEM = new ItemGem("fort", true);
  23.    
  24.     public static void registerItems(RegistryEvent.Register<Item> event) {
  25.         ModItems.registerGem(ModItems.FORT_GEM, ModItems.CRACKED_FORT_GEM, event);
  26.     }
  27.         public static void registerGem(ItemGem normal, ItemGem broken, RegistryEvent.Register<Item> event) {
  28.             ModItems.GEM_TABLE.put(normal, broken);
  29.             ModItems.GEM_TABLE.put(broken, normal);
  30.             ModItems.registerItem(normal, event);
  31.             ModItems.registerItem(broken, event);
  32.         }
  33.         public static void registerExternalGem(ItemGem normal, ItemGem broken, String prefix, RegistryEvent.Register<Item> event) {
  34.             ModItems.GEM_TABLE.put(normal, broken);
  35.             ModItems.GEM_TABLE.put(broken, normal);
  36.             ModItems.registerExternalItem(normal, prefix, event);
  37.             ModItems.registerExternalItem(broken, prefix, event);
  38.         }
  39.  
  40.         public static void registerItem(Item item, RegistryEvent.Register<Item> event) {
  41.             ModItems.registerItem(item, event, "");
  42.         }
  43.  
  44.         public static void registerItem(Item item, RegistryEvent.Register<Item> event, String oredictName) {
  45.             // GameRegistry.register(item, new
  46.             // ResourceLocation("kagic:" +
  47.             // item.getUnlocalizedName().replaceFirst("item\\.|tile\\.",
  48.             // "")));
  49.             item.setRegistryName(new ResourceLocation("kagic:" + item.getUnlocalizedName().replaceFirst("item\\.|tile\\.", "")));
  50.             event.getRegistry().register(item);
  51.  
  52.             if (!oredictName.isEmpty()) {
  53.                 OreDictionary.registerOre(oredictName, item);
  54.             }
  55.  
  56.             if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
  57.                 ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
  58.             }
  59.         }
  60.  
  61.         public static void registerExternalItem(Item item, String prefix, RegistryEvent.Register<Item> event) {
  62.             ModItems.registerExternalItem(item, prefix, event, "");
  63.         }
  64.  
  65.         public static void registerExternalItem(Item item, String prefix, RegistryEvent.Register<Item> event, String oredictName) {
  66.             // GameRegistry.register(item, new
  67.             // ResourceLocation(prefix + ":" +
  68.             // item.getUnlocalizedName().replaceFirst("item\\.|tile\\.",
  69.             // "")));
  70.             item.setRegistryName(new ResourceLocation(prefix + ":" + item.getUnlocalizedName().replaceFirst("item\\.|tile\\.", "")));
  71.             event.getRegistry().register(item);
  72.  
  73.             if (!oredictName.isEmpty()) {
  74.                 OreDictionary.registerOre(oredictName, item);
  75.             }
  76.            
  77.             if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
  78.                 ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
  79.             }
  80.         }
  81. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top