Search in sources :

Example 1 with ModelManager

use of net.minecraft.client.renderer.block.model.ModelManager in project Tropicraft by Tropicraft.

the class RenderBambooItemFrame method doRender.

/**
 * Renders the desired {@code T} type Entity.
 */
@Override
public void doRender(EntityBambooItemFrame entity, double x, double y, double z, float entityYaw, float partialTicks) {
    GlStateManager.pushMatrix();
    BlockPos blockpos = entity.getHangingPosition();
    double d0 = (double) blockpos.getX() - entity.posX + x;
    double d1 = (double) blockpos.getY() - entity.posY + y;
    double d2 = (double) blockpos.getZ() - entity.posZ + z;
    GlStateManager.translate(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D);
    GlStateManager.rotate(180.0F - entity.rotationYaw, 0.0F, 1.0F, 0.0F);
    this.renderManager.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
    ModelManager modelmanager = blockrendererdispatcher.getBlockModelShapes().getModelManager();
    IBakedModel ibakedmodel;
    if (entity.getDisplayedItem() != null && entity.getDisplayedItem().getItem() == Items.FILLED_MAP) {
        ibakedmodel = modelmanager.getModel(this.mapModel);
    } else {
        ibakedmodel = modelmanager.getModel(this.itemFrameModel);
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(-0.5F, -0.5F, -0.5F);
    if (this.renderOutlines) {
        GlStateManager.enableColorMaterial();
        GlStateManager.enableOutlineMode(this.getTeamColor(entity));
    }
    blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F);
    if (this.renderOutlines) {
        GlStateManager.disableOutlineMode();
        GlStateManager.disableColorMaterial();
    }
    GlStateManager.popMatrix();
    GlStateManager.translate(0.0F, 0.0F, 0.4375F);
    this.renderItem(entity);
    GlStateManager.popMatrix();
    this.renderName(entity, x + (double) ((float) entity.facingDirection.getFrontOffsetX() * 0.3F), y - 0.25D, z + (double) ((float) entity.facingDirection.getFrontOffsetZ() * 0.3F));
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelManager(net.minecraft.client.renderer.block.model.ModelManager) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 2 with ModelManager

use of net.minecraft.client.renderer.block.model.ModelManager in project MinecraftForge by MinecraftForge.

the class ItemModelMesherForge method rebuildCache.

public void rebuildCache() {
    final ModelManager manager = this.getModelManager();
    for (Map.Entry<Item, TIntObjectHashMap<ModelResourceLocation>> e : locations.entrySet()) {
        TIntObjectHashMap<IBakedModel> mods = models.get(e.getKey());
        if (mods != null) {
            mods.clear();
        } else {
            mods = new TIntObjectHashMap<IBakedModel>();
            models.put(e.getKey(), mods);
        }
        final TIntObjectHashMap<IBakedModel> map = mods;
        e.getValue().forEachEntry(new TIntObjectProcedure<ModelResourceLocation>() {

            @Override
            public boolean execute(int meta, ModelResourceLocation location) {
                map.put(meta, manager.getModel(location));
                return true;
            }
        });
    }
}
Also used : Item(net.minecraft.item.Item) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ModelManager(net.minecraft.client.renderer.block.model.ModelManager) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) IdentityHashMap(java.util.IdentityHashMap) Map(java.util.Map)

Example 3 with ModelManager

use of net.minecraft.client.renderer.block.model.ModelManager in project BetterWithAddons by DaedalusGame.

the class RenderArtifactFrame method renderModel.

private void renderModel(EntityArtifactFrame entity) {
    BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
    ModelManager modelmanager = blockrendererdispatcher.getBlockModelShapes().getModelManager();
    IBakedModel ibakedmodel;
    if (!entity.getDisplayedItem().isEmpty() && entity.getDisplayedItem().getItem() == Items.FILLED_MAP) {
        // ModelResourceLocation mapModel = new ModelResourceLocation(new ResourceLocation("betterwithaddons",this.mapModel.getResourcePath()),this.mapModel.getVariant());
        ibakedmodel = modelmanager.getModel(mapModel);
    } else {
        // ModelResourceLocation itemFrameModel = new ModelResourceLocation(new ResourceLocation("betterwithaddons",this.itemFrameModel.getResourcePath()),this.itemFrameModel.getVariant());
        ibakedmodel = modelmanager.getModel(itemFrameModel);
    }
    // GlStateManager.pushMatrix();
    // GlStateManager.translate(-0.5F, -0.5F, -0.5F);
    blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelManager(net.minecraft.client.renderer.block.model.ModelManager) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 4 with ModelManager

use of net.minecraft.client.renderer.block.model.ModelManager 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 {
            Map<IRegistryDelegate<Item>, TIntObjectHashMap<IBakedModel>> modelStore = (Map<IRegistryDelegate<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) 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) IRegistryDelegate(net.minecraftforge.registries.IRegistryDelegate) 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) HashMap(java.util.HashMap) Map(java.util.Map) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)4 ModelManager (net.minecraft.client.renderer.block.model.ModelManager)4 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 Map (java.util.Map)2 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 Item (net.minecraft.item.Item)2 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockModelShapes (net.minecraft.client.renderer.BlockModelShapes)1 ItemModelMesher (net.minecraft.client.renderer.ItemModelMesher)1 BlockPos (net.minecraft.util.math.BlockPos)1 IRegistry (net.minecraft.util.registry.IRegistry)1 ItemModelMesherForge (net.minecraftforge.client.ItemModelMesherForge)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 IRegistryDelegate (net.minecraftforge.registries.IRegistryDelegate)1