Search in sources :

Example 6 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 7 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project SilentGems by SilentChaos512.

the class ItemEnchantmentToken method registerModels.

@Override
public boolean registerModels() {
    ModelResourceLocation model;
    List<ModelResourceLocation> list = getVariants();
    ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    for (int i = 0; i < list.size(); ++i) {
        model = list.get(i);
        if (model != null) {
            ModelLoader.registerItemVariants(this, model);
            mesher.register(this, i, model);
        }
    }
    mesher.register(this, BLANK_META, list.get(0));
    return true;
}
Also used : ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 8 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project SilentGems by SilentChaos512.

the class ItemTeleporterLinker method registerModels.

@Override
public boolean registerModels() {
    ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    ModelResourceLocation model = new ModelResourceLocation(getFullName().toLowerCase(), "inventory");
    ModelLoader.registerItemVariants(this, model);
    mesher.register(this, 0, model);
    mesher.register(this, 1, model);
    return true;
}
Also used : ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 9 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project LogisticsPipes by RS485.

the class LogisticsRenderPipe method renderItemStackOnSign.

public void renderItemStackOnSign(@Nonnull ItemStack itemstack) {
    if (itemstack.isEmpty()) {
        // Only happens on false configuration
        return;
    }
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem itemRender = mc.getRenderItem();
    GlStateManager.disableLighting();
    // Forge: Reset color in case Items change it.
    GlStateManager.color(1F, 1F, 1F);
    // Forge: Make sure blend is enabled else tabs show a white border.
    GlStateManager.enableBlend();
    itemRender.zLevel = 100.0F;
    GlStateManager.enableRescaleNormal();
    // itemRender.renderItemAndEffectIntoGUI(itemstack, 0, 0);
    // item render code
    GlStateManager.pushMatrix();
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
    GlStateManager.enableRescaleNormal();
    GlStateManager.enableAlpha();
    GlStateManager.alphaFunc(516, 0.1F);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    // mezz.jei.render.ItemStackFastRenderer#getBakedModel
    ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    IBakedModel bakedModel = itemModelMesher.getItemModel(itemstack);
    bakedModel = bakedModel.getOverrides().handleItemState(bakedModel, itemstack, null, null);
    // make item/block flat and position it
    GlStateManager.translate(0.05F, 0F, 0F);
    GlStateManager.scale(0.8F, 0.8F, 0.001F);
    // model rotation
    bakedModel = ForgeHooksClient.handleCameraTransforms(bakedModel, ItemCameraTransforms.TransformType.GUI, false);
    // model scaling to fit on sign
    GlStateManager.scale(0.4F, 0.4F, 0.4F);
    itemRender.renderItem(itemstack, bakedModel);
    GlStateManager.disableRescaleNormal();
    GlStateManager.disableAlpha();
    GlStateManager.popMatrix();
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
    // item render code end
    // not needed?
    // itemRender.renderItemOverlays(mc.fontRenderer, itemstack, 0, 0);
    itemRender.zLevel = 0.0F;
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Minecraft(net.minecraft.client.Minecraft)

Example 10 with ItemModelMesher

use of net.minecraft.client.renderer.ItemModelMesher in project FoamFix by asiekierka.

the class FoamFixModelRegistryDuplicateWipe method onTextureStitchPost.

@SubscribeEvent
public void onTextureStitchPost(TextureStitchEvent.Post event) {
    ItemModelMesher imm = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    BlockModelShapes bms = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
    ModelManager mgr = bms.getModelManager();
    Field f = ReflectionHelper.findField(ModelManager.class, "modelRegistry", "field_174958_a");
    try {
        IRegistry<ModelResourceLocation, IBakedModel> registry = (IRegistry<ModelResourceLocation, IBakedModel>) f.get(mgr);
        FoamFix.logger.info("Clearing unnecessary model registry of size " + registry.getKeys().size() + ".");
        for (ModelResourceLocation l : registry.getKeys()) {
            registry.putObject(l, ProxyClient.DUMMY_MODEL);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    f = ReflectionHelper.findField(BlockModelShapes.class, "bakedModelStore", "field_178129_a");
    try {
        Map<IBlockState, IBakedModel> modelStore = (Map<IBlockState, IBakedModel>) f.get(bms);
        FoamFix.logger.info("Clearing unnecessary model store of size " + modelStore.size() + ".");
        modelStore.clear();
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (imm instanceof ItemModelMesherForge) {
        f = ReflectionHelper.findField(ItemModelMesherForge.class, "models");
        try {
            IdentityHashMap<Item, TIntObjectHashMap<IBakedModel>> modelStore = (IdentityHashMap<Item, TIntObjectHashMap<IBakedModel>>) f.get(imm);
            FoamFix.logger.info("Clearing unnecessary item shapes cache of size " + modelStore.size() + ".");
            modelStore.clear();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IdentityHashMap(java.util.IdentityHashMap) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ModelManager(net.minecraft.client.renderer.block.model.ModelManager) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes) Field(java.lang.reflect.Field) Item(net.minecraft.item.Item) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemModelMesherForge(net.minecraftforge.client.ItemModelMesherForge) IRegistry(net.minecraft.util.registry.IRegistry) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) IdentityHashMap(java.util.IdentityHashMap) Map(java.util.Map) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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