Spaces:
Paused
Paused
Update index.js
Browse files4 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);4 unmodified lines56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384854 unmodified linesconst hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('The Couple is exploring Zetrex.net! 🏛️🚶♂️'));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 Zetrex server. Msg: ${msg}. 1 short Taglish sentence.` }],max_tokens: 30});return out.choices[0].message.content.trim();} catch (e) { return "Ang ganda naman dito sa Zetrex! ✨"; }}function createBot(name, partnerName, isLeader, delay = 0) {setTimeout(() => {const bot = mineflayer.createBot({host: 'zetrex.net',username: name,auth: 'offline',version: false,checkTimeoutInterval: 120000});bot.loadPlugin(pathfinder);bot.on('spawn', () => {console.log(`${name} spawned in Zetrex!`);const mcData = require('minecraft-data')(bot.version);bot.pathfinder.setMovements(new Movements(bot, mcData));// Standard AuthsetTimeout(() => {bot.chat(`/register CouplePass123 CouplePass123`);bot.chat(`/login CouplePass123`);}, 3000);// --- ROAMING LOGIC ---setInterval(() => {const partner = bot.players[partnerName]?.entity;if (isLeader) {// BOYFRIEND: Wanders slowly to exploreif (!bot.pathfinder.isMoving()) {const rx = bot.entity.position.x + (Math.random() * 12 - 6);const rz = bot.entity.position.z + (Math.random() * 12 - 6);bot.pathfinder.setGoal(new goals.GoalNear(rx, bot.entity.position.y, rz, 1));}} else if (partner) {// GIRLFRIEND: Stays very close (0.5 to 1.5 blocks)bot.pathfinder.setGoal(new goals.GoalFollow(partner, 1), true);}}, 3000);});bot.on('chat', async (username, message) => {if (username === partnerName) {const p = isLeader ? "Chilled Leader BF" : "Shy Follower GF";const reply = await chatAI(name, partnerName, p, message);setTimeout(() => bot.chat(reply), 4000);}});bot.on('end', (reason) => {console.log(`${name} left: ${reason}. Reconnecting...`);setTimeout(() => createBot(name, partnerName, isLeader, 0), 20000);});bot.on('error', (err) => console.log(`${name} Error:`, err));}, delay);}// Start the DuocreateBot('sweetily', 'aprenda', false, 0);createBot('aprenda', 'sweetily', true, 25000); // Wait 25s for BF to join
index.js+38-28