RenderChunkBoundary.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:HardVox 作者:
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();
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号