private void drawArrow(float progress) { double arrowBaseWidth = 0.4D; double arrowBaseLength = 0.8D; double arrowLength = 1.5D; double arrowWidth = 0.7D; double scale = 0.1D; GL11.glPushMatrix(); GL11.glScaled(scale, scale, scale); GL11.glTranslatef(0, progress * 4, 0); BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION); wr.pos(-arrowBaseWidth, -arrowLength * 0.5D, 0).endVertex(); wr.pos(-arrowBaseWidth, -arrowLength * 0.5D + arrowBaseLength, 0).endVertex(); wr.pos(-arrowWidth, -arrowLength * 0.5D + arrowBaseLength, 0).endVertex(); wr.pos(0, arrowLength * 0.5D, 0).endVertex(); wr.pos(arrowWidth, -arrowLength * 0.5D + arrowBaseLength, 0).endVertex(); wr.pos(arrowBaseWidth, -arrowLength * 0.5D + arrowBaseLength, 0).endVertex(); wr.pos(arrowBaseWidth, -arrowLength * 0.5D, 0).endVertex(); Tessellator.getInstance().draw(); GL11.glPopMatrix(); }
@SideOnly(Side.CLIENT) public void renderInterpolated(RenderProgressingLine lastTickLine, float partialTick, float rotationYaw, float rotationPitch) { GL11.glPushMatrix(); double renderProgress = getInter(progress, lastTickLine.progress, partialTick); GL11.glTranslated((getInter(endX, lastTickLine.endX, partialTick) - startX) * renderProgress, (getInter(endY, lastTickLine.endY, partialTick) - startY) * renderProgress, (getInter(endZ, lastTickLine.endZ, partialTick) - startZ) * renderProgress); GL11.glRotatef(rotationYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(rotationPitch, 0.0F, 0.0F, 1.0F); BufferBuilder wr = Tessellator.getInstance().getBuffer(); GL11.glEnable(GL11.GL_LINE_SMOOTH); wr.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); RenderUtils.glColorHex(color); double size = 5 / 16D; for (int i = 0; i < PneumaticCraftUtils.circlePoints; i++) { wr.pos(0, PneumaticCraftUtils.sin[i] * size, PneumaticCraftUtils.cos[i] * size).endVertex(); } Tessellator.getInstance().draw(); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glPopMatrix(); }
private void renderAirParticle(float particleProgress) { int xStart = (width - xSize) / 2; int yStart = (height - ySize) / 2; float x = xStart + 117F; float y = yStart + 50.5F; if (particleProgress < 0.5F) { y += particleProgress * 56; } else if (particleProgress < 0.7F) { y += 28F; x -= (particleProgress - 0.5F) * 90; } else { y += 28F; x -= 18; y -= (particleProgress - 0.7F) * 70; } BufferBuilder wr = Tessellator.getInstance().getBuffer(); GL11.glPointSize(5); wr.begin(GL11.GL_POINTS, DefaultVertexFormats.POSITION); wr.pos(x, y, zLevel).endVertex(); Tessellator.getInstance().draw(); }
@Override public void render(int mouseX, int mouseY, float partialTick) { drawRect(x, y, x + CHECKBOX_WIDTH, y + CHECKBOX_HEIGHT, enabled ? 0xFFA0A0A0 : 0xFF999999); drawRect(x + 1, y + 1, x + CHECKBOX_WIDTH - 1, y + CHECKBOX_HEIGHT - 1, enabled ? 0xFF202020 : 0xFFAAAAAA); if (checked) { GlStateManager.disableTexture2D(); if (enabled) { GlStateManager.color(1, 1, 1, 1); } else { GlStateManager.color(0.8f, 0.8f, 0.8f, 1); } BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION); wr.pos(x + 2, y + 5, zLevel).endVertex(); wr.pos(x + 5, y + 7, zLevel).endVertex(); wr.pos(x + 8, y + 3, zLevel).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableTexture2D(); GlStateManager.color(0.25f, 0.25f, 0.25f, 1); } fontRenderer.drawString(I18n.format(text), x + 1 + CHECKBOX_WIDTH, y + CHECKBOX_HEIGHT / 2 - fontRenderer.FONT_HEIGHT / 2, enabled ? color : 0xFF888888); }
@Override public void render() { FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getTexture()); int width = getWidth() + (getParameters() != null && getParameters().length > 0 ? 10 : 0); int height = getHeight() + (hasStepOutput() ? 10 : 0); Pair<Double, Double> maxUV = getMaxUV(); double u = maxUV.getLeft(); double v = maxUV.getRight(); BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); wr.pos(0, 0, 0).tex(0, 0).endVertex(); wr.pos(0, height, 0).tex(0, v).endVertex(); wr.pos(width, height, 0).tex(u, v).endVertex(); wr.pos(width, 0, 0).tex(u, 0).endVertex(); Tessellator.getInstance().draw(); }
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { //super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); //System.out.println("rot: "+rotationX+" "+rotationZ+" "+rotationYZ+" "+rotationXY+" "+rotationXZ); EnumFacing face=this.block.sideHit; if(face == EnumFacing.UP) super.renderParticle(buffer, entityIn, partialTicks, 1, 0, 0, 0, 1); else if(face == EnumFacing.DOWN) super.renderParticle(buffer, entityIn, partialTicks, 1, 0, 0, 0, -1); else if(face == EnumFacing.NORTH) super.renderParticle(buffer, entityIn, partialTicks, 1, 1, 0, 0, 0); else if(face == EnumFacing.SOUTH) super.renderParticle(buffer, entityIn, partialTicks, -1, 1, 0, 0, 0); else if(face == EnumFacing.EAST) super.renderParticle(buffer, entityIn, partialTicks, 0, 1, 1, 0, 0); else if(face == EnumFacing.WEST) super.renderParticle(buffer, entityIn, partialTicks, 0, 1, -1, 0, 0); }
@Override public void render(Vector3 cameraPos) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buf = tessellator.getBuffer(); for (LineStyle line : this.style.getLines()) { if (!line.prepare(this.style.getRenderType())) { continue; } buf.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION); line.applyColour(); for (Vector3 vertex : this.vertices) { buf.pos(vertex.getX() - cameraPos.getX(), vertex.getY() - cameraPos.getY(), vertex.getZ() - cameraPos.getZ()).endVertex(); } tessellator.draw(); } }
public static void renderGhostModel(IBakedModel model, BlockPos position, Color color, boolean noDepth, float partialTicks) { GlStateManager.enableBlend(); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_DST_COLOR); BufferBuilder vb; if(noDepth) { GlStateManager.depthFunc(519); vb = prepRenderBlockDepth(partialTicks, true); } else vb = prepRender(partialTicks, true); vb.begin(7, DefaultVertexFormats.BLOCK); World world = Minecraft.getMinecraft().world; BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); dispatcher.getBlockModelRenderer().renderModel(world, model, Minecraft.getMinecraft().world.getBlockState(position), position.add(0, noDepth ? 500 : 0, 0), vb, false); for(int i = 0; i < vb.getVertexCount(); i++) vb.putColorMultiplier(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, i); vb.color(1, 1, 1, 0.1f); postRender(); GlStateManager.depthFunc(515); GlStateManager.disableBlend(); }
@SideOnly(Side.CLIENT) public void render(BufferBuilder renderer) { int numVertices = vertices.length; if(faceNormal == null) faceNormal = calculateFaceNormal(); renderer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL); for (int i = 0; i < numVertices; ++i) { Vertex v = vertices[i]; TextureCoordinate tc = textureCoordinates[i]; renderer.pos(v.x, v.y, v.z).tex(tc.u, tc.v).normal(faceNormal.x, faceNormal.y, faceNormal.z).endVertex(); } //Renderer works with four vertices so add start point again if face is only three vertices. if(numVertices == 3) renderer.pos(vertices[0].x, vertices[0].y, vertices[0].z).tex(textureCoordinates[0].u, textureCoordinates[0].v).normal(faceNormal.x, faceNormal.y, faceNormal.z).endVertex(); Tessellator.getInstance().draw(); }
private static void drawTextureWithMasking(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) { double uMin = (double) textureSprite.getMinU(); double uMax = (double) textureSprite.getMaxU(); double vMin = (double) textureSprite.getMinV(); double vMax = (double) textureSprite.getMaxV(); uMax = uMax - (maskRight / 16.0 * (uMax - uMin)); vMax = vMax - (maskTop / 16.0 * (vMax - vMin)); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferBuilder.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex(); bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex(); bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex(); bufferBuilder.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex(); tessellator.draw(); }
void render() { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buff = tessellator.getBuffer(); buff.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); buff.setTranslation( -TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ ); buff.pos(from.x, from.y, from.z).color(getRedColorF(), getGreenColorF(), getBlueColorF(), alpha * particleAlpha) .endVertex(); buff.pos(to.x, to.y, to.z).color(getRedColorF(), getGreenColorF(), getBlueColorF(), alpha * particleAlpha) .endVertex(); buff.setTranslation(0,0,0); tessellator.draw(); }
private static void drawCuboid(final BufferBuilder buffer, final BlockPos begin, final BlockPos end, final int sides, final int argb, final double delta) { if (buffer.getDrawMode() == -1 || sides == 0) { return; } final double x0 = begin.getX() - delta; final double y0 = begin.getY() - delta; final double z0 = begin.getZ() - delta; final double x1 = end.getX() + 1 + delta; final double y1 = end.getY() + 1 + delta; final double z1 = end.getZ() + 1 + delta; switch (buffer.getDrawMode()) { case GL11.GL_QUADS: drawQuads(buffer, x0, y0, z0, x1, y1, z1, sides, argb); break; case GL11.GL_LINES: drawLines(buffer, x0, y0, z0, x1, y1, z1, sides, argb); break; default: throw new IllegalStateException("Unsupported mode!"); } }
@Override public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { if(sprite != null) { double uMin = 0F; double uMax = 1F; double vMin = 0F; double vMax = 1F; if(sprite instanceof FrameSpriteResource) { FrameSpriteResource framedSprite = ((FrameSpriteResource) sprite); Tuple<Double, Double> uv = framedSprite.getUVFrame((int) particleAngle); double uOffset = framedSprite.getU(); double u = uv.getFirst(); double vOffset = framedSprite.getV(); double v = uv.getSecond(); uMin = u; uMax = u + uOffset; vMin = v; vMax = v + vOffset; } sprite.bindManager(); renderEasy(buffer, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ, uMin, uMax, vMin, vMax); } }
public void render(double size, float partialTicks) { double renderRotationAngle = oldRotationAngle + (rotationAngle - oldRotationAngle) * partialTicks; BufferBuilder wr = Tessellator.getInstance().getBuffer(); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); // GL11.glLineWidth((float)size * 20F); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glRotatef((float) renderRotationAngle, 0, 0, 1); for (int j = 0; j < 2; j++) { wr.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION); for (int i = 0; i < PneumaticCraftUtils.circlePoints / 4; i++) { wr.pos(PneumaticCraftUtils.cos[i] * size, PneumaticCraftUtils.sin[i] * size, 0).endVertex(); wr.pos(PneumaticCraftUtils.cos[i] * (size + 0.1D), PneumaticCraftUtils.sin[i] * (size + 0.1D), 0).endVertex(); } Tessellator.getInstance().draw(); if (renderAsTagged) { GL11.glColor4d(1, 0, 0, 1); wr.begin(GL11.GL_LINE_LOOP, DefaultVertexFormats.POSITION); for (int i = 0; i < PneumaticCraftUtils.circlePoints / 4; i++) { wr.pos(PneumaticCraftUtils.cos[i] * size, PneumaticCraftUtils.sin[i] * size, 0).endVertex(); } for (int i = PneumaticCraftUtils.circlePoints / 4 - 1; i >= 0; i--) { wr.pos(PneumaticCraftUtils.cos[i] * (size + 0.1D), PneumaticCraftUtils.sin[i] * (size + 0.1D), 0).endVertex(); } Tessellator.getInstance().draw(); GL11.glColor4d(1, 1, 0, 0.5); } GL11.glRotatef(180, 0, 0, 1); } GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
@Override public void renderTileEntityFast(@Nonnull TilePhenomena phenomena, double x, double y, double z, float partialTick, int breakStage, float partial, @Nullable BufferBuilder renderer) { if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); BlockPos pos = phenomena.getPos(); IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(phenomena.getWorld(), pos); IBlockState state = getState(phenomena, world, pos); if(state instanceof IExtendedBlockState) { IExtendedBlockState extendedState = (IExtendedBlockState) state; if(extendedState.getUnlistedNames().contains(Properties.AnimationProperty)) { float time = ((20 - phenomena.timer)) / 20F; // Using tile timer instead of world time. IAnimationStateMachine capability = phenomena.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null); if(capability != null) { Pair<IModelState, Iterable<Event>> pair = capability.apply(time); extendedState = extendedState.withProperty(Properties.AnimationProperty, pair.getLeft()); IBakedModel model = getModel(state); assert renderer != null; renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ()); blockRenderer.getBlockModelRenderer().renderModel(world, model, extendedState, pos, renderer, false); } } } }
public static void renderSearch(double x, double y, double z, int itemCount, int totalCount) { GL11.glPushMatrix(); GL11.glTranslated(x, y, z); GL11.glColor4d(0, 1, 0, 0.5D); GL11.glRotatef(180.0F - Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(180.0F - Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); // GL11.glLineWidth(1.0F); double ratio = (double) itemCount / totalCount; double diff = (1 - ratio) / 1.5D; double size = 1 - diff; /* for(double i = size; i > 0; i -= 0.06D) { GL11.glPushMatrix(); GL11.glScaled(i, i, i); renderCircle(); GL11.glPopMatrix(); } */ BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); wr.pos(-size, size, 0).tex(0, 1).endVertex(); wr.pos(-size, -size, 0).tex(0, 0).endVertex(); wr.pos(size, -size, 0).tex(1, 0).endVertex(); wr.pos(size, size, 0).tex(1, 1).endVertex(); Tessellator.getInstance().draw(); GL11.glPopMatrix(); }
private void renderQuad(int color) { BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); RenderUtils.glColorHex(color); wr.pos(-0.5, 0, 0).tex(0, 0).endVertex(); wr.pos(-0.5, 1, 0).tex(0, 1).endVertex(); wr.pos(0.5, 1, 0).tex(1, 1).endVertex(); wr.pos(0.5, 0, 0).tex(1, 0).endVertex(); Tessellator.getInstance().draw(); }
@SideOnly(Side.CLIENT) public void renderInterpolated(RenderProgressingLine lastTickLine, float partialTick) { BufferBuilder wr = Tessellator.getInstance().getBuffer(); wr.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); wr.pos(getInter(startX, lastTickLine.startX, partialTick), getInter(startY, lastTickLine.startY, partialTick), getInter(startZ, lastTickLine.startZ, partialTick)).endVertex(); wr.pos(getInter(startX, lastTickLine.startX, partialTick) + (getInter(endX, lastTickLine.endX, partialTick) - getInter(startX, lastTickLine.startX, partialTick)) * progress, getInter(startY, lastTickLine.startY, partialTick) + (getInter(startY, lastTickLine.startY, partialTick) - getInter(endY, lastTickLine.endY, partialTick)) * progress, getInter(startZ, lastTickLine.startZ, partialTick) + (getInter(endZ, lastTickLine.endZ, partialTick) - getInter(startZ, lastTickLine.startZ, partialTick)) * progress).endVertex(); Tessellator.getInstance().draw(); }
@Override public void render(TileEntityElevatorCaller te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { Tessellator tess = Tessellator.getInstance(); GlStateManager.pushMatrix(); GlStateManager.translate(x + 0.5, y + 1.5, z + 0.5); GlStateManager.scale(1.0F, -1F, -1F); PneumaticCraftUtils.rotateMatrixByMetadata(te.getBlockMetadata()); GlStateManager.translate(-1, 0, -1); FontRenderer fontRenderer = Minecraft.getMinecraft().getRenderManager().getFontRenderer(); for (TileEntityElevatorCaller.ElevatorButton button : te.getFloors()) { GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.color(button.red, button.green, button.blue, 1F); BufferBuilder bufferBuilder = tess.getBuffer(); bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); bufferBuilder.pos(button.posX + 0.5D, button.posY + 0.5D, 0.499D).endVertex(); bufferBuilder.pos(button.posX + 0.5D, button.posY + button.height + 0.5D, 0.499D).endVertex(); bufferBuilder.pos(button.posX + button.width + 0.5D, button.posY + button.height + 0.5D, 0.499D).endVertex(); bufferBuilder.pos(button.posX + button.width + 0.5D, button.posY + 0.5D, 0.499D).endVertex(); tess.draw(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); GlStateManager.enableLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(button.posX + 0.5D, button.posY + 0.5D, 0.498); GlStateManager.translate(button.width / 2, button.height / 2, 0); float textScale = Math.min((float)button.width / 10F, (float)button.height / 10F); GlStateManager.scale(textScale, textScale, textScale); fontRenderer.drawString(button.buttonText, -fontRenderer.getStringWidth(button.buttonText) / 2, -fontRenderer.FONT_HEIGHT / 2, 0xFF000000); GlStateManager.popMatrix(); } GlStateManager.popMatrix(); }
private static void draw(BufferBuilder renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha) { renderer.begin(7, DefaultVertexFormats.POSITION_COLOR); renderer.pos((double) (x), (double) (y), 0.0D).color(red, green, blue, alpha).endVertex(); renderer.pos((double) (x), (double) (y + height), 0.0D).color(red, green, blue, alpha).endVertex(); renderer.pos((double) (x + width), (double) (y + height), 0.0D).color(red, green, blue, alpha).endVertex(); renderer.pos((double) (x + width), (double) (y), 0.0D).color(red, green, blue, alpha).endVertex(); Tessellator.getInstance().draw(); }
public static void putOutlinedRectangle(BufferBuilder buffer, int x, int y, int w, int h, float... color) { putRectangle(buffer, x, y, w, h, color); float[] colorOutline = new float[4]; System.arraycopy(color, 4, colorOutline, 0, 4); putRectangle(buffer, x - 1, y - 1, 1, h + 2, colorOutline); putRectangle(buffer, x + w, y - 1, 1, h + 2, colorOutline); putRectangle(buffer, x, y - 1, w, 1, colorOutline); putRectangle(buffer, x, y + h, w, 1, colorOutline); }
private void renderChunkBorder(double yMin, double yMax, double xBase, double zBase) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buf = tessellator.getBuffer(); int spacing = 16; for (LineStyle line : this.style.getLines()) { if (line.prepare(this.style.getRenderType())) { buf.begin(GL_LINES, DefaultVertexFormats.POSITION); line.applyColour(); for (int x = -16; x <= 32; x += spacing) { for (int z = -16; z <= 32; z += spacing) { buf.pos(xBase + x, yMin, zBase - z).endVertex(); buf.pos(xBase + x, yMax, zBase - z).endVertex(); } } for (double y = yMin; y <= yMax; y += yMax) { buf.pos(xBase, y, zBase).endVertex(); buf.pos(xBase, y, zBase - 16).endVertex(); buf.pos(xBase, y, zBase - 16).endVertex(); buf.pos(xBase + 16, y, zBase - 16).endVertex(); buf.pos(xBase + 16, y, zBase - 16).endVertex(); buf.pos(xBase + 16, y, zBase).endVertex(); buf.pos(xBase + 16, y, zBase).endVertex(); buf.pos(xBase, y, zBase).endVertex(); } tessellator.draw(); } } }
private void renderChunkBoundary(int xChunk, int zChunk, double xBase, double zBase) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buf = tessellator.getBuffer(); Chunk chunk = this.mc.world.getChunkFromChunkCoords(xChunk, zChunk); for (LineStyle line : this.style.getLines()) { if (line.prepare(this.style.getRenderType())) { buf.begin(GL_LINES, DefaultVertexFormats.POSITION); line.applyColour(); int[][] lastHeight = { { -1, -1 }, { -1, -1 } }; for (int i = 0, height = 0; i < 16; i++) { for (int j = 0; j < 2; j++) { for (int axis = 0; axis < 2; axis++) { height = axis == 0 ? chunk.getHeightValue(j * 15, i) : chunk.getHeightValue(i, j * 15); double xPos = axis == 0 ? xBase + (j * 16) : xBase + i; double zPos = axis == 0 ? zBase - 16 + i : zBase - 16 + (j * 16); if (lastHeight[axis][j] > -1 && height != lastHeight[axis][j]) { buf.pos(xPos, lastHeight[axis][j], zPos).endVertex(); buf.pos(xPos, height, zPos).endVertex(); } buf.pos(xPos, height, zPos).endVertex(); buf.pos(xPos + axis, height, zPos + (1 - axis)).endVertex(); lastHeight[axis][j] = height; } } } tessellator.draw(); } } }
@Override public void render(Vector3 cameraPos) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buf = tessellator.getBuffer(); double xPos = this.centreX - cameraPos.getX(); double zPos = this.centreZ - cameraPos.getZ(); for (LineStyle line : this.style.getLines()) { if (!line.prepare(this.style.getRenderType())) { continue; } double twoPi = Math.PI * 2; for (int yBlock : new int[] { this.minY, this.maxY + 1 }) { buf.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION); line.applyColour(); for (int i = 0; i <= 75; i++) { double tempTheta = i * twoPi / 75; double tempX = this.radX * Math.cos(tempTheta); double tempZ = this.radZ * Math.sin(tempTheta); buf.pos(xPos + tempX, yBlock - cameraPos.getY(), zPos + tempZ).endVertex(); } tessellator.draw(); } } }
@Override public void render(Vector3 cameraPos) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buf = tessellator.getBuffer(); double xPos = this.centreX - cameraPos.getX(); double zPos = this.centreZ - cameraPos.getZ(); for (LineStyle line : this.style.getLines()) { if (!line.prepare(this.style.getRenderType())) { continue; } double twoPi = Math.PI * 2; for (int yBlock = this.minY + 1; yBlock <= this.maxY; yBlock++) { buf.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION); line.applyColour(); for (int i = 0; i <= 75; i++) { double tempTheta = i * twoPi / 75; double tempX = this.radX * Math.cos(tempTheta); double tempZ = this.radZ * Math.sin(tempTheta); buf.pos(xPos + tempX, yBlock - cameraPos.getY(), zPos + tempZ).endVertex(); } tessellator.draw(); } } }
/** * Draws the blue selection box. */ private void drawSelectionBox(int startX, int startY, int endX, int endY) { if (startX < endX) { int i = startX; startX = endX; endX = i; } if (startY < endY) { int j = startY; startY = endY; endY = j; } if (endX > this.x + this.width) { endX = this.x + this.width; } if (startX > this.x + this.width) { startX = this.x + this.width; } Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); GlStateManager.color(0.0F, 0.0F, 255.0F, 255.0F); GlStateManager.disableTexture2D(); GlStateManager.enableColorLogic(); GlStateManager.colorLogicOp(GlStateManager.LogicOp.OR_REVERSE); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); bufferbuilder.pos((double) startX, (double) endY, 0.0D).endVertex(); bufferbuilder.pos((double) endX, (double) endY, 0.0D).endVertex(); bufferbuilder.pos((double) endX, (double) startY, 0.0D).endVertex(); bufferbuilder.pos((double) startX, (double) startY, 0.0D).endVertex(); tessellator.draw(); GlStateManager.disableColorLogic(); GlStateManager.enableTexture2D(); }
private static void renderModel(IBakedModel model, VertexFormat fmt, int color) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder worldrenderer = tessellator.getBuffer(); worldrenderer.begin(GL11.GL_QUADS, fmt); for (BakedQuad bakedquad : model.getQuads(null, null, 0)) { LightUtil.renderQuadColor(worldrenderer, bakedquad, color); } tessellator.draw(); }
@Override public void renderParticle(BufferBuilder p_180434_1_, Entity p_180434_2_, float p_180434_3_, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_) { float f6 = (this.particleAge + p_180434_3_) / this.particleMaxAge; this.particleScale = 1.0F + f6 * f6 * 5.5F; super.renderParticle(p_180434_1_, p_180434_2_, p_180434_3_, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_); }
@SideOnly(Side.CLIENT) default void render(int x, int y, net.minecraft.client.Minecraft mc, int index) { mc.renderEngine.bindTexture(ResourceLocations.BREW_TEXTURES); final Tessellator tessellator = Tessellator.getInstance(); final BufferBuilder buf = tessellator.getBuffer(); GlStateManager.color(1F, 1F, 1F, 1F); final float f = 0.00390625F; buf.begin(7, DefaultVertexFormats.POSITION_TEX); buf.pos(x, y + 20, 0).tex(236 * f, (236 + 20) * f).endVertex(); buf.pos(x + 20, y + 20, 0).tex((236 + 20) * f, (236 + 20) * f).endVertex(); buf.pos(x + 20, y, 0).tex((236 + 20) * f, 236 * f).endVertex(); buf.pos(x, y, 0).tex(236 * f, 236 * f).endVertex(); tessellator.draw(); int textureX = index % 14 * 18; int textureY = index / 14 * 18; x += 1; y += 1; buf.begin(7, DefaultVertexFormats.POSITION_TEX); buf.pos(x, y + 18, 0).tex(textureX * f, (textureY + 18) * f).endVertex(); buf.pos(x + 18, y + 18, 0).tex((textureX + 18) * f, (textureY + 18) * f).endVertex(); buf.pos(x + 18, y, 0).tex((textureX + 18) * f, textureY * f).endVertex(); buf.pos(x, y, 0).tex(textureX * f, textureY * f).endVertex(); tessellator.draw(); }
@Override public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { int i = (int) (((float) this.life + partialTicks) / (float) this.particleMaxAge); if (i <= 7) { this.textureManager.bindTexture(ResourceLocations.BUBBLE); float minX = 0; float maxX = minX + 1; float minY = (float) i / 8F; float maxY = minY + 0.125F; float scale = 1.0F * this.particleScale; float x = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTicks - interpPosX); float y = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTicks - interpPosY); float z = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTicks - interpPosZ); Vec3d vec0 = new Vec3d(-rotationX * scale - rotationXY * scale, -rotationZ * scale, -rotationYZ * scale - rotationXZ * scale); Vec3d vec1 = new Vec3d(-rotationX * scale + rotationXY * scale, rotationZ * scale, -rotationYZ * scale + rotationXZ * scale); Vec3d vec2 = new Vec3d(rotationX * scale + rotationXY * scale, rotationZ * scale, rotationYZ * scale + rotationXZ * scale); Vec3d vec3 = new Vec3d(rotationX * scale - rotationXY * scale, -rotationZ * scale, rotationYZ * scale - rotationXZ * scale); GlStateManager.color(getRedColorF(), getGreenColorF(), getBlueColorF(), 1.0F); buffer.begin(7, VERTEX_FORMAT); buffer.pos((double) x + vec0.x, (double) y + vec0.y, (double) z + vec0.z).tex((double) maxX, (double) maxY).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); buffer.pos((double) x + vec1.x, (double) y + vec1.y, (double) z + vec1.z).tex((double) maxX, (double) minY).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); buffer.pos((double) x + vec2.x, (double) y + vec2.y, (double) z + vec2.z).tex((double) minX, (double) minY).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); buffer.pos((double) x + vec3.x, (double) y + vec3.y, (double) z + vec3.z).tex((double) minX, (double) maxY).color(this.particleRed, this.particleGreen, this.particleBlue, 1.0F).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); Tessellator.getInstance().draw(); } }
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { float scale = ((float) this.particleAge + partialTicks) / (float) this.particleMaxAge * 32.0F; scale = MathHelper.clamp(scale, 0.0F, 1.0F); this.particleScale = this.oSize * scale; super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); GlStateManager.color(getRedColorF(), getGreenColorF(), getBlueColorF(), 1.0F); }
private void renderTexture(double x, double y, double width, double height, double vMin, double vMax) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buff = tessellator.getBuffer(); buff.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); buff.pos(x, y + height, 0).tex(0, vMax).endVertex(); buff.pos(x + width, y + height, 0).tex(1, vMax).endVertex(); buff.pos(x + width, y, 0).tex(1, vMin).endVertex(); buff.pos(x, y, 0).tex(0, vMin).endVertex(); tessellator.draw(); }
@SideOnly(Side.CLIENT) @Override public void renderHUD(int x, int y, Minecraft mc, int amplifier) { mc.renderEngine.bindTexture(ResourceLocations.BREW_TEXTURES); final Tessellator tessellator = Tessellator.getInstance(); final BufferBuilder buf = tessellator.getBuffer(); GlStateManager.color(1F, 1F, 1F, 1F); final float f = 0.00390625F; buf.begin(7, DefaultVertexFormats.POSITION_TEX); buf.pos(x, y + 20, 0).tex(236 * f, (236 + 20) * f).endVertex(); buf.pos(x + 20, y + 20, 0).tex((236 + 20) * f, (236 + 20) * f).endVertex(); buf.pos(x + 20, y, 0).tex((236 + 20) * f, 236 * f).endVertex(); buf.pos(x, y, 0).tex(236 * f, 236 * f).endVertex(); tessellator.draw(); int textureX = 9 % 14 * 18; int textureY = 0; x += 1; y += 1; GlStateManager.pushMatrix(); EnumDyeColor dye = EnumDyeColor.byDyeDamage(Math.min(amplifier, EnumDyeColor.values().length - 1)); int rgb = dye.getColorValue(); float r = (rgb >>> 16 & 0xFF) / 256.0F; float g = (rgb >>> 8 & 0xFF) / 256.0F; float b = (rgb & 0xFF) / 256.0F; GlStateManager.color(r, g, b); buf.begin(7, DefaultVertexFormats.POSITION_TEX); buf.pos(x, y + 18, 0).tex(textureX * f, (textureY + 18) * f).endVertex(); buf.pos(x + 18, y + 18, 0).tex((textureX + 18) * f, (textureY + 18) * f).endVertex(); buf.pos(x + 18, y, 0).tex((textureX + 18) * f, textureY * f).endVertex(); buf.pos(x, y, 0).tex(textureX * f, textureY * f).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); }
public static void drawSelectionBoundingBox(AxisAlignedBB boundingBox) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(3, DefaultVertexFormats.POSITION); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); tessellator.draw(); vertexbuffer.begin(3, DefaultVertexFormats.POSITION); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); tessellator.draw(); vertexbuffer.begin(1, DefaultVertexFormats.POSITION); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex(); vertexbuffer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex(); tessellator.draw(); }
public static void drawTexture(int x, int y, float u, float v, float uWidth, float vHeight, int width, int height, float tileWidth, float tileHeight) { float f = 1.0F / tileWidth; float f1 = 1.0F / tileHeight; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferbuilder.pos((double)x, (double)(y + height), 0.0D).tex((double)(u * f), (double)((v + vHeight) * f1)).endVertex(); bufferbuilder.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)((u + uWidth) * f), (double)((v + vHeight) * f1)).endVertex(); bufferbuilder.pos((double)(x + width), (double)y, 0.0D).tex((double)((u + uWidth) * f), (double)(v * f1)).endVertex(); bufferbuilder.pos((double)x, (double)y, 0.0D).tex((double)(u * f), (double)(v * f1)).endVertex(); tessellator.draw(); }
public static void renderGhostBlock(IBlockState state, BlockPos position, Color color, boolean noDepth, float partialTicks) { if(!(state.getBlock() instanceof BlockLiquid) && !(state.getBlock() instanceof BlockFluidBase)) { renderGhostModel(Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state), position, color, noDepth, partialTicks); return; } GlStateManager.enableBlend(); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_DST_COLOR); BufferBuilder vb; if(noDepth) { GlStateManager.depthFunc(519); vb = prepRenderBlockDepth(partialTicks, true); } else vb = prepRender(partialTicks, true); vb.begin(7, DefaultVertexFormats.BLOCK); World world = Minecraft.getMinecraft().world; Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlock(state, position.add(0, noDepth ? 500 : 0, 0), world, vb); for(int i = 0; i < vb.getVertexCount(); i++) vb.putColorMultiplier(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, i); vb.color(1, 1, 1, 0.1f); postRender(); GlStateManager.disableBlend(); GlStateManager.depthFunc(515); }
public static BufferBuilder prepLineRender(float partialTicks) { GlStateManager.disableTexture2D(); GlStateManager.disableBlend(); GlStateManager.glLineWidth(line); BufferBuilder bufferbuilder = prepRender(partialTicks, true); bufferbuilder.begin(3, DefaultVertexFormats.POSITION_COLOR); return bufferbuilder; }
@SideOnly(Side.CLIENT) private void compileDisplayList(float scale) { this.displayList = GLAllocation.generateDisplayLists(1); GL11.glNewList(this.displayList, GL11.GL_COMPILE); BufferBuilder bufferbuilder = Tessellator.getInstance().getBuffer(); for (int i = 0; i < this.quadList.length; i++) { this.quadList[i].draw(bufferbuilder, scale); } GL11.glEndList(); this.compiled = true; }
public static BufferBuilder prepRenderBlockDepth(float partialTicks, boolean movePosition) { GlStateManager.pushMatrix(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); if(movePosition) translateCamera(0, 500, 0, partialTicks); return bufferbuilder; }
private void drawCustomGui(double x, double y, double width, double height, double zLevel) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); bufferbuilder.begin(7, DefaultVertexFormats.POSITION); bufferbuilder.pos(x + 0, y + height, zLevel).endVertex(); bufferbuilder.pos(x + width, y + height, zLevel).endVertex(); bufferbuilder.pos(x + width, y + 0, zLevel).endVertex(); bufferbuilder.pos(x + 0, y + 0, zLevel).endVertex(); tessellator.draw(); }