Search in sources :

Example 26 with BlockRendererDispatcher

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

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

use of net.minecraft.client.renderer.BlockRendererDispatcher in project Adventurers-Toolbox by the-realest-stu.

the class ExtraBlockBreakHandler method drawBlockDamageTexture.

private void drawBlockDamageTexture(Tessellator tessellatorIn, BufferBuilder bufferBuilderIn, Entity entityIn, float partialTicks) {
    double d3 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
    double d4 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
    double d5 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
    if (this.mc.world.getWorldTime() % 20 == 0) {
        this.cleanupExtraDamagedBlocks();
    }
    if (!this.extraDamagedBlocks.isEmpty()) {
        this.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        this.preRenderDamagedBlocks();
        bufferBuilderIn.begin(7, DefaultVertexFormats.BLOCK);
        bufferBuilderIn.setTranslation(-d3, -d4, -d5);
        bufferBuilderIn.noColor();
        for (Entry<Integer, DestroyExtraBlocksProgress> entry : this.extraDamagedBlocks.entrySet()) {
            DestroyExtraBlocksProgress destroyblockprogress = entry.getValue();
            BlockPos[] blockpositions = destroyblockprogress.getPositions();
            for (int i = 0; i < blockpositions.length; i++) {
                BlockPos blockpos = blockpositions[i];
                double d6 = (double) blockpos.getX() - d3;
                double d7 = (double) blockpos.getY() - d4;
                double d8 = (double) blockpos.getZ() - d5;
                Block block = this.mc.world.getBlockState(blockpos).getBlock();
                TileEntity te = this.mc.world.getTileEntity(blockpos);
                boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull;
                if (!hasBreak)
                    hasBreak = te != null && te.canRenderBreaking();
                if (!hasBreak) {
                    if (d6 * d6 + d7 * d7 + d8 * d8 > 16384) {
                        this.extraDamagedBlocks.remove(entry.getKey());
                    } else {
                        IBlockState iblockstate = mc.world.getBlockState(blockpos);
                        if (iblockstate.getMaterial() != Material.AIR) {
                            int k1 = destroyblockprogress.getPartialBlockDamage();
                            TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[k1];
                            BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
                            blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.mc.world);
                        }
                    }
                }
            }
        }
        tessellatorIn.draw();
        bufferBuilderIn.setTranslation(0.0D, 0.0D, 0.0D);
        this.postRenderDamagedBlocks();
    }
}
Also used : BlockSkull(net.minecraft.block.BlockSkull) IBlockState(net.minecraft.block.state.IBlockState) BlockChest(net.minecraft.block.BlockChest) BlockEnderChest(net.minecraft.block.BlockEnderChest) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) TileEntity(net.minecraft.tileentity.TileEntity) BlockSign(net.minecraft.block.BlockSign) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 29 with BlockRendererDispatcher

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

the class IoConfigRenderer method renderBlock.

public void renderBlock(@Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull IBlockAccess blockAccess, @Nonnull BufferBuilder worldRendererIn) {
    try {
        BlockRendererDispatcher blockrendererdispatcher = mc.getBlockRendererDispatcher();
        EnumBlockRenderType type = state.getRenderType();
        if (type != EnumBlockRenderType.MODEL) {
            blockrendererdispatcher.renderBlock(state, pos, blockAccess, worldRendererIn);
            return;
        }
        // We only want to change one param here, the check sides
        IBakedModel ibakedmodel = blockrendererdispatcher.getModelForState(state);
        state = state.getBlock().getExtendedState(state, world, pos);
        blockrendererdispatcher.getBlockModelRenderer().renderModel(blockAccess, ibakedmodel, state, pos, worldRendererIn, false);
    } catch (Throwable throwable) {
    // Just bury a render issue here, it is only the IO screen
    }
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType)

Example 30 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project ForestryMC by ForestryMC.

the class CamouflageHandlerBlock method getModel.

@SideOnly(Side.CLIENT)
@Override
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack) {
    Preconditions.checkArgument(!stack.isEmpty(), "Stack cannot be empty");
    BlockRendererDispatcher rendererDispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockModelShapes modelShapes = rendererDispatcher.getBlockModelShapes();
    Block block = Block.getBlockFromItem(stack.getItem());
    Preconditions.checkArgument(block != Blocks.AIR, "Block cannot be AIR");
    IBlockState state = block.getStateFromMeta(stack.getItemDamage());
    return Pair.of(state, modelShapes.getModelForState(state));
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockModelShapes(net.minecraft.client.renderer.BlockModelShapes) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)44 IBlockState (net.minecraft.block.state.IBlockState)20 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)15 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)13 BlockPos (net.minecraft.util.math.BlockPos)13 Tessellator (net.minecraft.client.renderer.Tessellator)12 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)5 World (net.minecraft.world.World)5 Block (net.minecraft.block.Block)4 BlockModelShapes (net.minecraft.client.renderer.BlockModelShapes)4 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)3 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)3 IBlockAccess (net.minecraft.world.IBlockAccess)3 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 Nullable (javax.annotation.Nullable)2 BlockChest (net.minecraft.block.BlockChest)2 BlockEnderChest (net.minecraft.block.BlockEnderChest)2 BlockSign (net.minecraft.block.BlockSign)2