Java Code Examples for net.minecraft.client.renderer.BufferBuilder#setTranslation()

The following examples show how to use net.minecraft.client.renderer.BufferBuilder#setTranslation() . 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: PhasedBlockRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static BufferBuilder beginRender() {
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.disableTexture2D();
	GlStateManager.enableCull();
	GlStateManager.cullFace(GlStateManager.CullFace.BACK);
	GlStateManager.depthMask(false);
	GlStateManager.enablePolygonOffset();
	GlStateManager.doPolygonOffset(-0.1f, -1000f);
	GlStateManager.enableColorMaterial();

	GlStateManager.color(1, 1, 1, 1);
	GlStateManager.shadeModel(GL11.GL_SMOOTH);

	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
	GL14.glBlendEquation(GL14.GL_FUNC_SUBTRACT);

	BufferBuilder buffer = Tessellator.getInstance().getBuffer();
	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
	buffer.setTranslation(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ);

	return buffer;
}
 
Example 2
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 3
Source File: EventsClient.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onDrawBlockHighlightEventFirst(DrawBlockHighlightEvent event) {
    GL11.glPushMatrix();
    BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
    Optional<PhysicsObject> physicsObject = ValkyrienUtils
        .getPhysicsObject(Minecraft.getMinecraft().world, pos);
    if (physicsObject.isPresent()) {
        RayTraceResult objectOver = Minecraft.getMinecraft().objectMouseOver;
        if (objectOver != null && objectOver.hitVec != null) {
            BufferBuilder buffer = Tessellator.getInstance().getBuffer();
            oldXOff = buffer.xOffset;
            oldYOff = buffer.yOffset;
            oldZOff = buffer.zOffset;

            buffer.setTranslation(-physicsObject.get()
                .getShipRenderer().offsetPos.getX(), -physicsObject.get()
                .getShipRenderer().offsetPos.getY(), -physicsObject.get()
                .getShipRenderer().offsetPos.getZ());
            physicsObject.get()
                .getShipRenderer()
                .applyRenderTransform(event.getPartialTicks());
        }
    }
}
 
Example 4
Source File: MetaTileEntityTESR.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderTileEntityFastPart(MetaTileEntityHolder te, double x, double y, double z, float partialTicks, int destroyStage) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();

    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    }
    else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

    renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, partialTicks, buffer);
    buffer.setTranslation(0, 0, 0);
    tessellator.draw();

    RenderHelper.enableStandardItemLighting();
}
 
Example 5
Source File: RenderChunkSchematicVbo.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void preRenderOverlay(BufferBuilder buffer, OverlayRenderType type)
{
    this.existingOverlays.add(type);
    this.hasOverlay = true;

    BlockPos pos = this.getPosition();
    buffer.begin(type.getGlMode(), DefaultVertexFormats.POSITION_COLOR);
    buffer.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
}
 
Example 6
Source File: ChunkRenderDispatcherLitematica.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ListenableFuture<Object> uploadChunkBlocks(final BlockRenderLayer layer, final BufferBuilder buffer,
        final RenderChunkSchematicVbo renderChunk, final CompiledChunk compiledChunk, final double distanceSq)
{
    if (Minecraft.getMinecraft().isCallingFromMinecraftThread())
    {
        //if (GuiBase.isCtrlDown()) System.out.printf("uploadChunkBlocks()\n");
        if (OpenGlHelper.useVbo())
        {
            this.uploadVertexBuffer(buffer, renderChunk.getVertexBufferByLayer(layer.ordinal()));
        }
        else
        {
            this.uploadDisplayList(buffer, ((RenderChunkSchematicList) renderChunk).getDisplayList(layer, compiledChunk), renderChunk);
        }

        buffer.setTranslation(0.0D, 0.0D, 0.0D);

        return Futures.<Object>immediateFuture(null);
    }
    else
    {
        ListenableFutureTask<Object> futureTask = ListenableFutureTask.<Object>create(new Runnable()
        {
            @Override
            public void run()
            {
                ChunkRenderDispatcherLitematica.this.uploadChunkBlocks(layer, buffer, renderChunk, compiledChunk, distanceSq);
            }
        }, null);

        synchronized (this.queueChunkUploads)
        {
            this.queueChunkUploads.add(new ChunkRenderDispatcherLitematica.PendingUpload(futureTask, distanceSq));
            return futureTask;
        }
    }
}
 
