net.minecraft.client.renderer.BlockRendererDispatcher Java Examples

The following examples show how to use net.minecraft.client.renderer.BlockRendererDispatcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiComponentSideSelector.java    From OpenModsLib with MIT License 6 votes vote down vote up
private void drawBlock() {
	final Tessellator tessellator = Tessellator.getInstance();
	final BufferBuilder wr = tessellator.getBuffer();
	final BlockRendererDispatcher dispatcher = parent.getMinecraft().getBlockRendererDispatcher();
	for (BlockRenderLayer layer : BlockRenderLayer.values()) {
		if (blockState.getBlock().canRenderInLayer(blockState, layer)) {
			net.minecraftforge.client.ForgeHooksClient.setRenderLayer(layer);
			wr.setTranslation(-0.5, -0.5, -0.5);
			wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
			dispatcher.renderBlock(blockState, FakeBlockAccess.ORIGIN, access, wr);
			tessellator.draw();
		}
	}
	wr.setTranslation(0.0D, 0.0D, 0.0D);

	net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
}
 
Example #2
Source File: RenderFallTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Renders the desired {@code T} type Entity.
 */
public void doRender(EntityFallTofu entity, double x, double y, double z, float entityYaw, float partialTicks) {

    IBlockState iblockstate = BlockLoader.tofuTerrain.getDefaultState();

    if (iblockstate.getRenderType() == EnumBlockRenderType.MODEL) {
        World world = entity.getWorldObj();

        if (iblockstate != world.getBlockState(new BlockPos(entity)) && iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();

            if (this.renderOutlines) {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            bufferbuilder.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float) (x - (double) blockpos.getX() - 0.5D), (float) (y - (double) blockpos.getY()), (float) (z - (double) blockpos.getZ() - 0.5D));
            BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(iblockstate), iblockstate, blockpos, bufferbuilder, false);
            tessellator.draw();

            if (this.renderOutlines) {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
            super.doRender(entity, x, y, z, entityYaw, partialTicks);
        }
    }

}
 
Example #3
Source File: LayerGnomeHeldBlock.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void doRenderLayer(GnomeType entitylivingbaseIn, float limbSwing,
		float limbSwingAmount, float partialTicks, float ageInTicks,
		float netHeadYaw, float headPitch, float scale)
{
       IBlockState iblockstate = entitylivingbaseIn.getCarried();

       if (iblockstate != null)
       {
           BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
           GlStateManager.enableRescaleNormal();
           GlStateManager.pushMatrix();
           GlStateManager.translate(0.25F, 1.125F, -0.25F);
           //GlStateManager.translate(0.0F, 0.6875F, -0.75F);
           GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
           //GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
           //GlStateManager.translate(0.25F, 0.1875F, 0.25F);
           GlStateManager.scale(-0.5F, -0.5F, 0.5F);
           int i = entitylivingbaseIn.getBrightnessForRender();
           int j = i % 65536;
           int k = i / 65536;
           OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
           GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
           this.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
           blockrendererdispatcher.renderBlockBrightness(iblockstate, 1.0F);
           GlStateManager.popMatrix();
           GlStateManager.disableRescaleNormal();
       }
}
 
Example #4
Source File: RenderGlobalSchematic.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public RenderGlobalSchematic(Minecraft mc)
{
    super(mc);

    this.mc = mc;
    this.renderManager = mc.getRenderManager();

    this.vboEnabled = OpenGlHelper.useVbo();

    if (this.vboEnabled)
    {
        this.renderContainer = new VboRenderListSchematic();
        this.renderChunkFactory = new RenderChunkFactoryVbo();
    }
    else
    {
        this.renderContainer = new RenderListSchematic();
        this.renderChunkFactory = new RenderChunkFactoryList();
    }

    BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher();
    this.blockModelShapes = dispatcher.getBlockModelShapes();
    this.blockModelRenderer = new BlockModelRendererSchematic(mc.getBlockColors());
    this.fluidRenderer = ((IMixinBlockRendererDispatcher) dispatcher).getFluidRenderer();

    DataManager.getSchematicPlacementManager().addRebuildListener(this);
}
 
Example #5
Source File: FastBlockModelRenderer.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
private static void generateRenderDataFor(World world, IBlockState state) {
    VERTEX_BUILDER.begin(7, DefaultVertexFormats.BLOCK);
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft()
        .getBlockRendererDispatcher();
    IBakedModel modelFromState = blockrendererdispatcher.getModelForState(state);
    blockrendererdispatcher.getBlockModelRenderer()
        .renderModel(Minecraft.getMinecraft().world, modelFromState,
            Blocks.AIR.getDefaultState(), offsetPos, VERTEX_BUILDER, false, 0);
    BufferBuilder.State toReturn = VERTEX_BUILDER.getVertexState();
    VERTEX_BUILDER.finishDrawing();
    VERTEX_BUILDER.reset();
    blockstateToVertexData.put(state, toReturn);
}
 
Example #6
Source File: BlockRenderingRegistry.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public static void init() {
    if (!initialized) {
        Minecraft mc = Minecraft.getInstance();
        BlockRendererDispatcher parentDispatcher = mc.getBlockRendererDispatcher();
        mc.blockRenderDispatcher = new CCBlockRendererDispatcher(parentDispatcher, mc.getBlockColors());
        initialized = true;
    }
}
 
