OutlineBufferSource.java

net.minecraft.client.renderer.OutlineBufferSource

信息

  • 全限定名:net.minecraft.client.renderer.OutlineBufferSource
  • 类型:public class
  • 包:net.minecraft.client.renderer
  • 源码路径:src/main/java/net/minecraft/client/renderer/OutlineBufferSource.java
  • 起始行号:L11
  • 实现:MultiBufferSource
  • 职责:

    TODO

字段/常量

  • outlineBufferSource

    • 类型: MultiBufferSource.BufferSource
    • 修饰符: private final
    • 源码定位: L12
    • 说明:

      TODO

  • outlineColor

    • 类型: int
    • 修饰符: private
    • 源码定位: L13
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.renderer.OutlineBufferSource.EntityOutlineGenerator
    • 类型: record
    • 修饰符: private
    • 源码定位: L40
    • 说明:

      TODO

构造器

方法

下面的方法块按源码顺序生成。

public VertexConsumer getBuffer(RenderType renderType) @ L15

  • 方法名:getBuffer
  • 源码定位:L15
  • 返回类型:VertexConsumer
  • 修饰符:public

参数:

  • renderType: RenderType

说明:

TODO

public void setColor(int color) @ L31

  • 方法名:setColor
  • 源码定位:L31
  • 返回类型:void
  • 修饰符:public

参数:

  • color: int

说明:

TODO

public void endOutlineBatch() @ L35

  • 方法名:endOutlineBatch
  • 源码定位:L35
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class OutlineBufferSource implements MultiBufferSource {
    private final MultiBufferSource.BufferSource outlineBufferSource = MultiBufferSource.immediate(new ByteBufferBuilder(1536));
    private int outlineColor = -1;
 
    @Override
    public VertexConsumer getBuffer(RenderType renderType) {
        if (renderType.isOutline()) {
            VertexConsumer delegate = this.outlineBufferSource.getBuffer(renderType);
            return new OutlineBufferSource.EntityOutlineGenerator(delegate, this.outlineColor);
        } else {
            Optional<RenderType> outline = renderType.outline();
            if (outline.isPresent()) {
                VertexConsumer delegate = this.outlineBufferSource.getBuffer(outline.get());
                return new OutlineBufferSource.EntityOutlineGenerator(delegate, this.outlineColor);
            } else {
                throw new IllegalStateException("Can't render an outline for this rendertype!");
            }
        }
    }
 
    public void setColor(int color) {
        this.outlineColor = color;
    }
 
    public void endOutlineBatch() {
        this.outlineBufferSource.endBatch();
    }
 
    @OnlyIn(Dist.CLIENT)
    private record EntityOutlineGenerator(VertexConsumer delegate, int color) implements VertexConsumer {
        @Override
        public VertexConsumer addVertex(float x, float y, float z) {
            this.delegate.addVertex(x, y, z).setColor(this.color);
            return this;
        }
 
        @Override
        public VertexConsumer setColor(int r, int g, int b, int a) {
            return this;
        }
 
        @Override
        public VertexConsumer setColor(int color) {
            return this;
        }
 
        @Override
        public VertexConsumer setUv(float u, float v) {
            this.delegate.setUv(u, v);
            return this;
        }
 
        @Override
        public VertexConsumer setUv1(int u, int v) {
            return this;
        }
 
        @Override
        public VertexConsumer setUv2(int u, int v) {
            return this;
        }
 
        @Override
        public VertexConsumer setNormal(float x, float y, float z) {
            return this;
        }
 
        @Override
        public VertexConsumer setLineWidth(float width) {
            return this;
        }
    }
}

引用的其他类