Example 7
Source File: ChunkRenderDispatcherLitematica.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ListenableFuture<Object> uploadChunkOverlay(final OverlayRenderType type, final BufferBuilder buffer,
        final RenderChunkSchematicVbo renderChunk, final CompiledChunkSchematic compiledChunk, final double distanceSq)
{
    if (Minecraft.getMinecraft().isCallingFromMinecraftThread())
    {
        //if (GuiBase.isCtrlDown()) System.out.printf("uploadChunkOverlay()\n");
        if (OpenGlHelper.useVbo())
        {
            this.uploadVertexBuffer(buffer, renderChunk.getOverlayVertexBuffer(type));
        }
        else
        {
            this.uploadDisplayList(buffer, ((RenderChunkSchematicList) renderChunk).getOverlayDisplayList(type, compiledChunk), renderChunk);
        }

        buffer.setTranslation(0.0D, 0.0D, 0.0D);

        return Futures.<Object>immediateFuture(null);
    }
    else
    {
        ListenableFutureTask<Object> futureTask = ListenableFutureTask.<Object>create(new Runnable()
        {
            @Override
            public void run()
            {
                ChunkRenderDispatcherLitematica.this.uploadChunkOverlay(type, buffer, renderChunk, compiledChunk, distanceSq);
            }
        }, null);

        synchronized (this.queueChunkUploads)
        {
            this.queueChunkUploads.add(new ChunkRenderDispatcherLitematica.PendingUpload(futureTask, distanceSq));
            return futureTask;
        }
    }
}
 
Example 8
Source File: PhasedBlockRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void finishRender(BufferBuilder buffer) {
	Tessellator.getInstance().draw();
	buffer.setTranslation(0, 0, 0);

	GlStateManager.glBlendEquation(GL14.GL_FUNC_ADD);
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
	GlStateManager.depthMask(true);

	GlStateManager.disablePolygonOffset();
	GlStateManager.enableDepth();
	GlStateManager.enableTexture2D();
}
 
Example 9
Source File: HydroponicTESR.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public void renderGrowthMedium(HydroponicTileEntity tileEntity, double x, double y, double z, float partialTicks,
         int destroyStage, float partial, BufferBuilder buffer) {

            // I was hella lazy here, could be improved

            final float PX = 1f / 16f;
            final float YOFF = 12 * PX;
            final float BORDER = 6f * PX;
            final float MAXHEIGHT = 4 * PX;
    
            float actualHeight = MAXHEIGHT + YOFF;

            TextureAtlasSprite containerTexture =  Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(CONTAINER_TEXTURE);
            TextureAtlasSprite texture = containerTexture;
            
            int mediumId = tileEntity.getGrowthMediumId();

            if (mediumId > 0) {
                IBlockState growthMediaBlockState = HydroponicHelper.getMediumBlockStateFromId(mediumId);
                BlockModelShapes bm = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
                texture = bm.getTexture(growthMediaBlockState);
            }

            // Lightmap calculations
            int upCombined = getWorld().getCombinedLight(tileEntity.getPos().up(), 0);
            int upLMa = upCombined >> 16 & 65535;
            int upLMb = upCombined & 65535;
    
            buffer.setTranslation(x,y,z);
    
            //UP face
            buffer.pos(BORDER, actualHeight, BORDER).color(1f,1f,1f,1f).tex(texture.getMinU(), texture.getMinV()).lightmap(upLMa,upLMb).endVertex();
            buffer.pos(1 - BORDER, actualHeight, BORDER).color(1f,1f,1f,1f).tex(texture.getMaxU(), texture.getMinV()).lightmap(upLMa,upLMb).endVertex();
            buffer.pos(1 - BORDER, actualHeight, 1 - BORDER).color(1f,1f,1f,1f).tex(texture.getMaxU(), texture.getMaxV()).lightmap(upLMa,upLMb).endVertex();
            buffer.pos(BORDER, actualHeight, 1 - BORDER).color(1f,1f,1f,1f).tex(texture.getMinU(), texture.getMaxV()).lightmap(upLMa,upLMb).endVertex();
}
 
