Search in sources :

Example 31 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project GregTech by GregTechCE.

the class FacadeRenderer method renderBlockCover.

public static boolean renderBlockCover(CCRenderState ccrs, Matrix4 translation, IBlockAccess world, BlockPos pos, int side, IBlockState state, Cuboid6 bounds) {
    EnumFacing face = EnumFacing.VALUES[side];
    IBlockAccess coverAccess = new FacadeBlockAccess(world, pos, face, state);
    BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    try {
        state = state.getActualState(coverAccess, pos);
    } catch (Exception ignored) {
    }
    IBakedModel model = dispatcher.getModelForState(state);
    try {
        state = state.getBlock().getExtendedState(state, coverAccess, pos);
    } catch (Exception ignored) {
    }
    long posRand = net.minecraft.util.math.MathHelper.getPositionRandom(pos);
    List<BakedQuad> bakedQuads = new LinkedList<>(model.getQuads(state, null, posRand));
    for (EnumFacing face2 : EnumFacing.VALUES) {
        bakedQuads.addAll(model.getQuads(state, face2, posRand));
    }
    List<CCQuad> quads = CCQuad.fromArray(bakedQuads);
    quads = sliceQuads(quads, side, bounds);
    if (!quads.isEmpty()) {
        VertexLighterFlat lighter = setupLighter(ccrs, translation, state, coverAccess, pos, model);
        return renderBlockQuads(lighter, coverAccess, state, quads, pos);
    }
    return false;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) EnumFacing(net.minecraft.util.EnumFacing) IBlockAccess(net.minecraft.world.IBlockAccess) CCQuad(codechicken.lib.render.CCQuad) LinkedList(java.util.LinkedList) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) VertexLighterFlat(net.minecraftforge.client.model.pipeline.VertexLighterFlat) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 32 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project ICBM-Classic by BuiltBrokenModding.

the class RenderExBlock method renderBlock.

public void renderBlock(EntityExplosive entity, double x, double y, double z, float entityYaw, float partialTicks) {
    final IBlockState blockState = BlockReg.blockExplosive.getDefaultState().withProperty(BlockICBM.ROTATION_PROP, // TODO get direction from rotation
    EnumFacing.UP).withProperty(BlockExplosive.EX_PROP, entity.getExplosiveData());
    final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
    // expansion shortly before explosion
    if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
        float f = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
        f = MathHelper.clamp(f, 0.0F, 1.0F);
        float f1 = 1.0F + f * f * f * 0.3F;
        GlStateManager.scale(f1, f1, f1);
    }
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.translate(-0.5F, -0.5F, 0.5F);
    blockrendererdispatcher.renderBlockBrightness(blockState, entity.getBrightness());
    GlStateManager.translate(0.0F, 0.0F, 1.0F);
    // white flashing
    if (entity.fuse / 5 % 2 == 0) {
        GlStateManager.disableTexture2D();
        GlStateManager.disableLighting();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.DST_ALPHA);
        GlStateManager.color(1.0F, 1.0F, 1.0F, (1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F);
        GlStateManager.doPolygonOffset(-3.0F, -3.0F);
        GlStateManager.enablePolygonOffset();
        blockrendererdispatcher.renderBlockBrightness(BlockReg.blockExplosive.getDefaultState(), 1.0F);
        GlStateManager.doPolygonOffset(0.0F, 0.0F);
        GlStateManager.disablePolygonOffset();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableBlend();
        GlStateManager.enableLighting();
        GlStateManager.enableTexture2D();
    }
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 33 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project ICBM-Classic by BuiltBrokenModding.

the class RenderEntityBlock method doRender.

@Override
public void doRender(EntityFlyingBlock entity, double x, double y, double z, float entityYaw, float partialTicks) {
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
    final IBlockState blockState = entity.getBlockState();
    final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.translate(-0.5F, -0.5F, 0.5F);
    blockrendererdispatcher.renderBlockBrightness(blockState, entity.getBrightness());
    GlStateManager.translate(0.0F, 0.0F, 1.0F);
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 34 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project MorePlanets by SteveKunG.

the class RenderAntiGravFallingBlock method doRender.

@Override
public void doRender(EntityAntiGravFallingBlock entity, double x, double y, double z, float entityYaw, float partialTicks) {
    if (entity.getBlockState() != null) {
        IBlockState state = entity.getBlockState();
        if (state.getRenderType() == EnumBlockRenderType.MODEL) {
            World world = entity.world;
            if (state != world.getBlockState(new BlockPos(entity)) && state.getRenderType() != EnumBlockRenderType.INVISIBLE) {
                this.bindEntityTexture(entity);
                GlStateManager.pushMatrix();
                GlStateManager.disableLighting();
                Tessellator tessellator = Tessellator.getInstance();
                BufferBuilder vertexbuffer = tessellator.getBuffer();
                if (this.renderOutlines) {
                    GlStateManager.enableColorMaterial();
                    GlStateManager.enableOutlineMode(this.getTeamColor(entity));
                }
                vertexbuffer.begin(GLConstants.QUADS, DefaultVertexFormats.BLOCK);
                BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
                GlStateManager.translate((float) (x - blockpos.getX() - 0.5D), (float) (y - blockpos.getY()), (float) (z - blockpos.getZ() - 0.5D));
                BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
                blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(state), state, blockpos, vertexbuffer, false, MathHelper.getPositionRandom(entity.getOrigin()));
                tessellator.draw();
                if (this.renderOutlines) {
                    GlStateManager.disableOutlineMode();
                    GlStateManager.disableColorMaterial();
                }
                GlStateManager.enableLighting();
                GlStateManager.popMatrix();
                super.doRender(entity, x, y, z, entityYaw, partialTicks);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

Example 35 with BlockRendererDispatcher

use of net.minecraft.client.renderer.BlockRendererDispatcher in project BetterWithAddons by DaedalusGame.

the class RenderArtifactFrame method renderModel.

private void renderModel(EntityArtifactFrame entity) {
    BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
    ModelManager modelmanager = blockrendererdispatcher.getBlockModelShapes().getModelManager();
    IBakedModel ibakedmodel;
    if (!entity.getDisplayedItem().isEmpty() && entity.getDisplayedItem().getItem() == Items.FILLED_MAP) {
        // ModelResourceLocation mapModel = new ModelResourceLocation(new ResourceLocation("betterwithaddons",this.mapModel.getResourcePath()),this.mapModel.getVariant());
        ibakedmodel = modelmanager.getModel(mapModel);
    } else {
        // ModelResourceLocation itemFrameModel = new ModelResourceLocation(new ResourceLocation("betterwithaddons",this.itemFrameModel.getResourcePath()),this.itemFrameModel.getVariant());
        ibakedmodel = modelmanager.getModel(itemFrameModel);
    }
    // GlStateManager.pushMatrix();
    // GlStateManager.translate(-0.5F, -0.5F, -0.5F);
    blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelManager(net.minecraft.client.renderer.block.model.ModelManager) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher)

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