Skip to main content
Glama
Mming-Lab
by Mming-Lab

build_rotate

Rotate and duplicate structures around a pivot point in Minecraft Bedrock. Create symmetrical layouts, multiple orientations, or decorative spins by specifying coordinates, axis, and angle.

Instructions

Rotate and copy a structure around a pivot point. Perfect for creating rotated copies of buildings, making symmetrical structures, or spinning decorations. Example: rotate a house 90° around its center to create multiple orientations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoBuild action to performbuild
angleYesRotation angle in degrees. Common angles: 90=quarter turn, 180=half turn, 270=three-quarter turn, 45=diagonal
axisYesRotation axis: y=spin horizontally (most common), x=tip forward/backward, z=roll left/right
materialNoBlock type to build the rotated copy with (e.g. same as original, or different material for contrast)minecraft:stone
originXYesCenter of rotation X coordinate
originYYesCenter of rotation Y coordinate
originZYesCenter of rotation Z coordinate
sourceCorner1XYesSource region corner 1 X coordinate
sourceCorner1YYesSource region corner 1 Y coordinate
sourceCorner1ZYesSource region corner 1 Z coordinate
sourceCorner2XYesSource region corner 2 X coordinate
sourceCorner2YYesSource region corner 2 Y coordinate
sourceCorner2ZYesSource region corner 2 Z coordinate

