Files
Mortdecai/ingame/test_connect.js
T
Seth 827850b8d7 Initial project scaffold: dataset schema, 31 seed training examples, Mineflayer bot framework, and 7-phase roadmap
- IDEA.md: project scope (Minecraft ops AI assistant via qwen3-coder LoRA/SFT)
- PLAN.md: complete roadmap with prior art analysis, architecture, phased plan, dev server docs
- data/schema.json: training example JSON Schema with negative_output support
- data/processed/seed_dataset.jsonl: 31 validated examples from repair code, prayer logs, session history
- data/validate_dataset.py: schema validator with summary statistics
- ingame/: Mineflayer bot framework (test_connect, spawn_bots, aware_bots with full event logging)
- Directory structure for knowledge/, eval/, training/, agent/ (Phase 1.3+ work)
2026-03-18 01:51:28 -04:00

72 lines
1.8 KiB
JavaScript

/**
* test_connect.js -- Verify Mineflayer can connect to the dev Paper server.
*
* Usage: node test_connect.js [host] [port]
* Defaults: 192.168.0.244 25568
*/
const mineflayer = require('mineflayer');
const host = process.argv[2] || '192.168.0.244';
const port = parseInt(process.argv[3] || '25568', 10);
console.log(`Connecting to ${host}:${port} as TestBot...`);
const bot = mineflayer.createBot({
host,
port,
username: 'TestBot',
auth: 'offline',
version: '1.21.11',
});
bot.on('login', () => {
console.log(`[OK] Logged in as ${bot.username}`);
});
bot.on('spawn', () => {
const pos = bot.entity.position;
console.log(`[OK] Spawned at x=${pos.x.toFixed(1)} y=${pos.y.toFixed(1)} z=${pos.z.toFixed(1)}`);
console.log(`[OK] Gamemode: ${bot.game.gameMode}`);
console.log(`[OK] Health: ${bot.health}, Food: ${bot.food}`);
// Look around and report nearby blocks
const block = bot.blockAt(bot.entity.position.offset(0, -1, 0));
console.log(`[OK] Block below: ${block ? block.name : 'unknown'}`);
// List nearby entities
const entities = Object.values(bot.entities).filter(e => e !== bot.entity);
console.log(`[OK] Nearby entities: ${entities.length}`);
console.log('\n=== Connection test passed ===');
console.log('Disconnecting in 3s...');
setTimeout(() => {
bot.quit('Test complete');
process.exit(0);
}, 3000);
});
bot.on('chat', (username, message) => {
console.log(`[CHAT] <${username}> ${message}`);
});
bot.on('error', (err) => {
console.error(`[ERROR] ${err.message}`);
process.exit(1);
});
bot.on('kicked', (reason) => {
console.error(`[KICKED] ${reason}`);
process.exit(1);
});
bot.on('end', (reason) => {
console.log(`[END] ${reason}`);
});
// Timeout if connection takes too long
setTimeout(() => {
console.error('[TIMEOUT] Connection took longer than 30s');
process.exit(1);
}, 30000);