Spaces:
Paused
Paused
Update index.js
Browse files5 unmodified lines678991011121314151616171819202122232425262728222924303132282933343536373839403637383940414142434344454648475051525354555657584849505951525363546566556856705758737459606162786364806566676885697071728990737475767778959697798081828384102103104105106107108109110858611211311487888990915 unmodified lines
const hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('German Rage Bot: Bereit zum Kampf! π©πͺπ₯'));app.get('/', (req, res) => res.send('System: Physics Calibrated. German Rage Active. π©πͺ'));app.listen(7860);
const bot = mineflayer.createBot({ host: 'nasi.lemak.xyz', username: 'Deutsch_Zerstorer', auth: 'offline', version: '1.21' version: '1.21', checkTimeoutInterval: 120000 // Prevents the ECONNRESET kick});
// --- THE FIX: LISTENING TO MINEFLAYER ---// We force the bot to treat 'physicTick' and 'physicsTick' as the same thingbot.on('physicsTick', () => { bot.emit('physicTick'); });
bot.loadPlugin(pathfinder);bot.loadPlugin(pvp);
// --- THE GERMAN RAGE AI ---async function getGermanTrashTalk(victim, type) { const prompt = `Context: Minecraft PVP. Situation: ${type} ${victim}. Task: Write 1 short, extremely toxic sentence in FULL GERMAN. Use insults like 'Lauch', 'Opfer', 'Hund'. Be very annoying. No hashtags.`; try { const out = await hf.chatCompletion({ model: "meta-llama/Llama-3.2-1B-Instruct", messages: [{ role: "user", content: prompt }], max_tokens: 35 messages: [{ role: "user", content: `Write 1 short, toxic German PVP insult for ${victim}.` }], max_tokens: 30 }); return out.choices[0].message.content.trim().replace(/"/g, ''); } catch (e) { return "GEH HEULEN DU LAUCH! π"; }}
bot.on('spawn', () => { console.log("Spawned! Handling Login & Compass..."); // Fix: Using the correct physicsTick event to avoid deprecation warning bot.on('physicsTick', () => { // Internal logic for movement updates }); console.log("SUCCESS: Physics synchronized. Handling Lobby...");
// 1. AUTHENTICATION setTimeout(() => { bot.chat('/register GermanPass99 GermanPass99'); bot.chat('/login GermanPass99');
// 2. COMPASS SELECTOR setTimeout(() => { const compass = bot.inventory.items().find(item => item.name.includes('compass')); if (compass) { bot.activateItem(); console.log("Compass used. Waiting for GUI..."); } else { // Fallback if no compass in hand bot.setQuickBarSlot(0); bot.activateItem(); } bot.setQuickBarSlot(0); bot.activateItem(); // Open Compass }, 5000); }, 4000); }, 3000);});
// 3. GUI HANDLING (SURVIVAL SELECTION)bot.on('windowOpen', async (window) => { console.log("Lobby Menu opened."); // Look for "Survival" in the window const survivalSlot = window.slots.find(slot => slot && slot.nbt && JSON.stringify(slot.nbt).toLowerCase().includes('survival')); if (survivalSlot) { console.log(`Found Survival at slot ${survivalSlot.slot}. Joining queue...`); bot.clickWindow(survivalSlot.slot, 0, 0); } else { console.log("Survival not found in NBT, clicking default slot 12..."); bot.clickWindow(12, 0, 0); bot.clickWindow(12, 0, 0); }});
// --- COMBAT & ROAMING LOOP ---// Combat Loop using the updated timingsetInterval(async () => { // SAFETY CHECK: Ensure bot.entity exists to prevent the 'position' crash if (!bot.entity || !bot.entity.position) return;
const target = bot.nearestEntity(e => e.type === 'player' && e.username !== bot.username && bot.entity.position.distanceTo(e.position) < 15 bot.entity.position.distanceTo(e.position) < 12 );
if (target) { if (Math.random() > 0.96) { const rage = await getGermanTrashTalk(target.username, "provocation"); if (Math.random() > 0.95) { const rage = await getGermanTrashTalk(target.username, "kill"); bot.chat(rage); } bot.pvp.attack(target); } else if (!bot.pathfinder.isMoving()) { // Roaming logic const x = bot.entity.position.x + (Math.random() * 20 - 10); const z = bot.entity.position.z + (Math.random() * 20 - 10); const x = bot.entity.position.x + (Math.random() * 10 - 5); const z = bot.entity.position.z + (Math.random() * 10 - 5); const mcData = require('minecraft-data')(bot.version); bot.pathfinder.setMovements(new Movements(bot, mcData)); bot.pathfinder.setGoal(new goals.GoalNear(x, bot.entity.position.y, z, 1)); }}, 3000);
// --- EVENTS ---bot.on('entityDead', async (entity) => { if (bot.pvp.target === entity) { const rage = await getGermanTrashTalk(entity.username || "Opfer", "killed"); setTimeout(() => bot.chat(rage), 1000); }});}, 4000);
bot.on('death', () => bot.respawn());bot.on('error', (err) => console.log("Bot Error:", err.message));bot.on('end', () => process.exit(1));bot.on('error', (err) => console.log(`[Physics Error]: ${err.message}`));bot.on('end', () => { console.log("Connection lost. Re-calibrating..."); setTimeout(() => process.exit(1), 5000); });index.js+28-51