in Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MazeDecoratorImplementation.java [562:622]
private void placeBlocks(World world, Cell[] grid, Cell start, Cell end)
{
BlockDrawingHelper drawContext = new BlockDrawingHelper();
drawContext.beginDrawing(world);
int scale = this.mazeParams.getSizeAndPosition().getScale();
// First remove any entities lying around in our area:
drawContext.clearEntities(world, this.xOrg, this.yOrg, this.zOrg, this.xOrg + this.width * scale, this.yOrg + this.mazeParams.getSizeAndPosition().getHeight(), this.zOrg + this.length * scale);
// Clear a volume of air, lay a carpet, and put the random pavement over it:
for (int x = 0; x < this.width * scale; x++)
{
for (int z = 0; z < this.length * scale; z++)
{
for (int y = 0; y < this.mazeParams.getSizeAndPosition().getHeight(); y++)
{
world.setBlockToAir(new BlockPos(x + this.xOrg, y + this.yOrg, z + this.zOrg));
}
BlockPos bp = new BlockPos(x + this.xOrg, this.yOrg, z + this.zOrg);
drawContext.setBlockState(world, bp, this.floorBlock);
Cell c = grid[(x/scale) + ((z/scale) * this.width)];
XMLBlockState bs = (c == null) ? this.gapBlock : (c.isOnOptimalPath ? this.optimalPathBlock : this.pathBlock);
int h = (c == null) ? this.gapHeight : (c.isOnOptimalPath ? this.optimalPathHeight : this.pathHeight);
if (c != null && c.isSubgoal)
{
bs = this.subgoalPathBlock;
h = this.subgoalHeight;
}
if (c != null && c.isWaypoint && x % scale == scale/2 && z % scale == scale/2)
{
if (this.mazeParams.getWaypoints().getWaypointBlock() != null)
{
bs = this.waypointBlock;
h = this.pathHeight;
}
else if (this.waypointItem != null)
{
// Place a waypoint item here:
int offset = 0;//(scale % 2 == 0) ? 1 : 0;
drawContext.placeItem(this.waypointItem.copy(), new BlockPos(x + this.xOrg + offset, this.yOrg + h + 1, z + this.zOrg + offset), world, (scale % 2 == 1));
}
}
if (c != null && c == start)
{
h = this.startHeight;
bs = this.startBlock;
}
if (c != null && c == end)
{
h = this.endHeight;
bs = this.endBlock;
}
for (int y = 1; y <= h; y++)
{
BlockPos pos = new BlockPos(x + this.xOrg, y + this.yOrg, z + this.zOrg);
drawContext.setBlockState(world, pos, bs);
}
}
}
}