Spaces:
Paused
Paused
Update index.js
Browse files4 unmodified lines567889101112131415161718192021221112131415161718192728202122232431252627282930313732333435413637383940474142435044524554554647484958596061505162526453545567686970717273565758596061767762636465666768697071728283847374754 unmodified lines
const hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('The Couple is exploring Hilex-MC! 🌲✨'));app.get('/', (req, res) => res.send('Duo is waiting for Hilex-MC to be Online... 🌲'));app.listen(7860);
const memories = { sweetily: [], aprenda: [] };
async function chatAI(name, partner, persona, msg) { try { const out = await hf.chatCompletion({ model: "meta-llama/Llama-3.2-1B-Instruct", messages: [{ role: "user", content: `Character: ${name}. Partner: ${partner}. Persona: ${persona}. Context: Exploring a chill Minecraft server. Message: ${msg}. 1 short Taglish sentence.` }], max_tokens: 35 }); return out.choices[0].message.content.trim(); } catch (e) { return "Ganda naman dito... 😍"; }}// --- CONFIG ---const host = 'hilex-MC.aternos.me';const port = 28723;
function createBot(name, partnerName, isLeader, delay = 0) { setTimeout(() => { console.log(`Attempting to connect ${name}...`); const bot = mineflayer.createBot({ host: 'hilex-MC.aternos.me', port: 28723, host: host, port: port, username: name, auth: 'offline', // Set version to 'false' to auto-negotiate, or '1.20.1' if you know it version: false version: false, hideErrors: true });
bot.loadPlugin(pathfinder);
bot.on('spawn', () => { console.log(`${name} joined Hilex-MC!`); console.log(`${name} is in! ✨`); const mcData = require('minecraft-data')(bot.version); bot.pathfinder.setMovements(new Movements(bot, mcData)); // Login Logic setTimeout(() => { bot.chat(`/register CouplePass123 CouplePass123`); bot.chat(`/login CouplePass123`); }, 3000);
// --- ROAMING LOGIC --- // ROAMING LOGIC setInterval(() => { const partner = bot.players[partnerName]?.entity;
if (isLeader) { // BOYFRIEND: Randomly wander if not moving if (!bot.pathfinder.isMoving()) { const rx = bot.entity.position.x + (Math.random() * 20 - 10); const rz = bot.entity.position.z + (Math.random() * 20 - 10); const rx = bot.entity.position.x + (Math.random() * 10 - 5); const rz = bot.entity.position.z + (Math.random() * 10 - 5); bot.pathfinder.setGoal(new goals.GoalNear(rx, bot.entity.position.y, rz, 1)); } } else { // GIRLFRIEND: Stay extremely close to the Boyfriend if (partner) { bot.pathfinder.setGoal(new goals.GoalFollow(partner, 1), true); } else if (partner) { bot.pathfinder.setGoal(new goals.GoalFollow(partner, 1), true); } } }, 4000); }, 5000); });
// Chat Interaction bot.on('chat', async (username, message) => { if (username === partnerName) { const p = isLeader ? "Protective but chill BF" : "Shy, admiring GF"; const reply = await chatAI(name, partnerName, p, message); setTimeout(() => bot.chat(reply), 4000); } // HANDLE DISCONNECT (Aternos often resets connections) bot.on('end', (reason) => { console.log(`${name} connection reset: ${reason}. Waiting for server to be online...`); setTimeout(() => createBot(name, partnerName, isLeader, 0), 30000); // 30s wait });
bot.on('end', () => setTimeout(() => createBot(name, partnerName, isLeader, 0), 15000)); bot.on('error', (err) => console.log(`${name} Error:`, err)); bot.on('error', (err) => { if (err.code === 'ECONNRESET') { console.log(`${name}: Server is likely OFFLINE or restarting.`); } else { console.log(`${name} Error: ${err.message}`); } });
}, delay);}
// Start the peaceful roamingcreateBot('sweetily', 'aprenda', false, 0); // GFcreateBot('aprenda', 'sweetily', true, 20000); // BF (Leader) joins after// Staggered logincreateBot('sweetily', 'aprenda', false, 0); createBot('aprenda', 'sweetily', true, 25000);index.js+32-41