Example 10
Source File: HydroponicTESR.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public void renderWaterLevel(HydroponicTileEntity tileEntity, double x, double y, double z, float partialTicks,
        int destroyStage, float partial, BufferBuilder buffer) {
    final float PX = 1f / 16f;
    final float YOFF = 12 * PX;
    final float BORDER = 1f * PX;
    final float MAXHEIGHT = 2 * PX;

    boolean hasWater = tileEntity.fluidHandler.getFluidAmount() > 0;

    if (!hasWater) {
        return;
    }

    float actualHeight = MAXHEIGHT + YOFF;

    BlockModelShapes bm = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
    IBlockState blockState = tileEntity.fluidHandler.getFluid().getFluid().getBlock().getDefaultState();
    TextureAtlasSprite texture =  bm.getTexture(blockState);

    // Lightmap calculations
    int upCombined = getWorld().getCombinedLight(tileEntity.getPos().up(), 0);
    int upLMa = upCombined >> 16 & 65535;
    int upLMb = upCombined & 65535;

    buffer.setTranslation(x, y, z);

    // UP face
    buffer.pos(BORDER, actualHeight, BORDER).color(1f, 1f, 1f, 0.8f).tex(texture.getMinU(), texture.getMinV())
            .lightmap(upLMa, upLMb).endVertex();
    buffer.pos(1 - BORDER, actualHeight, BORDER).color(1f, 1f, 1f, 0.8f).tex(texture.getMaxU(), texture.getMinV())
            .lightmap(upLMa, upLMb).endVertex();
    buffer.pos(1 - BORDER, actualHeight, 1 - BORDER).color(1f, 1f, 1f, 0.8f)
            .tex(texture.getMaxU(), texture.getMaxV()).lightmap(upLMa, upLMb).endVertex();
    buffer.pos(BORDER, actualHeight, 1 - BORDER).color(1f, 1f, 1f, 0.8f).tex(texture.getMinU(), texture.getMaxV())
            .lightmap(upLMa, upLMb).endVertex();
}
 
Example 11
Source File: RenderChunkSchematicVbo.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void preRenderBlocks(BufferBuilder buffer, BlockPos pos)
{
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    buffer.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
}
 
Example 12
Source File: RenderChunkSchematicVbo.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void preRenderOverlay(BufferBuilder buffer, int glMode)
{
    BlockPos pos = this.getPosition();
    buffer.begin(glMode, DefaultVertexFormats.POSITION_COLOR);
    buffer.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
}
 
Example 13
Source File: GuiDownloadTofuTerrain.java    From TofuCraftReload with MIT License 4 votes vote down vote up
private void drawPanorama(float ticks) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.pushMatrix();
    GlStateManager.loadIdentity();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.disableCull();
    GlStateManager.depthMask(false);
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GlStateManager.pushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GlStateManager.translate(f1, f2, f3);
        GlStateManager.rotate(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 15.0F + 10.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-(panoramaTimer + ticks) * 0.08F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GlStateManager.pushMatrix();

            switch (l) {
                case 1:
                    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 2:
                    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 3:
                    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
                    break;
                case 4:
                    GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
                    break;
                case 5:
                    GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
                    break;
            }

            mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l));
            buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
            int i = 255 / (k + 1);
            buffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, i).endVertex();
            buffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, i).endVertex();
            tessellator.draw();
            GlStateManager.popMatrix();
        }

        GlStateManager.popMatrix();
        GlStateManager.colorMask(true, true, true, false);
    }

    buffer.setTranslation(0.0D, 0.0D, 0.0D);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.matrixMode(GL11.GL_PROJECTION);
    GlStateManager.popMatrix();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.popMatrix();
    GlStateManager.depthMask(true);
    GlStateManager.enableCull();
    GlStateManager.enableDepth();
}
 
