Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.theviolentsquirrels.questsystem.renderer;
- import net.minecraft.block.Block;
- import net.minecraft.client.renderer.ItemMeshDefinition;
- import net.minecraft.client.resources.model.ModelBakery;
- import net.minecraft.client.resources.model.ModelResourceLocation;
- import net.minecraft.item.Item;
- import net.minecraftforge.client.model.ModelLoader;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import net.theviolentsquirrels.questsystem.Reference;
- import net.theviolentsquirrels.questsystem.block.BlockHandler;
- import net.theviolentsquirrels.questsystem.item.ItemHandler;
- import net.theviolentsquirrels.questsystem.renderer.item.ItemBowModel;
- import net.theviolentsquirrels.questsystem.utility.CustomStrings;
- @SideOnly(Side.CLIENT)
- public final class ModelManager {
- public static final ModelManager INSTANCE = new ModelManager();
- public ModelManager() {}
- public void registerBlockModels() {
- this.registerBlockItemModel(BlockHandler.blockBarrel);
- this.registerBlockItemModel(BlockHandler.blockSieve);
- }
- private void registerBlockItemModel(Block block) {
- Item item = Item.getItemFromBlock(block);
- if (item != null) this.registerItemModel(item);
- }
- public void registerItemModels() {
- ItemBowModel.registerBowPullingModels();
- this.registerItemModel(ItemHandler.itemBowWood, this.getModelResourceLocation(ItemHandler.itemBowWood, "standby"));
- this.registerItemModel(ItemHandler.itemLongbowWood, this.getModelResourceLocation(ItemHandler.itemLongbowWood, "standby"));
- this.registerItemModel(ItemHandler.itemBowIron, this.getModelResourceLocation(ItemHandler.itemBowIron, "standby"));
- this.registerItemModel(ItemHandler.itemBowGold, this.getModelResourceLocation(ItemHandler.itemBowGold, "standby"));
- this.registerItemModel(ItemHandler.itemBowDiamond, this.getModelResourceLocation(ItemHandler.itemBowDiamond, "standby"));
- this.registerItemModel(ItemHandler.itemLongbowLaatkin, this.getModelResourceLocation(ItemHandler.itemLongbowLaatkin, "standby"));
- /** Harvest items **/
- this.registerItemModel(ItemHandler.itemBarleySeed);
- this.registerItemModel(ItemHandler.itemBarleyCrop);
- }
- private void registerItemModel(Item item) {
- final ModelResourceLocation modelResourceLocation;
- modelResourceLocation = this.getModelResourceLocation(item, "inventory");
- this.registerItemModel(item, modelResourceLocation);
- }
- private void registerItemModel(Item item, ModelResourceLocation resourceLocation) {
- ItemMeshDefinition itemMeshDefinition;
- ModelBakery.registerItemVariants(item, resourceLocation);
- itemMeshDefinition = MeshDefinitionFix.create(stack -> resourceLocation);
- ModelLoader.setCustomMeshDefinition(item, itemMeshDefinition);
- }
- public ModelResourceLocation getModelResourceLocation(Item item, String variant) {
- String unlocalizedName;
- unlocalizedName = CustomStrings.substringUnlocalizedName(item.getUnlocalizedName());
- return (new ModelResourceLocation(Reference.MODID + ':' + unlocalizedName, variant));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement