Java Code Examples for com.mojang.blaze3d.systems.RenderSystem#color4f()
The following examples show how to use
com.mojang.blaze3d.systems.RenderSystem#color4f() .
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: HallowedLoadingScreen.java From the-hallow with MIT License | 6 votes |
@Override public void renderDirtBackground(int i) { // Copied mostly from renderDirtBackground() RenderSystem.disableLighting(); RenderSystem.disableFog(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder builder = tessellator.getBuffer(); minecraft.getTextureManager().bindTexture(backgroundTexture); int brightness = 130; RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); builder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR); builder.vertex(0, height, 0).texture(0, height / 32.0F + i).color(brightness, brightness, brightness, 255).next(); builder.vertex(width, height, 0).texture(width / 32.0F, height / 32.0F + i).color(brightness, brightness, brightness, 255).next(); builder.vertex(width, 0, 0).texture(width / 32.0F, i).color(brightness, brightness, brightness, 255).next(); builder.vertex(0, 0, 0).texture(0, i).color(brightness, brightness, brightness, 255).next(); tessellator.draw(); }
Example 2
Source File: ListWidget.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
protected void renderHoleBackground(int top, int bottom, int topAlpha, int bottomAlpha) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); client.getTextureManager() .bindTexture(DrawableHelper.BACKGROUND_TEXTURE); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR); bufferBuilder.vertex(left, bottom, 0.0D).texture(0.0F, bottom / 32.0F) .color(64, 64, 64, bottomAlpha).next(); bufferBuilder.vertex(left + width, bottom, 0.0D) .texture(width / 32.0F, bottom / 32.0F) .color(64, 64, 64, bottomAlpha).next(); bufferBuilder.vertex(left + width, top, 0.0D) .texture(width / 32.0F, top / 32.0F).color(64, 64, 64, topAlpha) .next(); bufferBuilder.vertex(left, top, 0.0D).texture(0.0F, top / 32.0F) .color(64, 64, 64, topAlpha).next(); tessellator.draw(); }
Example 3
Source File: WTextField.java From LibGui with MIT License | 6 votes |
@Environment(EnvType.CLIENT) private void invertedRect(int x, int y, int width, int height) { Tessellator tessellator_1 = Tessellator.getInstance(); BufferBuilder bufferBuilder_1 = tessellator_1.getBuffer(); RenderSystem.color4f(0.0F, 0.0F, 255.0F, 255.0F); RenderSystem.disableTexture(); RenderSystem.enableColorLogicOp(); RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE); bufferBuilder_1.begin(GL11.GL_QUADS, VertexFormats.POSITION); bufferBuilder_1.vertex(x, y+height, 0.0D).next(); bufferBuilder_1.vertex(x+width, y+height, 0.0D).next(); bufferBuilder_1.vertex(x+width, y, 0.0D).next(); bufferBuilder_1.vertex(x, y, 0.0D).next(); tessellator_1.draw(); RenderSystem.disableColorLogicOp(); RenderSystem.enableTexture(); }
Example 4
Source File: ToggleButton.java From MiningGadgets with MIT License | 6 votes |
@Override public void renderButton(int p_renderButton_1_, int p_renderButton_2_, float p_renderButton_3_) { Color activeColor = this.enabled ? Color.GREEN : Color.RED; RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.param, GlStateManager.SourceFactor.ONE.param, GlStateManager.DestFactor.ZERO.param); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.param); RenderSystem.disableTexture(); RenderSystem.color4f(activeColor.getRed() / 255f, activeColor.getGreen() / 255f, activeColor.getBlue() / 255f, this.enabled ? .4f : .6f); blit(this.x, this.y, 0, 0, this.width, this.height); RenderSystem.enableTexture(); RenderSystem.color4f(1f, 1f, 1f, 1f); Minecraft.getInstance().getTextureManager().bindTexture(texture); blit(this.x +2, this.y + 5, 0, 0, 16, 16, 16, 16); }
Example 5
Source File: SawmillScreen.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void func_230450_a_(MatrixStack matrixStack, float partialTicks, int mouseX, int mouseY) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.field_230706_i_.getTextureManager().bindTexture(GUI_TEXTURE_LOCATION); int x = this.guiLeft; int y = this.guiTop; this.func_238474_b_(matrixStack, x, y, 0, 0, xSize, ySize); if (container.isBurning()) { int k = this.getBurnLeftScaled(13); this.func_238474_b_(matrixStack, x + 56, y + 36 + 12 - k, 176, 12 - k, 14, k + 1); } int l = this.getCookProgressScaled(24); this.func_238474_b_(matrixStack, x + 79, y + 34, 176, 14, l + 1, 16); }
Example 6
Source File: GuiBase.java From XRay-Mod with GNU General Public License v3.0 | 6 votes |
public static void drawTexturedQuadFit(double x, double y, double width, double height, int[] color, float alpha) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder tessellate = tessellator.getBuffer(); RenderSystem.pushMatrix(); tessellate.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); if ( color != null ) RenderSystem.color4f((float) color[0] / 255, (float) color[1] / 255, (float) color[2] / 255, alpha / 255); tessellate.pos(x + 0, y + height, (double) 0).tex( 0,1).endVertex(); tessellate.pos(x + width, y + height, (double) 0).tex( 1, 1).endVertex(); tessellate.pos(x + width, y + 0, (double) 0).tex( 1,0).endVertex(); tessellate.pos(x + 0, y + 0, (double) 0).tex( 0, 0).endVertex(); tessellator.draw(); RenderSystem.popMatrix(); }
Example 7
Source File: GuiAddBlock.java From XRay-Mod with GNU General Public License v3.0 | 6 votes |
static void renderPreview(int x, int y, float r, float g, float b) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder tessellate = tessellator.getBuffer(); RenderSystem.enableBlend(); RenderSystem.disableTexture(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); RenderSystem.color4f(r/255, g/255, b/255, 1); tessellate.begin(7, DefaultVertexFormats.POSITION); tessellate.pos(x, y, 0.0D).endVertex(); tessellate.pos(x, y + 45, 0.0D).endVertex(); tessellate.pos(x + 202, y + 45, 0.0D).endVertex(); tessellate.pos(x + 202, y, 0.0D).endVertex(); tessellator.draw(); RenderSystem.enableTexture(); RenderSystem.disableBlend(); }
Example 8
Source File: MiningSettingScreen.java From MiningGadgets with MIT License | 5 votes |
@Override public void renderButton(int p_renderButton_1_, int p_renderButton_2_, float p_renderButton_3_) { RenderSystem.disableTexture(); RenderSystem.color4f(.4f, .4f, .4f, 1f); this.blit(this.x, this.y, 0, 0, this.width, this.height); if( this.isWhitelist ) RenderSystem.color4f(1f, 1f, 1f, 1f); else RenderSystem.color4f(0f, 0f, 0f, 1f); this.blit(this.x + 2, this.y + 2, 0, 0, this.width-4, this.height-4); RenderSystem.enableTexture(); }
Example 9
Source File: FilterScreen.java From MiningGadgets with MIT License | 5 votes |
@Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); getMinecraft().getTextureManager().bindTexture(TEXTURE); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; // Stolen from minecraft chests :D this.blit(x, y, 0, 0, this.xSize, 71); this.blit(x, y + 71, 0, 126, this.xSize, 96); }
Example 10
Source File: DireButton.java From MiningGadgets with MIT License | 5 votes |
@Override public void render(int mouseX, int mouseY, float partialTicks) { if (this.visible) { FontRenderer fontrenderer = Minecraft.getInstance().fontRenderer; Minecraft.getInstance().getTextureManager().bindTexture(WIDGETS_LOCATION); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.isHovered = isMouseOver(mouseX, mouseY); RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.param, GlStateManager.SourceFactor.ONE.param, GlStateManager.DestFactor.ZERO.param); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.param); this.blit(this.x, this.y, 0, 46, this.width / 2, this.height); this.blit(this.x + this.width / 2, this.y, 200 - this.width / 2, 46, this.width / 2, this.height); int bottomToDraw = 2; this.blit(this.x, this.y + this.height - bottomToDraw, 0, 66 - bottomToDraw, this.width / 2, bottomToDraw); this.blit(this.x + this.width / 2, this.y + this.height - bottomToDraw, 200 - this.width / 2, 66 - bottomToDraw, this.width / 2, bottomToDraw); int j = 14737632; if (this.packedFGColor != 0) { j = this.packedFGColor; } else if (!this.active) { j = 10526880; } else if (this.isHovered) { j = 16777120; } this.drawCenteredString(fontrenderer, this.getMessage(), this.x + this.width / 2, this.y + (this.height - 7) / 2, j); } }
Example 11
Source File: ModificationTableScreen.java From MiningGadgets with MIT License | 5 votes |
@Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); getMinecraft().getTextureManager().bindTexture(GUI); int relX = (this.width - this.xSize) / 2; int relY = (this.height - this.ySize) / 2; this.blit(relX - 23, relY, 0, 0, this.xSize + 23, this.ySize); }
Example 12
Source File: DryingRackScreen.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void func_230450_a_(MatrixStack matrixStack, float p_230450_2_, int p_230450_3_, int p_230450_4_) { RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); int x = (field_230708_k_ - xSize) / 2; int y = (field_230709_l_ - ySize) / 2; field_230706_i_.textureManager.bindTexture(guiTextureLocation); this.func_238474_b_(matrixStack, x, y, 0, 0, xSize, ySize); for (int s = 0; s < container.dryTimeRemainingArray.size(); s++) { int mt = DryingRecipe.getDryingTime(field_230706_i_.world, container.getSlot(s).getStack()); int ct = container.dryTimeRemainingArray.get(s); if (ct > 0 && mt > 0) { int sx = x + 44 + 36 * s; int ny = (int) Math.ceil(ct * 20.0 / mt); int sy = 20 - ny; this.func_238474_b_(matrixStack, sx, y + 32 + sy, 176, sy, 9, ny); } } }
Example 13
Source File: ListWidget.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
protected void renderList(MatrixStack matrixStack, int i, int j, int k, int l, float f) { int m = getItemCount(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); for(int n = 0; n < m; ++n) { int o = j + n * itemHeight + headerHeight; int p = itemHeight - 4; if(o > bottom || o + p < top) updateItemPosition(n, i, o, f); if(renderSelection && isSelectedItem(n)) { int q = left + width / 2 - getRowWidth() / 2; int r = left + width / 2 + getRowWidth() / 2; RenderSystem.disableTexture(); float g = isFocused() ? 1.0F : 0.5F; RenderSystem.color4f(g, g, g, 1.0F); bufferBuilder.begin(7, VertexFormats.POSITION); bufferBuilder.vertex(q, o + p + 2, 0.0D).next(); bufferBuilder.vertex(r, o + p + 2, 0.0D).next(); bufferBuilder.vertex(r, o - 2, 0.0D).next(); bufferBuilder.vertex(q, o - 2, 0.0D).next(); tessellator.draw(); RenderSystem.color4f(0.0F, 0.0F, 0.0F, 1.0F); bufferBuilder.begin(7, VertexFormats.POSITION); bufferBuilder.vertex(q + 1, o + p + 1, 0.0D).next(); bufferBuilder.vertex(r - 1, o + p + 1, 0.0D).next(); bufferBuilder.vertex(r - 1, o - 1, 0.0D).next(); bufferBuilder.vertex(q + 1, o - 1, 0.0D).next(); tessellator.draw(); RenderSystem.enableTexture(); } renderItem(matrixStack, n, i, o, p, k, l, f); } }
Example 14
Source File: RenderMiningLaser.java From MiningGadgets with MIT License | 4 votes |
private static void drawLasers(RenderWorldLastEvent event, Vec3d from, RayTraceResult trace, double xOffset, double yOffset, double zOffset, float r, float g, float b, float thickness, PlayerEntity player, float ticks, float speedModifier) { Hand activeHand; if (player.getHeldItemMainhand().getItem() instanceof MiningGadget) { activeHand = Hand.MAIN_HAND; } else if (player.getHeldItemOffhand().getItem() instanceof MiningGadget) { activeHand = Hand.OFF_HAND; } else { return; } ItemStack stack = player.getHeldItem(activeHand); double distance = from.subtract(trace.getHitVec()).length(); long gameTime = player.world.getGameTime(); double v = gameTime * speedModifier; float additiveThickness = (thickness * 3.5f) * calculateLaserFlickerModifier(gameTime); BufferBuilder wr = Tessellator.getInstance().getBuffer(); Vec3d view = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView(); MatrixStack matrix = event.getMatrixStack(); matrix.translate(view.getX(), view.getY(), view.getZ()); if( trace.getType() == RayTraceResult.Type.MISS ) matrix.translate(-from.x, -from.y, -from.z); RenderSystem.pushMatrix(); RenderSystem.multMatrix(matrix.getLast().getMatrix()); RenderSystem.enableColorMaterial(); // This makes it so we don't clip into the world, we're effectively drawing on it RenderSystem.disableDepthTest(); RenderSystem.enableBlend(); //This makes it so multiplayer doesn't matter which side the player is standing on to see someone elses laser RenderSystem.disableCull(); RenderSystem.enableTexture(); RenderSystem.rotatef(MathHelper.lerp(ticks, -player.rotationYaw, -player.prevRotationYaw), 0, 1, 0); RenderSystem.rotatef(MathHelper.lerp(ticks, player.rotationPitch, player.prevRotationPitch), 1, 0, 0); // additive laser beam RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderSystem.color4f(r, g, b, 0.7f); Minecraft.getInstance().getTextureManager().bindTexture(laserBeamGlow); drawBeam(xOffset, yOffset, zOffset, additiveThickness, activeHand, distance, wr, 0.5, 1, ticks); // main laser, colored part RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderSystem.color4f(r, g, b, 1.0f); Minecraft.getInstance().getTextureManager().bindTexture(laserBeam2); drawBeam(xOffset, yOffset, zOffset, thickness, activeHand, distance, wr, v, v + distance * 1.5, ticks); // white core RenderSystem.color4f(MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f, 1.0f); Minecraft.getInstance().getTextureManager().bindTexture(laserBeam); drawBeam(xOffset, yOffset, zOffset, thickness / 2, activeHand, distance, wr, v, v + distance * 1.5, ticks); RenderSystem.enableDepthTest(); RenderSystem.enableCull(); RenderSystem.popMatrix(); }
Example 15
Source File: Colour.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@OnlyIn (Dist.CLIENT) public void glColour() { RenderSystem.color4f((r & 0xFF) / 255F, (g & 0xFF) / 255F, (b & 0xFF) / 255F, (a & 0xFF) / 255F); }
Example 16
Source File: Colour.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
@OnlyIn (Dist.CLIENT) public void glColour(int a) { RenderSystem.color4f((r & 0xFF) / 255F, (g & 0xFF) / 255F, (b & 0xFF) / 255F, a / 255F); }