Search in sources :

Example 11 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project HorsePower by GoryMoon.

the class ColorGetter method getTextureAtlasSprite.

@Nullable
private static TextureAtlasSprite getTextureAtlasSprite(ItemStack itemStack) {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    ItemModelMesher itemModelMesher = renderItem.getItemModelMesher();
    IBakedModel itemModel = itemModelMesher.getItemModel(itemStack);
    return itemModel.getParticleTexture();
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Nullable(javax.annotation.Nullable)

Example 12 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 13 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)

Example 14 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project ClaySoldiersMod by SanAndreasP.

the class ParticleNbtItemBreaking method init.

private void init(ItemStack stack) {
    ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    IBakedModel model = mesher.getItemModel(stack);
    this.setParticleTexture(model.getOverrides().handleItemState(model, stack, null, null).getParticleTexture());
    ColorObj clr = new ColorObj(Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, 0));
    this.particleRed = clr.fRed();
    this.particleGreen = clr.fGreen();
    this.particleBlue = clr.fBlue();
}
Also used : ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ColorObj(de.sanandrew.mods.sanlib.lib.ColorObj)

Example 15 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project A-Little-Extra-Tiles by Doc-1.

the class GuiStack method getTexture.

public String getTexture(ItemStack stack) {
    Block block = Block.getBlockFromItem(stack.getItem());
    Item item = stack.getItem();
    int damage = item.getDamage(stack);
    int meta = item.getMetadata(damage);
    IBlockState state = BlockUtils.getState(block, meta);
    Minecraft minecraft = Minecraft.getMinecraft();
    if (this.useBlock) {
        ResourceLocation reg = block.getRegistryName();
        BlockRendererDispatcher ren = minecraft.getBlockRendererDispatcher();
        texture = ren.getModelForState(state).getQuads(state, facing, 0).get(0).getSprite().toString();
    } else {
        RenderItem itemRen = minecraft.getRenderItem();
        ItemModelMesher mesher = itemRen.getItemModelMesher();
        CreativeBakedModel model;
        texture = mesher.getItemModel(stack).getQuads(null, null, 0).get(0).getSprite().toString();
    // texture =
    // .getQuads(null, null, 0).get(0).getSprite().toString();
    }
    return texture;
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.RenderItem) IBlockState(net.minecraft.block.state.IBlockState) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) CreativeBakedModel(com.creativemd.creativecore.client.rendering.model.CreativeBakedModel)

Aggregations

ItemModelMesher (net.minecraft.client.renderer.ItemModelMesher)15 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)9 RenderItem (net.minecraft.client.renderer.RenderItem)6 Minecraft (net.minecraft.client.Minecraft)5 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)5 Item (net.minecraft.item.Item)5 ResourceLocation (net.minecraft.util.ResourceLocation)3 ArrayList (java.util.ArrayList)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 BaubleType (baubles.api.BaubleType)1 CreativeBakedModel (com.creativemd.creativecore.client.rendering.model.CreativeBakedModel)1 CookedItem (com.skelril.nitro.registry.item.CookedItem)1 ICustomItem (com.skelril.nitro.registry.item.ICustomItem)1 ColorObj (de.sanandrew.mods.sanlib.lib.ColorObj)1 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 Field (java.lang.reflect.Field)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1