Example #7
Source File: CCBlockRendererDispatcher.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public CCBlockRendererDispatcher(BlockRendererDispatcher parent, BlockColors blockColours) {
    super(parent.getBlockModelShapes(), blockColours);
    parentDispatcher = parent;
    this.blockModelRenderer = parent.blockModelRenderer;
    this.fluidRenderer = parent.fluidRenderer;
    this.blockModelShapes = parent.blockModelShapes;
}
 
Example #8
Source File: MixinRenderGlobal.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
/**
 * aa
 *
 * @author xd
 */
@Overwrite
public void drawBlockDamageTexture(Tessellator tessellatorIn, BufferBuilder worldRendererIn,
    Entity entityIn, float partialTicks) {
    double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * partialTicks;
    double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * partialTicks;
    double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * partialTicks;

    if (!this.damagedBlocks.isEmpty()) {
        this.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        this.preRenderDamagedBlocks();
        worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
        worldRendererIn.setTranslation(-d0, -d1, -d2);
        worldRendererIn.noColor();
        Iterator<DestroyBlockProgress> iterator = this.damagedBlocks.values().iterator();

        while (iterator.hasNext()) {
            DestroyBlockProgress destroyblockprogress = iterator.next();
            BlockPos blockpos = destroyblockprogress.getPosition();
            double d3 = blockpos.getX() - d0;
            double d4 = blockpos.getY() - d1;
            double d5 = blockpos.getZ() - d2;
            Block block = this.world.getBlockState(blockpos).getBlock();
            TileEntity te = this.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) {
                Optional<PhysicsObject> physicsObject = ValkyrienUtils
                    .getPhysicsObject(world, blockpos);
                if (!physicsObject.isPresent() && (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D)) {
                    iterator.remove();
                } else {
                    IBlockState iblockstate = this.world.getBlockState(blockpos);
                    if (physicsObject.isPresent()) {
                        physicsObject.get()
                            .getShipRenderer()
                            .applyRenderTransform(partialTicks);
                        worldRendererIn.setTranslation(-physicsObject.get()
                            .getShipRenderer().offsetPos.getX(), -physicsObject.get()
                            .getShipRenderer().offsetPos.getY(), -physicsObject.get()
                            .getShipRenderer().offsetPos.getZ());
                    }
                    if (iblockstate.getMaterial() != Material.AIR) {
                        int i = destroyblockprogress.getPartialBlockDamage();
                        TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i];
                        BlockRendererDispatcher blockrendererdispatcher = this.mc
                            .getBlockRendererDispatcher();
                        try {
                            blockrendererdispatcher
                                .renderBlockDamage(iblockstate, blockpos, textureatlassprite,
                                    this.world);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    worldRendererIn.setTranslation(-d0, -d1, -d2);
                    // TODO: Reverse the Matrix Transforms here
                    if (physicsObject.isPresent()) {
                        tessellatorIn.draw();
                        worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
                        physicsObject.get()
                            .getShipRenderer()
                            .inverseTransform(partialTicks);
                    }
                }
            }
        }

        tessellatorIn.draw();
        worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
        this.postRenderDamagedBlocks();
    }
}
 
Example #9
Source File: RenderFallingBlockEU.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void doRender(EntityFallingBlockEU entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    IBlockState state = entity.getBlockState();

    if (state != null && state.getRenderType() == EnumBlockRenderType.MODEL)
    {
        World world = entity.getEntityWorld();

        if (state != world.getBlockState(new BlockPos(entity)) && state.getRenderType() != EnumBlockRenderType.INVISIBLE)
        {
            this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder buffer = tessellator.getBuffer();

            if (this.renderOutlines)
            {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }

            buffer.begin(7, DefaultVertexFormats.BLOCK);
            BlockPos pos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
            GlStateManager.translate((float)(x - pos.getX() - 0.5D), (float)(y - pos.getY()), (float)(z - pos.getZ() - 0.5D));
            BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
            dispatcher.getBlockModelRenderer().renderModel(
                world, dispatcher.getModelForState(state), state, pos, buffer, 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);
        }
    }
}
 
Example #10
Source File: RenderPrimedCharge.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public void doRender(EntityPrimedCharge entity, double x, double y, double z, float p_76986_8_, float partialTicks) {

  BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
  GlStateManager.pushMatrix();
  GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
  float f2;

  if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
    f2 = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
    f2 = MathHelper.clamp(f2, 0.0F, 1.0F);
    f2 *= f2;
    f2 *= f2;
    float f3 = 1.0F + f2 * 0.3F;
    GlStateManager.scale(f3, f3, f3);
  }

  f2 = (1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
  this.bindEntityTexture(entity);
  GlStateManager.translate(-0.5F, -0.5F, 0.5F);
  blockrendererdispatcher.renderBlockBrightness(entity.getBlock().getDefaultState(), entity.getBrightness());
  GlStateManager.translate(0.0F, 0.0F, 1.0F);

  if (entity.fuse / 5 % 2 == 0) {
    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 772);
    GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
    GlStateManager.doPolygonOffset(-3.0F, -3.0F);
    GlStateManager.enablePolygonOffset();
    blockrendererdispatcher.renderBlockBrightness(entity.getBlock().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();
  super.doRender(entity, x, y, z, p_76986_8_, partialTicks);
}