| 37 | import java.awt.*; |
| 38 | |
| 39 | public interface IRenderer { |
| 40 | |
| 41 | Tesselator tessellator = Tesselator.getInstance(); |
| 42 | IEntityRenderManager renderManager = (IEntityRenderManager) Minecraft.getInstance().getEntityRenderDispatcher(); |
| 43 | Settings settings = BaritoneAPI.getSettings(); |
| 44 | RenderPipeline.Snippet BARITONE_LINES_SNIPPET = RenderPipeline.builder(((IRenderPipelines) new RenderPipelines()).getLinesSnippet()) |
| 45 | .withBlend(new BlendFunction( |
| 46 | SourceFactor.SRC_ALPHA, |
| 47 | DestFactor.ONE_MINUS_SRC_ALPHA, |
| 48 | SourceFactor.ONE, |
| 49 | DestFactor.ZERO |
| 50 | )) |
| 51 | .withDepthWrite(false) |
| 52 | .withCull(false) |
| 53 | .buildSnippet(); |
| 54 | RenderType linesWithDepthRenderType = BaritoneRenderType.create( |
| 55 | "renderType/baritone_lines_with_depth", |
| 56 | 256, |
| 57 | RenderPipeline.builder(BARITONE_LINES_SNIPPET) |
| 58 | .withLocation("pipelines/baritone_lines_with_depth") |
| 59 | .withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST) |
| 60 | .build() |
| 61 | ); |
| 62 | RenderType linesNoDepthRenderType = BaritoneRenderType.create( |
| 63 | "renderType/baritone_lines_no_depth", |
| 64 | 256, |
| 65 | RenderPipeline.builder(BARITONE_LINES_SNIPPET) |
| 66 | .withLocation("pipelines/baritone_lines_no_depth") |
| 67 | .withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST) |
| 68 | .build() |
| 69 | ); |
| 70 | |
| 71 | float[] color = new float[]{1.0F, 1.0F, 1.0F, 255.0F}; |
| 72 | |
| 73 | static void glColor(Color color, float alpha) { |
| 74 | float[] colorComponents = color.getColorComponents(null); |
| 75 | IRenderer.color[0] = colorComponents[0]; |
| 76 | IRenderer.color[1] = colorComponents[1]; |
| 77 | IRenderer.color[2] = colorComponents[2]; |
| 78 | IRenderer.color[3] = alpha; |
| 79 | } |
| 80 | |
| 81 | static BufferBuilder startLines(Color color, float alpha, float lineWidth) { |
| 82 | glColor(color, alpha); |
| 83 | RenderSystem.lineWidth(lineWidth); |
| 84 | return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL); |
| 85 | } |
| 86 | |
| 87 | static BufferBuilder startLines(Color color, float lineWidth) { |
| 88 | return startLines(color, .4f, lineWidth); |
| 89 | } |
| 90 | |
| 91 | static void endLines(BufferBuilder bufferBuilder, boolean ignoredDepth) { |
| 92 | MeshData meshData = bufferBuilder.build(); |
| 93 | if (meshData != null) { |
| 94 | if (ignoredDepth) { |
| 95 | linesNoDepthRenderType.draw(meshData); |
| 96 | } else { |
no test coverage detected