Search in sources :

Example 36 with IBakedModel

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

the class ItemQuadCollector method addBlockState.

public void addBlockState(IBlockState state, @Nonnull ItemStack stack, boolean allFacesToGeneral) {
    if (state != null) {
        if (Prep.isInvalid(stack)) {
            stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
        }
        BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
        IBakedModel model = modelShapes.getModelForState(state);
        addBakedModel(model, stack, allFacesToGeneral);
    }
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes)

Example 37 with IBakedModel

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

the class TelePadSpecialRenderer method render.

public void render(@Nonnull TileEntity tileEntity, @Nonnull final IBlockState state) {
    final BlockPos pos = tileEntity.getPos();
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder vertexBuffer = tessellator.getBuffer();
    final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    final IBakedModel ibakedmodel = blockrendererdispatcher.getBlockModelShapes().getModelForState(state);
    vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    vertexBuffer.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
    blockrendererdispatcher.getBlockModelRenderer().renderModel(tileEntity.getWorld(), ibakedmodel, state, pos, vertexBuffer, false);
    vertexBuffer.setTranslation(0, 0, 0);
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 38 with IBakedModel

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

the class SoulBinderTESR method renderBlockModel.

@SuppressWarnings("null")
public static void renderBlockModel(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean translateToOrigin, boolean relight) {
    BufferBuilder wr = Tessellator.getInstance().getBuffer();
    wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    if (translateToOrigin) {
        wr.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
    }
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
    IBakedModel ibakedmodel = modelShapes.getModelForState(state);
    final IBlockAccess worldWrapper = relight ? new WorldWrapper(world, pos) : world;
    for (BlockRenderLayer layer : BlockRenderLayer.values()) {
        if (state.getBlock().canRenderInLayer(state, layer)) {
            ForgeHooksClient.setRenderLayer(layer);
            blockrendererdispatcher.getBlockModelRenderer().renderModel(worldWrapper, ibakedmodel, state, pos, wr, false);
        }
    }
    ForgeHooksClient.setRenderLayer(null);
    if (translateToOrigin) {
        wr.setTranslation(0, 0, 0);
    }
    Tessellator.getInstance().draw();
}
Also used : BufferBuilder(net.minecraft.client.renderer.BufferBuilder) IBlockAccess(net.minecraft.world.IBlockAccess) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 39 with IBakedModel

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

the class TravelEntitySpecialRenderer method renderItemLabel.

private void renderItemLabel(@Nonnull ItemStack itemLabel, double globalScale) {
    if (!itemLabel.isEmpty()) {
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.5f, 0.75f, 0.5f);
        // TODO: This doesn't work that well with 3D items, find a rotation that does
        GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate((renderManager.options.thirdPersonView == 2 ? -1 : 1) * renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(globalScale, globalScale, globalScale);
        GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
        RenderHelper.enableStandardItemLighting();
        IBakedModel bakedmodel = itemRenderer.getItemModelWithOverrides(itemLabel, (World) null, (EntityLivingBase) null);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR, GlStateManager.SourceFactor.ONE.factor, GlStateManager.DestFactor.ZERO.factor);
        GL14.glBlendColor(itemBlend.x, itemBlend.y, itemBlend.z, itemBlend.w);
        bakedmodel = ForgeHooksClient.handleCameraTransforms(bakedmodel, ItemCameraTransforms.TransformType.GUI, false);
        itemRenderer.renderItem(itemLabel, NullHelper.notnullF(bakedmodel, "handleCameraTransforms returned null!"));
        RenderHelper.disableStandardItemLighting();
        GL14.glBlendColor(1, 1, 1, 1);
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.popMatrix();
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Example 40 with IBakedModel

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

the class TravelEntitySpecialRenderer method renderBlock.

public void renderBlock(@Nonnull BlockPos pos, IBlockAccess blockAccess, double globalScale, boolean highlight) {
    BufferBuilder tes = Tessellator.getInstance().getBuffer();
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.5f, 0.5f, 0.5f);
    GlStateManager.scale(globalScale, globalScale, globalScale);
    GlStateManager.translate(-0.5f, -0.5f, -0.5f);
    IBlockState state = blockAccess.getBlockState(pos).getActualState(blockAccess, pos);
    IBakedModel ibakedmodel = blockrendererdispatcher.getModelForState(state);
    state = state.getBlock().getExtendedState(state, blockAccess, pos);
    tes.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
    Vector4f color = highlight ? selectedBlockBlend : blockBlend;
    GlStateManager.color(1, 1, 1, 1);
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR, GlStateManager.SourceFactor.ONE.factor, GlStateManager.DestFactor.ZERO.factor);
    GL14.glBlendColor(color.x, color.y, color.z, color.w);
    tes.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    for (BlockRenderLayer layer : BlockRenderLayer.values()) {
        if (state.getBlock().canRenderInLayer(state, NullHelper.notnullJ(layer, "BlockRenderLayer value was null!"))) {
            ForgeHooksClient.setRenderLayer(layer);
            blockrendererdispatcher.getBlockModelRenderer().renderModel(blockAccess, ibakedmodel, state, pos, tes, false);
        }
    }
    ForgeHooksClient.setRenderLayer(null);
    Tessellator.getInstance().draw();
    GL14.glBlendColor(1, 1, 1, 1);
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    tes.setTranslation(0, 0, 0);
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Vector4f(com.enderio.core.common.vecmath.Vector4f) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

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