Implementation Reference

  • Core handler function that validates parameters, rotates source region blocks around specified origin and axis, deduplicates positions, and places rotated structure using Socket-BE world.setBlock API.
    async execute(args: {
        action?: string;
        sourceCorner1X: number;
        sourceCorner1Y: number;
        sourceCorner1Z: number;
        sourceCorner2X: number;
        sourceCorner2Y: number;
        sourceCorner2Z: number;
        originX: number;
        originY: number;
        originZ: number;
        axis: string;
        angle: number;
        material?: string;
    }): Promise<ToolCallResult> {
        try {
            // Socket-BE API接続確認
            if (!this.world) {
                return { success: false, message: "World not available. Ensure Minecraft is connected." };
            }
    
            const {
                action = 'build',
                sourceCorner1X, sourceCorner1Y, sourceCorner1Z,
                sourceCorner2X, sourceCorner2Y, sourceCorner2Z,
                originX, originY, originZ,
                axis, angle,
                material = 'minecraft:stone'
            } = args;
            
            // actionパラメータをサポート(現在は build のみ)
            if (action !== 'build') {
                return this.createErrorResponse(`Unknown action: ${action}. Only 'build' is supported.`);
            }
    
            // 座標の整数化
            const source1 = {
                x: this.normalizeCoordinate(sourceCorner1X),
                y: this.normalizeCoordinate(sourceCorner1Y),
                z: this.normalizeCoordinate(sourceCorner1Z)
            };
    
            const source2 = {
                x: this.normalizeCoordinate(sourceCorner2X),
                y: this.normalizeCoordinate(sourceCorner2Y),
                z: this.normalizeCoordinate(sourceCorner2Z)
            };
    
            const origin = {
                x: this.normalizeCoordinate(originX),
                y: this.normalizeCoordinate(originY),
                z: this.normalizeCoordinate(originZ)
            };
    
            // パラメータ検証
            if (!['x', 'y', 'z'].includes(axis)) {
                return this.createErrorResponse('Axis must be x, y, or z');
            }
    
            if (angle < 0 || angle > 360) {
                return this.createErrorResponse('Angle must be between 0 and 360 degrees');
            }
    
            // ソース領域の範囲を計算
            const minX = Math.min(source1.x, source2.x);
            const maxX = Math.max(source1.x, source2.x);
            const minY = Math.min(source1.y, source2.y);
            const maxY = Math.max(source1.y, source2.y);
            const minZ = Math.min(source1.z, source2.z);
            const maxZ = Math.max(source1.z, source2.z);
    
            // 座標検証
            if (!this.validateCoordinates(minX, minY, minZ) || 
                !this.validateCoordinates(maxX, maxY, maxZ) ||
                !this.validateCoordinates(origin.x, origin.y, origin.z)) {
                return this.createErrorResponse('Coordinates extend beyond valid range');
            }
    
            // ブロック数の事前チェック
            const totalBlocks = (maxX - minX + 1) * (maxY - minY + 1) * (maxZ - minZ + 1);
            if (totalBlocks > 5000) {
                return this.createErrorResponse('Source region too large (maximum 5000 blocks)');
            }
    
            // ブロックIDの正規化
            const blockId = this.normalizeBlockId(material);
    
            const commands: string[] = [];
            let blocksPlaced = 0;
            const placedPositions = new Set<string>();
    
            // ソース領域の各座標を回転して配置
            for (let x = minX; x <= maxX; x++) {
                for (let y = minY; y <= maxY; y++) {
                    for (let z = minZ; z <= maxZ; z++) {
                        // 座標を回転(共通ライブラリ使用)
                        const rotated = rotatePoint3D(
                            { x, y, z },
                            origin,
                            axis as 'x' | 'y' | 'z',
                            angle
                        );
    
                        // 回転後の座標が有効範囲内かチェック
                        if (this.validateCoordinates(rotated.x, rotated.y, rotated.z)) {
                            const positionKey = `${rotated.x},${rotated.y},${rotated.z}`;
                            
                            // 重複座標を避ける
                            if (!placedPositions.has(positionKey)) {
                                placedPositions.add(positionKey);
                                commands.push(`setblock ${rotated.x} ${rotated.y} ${rotated.z} ${blockId}`);
                                blocksPlaced++;
                            }
                        }
                    }
                }
            }
    
            if (commands.length === 0) {
                return this.createErrorResponse('No valid blocks to place after rotation');
            }
    
            try {
                // Socket-BE APIを使用した実装
                let actualBlocksPlaced = 0;
                
                // コマンド配列をSocket-BE API呼び出しに変換
                for (const command of commands) {
                    if (command.startsWith('setblock ')) {
                        const parts = command.split(' ');
                        if (parts.length >= 5) {
                            const x = parseInt(parts[1]);
                            const y = parseInt(parts[2]);
                            const z = parseInt(parts[3]);
                            const block = parts[4];
                            
                            await this.world.setBlock({x, y, z}, block);
                            actualBlocksPlaced++;
                            
                            if (actualBlocksPlaced > BUILD_LIMITS.ROTATE) {
                                return this.createErrorResponse(`Too many blocks to place (maximum ${BUILD_LIMITS.ROTATE.toLocaleString()})`);
                            }
                        }
                    }
                }
                
                return this.createSuccessResponse(
                    `Rotated structure built with ${blockId}. Rotated ${totalBlocks} blocks by ${angle}° around ${axis}-axis at origin (${origin.x},${origin.y},${origin.z}). Placed ${actualBlocksPlaced} blocks.`,
                    {
                        type: 'rotation',
                        sourceRegion: {
                            corner1: source1,
                            corner2: source2
                        },
                        origin: origin,
                        axis: axis,
                        angle: angle,
                        material: blockId,
                        originalBlocks: totalBlocks,
                        blocksPlaced: actualBlocksPlaced,
                        apiUsed: 'Socket-BE'
                    }
                );
            } catch (buildError) {
                return this.createErrorResponse(`Building error: ${buildError instanceof Error ? buildError.message : String(buildError)}`);
            }
    
        } catch (error) {
            return this.createErrorResponse(
                `Error building rotated structure: ${error instanceof Error ? error.message : String(error)}`
            );
        }
    }
  • Input schema defining parameters for source region (two corners), rotation origin, axis (x/y/z), angle in degrees, and optional material for placed blocks.
    readonly inputSchema: InputSchema = {
        type: 'object',
        properties: {
            action: {
                type: 'string',
                description: 'Build action to perform',
                enum: ['build'],
                default: 'build'
            },
            sourceCorner1X: {
                type: 'number',
                description: 'Source region corner 1 X coordinate'
            },
            sourceCorner1Y: {
                type: 'number',
                description: 'Source region corner 1 Y coordinate'
            },
            sourceCorner1Z: {
                type: 'number',
                description: 'Source region corner 1 Z coordinate'
            },
            sourceCorner2X: {
                type: 'number',
                description: 'Source region corner 2 X coordinate'
            },
            sourceCorner2Y: {
                type: 'number',
                description: 'Source region corner 2 Y coordinate'
            },
            sourceCorner2Z: {
                type: 'number',
                description: 'Source region corner 2 Z coordinate'
            },
            originX: {
                type: 'number',
                description: 'Center of rotation X coordinate'
            },
            originY: {
                type: 'number',
                description: 'Center of rotation Y coordinate'
            },
            originZ: {
                type: 'number',
                description: 'Center of rotation Z coordinate'
            },
            axis: {
                type: 'string',
                description: 'Rotation axis: y=spin horizontally (most common), x=tip forward/backward, z=roll left/right',
                enum: ['x', 'y', 'z']
            },
            angle: {
                type: 'number',
                description: 'Rotation angle in degrees. Common angles: 90=quarter turn, 180=half turn, 270=three-quarter turn, 45=diagonal',
                minimum: 0,
                maximum: 360
            },
            material: {
                type: 'string',
                description: 'Block type to build the rotated copy with (e.g. same as original, or different material for contrast)',
                default: 'minecraft:stone'
            }
        },
        required: ['sourceCorner1X', 'sourceCorner1Y', 'sourceCorner1Z', 'sourceCorner2X', 'sourceCorner2Y', 'sourceCorner2Z', 'originX', 'originY', 'originZ', 'axis', 'angle']
    };
  • src/server.ts:348-372 (registration)
    Tool instantiation within the tools array in initializeTools(), which are then registered to MCP server via registerModularTools() loop using tool.name ('build_rotate'). Import at line 21.
    this.tools = [
      // Socket-BE Core API ツール(推奨 - シンプルでAI使いやすい)
      new AgentTool(),
      new WorldTool(),
      new PlayerTool(),
      new BlocksTool(),
      new SystemTool(),
      new CameraTool(),
      new SequenceTool(),
      new MinecraftWikiTool(),
    
      // Advanced Building ツール(高レベル建築機能)
      new BuildCubeTool(), // ✅ 完全動作
      new BuildLineTool(), // ✅ 完全動作
      new BuildSphereTool(), // ✅ 完全動作
      new BuildCylinderTool(), // ✅ 修正済み
      new BuildParaboloidTool(), // ✅ 基本動作
      new BuildHyperboloidTool(), // ✅ 基本動作
      new BuildRotateTool(), // ✅ 基本動作
      new BuildTransformTool(), // ✅ 基本動作
      new BuildTorusTool(), // ✅ 修正完了
      new BuildHelixTool(), // ✅ 修正完了
      new BuildEllipsoidTool(), // ✅ 修正完了
      new BuildBezierTool(), // ✅ 新規追加(可変制御点ベジェ曲線)
    ];
  • src/server.ts:21-21 (registration)
    Import statement for BuildRotateTool class.
    import { BuildRotateTool } from "./tools/advanced/building/build-rotate";
  • Class definition extending BaseTool with tool name 'build_rotate' and description.
    export class BuildRotateTool extends BaseTool {
        readonly name = 'build_rotate';
        readonly description = 'Rotate and copy a structure around a pivot point. Perfect for creating rotated copies of buildings, making symmetrical structures, or spinning decorations. Example: rotate a house 90° around its center to create multiple orientations';
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Mming-Lab/minecraft-bedrock-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server