Example 14
Source File: PropellerEngineTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityPropellerEngine tileentity, double x, double y, double z,
    float partialTick,
    int destroyStage, float alpha) {
    IBlockState state = tileentity.getWorld().getBlockState(tileentity.getPos());
    if (state.getBlock() instanceof BlockAirshipEngine) {
        EnumFacing facing = state.getValue(BlockAirshipEngine.FACING);

        IBlockState engineRenderState = getRenderState(state);
        IBlockState propellerRenderState = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipWheel
            .getStateFromMeta(14);

        this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        GlStateManager.pushMatrix();
        GlStateManager.disableLighting();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder BufferBuilder = tessellator.getBuffer();

        double oldX = BufferBuilder.xOffset;
        double oldY = BufferBuilder.yOffset;
        double oldZ = BufferBuilder.zOffset;

        BufferBuilder.setTranslation(0, 0, 0);
        GL11.glTranslated(x, y, z);
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();

        int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);

        // GL11.glScaled(1.2D, 1.2D, 1.2D);

        GL11.glTranslated(0.5D, 0.5D, 0.5D);

        switch (facing) {
            case UP:
                GL11.glRotated(-90, 1, 0, 0);
                break;
            case DOWN:
                GL11.glRotated(90, 1, 0, 0);
                break;
            case NORTH:
                GL11.glRotated(180, 0, 1, 0);
                break;
            case EAST:
                GL11.glRotated(90, 0, 1, 0);
                break;
            case SOUTH:
                GL11.glRotated(0, 0, 1, 0);
                break;
            case WEST:
                GL11.glRotated(270, 0, 1, 0);
                break;

        }

        GL11.glTranslated(-0.5D, -0.5D, -0.5D);

        FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(),
            engineRenderState, brightness);

        GL11.glPushMatrix();

        GL11.glTranslated(0.5D, 0.214D, 0.5D);
        GL11.glRotated(tileentity.getPropellerAngle(partialTick), 0, 0, 1);
        GL11.glScaled(1.5D, 1.5D, 1);
        GL11.glTranslated(-0.5D, -0.214D, -0.5D);

        FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(),
            propellerRenderState, brightness);

        GL11.glPopMatrix();

        GL11.glPopMatrix();

        BufferBuilder.setTranslation(oldX, oldY, oldZ);
    }
}
 
Example 15
Source File: PropellerEngineTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityPropellerEngine tileentity, double x, double y, double z,
    float partialTick,
    int destroyStage, float alpha) {
    IBlockState state = tileentity.getWorld().getBlockState(tileentity.getPos());
    if (state.getBlock() instanceof BlockAirshipEngine) {
        EnumFacing facing = state.getValue(BlockAirshipEngine.FACING);

        IBlockState engineRenderState = getRenderState(state);
        IBlockState propellerRenderState = ValkyrienSkiesControl.INSTANCE.vsControlBlocks.shipWheel
            .getStateFromMeta(14);

        this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        GlStateManager.pushMatrix();
        GlStateManager.disableLighting();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder BufferBuilder = tessellator.getBuffer();

        double oldX = BufferBuilder.xOffset;
        double oldY = BufferBuilder.yOffset;
        double oldZ = BufferBuilder.zOffset;

        BufferBuilder.setTranslation(0, 0, 0);
        GL11.glTranslated(x, y, z);
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();

        int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);

        // GL11.glScaled(1.2D, 1.2D, 1.2D);

        GL11.glTranslated(0.5D, 0.5D, 0.5D);

        switch (facing) {
            case UP:
                GL11.glRotated(-90, 1, 0, 0);
                break;
            case DOWN:
                GL11.glRotated(90, 1, 0, 0);
                break;
            case NORTH:
                GL11.glRotated(180, 0, 1, 0);
                break;
            case EAST:
                GL11.glRotated(90, 0, 1, 0);
                break;
            case SOUTH:
                GL11.glRotated(0, 0, 1, 0);
                break;
            case WEST:
                GL11.glRotated(270, 0, 1, 0);
                break;

        }

        GL11.glTranslated(-0.5D, -0.5D, -0.5D);

        FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(),
            engineRenderState, brightness);

        GL11.glPushMatrix();

        GL11.glTranslated(0.5D, 0.214D, 0.5D);
        GL11.glRotated(tileentity.getPropellerAngle(partialTick), 0, 0, 1);
        GL11.glScaled(1.5D, 1.5D, 1);
        GL11.glTranslated(-0.5D, -0.214D, -0.5D);

        FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(),
            propellerRenderState, brightness);

        GL11.glPopMatrix();

        GL11.glPopMatrix();

        BufferBuilder.setTranslation(oldX, oldY, oldZ);
    }
}
 
