SectionPos.java
net.minecraft.core.SectionPos
信息
- 全限定名:net.minecraft.core.SectionPos
- 类型:public class
- 包:net.minecraft.core
- 源码路径:src/main/java/net/minecraft/core/SectionPos.java
- 起始行号:L16
- 继承:Vec3i
- 职责:
TODO
字段/常量
-
SECTION_BITS- 类型:
int - 修饰符:
public static final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
SECTION_SIZE- 类型:
int - 修饰符:
public static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
SECTION_MASK- 类型:
int - 修饰符:
public static final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
SECTION_HALF_SIZE- 类型:
int - 修饰符:
public static final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
SECTION_MAX_INDEX- 类型:
int - 修饰符:
public static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
PACKED_X_LENGTH- 类型:
int - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
PACKED_Y_LENGTH- 类型:
int - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
PACKED_Z_LENGTH- 类型:
int - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
PACKED_X_MASK- 类型:
long - 修饰符:
private static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
PACKED_Y_MASK- 类型:
long - 修饰符:
private static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
PACKED_Z_MASK- 类型:
long - 修饰符:
private static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
Y_OFFSET- 类型:
int - 修饰符:
private static final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
Z_OFFSET- 类型:
int - 修饰符:
private static final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
X_OFFSET- 类型:
int - 修饰符:
private static final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
RELATIVE_X_SHIFT- 类型:
int - 修饰符:
private static final - 源码定位:
L31 - 说明:
TODO
- 类型:
-
RELATIVE_Y_SHIFT- 类型:
int - 修饰符:
private static final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
RELATIVE_Z_SHIFT- 类型:
int - 修饰符:
private static final - 源码定位:
L33 - 说明:
TODO
- 类型:
-
STREAM_CODEC- 类型:
StreamCodec<ByteBuf,SectionPos> - 修饰符:
public static final - 源码定位:
L34 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private SectionPos(int x, int y, int z) @ L36
- 构造器名:SectionPos
- 源码定位:L36
- 修饰符:private
参数:
- x: int
- y: int
- z: int
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static SectionPos of(int x, int y, int z) @ L40
- 方法名:of
- 源码定位:L40
- 返回类型:SectionPos
- 修饰符:public static
参数:
- x: int
- y: int
- z: int
说明:
TODO
public static SectionPos of(BlockPos pos) @ L44
- 方法名:of
- 源码定位:L44
- 返回类型:SectionPos
- 修饰符:public static
参数:
- pos: BlockPos
说明:
TODO
public static SectionPos of(ChunkPos pos, int sectionY) @ L48
- 方法名:of
- 源码定位:L48
- 返回类型:SectionPos
- 修饰符:public static
参数:
- pos: ChunkPos
- sectionY: int
说明:
TODO
public static SectionPos of(EntityAccess entity) @ L52
- 方法名:of
- 源码定位:L52
- 返回类型:SectionPos
- 修饰符:public static
参数:
- entity: EntityAccess
说明:
TODO
public static SectionPos of(Position pos) @ L56
- 方法名:of
- 源码定位:L56
- 返回类型:SectionPos
- 修饰符:public static
参数:
- pos: Position
说明:
TODO
public static SectionPos of(long sectionNode) @ L60
- 方法名:of
- 源码定位:L60
- 返回类型:SectionPos
- 修饰符:public static
参数:
- sectionNode: long
说明:
TODO
public static SectionPos bottomOf(ChunkAccess chunk) @ L64
- 方法名:bottomOf
- 源码定位:L64
- 返回类型:SectionPos
- 修饰符:public static
参数:
- chunk: ChunkAccess
说明:
TODO
public static long offset(long sectionNode, Direction offset) @ L68
- 方法名:offset
- 源码定位:L68
- 返回类型:long
- 修饰符:public static
参数:
- sectionNode: long
- offset: Direction
说明:
TODO
public static long offset(long sectionNode, int stepX, int stepY, int stepZ) @ L72
- 方法名:offset
- 源码定位:L72
- 返回类型:long
- 修饰符:public static
参数:
- sectionNode: long
- stepX: int
- stepY: int
- stepZ: int
说明:
TODO
public static int posToSectionCoord(double pos) @ L76
- 方法名:posToSectionCoord
- 源码定位:L76
- 返回类型:int
- 修饰符:public static
参数:
- pos: double
说明:
TODO
public static int blockToSectionCoord(int blockCoord) @ L80
- 方法名:blockToSectionCoord
- 源码定位:L80
- 返回类型:int
- 修饰符:public static
参数:
- blockCoord: int
说明:
TODO
public static int blockToSectionCoord(double coord) @ L84
- 方法名:blockToSectionCoord
- 源码定位:L84
- 返回类型:int
- 修饰符:public static
参数:
- coord: double
说明:
TODO
public static int sectionRelative(int blockCoord) @ L88
- 方法名:sectionRelative
- 源码定位:L88
- 返回类型:int
- 修饰符:public static
参数:
- blockCoord: int
说明:
TODO
public static short sectionRelativePos(BlockPos pos) @ L92
- 方法名:sectionRelativePos
- 源码定位:L92
- 返回类型:short
- 修饰符:public static
参数:
- pos: BlockPos
说明:
TODO
public static int sectionRelativeX(short relative) @ L99
- 方法名:sectionRelativeX
- 源码定位:L99
- 返回类型:int
- 修饰符:public static
参数:
- relative: short
说明:
TODO
public static int sectionRelativeY(short relative) @ L103
- 方法名:sectionRelativeY
- 源码定位:L103
- 返回类型:int
- 修饰符:public static
参数:
- relative: short
说明:
TODO
public static int sectionRelativeZ(short relative) @ L107
- 方法名:sectionRelativeZ
- 源码定位:L107
- 返回类型:int
- 修饰符:public static
参数:
- relative: short
说明:
TODO
public int relativeToBlockX(short relative) @ L111
- 方法名:relativeToBlockX
- 源码定位:L111
- 返回类型:int
- 修饰符:public
参数:
- relative: short
说明:
TODO
public int relativeToBlockY(short relative) @ L115
- 方法名:relativeToBlockY
- 源码定位:L115
- 返回类型:int
- 修饰符:public
参数:
- relative: short
说明:
TODO
public int relativeToBlockZ(short relative) @ L119
- 方法名:relativeToBlockZ
- 源码定位:L119
- 返回类型:int
- 修饰符:public
参数:
- relative: short
说明:
TODO
public BlockPos relativeToBlockPos(short relative) @ L123
- 方法名:relativeToBlockPos
- 源码定位:L123
- 返回类型:BlockPos
- 修饰符:public
参数:
- relative: short
说明:
TODO
public static int sectionToBlockCoord(int sectionCoord) @ L127
- 方法名:sectionToBlockCoord
- 源码定位:L127
- 返回类型:int
- 修饰符:public static
参数:
- sectionCoord: int
说明:
TODO
public static int sectionToBlockCoord(int sectionCoord, int offset) @ L131
- 方法名:sectionToBlockCoord
- 源码定位:L131
- 返回类型:int
- 修饰符:public static
参数:
- sectionCoord: int
- offset: int
说明:
TODO
public static int x(long sectionNode) @ L135
- 方法名:x
- 源码定位:L135
- 返回类型:int
- 修饰符:public static
参数:
- sectionNode: long
说明:
TODO
public static int y(long sectionNode) @ L139
- 方法名:y
- 源码定位:L139
- 返回类型:int
- 修饰符:public static
参数:
- sectionNode: long
说明:
TODO
public static int z(long sectionNode) @ L143
- 方法名:z
- 源码定位:L143
- 返回类型:int
- 修饰符:public static
参数:
- sectionNode: long
说明:
TODO
public int x() @ L147
- 方法名:x
- 源码定位:L147
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int y() @ L151
- 方法名:y
- 源码定位:L151
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int z() @ L155
- 方法名:z
- 源码定位:L155
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int minBlockX() @ L159
- 方法名:minBlockX
- 源码定位:L159
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int minBlockY() @ L163
- 方法名:minBlockY
- 源码定位:L163
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int minBlockZ() @ L167
- 方法名:minBlockZ
- 源码定位:L167
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int maxBlockX() @ L171
- 方法名:maxBlockX
- 源码定位:L171
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int maxBlockY() @ L175
- 方法名:maxBlockY
- 源码定位:L175
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int maxBlockZ() @ L179
- 方法名:maxBlockZ
- 源码定位:L179
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public static long blockToSection(long blockNode) @ L183
- 方法名:blockToSection
- 源码定位:L183
- 返回类型:long
- 修饰符:public static
参数:
- blockNode: long
说明:
TODO
public static long getZeroNode(int x, int z) @ L189
- 方法名:getZeroNode
- 源码定位:L189
- 返回类型:long
- 修饰符:public static
参数:
- x: int
- z: int
说明:
TODO
public static long getZeroNode(long sectionNode) @ L193
- 方法名:getZeroNode
- 源码定位:L193
- 返回类型:long
- 修饰符:public static
参数:
- sectionNode: long
说明:
TODO
public static long sectionToChunk(long sectionNode) @ L197
- 方法名:sectionToChunk
- 源码定位:L197
- 返回类型:long
- 修饰符:public static
参数:
- sectionNode: long
说明:
TODO
public BlockPos origin() @ L201
- 方法名:origin
- 源码定位:L201
- 返回类型:BlockPos
- 修饰符:public
参数:
- 无
说明:
TODO
public BlockPos center() @ L205
- 方法名:center
- 源码定位:L205
- 返回类型:BlockPos
- 修饰符:public
参数:
- 无
说明:
TODO
public ChunkPos chunk() @ L210
- 方法名:chunk
- 源码定位:L210
- 返回类型:ChunkPos
- 修饰符:public
参数:
- 无
说明:
TODO
public static long asLong(BlockPos pos) @ L214
- 方法名:asLong
- 源码定位:L214
- 返回类型:long
- 修饰符:public static
参数:
- pos: BlockPos
说明:
TODO
public static long asLong(int x, int y, int z) @ L218
- 方法名:asLong
- 源码定位:L218
- 返回类型:long
- 修饰符:public static
参数:
- x: int
- y: int
- z: int
说明:
TODO
public long asLong() @ L225
- 方法名:asLong
- 源码定位:L225
- 返回类型:long
- 修饰符:public
参数:
- 无
说明:
TODO
public SectionPos offset(int x, int y, int z) @ L229
- 方法名:offset
- 源码定位:L229
- 返回类型:SectionPos
- 修饰符:public
参数:
- x: int
- y: int
- z: int
说明:
TODO
public Stream<BlockPos> blocksInside() @ L233
- 方法名:blocksInside
- 源码定位:L233
- 返回类型:Stream
- 修饰符:public
参数:
- 无
说明:
TODO
public static Stream<SectionPos> cube(SectionPos center, int radius) @ L237
- 方法名:cube
- 源码定位:L237
- 返回类型:Stream
- 修饰符:public static
参数:
- center: SectionPos
- radius: int
说明:
TODO
public static Stream<SectionPos> aroundChunk(ChunkPos center, int radius, int minSection, int maxSection) @ L244
- 方法名:aroundChunk
- 源码定位:L244
- 返回类型:Stream
- 修饰符:public static
参数:
- center: ChunkPos
- radius: int
- minSection: int
- maxSection: int
说明:
TODO
public static Stream<SectionPos> betweenClosedStream(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) @ L250
- 方法名:betweenClosedStream
- 源码定位:L250
- 返回类型:Stream
- 修饰符:public static
参数:
- minX: int
- minY: int
- minZ: int
- maxX: int
- maxY: int
- maxZ: int
说明:
TODO
public static void aroundAndAtBlockPos(BlockPos blockPos, LongConsumer sectionConsumer) @ L266
- 方法名:aroundAndAtBlockPos
- 源码定位:L266
- 返回类型:void
- 修饰符:public static
参数:
- blockPos: BlockPos
- sectionConsumer: LongConsumer
说明:
TODO
public static void aroundAndAtBlockPos(long blockPos, LongConsumer sectionConsumer) @ L270
- 方法名:aroundAndAtBlockPos
- 源码定位:L270
- 返回类型:void
- 修饰符:public static
参数:
- blockPos: long
- sectionConsumer: LongConsumer
说明:
TODO
public static void aroundAndAtBlockPos(int blockX, int blockY, int blockZ, LongConsumer sectionConsumer) @ L274
- 方法名:aroundAndAtBlockPos
- 源码定位:L274
- 返回类型:void
- 修饰符:public static
参数:
- blockX: int
- blockY: int
- blockZ: int
- sectionConsumer: LongConsumer
说明:
TODO
代码
public class SectionPos extends Vec3i {
public static final int SECTION_BITS = 4;
public static final int SECTION_SIZE = 16;
public static final int SECTION_MASK = 15;
public static final int SECTION_HALF_SIZE = 8;
public static final int SECTION_MAX_INDEX = 15;
private static final int PACKED_X_LENGTH = 22;
private static final int PACKED_Y_LENGTH = 20;
private static final int PACKED_Z_LENGTH = 22;
private static final long PACKED_X_MASK = 4194303L;
private static final long PACKED_Y_MASK = 1048575L;
private static final long PACKED_Z_MASK = 4194303L;
private static final int Y_OFFSET = 0;
private static final int Z_OFFSET = 20;
private static final int X_OFFSET = 42;
private static final int RELATIVE_X_SHIFT = 8;
private static final int RELATIVE_Y_SHIFT = 0;
private static final int RELATIVE_Z_SHIFT = 4;
public static final StreamCodec<ByteBuf, SectionPos> STREAM_CODEC = ByteBufCodecs.LONG.map(SectionPos::of, SectionPos::asLong);
private SectionPos(int x, int y, int z) {
super(x, y, z);
}
public static SectionPos of(int x, int y, int z) {
return new SectionPos(x, y, z);
}
public static SectionPos of(BlockPos pos) {
return new SectionPos(blockToSectionCoord(pos.getX()), blockToSectionCoord(pos.getY()), blockToSectionCoord(pos.getZ()));
}
public static SectionPos of(ChunkPos pos, int sectionY) {
return new SectionPos(pos.x(), sectionY, pos.z());
}
public static SectionPos of(EntityAccess entity) {
return of(entity.blockPosition());
}
public static SectionPos of(Position pos) {
return new SectionPos(blockToSectionCoord(pos.x()), blockToSectionCoord(pos.y()), blockToSectionCoord(pos.z()));
}
public static SectionPos of(long sectionNode) {
return new SectionPos(x(sectionNode), y(sectionNode), z(sectionNode));
}
public static SectionPos bottomOf(ChunkAccess chunk) {
return of(chunk.getPos(), chunk.getMinSectionY());
}
public static long offset(long sectionNode, Direction offset) {
return offset(sectionNode, offset.getStepX(), offset.getStepY(), offset.getStepZ());
}
public static long offset(long sectionNode, int stepX, int stepY, int stepZ) {
return asLong(x(sectionNode) + stepX, y(sectionNode) + stepY, z(sectionNode) + stepZ);
}
public static int posToSectionCoord(double pos) {
return blockToSectionCoord(Mth.floor(pos));
}
public static int blockToSectionCoord(int blockCoord) {
return blockCoord >> 4;
}
public static int blockToSectionCoord(double coord) {
return Mth.floor(coord) >> 4;
}
public static int sectionRelative(int blockCoord) {
return blockCoord & 15;
}
public static short sectionRelativePos(BlockPos pos) {
int x = sectionRelative(pos.getX());
int y = sectionRelative(pos.getY());
int z = sectionRelative(pos.getZ());
return (short)(x << 8 | z << 4 | y << 0);
}
public static int sectionRelativeX(short relative) {
return relative >>> 8 & 15;
}
public static int sectionRelativeY(short relative) {
return relative >>> 0 & 15;
}
public static int sectionRelativeZ(short relative) {
return relative >>> 4 & 15;
}
public int relativeToBlockX(short relative) {
return this.minBlockX() + sectionRelativeX(relative);
}
public int relativeToBlockY(short relative) {
return this.minBlockY() + sectionRelativeY(relative);
}
public int relativeToBlockZ(short relative) {
return this.minBlockZ() + sectionRelativeZ(relative);
}
public BlockPos relativeToBlockPos(short relative) {
return new BlockPos(this.relativeToBlockX(relative), this.relativeToBlockY(relative), this.relativeToBlockZ(relative));
}
public static int sectionToBlockCoord(int sectionCoord) {
return sectionCoord << 4;
}
public static int sectionToBlockCoord(int sectionCoord, int offset) {
return sectionToBlockCoord(sectionCoord) + offset;
}
public static int x(long sectionNode) {
return (int)(sectionNode << 0 >> 42);
}
public static int y(long sectionNode) {
return (int)(sectionNode << 44 >> 44);
}
public static int z(long sectionNode) {
return (int)(sectionNode << 22 >> 42);
}
public int x() {
return this.getX();
}
public int y() {
return this.getY();
}
public int z() {
return this.getZ();
}
public int minBlockX() {
return sectionToBlockCoord(this.x());
}
public int minBlockY() {
return sectionToBlockCoord(this.y());
}
public int minBlockZ() {
return sectionToBlockCoord(this.z());
}
public int maxBlockX() {
return sectionToBlockCoord(this.x(), 15);
}
public int maxBlockY() {
return sectionToBlockCoord(this.y(), 15);
}
public int maxBlockZ() {
return sectionToBlockCoord(this.z(), 15);
}
public static long blockToSection(long blockNode) {
return asLong(
blockToSectionCoord(BlockPos.getX(blockNode)), blockToSectionCoord(BlockPos.getY(blockNode)), blockToSectionCoord(BlockPos.getZ(blockNode))
);
}
public static long getZeroNode(int x, int z) {
return getZeroNode(asLong(x, 0, z));
}
public static long getZeroNode(long sectionNode) {
return sectionNode & -1048576L;
}
public static long sectionToChunk(long sectionNode) {
return ChunkPos.pack(x(sectionNode), z(sectionNode));
}
public BlockPos origin() {
return new BlockPos(sectionToBlockCoord(this.x()), sectionToBlockCoord(this.y()), sectionToBlockCoord(this.z()));
}
public BlockPos center() {
int delta = 8;
return this.origin().offset(8, 8, 8);
}
public ChunkPos chunk() {
return new ChunkPos(this.x(), this.z());
}
public static long asLong(BlockPos pos) {
return asLong(blockToSectionCoord(pos.getX()), blockToSectionCoord(pos.getY()), blockToSectionCoord(pos.getZ()));
}
public static long asLong(int x, int y, int z) {
long node = 0L;
node |= (x & 4194303L) << 42;
node |= (y & 1048575L) << 0;
return node | (z & 4194303L) << 20;
}
public long asLong() {
return asLong(this.x(), this.y(), this.z());
}
public SectionPos offset(int x, int y, int z) {
return x == 0 && y == 0 && z == 0 ? this : new SectionPos(this.x() + x, this.y() + y, this.z() + z);
}
public Stream<BlockPos> blocksInside() {
return BlockPos.betweenClosedStream(this.minBlockX(), this.minBlockY(), this.minBlockZ(), this.maxBlockX(), this.maxBlockY(), this.maxBlockZ());
}
public static Stream<SectionPos> cube(SectionPos center, int radius) {
int x = center.x();
int y = center.y();
int z = center.z();
return betweenClosedStream(x - radius, y - radius, z - radius, x + radius, y + radius, z + radius);
}
public static Stream<SectionPos> aroundChunk(ChunkPos center, int radius, int minSection, int maxSection) {
int x = center.x();
int z = center.z();
return betweenClosedStream(x - radius, minSection, z - radius, x + radius, maxSection, z + radius);
}
public static Stream<SectionPos> betweenClosedStream(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
return StreamSupport.stream(new AbstractSpliterator<SectionPos>((maxX - minX + 1) * (maxY - minY + 1) * (maxZ - minZ + 1), 64) {
final Cursor3D cursor = new Cursor3D(minX, minY, minZ, maxX, maxY, maxZ);
@Override
public boolean tryAdvance(Consumer<? super SectionPos> action) {
if (this.cursor.advance()) {
action.accept(new SectionPos(this.cursor.nextX(), this.cursor.nextY(), this.cursor.nextZ()));
return true;
} else {
return false;
}
}
}, false);
}
public static void aroundAndAtBlockPos(BlockPos blockPos, LongConsumer sectionConsumer) {
aroundAndAtBlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ(), sectionConsumer);
}
public static void aroundAndAtBlockPos(long blockPos, LongConsumer sectionConsumer) {
aroundAndAtBlockPos(BlockPos.getX(blockPos), BlockPos.getY(blockPos), BlockPos.getZ(blockPos), sectionConsumer);
}
public static void aroundAndAtBlockPos(int blockX, int blockY, int blockZ, LongConsumer sectionConsumer) {
int minSectionX = blockToSectionCoord(blockX - 1);
int maxSectionX = blockToSectionCoord(blockX + 1);
int minSectionY = blockToSectionCoord(blockY - 1);
int maxSectionY = blockToSectionCoord(blockY + 1);
int minSectionZ = blockToSectionCoord(blockZ - 1);
int maxSectionZ = blockToSectionCoord(blockZ + 1);
if (minSectionX == maxSectionX && minSectionY == maxSectionY && minSectionZ == maxSectionZ) {
sectionConsumer.accept(asLong(minSectionX, minSectionY, minSectionZ));
} else {
for (int sectionX = minSectionX; sectionX <= maxSectionX; sectionX++) {
for (int sectionY = minSectionY; sectionY <= maxSectionY; sectionY++) {
for (int sectionZ = minSectionZ; sectionZ <= maxSectionZ; sectionZ++) {
sectionConsumer.accept(asLong(sectionX, sectionY, sectionZ));
}
}
}
}
}
}引用的其他类
-
- 引用位置:
参数/方法调用/构造调用/返回值 - 关联成员:
BlockPos(), BlockPos.betweenClosedStream(), BlockPos.getX(), BlockPos.getY(), BlockPos.getZ()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
Cursor3D()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.floor()
- 引用位置:
-
- 引用位置:
参数/方法调用/构造调用/返回值 - 关联成员:
ChunkPos(), ChunkPos.pack()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: