Search in sources :

Example 1 with BlockModelShapes

use of net.minecraft.client.renderer.BlockModelShapes 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 2 with BlockModelShapes

use of net.minecraft.client.renderer.BlockModelShapes 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 3 with BlockModelShapes

use of net.minecraft.client.renderer.BlockModelShapes in project EnderIO by SleepyTrousers.

the class EnchanterModelRenderer method renderBase.

private void renderBase() {
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
    IBakedModel bakedModel = modelShapes.getModelForState(MachineObject.block_enchanter.getBlockNN().getDefaultState().withProperty(EnumRenderMode.RENDER, EnumRenderMode.FRONT));
    RenderUtil.bindBlockTexture();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    for (EnumFacing enumfacing : EnumFacing.values()) {
        this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, enumfacing, 0L));
    }
    this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, (EnumFacing) null, 0L));
    tessellator.draw();
    GlStateManager.popMatrix();
    GlStateManager.disableRescaleNormal();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IBlockState(net.minecraft.block.state.IBlockState) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) EnumFacing(net.minecraft.util.EnumFacing) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 4 with BlockModelShapes

use of net.minecraft.client.renderer.BlockModelShapes in project HorsePower by GoryMoon.

the class ColorGetter method getTextureAtlasSprite.

@Nullable
private static TextureAtlasSprite getTextureAtlasSprite(IBlockState blockState) {
    Minecraft minecraft = Minecraft.getMinecraft();
    BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher();
    BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes();
    TextureAtlasSprite textureAtlasSprite = blockModelShapes.getTexture(blockState);
    if (textureAtlasSprite == minecraft.getTextureMapBlocks().getMissingSprite()) {
        return null;
    }
    return textureAtlasSprite;
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Minecraft(net.minecraft.client.Minecraft) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) Nullable(javax.annotation.Nullable)

Example 5 with BlockModelShapes

use of net.minecraft.client.renderer.BlockModelShapes in project EnderIO by SleepyTrousers.

the class ItemQuadCollector method addBlockStates.

public void addBlockStates(List<Pair<IBlockState, ItemStack>> states, @Nonnull ItemStack parent, Block parentBlock) {
    if (states == null || states.isEmpty()) {
        return;
    }
    BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
    for (Pair<IBlockState, ItemStack> pair : states) {
        IBlockState state = pair.getLeft();
        if (state != null) {
            ItemStack stack = pair.getRight();
            if (stack == null || Prep.isInvalid(stack)) {
                if (state.getBlock() == parentBlock) {
                    stack = parent;
                } else {
                    stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
                }
            }
            IBakedModel model = modelShapes.getModelForState(state);
            addBakedModel(model, NullHelper.notnullJ(stack, "If you see this, the world will be ending yesterday half past yellow!"));
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes)

Aggregations

BlockModelShapes (net.minecraft.client.renderer.BlockModelShapes)9 IBlockState (net.minecraft.block.state.IBlockState)6 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)6 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)4 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 ItemStack (net.minecraft.item.ItemStack)2 EnumFacing (net.minecraft.util.EnumFacing)2 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1 BlockPneumaticCraftCamo (me.desht.pneumaticcraft.common.block.BlockPneumaticCraftCamo)1 Block (net.minecraft.block.Block)1 Minecraft (net.minecraft.client.Minecraft)1 ItemModelMesher (net.minecraft.client.renderer.ItemModelMesher)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 ModelManager (net.minecraft.client.renderer.block.model.ModelManager)1