Advertisement
Guest User

Untitled

a guest
Mar 10th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.48 KB | None | 0 0
  1. package net.theviolentsquirrels.questsystem.renderer;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.client.renderer.ItemMeshDefinition;
  5. import net.minecraft.client.resources.model.ModelBakery;
  6. import net.minecraft.client.resources.model.ModelResourceLocation;
  7. import net.minecraft.item.Item;
  8. import net.minecraftforge.client.model.ModelLoader;
  9. import net.minecraftforge.fml.relauncher.Side;
  10. import net.minecraftforge.fml.relauncher.SideOnly;
  11. import net.theviolentsquirrels.questsystem.Reference;
  12. import net.theviolentsquirrels.questsystem.block.BlockHandler;
  13. import net.theviolentsquirrels.questsystem.item.ItemHandler;
  14. import net.theviolentsquirrels.questsystem.renderer.item.ItemBowModel;
  15. import net.theviolentsquirrels.questsystem.utility.CustomStrings;
  16.  
  17. @SideOnly(Side.CLIENT)
  18. public final class                      ModelManager {
  19.     public static final ModelManager    INSTANCE = new ModelManager();
  20.  
  21.     public                              ModelManager() {}
  22.  
  23.     public void                         registerBlockModels() {
  24.         this.registerBlockItemModel(BlockHandler.blockBarrel);
  25.         this.registerBlockItemModel(BlockHandler.blockSieve);
  26.     }
  27.  
  28.     private void                        registerBlockItemModel(Block block) {
  29.         Item                            item = Item.getItemFromBlock(block);
  30.  
  31.         if (item != null) this.registerItemModel(item);
  32.     }
  33.  
  34.     public void                         registerItemModels() {
  35.         ItemBowModel.registerBowPullingModels();
  36.         this.registerItemModel(ItemHandler.itemBowWood, this.getModelResourceLocation(ItemHandler.itemBowWood, "standby"));
  37.         this.registerItemModel(ItemHandler.itemLongbowWood, this.getModelResourceLocation(ItemHandler.itemLongbowWood, "standby"));
  38.         this.registerItemModel(ItemHandler.itemBowIron, this.getModelResourceLocation(ItemHandler.itemBowIron, "standby"));
  39.         this.registerItemModel(ItemHandler.itemBowGold, this.getModelResourceLocation(ItemHandler.itemBowGold, "standby"));
  40.         this.registerItemModel(ItemHandler.itemBowDiamond, this.getModelResourceLocation(ItemHandler.itemBowDiamond, "standby"));
  41.         this.registerItemModel(ItemHandler.itemLongbowLaatkin, this.getModelResourceLocation(ItemHandler.itemLongbowLaatkin, "standby"));
  42.  
  43.         /**                             Harvest items **/
  44.         this.registerItemModel(ItemHandler.itemBarleySeed);
  45.         this.registerItemModel(ItemHandler.itemBarleyCrop);
  46.     }
  47.  
  48.     private void                        registerItemModel(Item item) {
  49.         final ModelResourceLocation     modelResourceLocation;
  50.  
  51.         modelResourceLocation = this.getModelResourceLocation(item, "inventory");
  52.         this.registerItemModel(item, modelResourceLocation);
  53.     }
  54.  
  55.     private void                        registerItemModel(Item item, ModelResourceLocation resourceLocation) {
  56.         ItemMeshDefinition              itemMeshDefinition;
  57.  
  58.         ModelBakery.registerItemVariants(item, resourceLocation);
  59.         itemMeshDefinition = MeshDefinitionFix.create(stack -> resourceLocation);
  60.         ModelLoader.setCustomMeshDefinition(item, itemMeshDefinition);
  61.     }
  62.  
  63.     public ModelResourceLocation        getModelResourceLocation(Item item, String variant) {
  64.         String                          unlocalizedName;
  65.  
  66.         unlocalizedName = CustomStrings.substringUnlocalizedName(item.getUnlocalizedName());
  67.         return (new ModelResourceLocation(Reference.MODID + ':' + unlocalizedName, variant));
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement