StructureGridSpawner.java
net.minecraft.gametest.framework.StructureGridSpawner
信息
- 全限定名:net.minecraft.gametest.framework.StructureGridSpawner
- 类型:public class
- 包:net.minecraft.gametest.framework
- 源码路径:src/main/java/net/minecraft/gametest/framework/StructureGridSpawner.java
- 起始行号:L11
- 实现:GameTestRunner.StructureSpawner
- 职责:
TODO
字段/常量
-
SPACE_BETWEEN_COLUMNS- 类型:
int - 修饰符:
private static final - 源码定位:
L12 - 说明:
TODO
- 类型:
-
SPACE_BETWEEN_ROWS- 类型:
int - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
testsPerRow- 类型:
int - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
currentRowCount- 类型:
int - 修饰符:
private - 源码定位:
L15 - 说明:
TODO
- 类型:
-
rowBounds- 类型:
AABB - 修饰符:
private - 源码定位:
L16 - 说明:
TODO
- 类型:
-
nextTestNorthWestCorner- 类型:
BlockPos.MutableBlockPos - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
firstTestNorthWestCorner- 类型:
BlockPos - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
clearOnBatch- 类型:
boolean - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
maxX- 类型:
float - 修饰符:
private - 源码定位:
L20 - 说明:
TODO
- 类型:
-
testInLastBatch- 类型:
Collection<GameTestInfo> - 修饰符:
private final - 源码定位:
L21 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public StructureGridSpawner(BlockPos firstTestNorthWestCorner, int testsPerRow, boolean clearOnBatch) @ L23
- 构造器名:StructureGridSpawner
- 源码定位:L23
- 修饰符:public
参数:
- firstTestNorthWestCorner: BlockPos
- testsPerRow: int
- clearOnBatch: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void onBatchStart(ServerLevel level) @ L31
- 方法名:onBatchStart
- 源码定位:L31
- 返回类型:void
- 修饰符:public
参数:
- level: ServerLevel
说明:
TODO
public Optional<GameTestInfo> spawnStructure(GameTestInfo testInfo) @ L44
- 方法名:spawnStructure
- 源码定位:L44
- 返回类型:Optional
- 修饰符:public
参数:
- testInfo: GameTestInfo
说明:
TODO
代码
public class StructureGridSpawner implements GameTestRunner.StructureSpawner {
private static final int SPACE_BETWEEN_COLUMNS = 5;
private static final int SPACE_BETWEEN_ROWS = 6;
private final int testsPerRow;
private int currentRowCount;
private AABB rowBounds;
private final BlockPos.MutableBlockPos nextTestNorthWestCorner;
private final BlockPos firstTestNorthWestCorner;
private final boolean clearOnBatch;
private float maxX = -1.0F;
private final Collection<GameTestInfo> testInLastBatch = new ArrayList<>();
public StructureGridSpawner(BlockPos firstTestNorthWestCorner, int testsPerRow, boolean clearOnBatch) {
this.testsPerRow = testsPerRow;
this.nextTestNorthWestCorner = firstTestNorthWestCorner.mutable();
this.rowBounds = new AABB(this.nextTestNorthWestCorner);
this.firstTestNorthWestCorner = firstTestNorthWestCorner;
this.clearOnBatch = clearOnBatch;
}
@Override
public void onBatchStart(ServerLevel level) {
if (this.clearOnBatch) {
this.testInLastBatch.forEach(info -> {
BoundingBox boundingBox = info.getTestInstanceBlockEntity().getTestBoundingBox();
StructureUtils.clearSpaceForStructure(boundingBox, level);
});
this.testInLastBatch.clear();
this.rowBounds = new AABB(this.firstTestNorthWestCorner);
this.nextTestNorthWestCorner.set(this.firstTestNorthWestCorner);
}
}
@Override
public Optional<GameTestInfo> spawnStructure(GameTestInfo testInfo) {
BlockPos northWestCorner = new BlockPos(this.nextTestNorthWestCorner);
testInfo.setTestBlockPos(northWestCorner);
GameTestInfo infoWithStructure = testInfo.prepareTestStructure();
if (infoWithStructure == null) {
return Optional.empty();
} else {
infoWithStructure.startExecution(1);
AABB structureBounds = testInfo.getTestInstanceBlockEntity().getTestBounds();
this.rowBounds = this.rowBounds.minmax(structureBounds);
this.nextTestNorthWestCorner.move((int)structureBounds.getXsize() + 5, 0, 0);
if (this.nextTestNorthWestCorner.getX() > this.maxX) {
this.maxX = this.nextTestNorthWestCorner.getX();
}
if (++this.currentRowCount >= this.testsPerRow) {
this.currentRowCount = 0;
this.nextTestNorthWestCorner.move(0, 0, (int)this.rowBounds.getZsize() + 6);
this.nextTestNorthWestCorner.setX(this.firstTestNorthWestCorner.getX());
this.rowBounds = new AABB(this.nextTestNorthWestCorner);
}
this.testInLastBatch.add(testInfo);
return Optional.of(testInfo);
}
}
}引用的其他类
-
- 引用位置:
参数/字段/构造调用 - 关联成员:
BlockPos()
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
StructureUtils.clearSpaceForStructure()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
AABB()
- 引用位置: