ColumnPos.java

net.minecraft.server.level.ColumnPos

信息

  • 全限定名:net.minecraft.server.level.ColumnPos
  • 类型:public record
  • 包:net.minecraft.server.level
  • 源码路径:src/main/java/net/minecraft/server/level/ColumnPos.java
  • 起始行号:L6
  • 职责:

    TODO

字段/常量

  • COORD_BITS

    • 类型: long
    • 修饰符: private static final
    • 源码定位: L7
    • 说明:

      TODO

  • COORD_MASK

    • 类型: long
    • 修饰符: private static final
    • 源码定位: L8
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

public ChunkPos toChunkPos() @ L10

  • 方法名:toChunkPos
  • 源码定位:L10
  • 返回类型:ChunkPos
  • 修饰符:public

参数:

说明:

TODO

public long toLong() @ L14

  • 方法名:toLong
  • 源码定位:L14
  • 返回类型:long
  • 修饰符:public

参数:

说明:

TODO

public static long asLong(int x, int z) @ L18

  • 方法名:asLong
  • 源码定位:L18
  • 返回类型:long
  • 修饰符:public static

参数:

  • x: int
  • z: int

说明:

TODO

public static int getX(long pos) @ L22

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

参数:

  • pos: long

说明:

TODO

public static int getZ(long pos) @ L26

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

参数:

  • pos: long

说明:

TODO

public String toString() @ L30

  • 方法名:toString
  • 源码定位:L30
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

public int hashCode() @ L35

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

参数:

说明:

TODO

代码

public record ColumnPos(int x, int z) {
    private static final long COORD_BITS = 32L;
    private static final long COORD_MASK = 4294967295L;
 
    public ChunkPos toChunkPos() {
        return new ChunkPos(SectionPos.blockToSectionCoord(this.x), SectionPos.blockToSectionCoord(this.z));
    }
 
    public long toLong() {
        return asLong(this.x, this.z);
    }
 
    public static long asLong(int x, int z) {
        return x & 4294967295L | (z & 4294967295L) << 32;
    }
 
    public static int getX(long pos) {
        return (int)(pos & 4294967295L);
    }
 
    public static int getZ(long pos) {
        return (int)(pos >>> 32 & 4294967295L);
    }
 
    @Override
    public String toString() {
        return "[" + this.x + ", " + this.z + "]";
    }
 
    @Override
    public int hashCode() {
        return ChunkPos.hash(this.x, this.z);
    }
}

引用的其他类

  • SectionPos

    • 引用位置: 方法调用
    • 关联成员: SectionPos.blockToSectionCoord()
  • ChunkPos

    • 引用位置: 方法调用/构造调用/返回值
    • 关联成员: ChunkPos(), ChunkPos.hash()