Example 16
Source File: SpeedTelegraphTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntitySpeedTelegraph tileentity, double x, double y, double z,
    float partialTick, int destroyStage, float alpha) {
    IBlockState telegraphState = tileentity.getWorld().getBlockState(tileentity.getPos());

    if (telegraphState.getBlock()
        != ValkyrienSkiesControl.INSTANCE.vsControlBlocks.speedTelegraph) {
        return;
    }

    GlStateManager.resetColor();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder tessellatorBuffer = tessellator.getBuffer();

    double oldX = tessellatorBuffer.xOffset;
    double oldY = tessellatorBuffer.yOffset;
    double oldZ = tessellatorBuffer.zOffset;

    tessellatorBuffer.setTranslation(0, 0, 0);
    GL11.glTranslated(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();

    BlockPos originPos = tileentity.getPos();

    int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);

    double multiplier = 1.9D;

    GL11.glTranslated((1D - multiplier) / 2.0D, 0, (1D - multiplier) / 2.0D);
    GL11.glScaled(multiplier, multiplier, multiplier);
    EnumFacing enumfacing = telegraphState.getValue(BlockSpeedTelegraph.FACING);
    double wheelAndCompassStateRotation = enumfacing.getHorizontalAngle();

    GL11.glTranslated(0.5D, 0, 0.5D);
    GL11.glRotated(wheelAndCompassStateRotation, 0, 1, 0);
    GL11.glTranslated(-0.5D, 0, -0.5D);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), helmStateToRender, brightness);

    GibsModelRegistry.renderGibsModel("chadburn_speed_telegraph_simplevoxel_geo", brightness);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), dialState, brightness);

    GibsModelRegistry.renderGibsModel("chadburn_dial_simplevoxel_geo", brightness);

    GL11.glPushMatrix();

    GL11.glTranslated(0.497D, 0.857D, 0.5D);
    GL11.glRotated(tileentity.getHandleRenderRotation(partialTick), 0D, 0D, 1D);
    GL11.glTranslated(-0.497D, -0.857D, -0.5D);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), rightHandleState, brightness);

    GibsModelRegistry.renderGibsModel("chadburn_handles_simplevoxel_geo", brightness);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), leftHandleState, brightness);

    GL11.glPopMatrix();

    GlStateManager.enableAlpha();
    GlStateManager.enableBlend();
    // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // FastBlockModelRenderer.renderBlockModel(tessellator, tileentity.getWorld(), glassState, brightness);
    GibsModelRegistry.renderGibsModel("chadburn_glass_simplevoxel_geo", brightness);

    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();

    GL11.glPopMatrix();
    tessellatorBuffer.setTranslation(oldX, oldY, oldZ);

    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
