Search in sources :

Example 1 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project minecolonies by Minecolonies.

the class ClientProxy method registerRenderer.

@Override
public void registerRenderer() {
    super.registerRenderer();
    final ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutBaker), 0, new ModelResourceLocation(ModBlocks.blockHutBaker.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutBlacksmith), 0, new ModelResourceLocation(ModBlocks.blockHutBlacksmith.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutBuilder), 0, new ModelResourceLocation(ModBlocks.blockHutBuilder.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutCitizen), 0, new ModelResourceLocation(ModBlocks.blockHutCitizen.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutFarmer), 0, new ModelResourceLocation(ModBlocks.blockHutFarmer.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutFisherman), 0, new ModelResourceLocation(ModBlocks.blockHutFisherman.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutLumberjack), 0, new ModelResourceLocation(ModBlocks.blockHutLumberjack.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutMiner), 0, new ModelResourceLocation(ModBlocks.blockHutMiner.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutStonemason), 0, new ModelResourceLocation(ModBlocks.blockHutStonemason.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutTownHall), 0, new ModelResourceLocation(ModBlocks.blockHutTownHall.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutWareHouse), 0, new ModelResourceLocation(ModBlocks.blockHutWareHouse.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutDeliveryman), 0, new ModelResourceLocation(ModBlocks.blockHutDeliveryman.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockSubstitution), 0, new ModelResourceLocation(ModBlocks.blockSubstitution.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutField), 0, new ModelResourceLocation(ModBlocks.blockHutField.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutGuardTower), 0, new ModelResourceLocation(ModBlocks.blockHutGuardTower.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockSolidSubstitution), 0, new ModelResourceLocation(ModBlocks.blockSolidSubstitution.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockConstructionTape), 0, new ModelResourceLocation(ModBlocks.blockConstructionTape.getRegistryName(), INVENTORY));
    itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockConstructionTapeCorner), 0, new ModelResourceLocation(ModBlocks.blockConstructionTapeCorner.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.buildTool, 0, new ModelResourceLocation(ModItems.buildTool.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.caliper, 0, new ModelResourceLocation(ModItems.caliper.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.scanTool, 0, new ModelResourceLocation(ModItems.scanTool.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.scepterGuard, 0, new ModelResourceLocation(ModItems.scepterGuard.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.supplyChest, 0, new ModelResourceLocation(ModItems.supplyChest.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.supplyCamp, 0, new ModelResourceLocation(ModItems.supplyCamp.getRegistryName(), INVENTORY));
    // Achievement proxy Items
    itemModelMesher.register(ModItems.itemAchievementProxySettlement, 0, new ModelResourceLocation(ModItems.itemAchievementProxySettlement.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.itemAchievementProxyTown, 0, new ModelResourceLocation(ModItems.itemAchievementProxyTown.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.itemAchievementProxyCity, 0, new ModelResourceLocation(ModItems.itemAchievementProxyCity.getRegistryName(), INVENTORY));
    itemModelMesher.register(ModItems.itemAchievementProxyMetropolis, 0, new ModelResourceLocation(ModItems.itemAchievementProxyMetropolis.getRegistryName(), INVENTORY));
}
Also used : ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 2 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project Bookshelf by Darkhax-Minecraft.

the class RenderUtils method getSprite.

/**
     * Gets the TextureAtlasSprite for the ItemStack. Has support for both Items and Blocks.
     *
     * @param stack The ItemStack to get the sprite for.
     * @return The sprite for the ItemStack.
     */
public static TextureAtlasSprite getSprite(ItemStack stack) {
    final Minecraft mc = Minecraft.getMinecraft();
    final Block block = StackUtils.getBlockFromStack(stack);
    if (block == null) {
        final ItemModelMesher mesher = mc.getRenderItem().getItemModelMesher();
        return !stack.isEmpty() ? mesher.getParticleIcon(stack.getItem(), stack.getItemDamage()) : mesher.getItemModel(null).getParticleTexture();
    }
    return mc.getBlockRendererDispatcher().getBlockModelShapes().getTexture(block.getStateFromMeta(stack.getItemDamage()));
}
Also used : ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft)

Example 3 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project Binnie by ForestryMC.

the class ControlLumbermillProgress method getWoodSprite.

@SideOnly(Side.CLIENT)
private TextureAtlasSprite getWoodSprite(ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    ItemModelMesher modelMesher = renderItem.getItemModelMesher();
    IBakedModel model = modelMesher.getItemModel(stack);
    TextureAtlasSprite sprite = model.getParticleTexture();
    if (sprite == mc.getTextureMapBlocks().getMissingSprite()) {
        return getWoodSprite(new ItemStack(Blocks.LOG));
    }
    return sprite;
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project Skree by Skelril.

the class CustomItemSystem method render.

// Invoked via reflection
@SuppressWarnings("unused")
private void render(Object item) {
    if (item instanceof Item && item instanceof ICustomItem) {
        if (Sponge.getPlatform().getExecutionType().isClient()) {
            RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
            ItemModelMesher mesher = renderItem.getItemModelMesher();
            Optional<ItemMeshDefinition> optMeshDefinition = ((ICustomItem) item).__getCustomMeshDefinition();
            if (optMeshDefinition.isPresent()) {
                mesher.register((Item) item, optMeshDefinition.get());
            }
            List<String> variants = ((ICustomItem) item).__getMeshDefinitions();
            List<ResourceLocation> modelResources = new ArrayList<>();
            for (int i = 0; i < variants.size(); ++i) {
                ModelResourceLocation resourceLocation = new ModelResourceLocation("skree:" + variants.get(i), "inventory");
                if (!optMeshDefinition.isPresent()) {
                    mesher.register((Item) item, i, resourceLocation);
                }
                modelResources.add(resourceLocation);
            }
            ModelBakery.registerItemVariants((Item) item, modelResources.toArray(new ResourceLocation[modelResources.size()]));
        }
    } else {
        throw new IllegalArgumentException("Invalid custom item!");
    }
}
Also used : ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ICustomItem(com.skelril.nitro.registry.item.ICustomItem) RenderItem(net.minecraft.client.renderer.RenderItem) ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) Item(net.minecraft.item.Item) CookedItem(com.skelril.nitro.registry.item.CookedItem) ICustomItem(com.skelril.nitro.registry.item.ICustomItem) RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 5 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project Skree by Skelril.

the class GameIntegrator method registerItemRendering.

private void registerItemRendering(ItemDescriptor descriptor) {
    Item item = descriptor.item;
    ItemConfig config = descriptor.config;
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    ItemModelMesher mesher = renderItem.getItemModelMesher();
    // TODO Custom mesher currently not supported
    // Optional<ItemMeshDefinition> optMeshDefinition = (item).__getCustomMeshDefinition();
    // if (optMeshDefinition.isPresent()) {
    // mesher.register((Item) item, optMeshDefinition.get());
    // }
    List<String> variants = config.getMeshDefinitions();
    List<ResourceLocation> modelResources = new ArrayList<>();
    for (int i = 0; i < variants.size(); ++i) {
        ModelResourceLocation resourceLocation = new ModelResourceLocation(modID + ":" + variants.get(i), "inventory");
        // if (!optMeshDefinition.isPresent()) {
        mesher.register(item, i, resourceLocation);
        // }
        modelResources.add(resourceLocation);
    }
    ModelBakery.registerItemVariants(item, modelResources.toArray(new ResourceLocation[modelResources.size()]));
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Aggregations

ItemModelMesher (net.minecraft.client.renderer.ItemModelMesher)8 RenderItem (net.minecraft.client.renderer.RenderItem)5 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)4 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)4 Minecraft (net.minecraft.client.Minecraft)3 Item (net.minecraft.item.Item)3 ArrayList (java.util.ArrayList)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 CookedItem (com.skelril.nitro.registry.item.CookedItem)1 ICustomItem (com.skelril.nitro.registry.item.ICustomItem)1 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockModelShapes (net.minecraft.client.renderer.BlockModelShapes)1 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)1