Spaces:
Paused
Paused
Update index.js
Browse files4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283844 unmodified linesconst hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('The Couple is exploring Hilex-MC! 🌲✨'));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... 😍"; }}function createBot(name, partnerName, isLeader, delay = 0) {setTimeout(() => {const bot = mineflayer.createBot({host: 'hilex-MC.aternos.me',port: 28723,username: name,auth: 'offline',version: false});bot.loadPlugin(pathfinder);bot.on('spawn', () => {console.log(`${name} joined Hilex-MC!`);const mcData = require('minecraft-data')(bot.version);bot.pathfinder.setMovements(new Movements(bot, mcData));// Login LogicsetTimeout(() => {bot.chat(`/register CouplePass123 CouplePass123`);bot.chat(`/login CouplePass123`);}, 3000);// --- ROAMING LOGIC ---setInterval(() => {const partner = bot.players[partnerName]?.entity;if (isLeader) {// BOYFRIEND: Randomly wander if not movingif (!bot.pathfinder.isMoving()) {const rx = bot.entity.position.x + (Math.random() * 20 - 10);const rz = bot.entity.position.z + (Math.random() * 20 - 10);bot.pathfinder.setGoal(new goals.GoalNear(rx, bot.entity.position.y, rz, 1));}} else {// GIRLFRIEND: Stay extremely close to the Boyfriendif (partner) {bot.pathfinder.setGoal(new goals.GoalFollow(partner, 1), true);}}}, 4000);});// Chat Interactionbot.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);}});bot.on('end', () => setTimeout(() => createBot(name, partnerName, isLeader, 0), 15000));bot.on('error', (err) => console.log(`${name} Error:`, err));}, delay);}// Start the peaceful roamingcreateBot('sweetily', 'aprenda', false, 0); // GFcreateBot('aprenda', 'sweetily', true, 20000); // BF (Leader) joins after4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374754 unmodified linesconst hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('Duo is waiting for Hilex-MC to be Online... 🌲'));app.listen(7860);// --- 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: host,port: port,username: name,auth: 'offline',// Set version to 'false' to auto-negotiate, or '1.20.1' if you know itversion: false,hideErrors: true});bot.loadPlugin(pathfinder);bot.on('spawn', () => {console.log(`${name} is in! ✨`);const mcData = require('minecraft-data')(bot.version);bot.pathfinder.setMovements(new Movements(bot, mcData));setTimeout(() => {bot.chat(`/register CouplePass123 CouplePass123`);bot.chat(`/login CouplePass123`);}, 3000);// ROAMING LOGICsetInterval(() => {const partner = bot.players[partnerName]?.entity;if (isLeader) {if (!bot.pathfinder.isMoving()) {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 if (partner) {bot.pathfinder.setGoal(new goals.GoalFollow(partner, 1), true);}}, 5000);});// 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('error', (err) => {if (err.code === 'ECONNRESET') {console.log(`${name}: Server is likely OFFLINE or restarting.`);} else {console.log(`${name} Error: ${err.message}`);}});}, delay);}// Staggered logincreateBot('sweetily', 'aprenda', false, 0);createBot('aprenda', 'sweetily', true, 25000);
index.js+32-41