use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.
the class TreeTests method computeAABB.
private Vector3i computeAABB(TreeGenerator treeGen, long seed) {
Vector3i pos = new Vector3i(ChunkConstants.SIZE_X / 2, 0, ChunkConstants.SIZE_Z / 2);
final Vector3i min = new Vector3i(pos);
final Vector3i max = new Vector3i(pos);
Rect2i chunks = Rect2i.createFromMinAndMax(-1, -1, 1, 1);
for (BaseVector2i chunkPos : chunks.contents()) {
Chunk chunk = new ChunkImpl(chunkPos.getX(), 0, chunkPos.getY(), blockManager, biomeManager) {
@Override
public Block setBlock(int x, int y, int z, Block block) {
Vector3i world = chunkToWorldPosition(x, y, z);
minimize(min, world);
maximize(max, world);
return null;
}
};
Random random = new MersenneRandom(seed);
BlockManager blockManagerLocal = CoreRegistry.get(BlockManager.class);
Vector3i relPos = chunk.chunkToWorldPosition(0, 0, 0).sub(pos).invert();
treeGen.generate(blockManagerLocal, chunk, random, relPos.x, relPos.y, relPos.z);
}
Vector3i ext = new Vector3i(max).sub(min);
return ext;
}
Aggregations