buildSomething.txt•7.35 kB
// Example 1: Simple House
const simpleHouse = `
// Build a simple house
const startX = pos.x;
const startY = pos.y;
const startZ = pos.z;
// Clear the area first
fill(startX - 5, startY, startZ - 5, startX + 5, startY + 10, startZ + 5, 'air');
// Build floor
fill(startX - 4, startY - 1, startZ - 4, startX + 4, startY - 1, startZ + 4, 'oak_planks');
// Build walls
fill(startX - 4, startY, startZ - 4, startX + 4, startY + 4, startZ - 4, 'oak_planks'); // Front wall
fill(startX - 4, startY, startZ + 4, startX + 4, startY + 4, startZ + 4, 'oak_planks'); // Back wall
fill(startX - 4, startY, startZ - 4, startX - 4, startY + 4, startZ + 4, 'oak_planks'); // Left wall
fill(startX + 4, startY, startZ - 4, startX + 4, startY + 4, startZ + 4, 'oak_planks'); // Right wall
// Add door
fill(startX - 1, startY, startZ - 4, startX + 1, startY + 2, startZ - 4, 'air');
// Add windows
setBlock(startX - 2, startY + 2, startZ - 4, 'glass');
setBlock(startX + 2, startY + 2, startZ - 4, 'glass');
setBlock(startX - 4, startY + 2, startZ - 2, 'glass');
setBlock(startX - 4, startY + 2, startZ + 2, 'glass');
setBlock(startX + 4, startY + 2, startZ - 2, 'glass');
setBlock(startX + 4, startY + 2, startZ + 2, 'glass');
// Build roof
for (let i = 0; i <= 4; i++) {
fill(startX - 4 + i, startY + 5 + i, startZ - 4, startX + 4 - i, startY + 5 + i, startZ + 4, 'oak_stairs');
}
log('House built successfully!');
`;
// Example 2: Spiral Tower
const spiralTower = `
// Build a spiral tower
const centerX = pos.x;
const centerY = pos.y;
const centerZ = pos.z;
const radius = 5;
const height = 20;
const stepsPerRotation = 16;
// Clear the area
fill(centerX - radius - 1, centerY, centerZ - radius - 1,
centerX + radius + 1, centerY + height + 5, centerZ + radius + 1, 'air');
// Build the tower base
for (let y = 0; y < height; y++) {
for (let angle = 0; angle < 2 * Math.PI; angle += Math.PI / 8) {
const x = Math.round(centerX + radius * Math.cos(angle));
const z = Math.round(centerZ + radius * Math.sin(angle));
setBlock(x, centerY + y, z, 'stone_bricks');
}
}
// Build spiral staircase
for (let step = 0; step < height * 2; step++) {
const angle = (step / stepsPerRotation) * 2 * Math.PI;
const y = centerY + step * 0.5;
const x = Math.round(centerX + (radius - 1) * Math.cos(angle));
const z = Math.round(centerZ + (radius - 1) * Math.sin(angle));
setBlock(x, Math.floor(y), z, 'oak_stairs');
// Add safety rail
if (step % 2 === 0) {
const railX = Math.round(centerX + (radius - 2) * Math.cos(angle));
const railZ = Math.round(centerZ + (radius - 2) * Math.sin(angle));
setBlock(railX, Math.floor(y) + 1, railZ, 'fence');
}
}
// Add a platform at the top
fill(centerX - radius, centerY + height, centerZ - radius,
centerX + radius, centerY + height, centerZ + radius, 'stone_bricks');
// Add battlements
for (let angle = 0; angle < 2 * Math.PI; angle += Math.PI / 4) {
const x = Math.round(centerX + radius * Math.cos(angle));
const z = Math.round(centerZ + radius * Math.sin(angle));
setBlock(x, centerY + height + 1, z, 'stone_brick_wall');
}
log('Spiral tower completed!');
`;
// Example 3: Rainbow Road
const rainbowRoad = `
// Build a rainbow road
const startX = pos.x;
const startY = pos.y;
const startZ = pos.z;
const length = 50;
const width = 7;
const colors = ['red_wool', 'orange_wool', 'yellow_wool', 'lime_wool', 'light_blue_wool', 'blue_wool', 'purple_wool'];
// Build the rainbow road
for (let i = 0; i < length; i++) {
for (let w = 0; w < width; w++) {
const color = colors[w % colors.length];
const height = startY + Math.sin(i * 0.2) * 3; // Make it wavy
setBlock(startX + i, Math.floor(height), startZ - Math.floor(width/2) + w, color);
// Add glass barriers on the sides
if (w === 0 || w === width - 1) {
setBlock(startX + i, Math.floor(height) + 1, startZ - Math.floor(width/2) + w, 'glass');
setBlock(startX + i, Math.floor(height) + 2, startZ - Math.floor(width/2) + w, 'glass');
}
}
// Add glowstone lighting every 5 blocks
if (i % 5 === 0) {
setBlock(startX + i, Math.floor(startY + Math.sin(i * 0.2) * 3) - 1, startZ, 'glowstone');
}
}
log('Rainbow road built! Enjoy the ride!');
`;
// Example 4: Pyramid
const pyramid = `
// Build a pyramid
const baseX = pos.x;
const baseY = pos.y;
const baseZ = pos.z;
const size = 15;
// Clear area
fill(baseX - size, baseY, baseZ - size, baseX + size, baseY + size, baseZ + size, 'air');
// Build pyramid layers
for (let level = 0; level < size; level++) {
const currentSize = size - level;
fill(baseX - currentSize, baseY + level, baseZ - currentSize,
baseX + currentSize, baseY + level, baseZ + currentSize, 'sandstone');
}
// Add entrance
fill(baseX - 1, baseY, baseZ - size, baseX + 1, baseY + 2, baseZ - size + 2, 'air');
// Add treasure room in center
fill(baseX - 3, baseY + 1, baseZ - 3, baseX + 3, baseY + 4, baseZ + 3, 'air');
setBlock(baseX, baseY + 1, baseZ, 'gold_block');
// Add torches for lighting
setBlock(baseX - 2, baseY + 2, baseZ - 2, 'torch');
setBlock(baseX + 2, baseY + 2, baseZ - 2, 'torch');
setBlock(baseX - 2, baseY + 2, baseZ + 2, 'torch');
setBlock(baseX + 2, baseY + 2, baseZ + 2, 'torch');
log('Ancient pyramid constructed!');
`;
// Example 5: Tree
const customTree = `
// Build a custom tree
const treeX = pos.x;
const treeY = pos.y;
const treeZ = pos.z;
const trunkHeight = 8;
const leavesRadius = 4;
// Build trunk
for (let y = 0; y < trunkHeight; y++) {
setBlock(treeX, treeY + y, treeZ, 'oak_log');
}
// Build leaves in layers
for (let layer = 0; layer < 3; layer++) {
const y = treeY + trunkHeight - layer - 1;
const radius = leavesRadius - layer;
for (let x = -radius; x <= radius; x++) {
for (let z = -radius; z <= radius; z++) {
// Make it roughly circular
if (x * x + z * z <= radius * radius) {
setBlock(treeX + x, y, treeZ + z, 'oak_leaves');
}
}
}
}
// Add top
setBlock(treeX, treeY + trunkHeight, treeZ, 'oak_leaves');
setBlock(treeX, treeY + trunkHeight + 1, treeZ, 'oak_leaves');
log('Custom tree grown!');
`;
// Export examples
module.exports = {
simpleHouse,
spiralTower,
rainbowRoad,
pyramid,
customTree
};
// Usage instructions
console.log(`
BuildSomething Skill Examples
============================
To use these examples with the buildSomething skill:
1. Simple House:
buildSomething({ code: simpleHouse })
2. Spiral Tower:
buildSomething({ code: spiralTower })
3. Rainbow Road:
buildSomething({ code: rainbowRoad })
4. Pyramid:
buildSomething({ code: pyramid })
5. Custom Tree:
buildSomething({ code: customTree })
You can also modify these examples or create your own!
Available functions in code mode:
- setBlock(x, y, z, blockType)
- fill(x1, y1, z1, x2, y2, z2, blockType, mode?)
- clone(x1, y1, z1, x2, y2, z2, dx, dy, dz, mode?)
- summon(entityType, x?, y?, z?)
- give(itemName, count?)
- execute(command)
- wait(ticks)
- log(message)
Available variables:
- bot: The bot instance
- pos: Bot's current position {x, y, z}
- Math: JavaScript Math object
- shouldStop(): Function to check if execution should stop
`);