Example 17
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 18
Source File: ClientEventHandler.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onWorldRender(RenderWorldLastEvent event){
    Tessellator t = Tessellator.getInstance();
    BufferBuilder b = t.getBuffer();

    EntityPlayer player = Minecraft.getMinecraft().player;
    if(!shouldRender()) return;

    double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.getPartialTicks();
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.getPartialTicks();
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.getPartialTicks();
    int dimensionID = player.world.provider.getDimension();
    GL11.glPushMatrix();
    GL11.glTranslated(-playerX, -playerY, -playerZ);

    GL11.glPointSize(10);

    GlStateManager.disableTexture2D();
    GlStateManager.disableLighting();
    b.setTranslation(0, 0, 0);

    NetworkVisualizationSettings visualizationSettings = player.isSneaking() ? SignalsConfig.client.networkVisualization.sneaking : SignalsConfig.client.networkVisualization.notSneaking;
    switch(visualizationSettings.renderType){
        case EDGES:
            edgeRenderer.render(dimensionID, b);
            break;
        case PATHS:
            pathRenderer.render(dimensionID, b);
            break;
        case SECTION:
            blockSectionRenderer.render(dimensionID, b);
            break;
    }
    //claimRenderer.render(b);
    if(visualizationSettings.renderDirectionality) {
        directionalityRenderer.render(dimensionID, b);
    }

    b.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);

    List<NetworkStation<MCPos>> stations = RailNetworkManager.getClientInstance().getNetwork().railObjects.getStations();
    for(int i = 0; i < stations.size(); i++) {
        NetworkStation<MCPos> station1 = stations.get(i);
        if(station1.getPos().getDimID() != dimensionID) continue;
        for(int j = 0; j < i; j++) {
            NetworkStation<MCPos> station2 = stations.get(j);
            if(station2.getPos().getDimID() != dimensionID) continue;

            if(station1.stationName.equals(station2.stationName) && station1.getPos().getDimID() == station2.getPos().getDimID()) {
                drawBetween(b, station1.getPos().getPos(), station2.getPos().getPos(), 1, 0, 1, 0, 1);
            }
        }
    }

    t.draw();

    GlStateManager.enableTexture2D();
    GlStateManager.enableLighting();
    GL11.glPopMatrix();
}
 
Example 19
Source File: GuiCustom.java    From Custom-Main-Menu with MIT License 4 votes vote down vote up
private void drawPanorama(int p_73970_1_, int p_73970_2_, float p_73970_3_)
{
	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder vertexBuffer = tessellator.getBuffer();
	GlStateManager.matrixMode(5889);
	GlStateManager.pushMatrix();
	GlStateManager.loadIdentity();
	Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
	GlStateManager.matrixMode(5888);
	GlStateManager.pushMatrix();
	GlStateManager.loadIdentity();
	GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
	GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
	GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
	GlStateManager.enableBlend();
	GlStateManager.disableAlpha();
	GlStateManager.disableCull();
	GlStateManager.depthMask(false);
	GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
	int i = 8;

	for (int j = 0; j < 64; ++j)
	{
		GlStateManager.pushMatrix();
		float f = ((float) (j % i) / (float) i - 0.5F) / 64.0F;
		float f1 = ((float) (j / i) / (float) i - 0.5F) / 64.0F;
		float f2 = 0.0F;
		GlStateManager.translate(f, f1, 0.0F);
		GlStateManager.rotate(MathHelper.sin(this.panoramaTimer / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F);
		GlStateManager.rotate(-this.panoramaTimer * 0.1F, 0.0F, 1.0F, 0.0F);

		for (int k = 0; k < 6; ++k)
		{
			GlStateManager.pushMatrix();

			if (k == 1)
			{
				GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
			}

			if (k == 2)
			{
				GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
			}

			if (k == 3)
			{
				GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
			}

			if (k == 4)
			{
				GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
			}

			if (k == 5)
			{
				GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
			}

			titlePanoramaPaths[k].bind();
			vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
			int l = 255 / (j + 1);
			float f3 = 0.0F;
			vertexBuffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, l).endVertex();
			vertexBuffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, l).endVertex();
			vertexBuffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, l).endVertex();
			vertexBuffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, l).endVertex();
			tessellator.draw();
			GlStateManager.popMatrix();
		}

		GlStateManager.popMatrix();
		GlStateManager.colorMask(true, true, true, false);
	}

	vertexBuffer.setTranslation(0.0D, 0.0D, 0.0D);
	GlStateManager.colorMask(true, true, true, true);
	GlStateManager.matrixMode(5889);
	GlStateManager.popMatrix();
	GlStateManager.matrixMode(5888);
	GlStateManager.popMatrix();
	GlStateManager.depthMask(true);
	GlStateManager.enableCull();
	GlStateManager.enableDepth();
}