Search in sources :

Example 6 with IBakedModel

use of net.minecraft.client.resources.model.IBakedModel in project Galacticraft by micdoodle8.

the class SpawnerRenderer method renderItem.

public void renderItem(ItemStack stack) {
    int meta = stack.getItemDamage();
    if (meta == 0) {
        meta = ItemMobSpawner.idPig;
    }
    String bossName = BossStatus.bossName;
    int bossTimeout = BossStatus.statusBarTime;
    Minecraft mc = Minecraft.getMinecraft();
    World world = mc.theWorld;
    IBakedModel baseModel = mc.getRenderItem().getItemModelMesher().getModelManager().getModel(new ModelResourceLocation("mob_spawner"));
    GlStateManager.pushMatrix();
    GlStateManager.translate(.5, .5, .5);
    GlStateManager.scale(2, 2, 2);
    mc.getRenderItem().renderItem(stack, baseModel);
    GlStateManager.popMatrix();
    try {
        Entity entity = ItemMobSpawner.getEntity(meta);
        entity.setWorld(world);
        float scale = 0.6F / Math.max(entity.height, entity.width);
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.5, 0.4, 0.5);
        GlStateManager.rotate((float) (ClientUtils.getRenderTime() * 10), 0, 1, 0);
        GlStateManager.rotate(-20, 1, 0, 0);
        GlStateManager.translate(0, -0.4, 0);
        GlStateManager.scale(scale, scale, scale);
        entity.setLocationAndAngles(0, 0, 0, 0, 0);
        mc.getRenderManager().renderEntityWithPosYaw(entity, 0, 0, 0, 0, 0);
        GlStateManager.disableLighting();
        GlStateManager.popMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    } catch (Exception e) {
        if (Tessellator.getInstance().getWorldRenderer().isDrawing) {
            Tessellator.getInstance().draw();
        }
    }
    BossStatus.bossName = bossName;
    BossStatus.statusBarTime = bossTimeout;
}
Also used : Entity(net.minecraft.entity.Entity) IBakedModel(net.minecraft.client.resources.model.IBakedModel) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) World(net.minecraft.world.World) Minecraft(net.minecraft.client.Minecraft)

Example 7 with IBakedModel

use of net.minecraft.client.resources.model.IBakedModel in project BuildCraft by BuildCraft.

the class FakeWorldManager method renderBlock.

private void renderBlock(BlockPos pos, EnumWorldBlockLayer layer, WorldRenderer renderer) {
    IBlockState actualState = world.getBlockState(pos);
    Block block = actualState.getBlock();
    if (block == Blocks.air || block == null) {
        return;
    }
    if (!block.canRenderInLayer(layer)) {
        return;
    }
    actualState = block.getActualState(actualState, world, pos);
    BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher();
    IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(actualState);
    if (model == null || model.getParticleTexture() == null || model.getGeneralQuads() == null) {
        return;
    }
    boolean checkSides = pos.getY() > 0;
    try {
        dispatcher.getBlockModelRenderer().renderModelStandard(world, model, block, pos, renderer, checkSides);
    } catch (Throwable t) {
        BCLog.logger.warn("The model from the block " + block + " was invalid for layer " + layer, t);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) IBakedModel(net.minecraft.client.resources.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 8 with IBakedModel

use of net.minecraft.client.resources.model.IBakedModel in project BuildCraft by BuildCraft.

the class RobotItemModel method handle.

public static RobotItemModel handle(ItemStack stack) {
    if (stack != null) {
        RedstoneBoardRobotNBT board = ItemRobot.getRobotNBT(stack);
        IBakedModel model = board != null ? RoboticsProxyClient.robotModel.get(board.getID()) : null;
        if (model == null) {
            model = RoboticsProxyClient.defaultRobotModel;
        }
        if (model != null) {
            return new RobotItemModel(ImmutableList.copyOf(model.getGeneralQuads()), model.getParticleTexture(), DefaultVertexFormats.ITEM);
        }
    }
    return new RobotItemModel(ImmutableList.<BakedQuad>of(), null, DefaultVertexFormats.ITEM);
}
Also used : IBakedModel(net.minecraft.client.resources.model.IBakedModel) RedstoneBoardRobotNBT(buildcraft.api.boards.RedstoneBoardRobotNBT)

Aggregations

IBakedModel (net.minecraft.client.resources.model.IBakedModel)8 ModelResourceLocation (net.minecraft.client.resources.model.ModelResourceLocation)4 Minecraft (net.minecraft.client.Minecraft)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Function (com.google.common.base.Function)2 IOException (java.io.IOException)2 OBJLoaderGC (micdoodle8.mods.galacticraft.core.client.model.OBJLoaderGC)2 Block (net.minecraft.block.Block)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 DefaultVertexFormats (net.minecraft.client.renderer.vertex.DefaultVertexFormats)2 TRSRTransformation (net.minecraftforge.client.model.TRSRTransformation)2 OBJModel (net.minecraftforge.client.model.obj.OBJModel)2 Side (net.minecraftforge.fml.relauncher.Side)2 RedstoneBoardRobotNBT (buildcraft.api.boards.RedstoneBoardRobotNBT)1 StackAtPosition (buildcraft.core.StackAtPosition)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 List (java.util.List)1