BlockBox.java
net.minecraft.core.BlockBox
信息
- 全限定名:net.minecraft.core.BlockBox
- 类型:public record
- 包:net.minecraft.core
- 源码路径:src/main/java/net/minecraft/core/BlockBox.java
- 起始行号:L9
- 实现:Iterable
- 职责:
TODO
字段/常量
STREAM_CODEC- 类型:
StreamCodec<ByteBuf,BlockBox> - 修饰符:
public static final public public - 源码定位:
L10 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public BlockBox(BlockPos min, BlockPos max) @ L21
- 构造器名:BlockBox
- 源码定位:L21
- 修饰符:public
参数:
- min: BlockPos
- max: BlockPos
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static BlockBox of(BlockPos pos) @ L26
- 方法名:of
- 源码定位:L26
- 返回类型:BlockBox
- 修饰符:public static
参数:
- pos: BlockPos
说明:
TODO
public static BlockBox of(BlockPos a, BlockPos b) @ L30
- 方法名:of
- 源码定位:L30
- 返回类型:BlockBox
- 修饰符:public static
参数:
- a: BlockPos
- b: BlockPos
说明:
TODO
public BlockBox include(BlockPos pos) @ L34
- 方法名:include
- 源码定位:L34
- 返回类型:BlockBox
- 修饰符:public
参数:
- pos: BlockPos
说明:
TODO
public boolean isBlock() @ L38
- 方法名:isBlock
- 源码定位:L38
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean contains(BlockPos pos) @ L42
- 方法名:contains
- 源码定位:L42
- 返回类型:boolean
- 修饰符:public
参数:
- pos: BlockPos
说明:
TODO
public AABB aabb() @ L51
- 方法名:aabb
- 源码定位:L51
- 返回类型:AABB
- 修饰符:public
参数:
- 无
说明:
TODO
public Iterator<BlockPos> iterator() @ L55
- 方法名:iterator
- 源码定位:L55
- 返回类型:Iterator
- 修饰符:public
参数:
- 无
说明:
TODO
public int sizeX() @ L60
- 方法名:sizeX
- 源码定位:L60
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int sizeY() @ L64
- 方法名:sizeY
- 源码定位:L64
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int sizeZ() @ L68
- 方法名:sizeZ
- 源码定位:L68
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public BlockBox extend(Direction direction, int amount) @ L72
- 方法名:extend
- 源码定位:L72
- 返回类型:BlockBox
- 修饰符:public
参数:
- direction: Direction
- amount: int
说明:
TODO
public BlockBox move(Direction direction, int amount) @ L82
- 方法名:move
- 源码定位:L82
- 返回类型:BlockBox
- 修饰符:public
参数:
- direction: Direction
- amount: int
说明:
TODO
public BlockBox offset(Vec3i offset) @ L86
- 方法名:offset
- 源码定位:L86
- 返回类型:BlockBox
- 修饰符:public
参数:
- offset: Vec3i
说明:
TODO
代码
public record BlockBox(BlockPos min, BlockPos max) implements Iterable<BlockPos> {
public static final StreamCodec<ByteBuf, BlockBox> STREAM_CODEC = new StreamCodec<ByteBuf, BlockBox>() {
public BlockBox decode(ByteBuf input) {
return new BlockBox(FriendlyByteBuf.readBlockPos(input), FriendlyByteBuf.readBlockPos(input));
}
public void encode(ByteBuf output, BlockBox value) {
FriendlyByteBuf.writeBlockPos(output, value.min());
FriendlyByteBuf.writeBlockPos(output, value.max());
}
};
public BlockBox(BlockPos min, BlockPos max) {
this.min = BlockPos.min(min, max);
this.max = BlockPos.max(min, max);
}
public static BlockBox of(BlockPos pos) {
return new BlockBox(pos, pos);
}
public static BlockBox of(BlockPos a, BlockPos b) {
return new BlockBox(a, b);
}
public BlockBox include(BlockPos pos) {
return new BlockBox(BlockPos.min(this.min, pos), BlockPos.max(this.max, pos));
}
public boolean isBlock() {
return this.min.equals(this.max);
}
public boolean contains(BlockPos pos) {
return pos.getX() >= this.min.getX()
&& pos.getY() >= this.min.getY()
&& pos.getZ() >= this.min.getZ()
&& pos.getX() <= this.max.getX()
&& pos.getY() <= this.max.getY()
&& pos.getZ() <= this.max.getZ();
}
public AABB aabb() {
return AABB.encapsulatingFullBlocks(this.min, this.max);
}
@Override
public Iterator<BlockPos> iterator() {
return BlockPos.betweenClosed(this.min, this.max).iterator();
}
public int sizeX() {
return this.max.getX() - this.min.getX() + 1;
}
public int sizeY() {
return this.max.getY() - this.min.getY() + 1;
}
public int sizeZ() {
return this.max.getZ() - this.min.getZ() + 1;
}
public BlockBox extend(Direction direction, int amount) {
if (amount == 0) {
return this;
} else {
return direction.getAxisDirection() == Direction.AxisDirection.POSITIVE
? of(this.min, BlockPos.max(this.min, this.max.relative(direction, amount)))
: of(BlockPos.min(this.min.relative(direction, amount), this.max), this.max);
}
}
public BlockBox move(Direction direction, int amount) {
return amount == 0 ? this : new BlockBox(this.min.relative(direction, amount), this.max.relative(direction, amount));
}
public BlockBox offset(Vec3i offset) {
return new BlockBox(this.min.offset(offset), this.max.offset(offset));
}
}引用的其他类
-
- 引用位置:
参数/实现/方法调用/返回值 - 关联成员:
BlockPos.betweenClosed(), BlockPos.max(), BlockPos.min()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
FriendlyByteBuf.readBlockPos(), FriendlyByteBuf.writeBlockPos()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
AABB.encapsulatingFullBlocks()
- 引用位置: