Search in sources :

Example 76 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project Railcraft by Railcraft.

the class JSONModelRenderer method renderModel.

public void renderModel(ResourceLocation model) {
    IBakedModel bakedModel = bakedModels.get(model);
    if (bakedModel == null)
        return;
    Minecraft mc = Minecraft.getMinecraft();
    mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
    Tessellator tess = Tessellator.getInstance();
    BufferBuilder buffer = tess.getBuffer();
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    putQuads(buffer, bakedModel.getQuads(null, null, 1234));
    for (EnumFacing side : EnumFacing.VALUES) {
        putQuads(buffer, bakedModel.getQuads(null, side, 1234));
    }
    tess.draw();
    mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Minecraft(net.minecraft.client.Minecraft)

Example 77 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project Railcraft by Railcraft.

the class CartContentRendererCargo method renderCargo.

public void renderCargo(RenderCart renderer, EntityCartCargo cart) {
    if (!cart.hasFilter())
        return;
    OpenGL.glPushMatrix();
    OpenGL.glPushAttrib(GL11.GL_ENABLE_BIT);
    OpenGL.glPushAttrib(GL11.GL_LIGHTING_BIT);
    OpenGL.glEnable(GL11.GL_LIGHTING);
    OpenGL.glDisable(GL11.GL_BLEND);
    EntityItem item = new EntityItem(cart.getEntityWorld(), 0.0D, 0.0D, 0.0D, cart.getFilterItem().copy());
    setSize(item.getItem(), 1);
    item.hoverStart = 0.0F;
    IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(item.getItem(), cart.world, null);
    boolean renderIn3D = model.isGui3d();
    int numIterations;
    float yOffset;
    float scale;
    float xScale;
    float zScale;
    if (renderIn3D) {
        xScale = 0.3f;
        zScale = 0.2F;
        scale = 2.5F;
        int slotsFilled = cart.getSlotsFilled();
        if (slotsFilled <= 0) {
            numIterations = 0;
        } else {
            numIterations = (int) Math.ceil(slotsFilled / 2f);
            numIterations = MathHelper.clamp(numIterations, 1, 6);
        }
        yOffset = -1.1F;
    } else {
        xScale = 0.5f;
        zScale = 0.6F;
        scale = 1.6F;
        numIterations = cart.getSlotsFilled();
        yOffset = -0.8F;
    }
    OpenGL.glTranslatef(0.0F, yOffset, 0.0F);
    OpenGL.glScalef(scale, scale, scale);
    OpenGL.glRotatef(90.F, 0.0F, 1.0F, 0.0F);
    rand.setSeed(cart.getEntityId());
    for (int i = 0; i < numIterations; i++) {
        OpenGL.glPushMatrix();
        float tx = (float) (rand.nextDouble() - 0.5F) * xScale;
        float ty = (float) (rand.nextDouble() - 0.5F) * 0.15F;
        float tz = (float) (rand.nextDouble() - 0.5F) * zScale;
        OpenGL.glTranslatef(tx, ty, tz);
        renderEntityItem(renderer.getRenderManager(), item);
        OpenGL.glPopMatrix();
    }
    OpenGL.glPopAttrib();
    OpenGL.glPopAttrib();
    OpenGL.glPopMatrix();
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) EntityItem(net.minecraft.entity.item.EntityItem)

Example 78 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project BiomesOPlenty by Glitchfiend.

the class ModelUtils method generateModelsForTextures.

public static IBakedModel[] generateModelsForTextures(IModel model, TextureAtlasSprite[] textures) {
    IBakedModel[] output = new IBakedModel[textures.length];
    for (int i = 0; i < output.length; i++) {
        final TextureAtlasSprite texture = textures[i];
        // Defines how TextureAtlasSprites are obtained whilst baking
        Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {

            public TextureAtlasSprite apply(ResourceLocation location) {
                return texture;
            }
        };
        output[i] = model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter);
    }
    return output;
}
Also used : Function(com.google.common.base.Function) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ResourceLocation(net.minecraft.util.ResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 79 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project LogisticsPipes by RS485.

the class LogisticsBlockModel method bake.

@Nonnull
@Override
public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, @Nonnull Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    final List<BakedQuad> quads = Lists.newArrayList();
    TextureAtlasSprite inactiveT = bakedTextureGetter.apply(inactive);
    TextureAtlasSprite activeT = bakedTextureGetter.apply(active);
    return new IBakedModel() {

        @Override
        @Nonnull
        public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
            if (side == null) {
                if (quads.isEmpty()) {
                    quads.addAll(LogisticsRenderPipe.secondRenderer.getQuadsFromRenderList(generateBlockRenderList(state, inactiveT, activeT), format, true));
                }
                return quads;
            } else {
                // LogisticsRenderPipe.secondRenderer.getQuadsFromRenderList(generateBlockRenderList(state), format);
                return Collections.emptyList();
            }
        }

        @Override
        public boolean isAmbientOcclusion() {
            return false;
        }

        @Override
        public boolean isGui3d() {
            return true;
        }

        @Override
        public boolean isBuiltInRenderer() {
            return false;
        }

        @Override
        @Nonnull
        public TextureAtlasSprite getParticleTexture() {
            return inactiveT;
        }

        @Override
        @Nonnull
        public ItemOverrideList getOverrides() {
            return ItemOverrideList.NONE;
        }

        @Override
        @Nonnull
        public Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) {
            return PerspectiveMapWrapper.handlePerspective(this, SimpleServiceLocator.cclProxy.getDefaultBlockState(), cameraTransformType);
        }
    };
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Matrix4f(javax.vecmath.Matrix4f) IBlockState(net.minecraft.block.state.IBlockState) Nonnull(javax.annotation.Nonnull) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Nullable(javax.annotation.Nullable) Nonnull(javax.annotation.Nonnull)

Example 80 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method drawFluidPumpTop.

@Override
public void drawFluidPumpTop() {
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    IBlockState state = IEContent.blockMetalDevice0.getStateFromMeta(BlockTypes_MetalDevice0.FLUID_PUMP.getMeta());
    state = state.withProperty(IEProperties.MULTIBLOCKSLAVE, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    GlStateManager.pushMatrix();
    GlStateManager.translate(0, 0, 1);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    blockRenderer.getBlockModelRenderer().renderModelBrightness(model, state, .75f, false);
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)197 IBlockState (net.minecraft.block.state.IBlockState)94 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)42 BlockPos (net.minecraft.util.math.BlockPos)40 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)38 EnumFacing (net.minecraft.util.EnumFacing)38 ResourceLocation (net.minecraft.util.ResourceLocation)36 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 ItemStack (net.minecraft.item.ItemStack)27 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)24 Block (net.minecraft.block.Block)23 IModel (net.minecraftforge.client.model.IModel)22 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)22 ArrayList (java.util.ArrayList)20 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)15 List (java.util.List)14 ItemOverride (net.minecraft.client.renderer.block.model.ItemOverride)14 ImmutableList (com.google.common.collect.ImmutableList)13