RenderSectionRegion.java

net.minecraft.client.renderer.chunk.RenderSectionRegion

信息

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

    TODO

字段/常量

  • RADIUS

    • 类型: int
    • 修饰符: public static final
    • 源码定位: L19
    • 说明:

      TODO

  • SIZE

    • 类型: int
    • 修饰符: public static final
    • 源码定位: L20
    • 说明:

      TODO

  • minSectionX

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

      TODO

  • minSectionY

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

      TODO

  • minSectionZ

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

      TODO

  • sections

    • 类型: SectionCopy[]
    • 修饰符: private final
    • 源码定位: L24
    • 说明:

      TODO

  • level

    • 类型: ClientLevel
    • 修饰符: private final
    • 源码定位: L25
    • 说明:

      TODO

  • cardinalLighting

    • 类型: CardinalLighting
    • 修饰符: private final
    • 源码定位: L26
    • 说明:

      TODO

  • lightEngine

    • 类型: LevelLightEngine
    • 修饰符: private final
    • 源码定位: L27
    • 说明:

      TODO

内部类/嵌套类型

构造器

RenderSectionRegion(ClientLevel level, int minSectionX, int minSectionY, int minSectionZ, SectionCopy[] sections) @ L29

  • 构造器名:RenderSectionRegion
  • 源码定位:L29
  • 修饰符:package-private

参数:

  • level: ClientLevel
  • minSectionX: int
  • minSectionY: int
  • minSectionZ: int
  • sections: SectionCopy[]

说明:

TODO

方法

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

public BlockState getBlockState(BlockPos pos) @ L39

  • 方法名:getBlockState
  • 源码定位:L39
  • 返回类型:BlockState
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public FluidState getFluidState(BlockPos pos) @ L47

  • 方法名:getFluidState
  • 源码定位:L47
  • 返回类型:FluidState
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

public CardinalLighting cardinalLighting() @ L56

  • 方法名:cardinalLighting
  • 源码定位:L56
  • 返回类型:CardinalLighting
  • 修饰符:public

参数:

说明:

TODO

public LevelLightEngine getLightEngine() @ L61

  • 方法名:getLightEngine
  • 源码定位:L61
  • 返回类型:LevelLightEngine
  • 修饰符:public

参数:

说明:

TODO

public BlockEntity getBlockEntity(BlockPos pos) @ L66

  • 方法名:getBlockEntity
  • 源码定位:L66
  • 返回类型:BlockEntity
  • 修饰符:public

参数:

  • pos: BlockPos

说明:

TODO

private SectionCopy getSection(int sectionX, int sectionY, int sectionZ) @ L74

  • 方法名:getSection
  • 源码定位:L74
  • 返回类型:SectionCopy
  • 修饰符:private

参数:

  • sectionX: int
  • sectionY: int
  • sectionZ: int

说明:

TODO

public int getBlockTint(BlockPos pos, ColorResolver resolver) @ L78

  • 方法名:getBlockTint
  • 源码定位:L78
  • 返回类型:int
  • 修饰符:public

参数:

  • pos: BlockPos
  • resolver: ColorResolver

说明:

TODO

public int getMinY() @ L83

  • 方法名:getMinY
  • 源码定位:L83
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public int getHeight() @ L88

  • 方法名:getHeight
  • 源码定位:L88
  • 返回类型:int
  • 修饰符:public

参数:

说明:

TODO

public static int index(int minSectionX, int minSectionY, int minSectionZ, int sectionX, int sectionY, int sectionZ) @ L93

  • 方法名:index
  • 源码定位:L93
  • 返回类型:int
  • 修饰符:public static

参数:

  • minSectionX: int
  • minSectionY: int
  • minSectionZ: int
  • sectionX: int
  • sectionY: int
  • sectionZ: int

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class RenderSectionRegion implements BlockAndTintGetter {
    public static final int RADIUS = 1;
    public static final int SIZE = 3;
    private final int minSectionX;
    private final int minSectionY;
    private final int minSectionZ;
    private final SectionCopy[] sections;
    private final ClientLevel level;
    private final CardinalLighting cardinalLighting;
    private final LevelLightEngine lightEngine;
 
    RenderSectionRegion(ClientLevel level, int minSectionX, int minSectionY, int minSectionZ, SectionCopy[] sections) {
        this.level = level;
        this.minSectionX = minSectionX;
        this.minSectionY = minSectionY;
        this.minSectionZ = minSectionZ;
        this.sections = sections;
        this.cardinalLighting = level.cardinalLighting();
        this.lightEngine = level.getLightEngine();
    }
 
    @Override
    public BlockState getBlockState(BlockPos pos) {
        return this.getSection(
                SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ())
            )
            .getBlockState(pos);
    }
 
    @Override
    public FluidState getFluidState(BlockPos pos) {
        return this.getSection(
                SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ())
            )
            .getBlockState(pos)
            .getFluidState();
    }
 
    @Override
    public CardinalLighting cardinalLighting() {
        return this.cardinalLighting;
    }
 
    @Override
    public LevelLightEngine getLightEngine() {
        return this.lightEngine;
    }
 
    @Override
    public @Nullable BlockEntity getBlockEntity(BlockPos pos) {
        return this.getSection(
                SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getY()), SectionPos.blockToSectionCoord(pos.getZ())
            )
            .getBlockEntity(pos);
    }
 
    private SectionCopy getSection(int sectionX, int sectionY, int sectionZ) {
        return this.sections[index(this.minSectionX, this.minSectionY, this.minSectionZ, sectionX, sectionY, sectionZ)];
    }
 
    @Override
    public int getBlockTint(BlockPos pos, ColorResolver resolver) {
        return this.level.getBlockTint(pos, resolver);
    }
 
    @Override
    public int getMinY() {
        return this.level.getMinY();
    }
 
    @Override
    public int getHeight() {
        return this.level.getHeight();
    }
 
    public static int index(int minSectionX, int minSectionY, int minSectionZ, int sectionX, int sectionY, int sectionZ) {
        return sectionX - minSectionX + (sectionY - minSectionY) * 3 + (sectionZ - minSectionZ) * 3 * 3;
    }
}

引用的其他类