Spaces:
Paused
Paused
Update index.js
Browse files5 unmodified lines67891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131145 unmodified linesconst hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('German Rage Bot: Bereit zum Kampf! 🇩🇪🔥'));app.listen(7860);const bot = mineflayer.createBot({host: 'nasi.lemak.xyz',username: 'Deutsch_Zerstorer',auth: 'offline',version: '1.21'});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});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 warningbot.on('physicsTick', () => {// Internal logic for movement updates});// 1. AUTHENTICATIONsetTimeout(() => {bot.chat('/register GermanPass99 GermanPass99');bot.chat('/login GermanPass99');// 2. COMPASS SELECTORsetTimeout(() => {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 handbot.setQuickBarSlot(0);bot.activateItem();}}, 4000);}, 3000);});// 3. GUI HANDLING (SURVIVAL SELECTION)bot.on('windowOpen', async (window) => {console.log("Lobby Menu opened.");// Look for "Survival" in the windowconst 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);}});// --- COMBAT & ROAMING LOOP ---setInterval(async () => {// SAFETY CHECK: Ensure bot.entity exists to prevent the 'position' crashif (!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);if (target) {if (Math.random() > 0.96) {const rage = await getGermanTrashTalk(target.username, "provocation");bot.chat(rage);}bot.pvp.attack(target);} else if (!bot.pathfinder.isMoving()) {// Roaming logicconst x = bot.entity.position.x + (Math.random() * 20 - 10);const z = bot.entity.position.z + (Math.random() * 20 - 10);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);}});bot.on('death', () => bot.respawn());bot.on('error', (err) => console.log("Bot Error:", err.message));bot.on('end', () => process.exit(1));5 unmodified lines6789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990915 unmodified linesconst hf = new HfInference(process.env.HF_TOKEN);const app = express();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',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);async function getGermanTrashTalk(victim, type) {try {const out = await hf.chatCompletion({model: "meta-llama/Llama-3.2-1B-Instruct",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("SUCCESS: Physics synchronized. Handling Lobby...");setTimeout(() => {bot.chat('/register GermanPass99 GermanPass99');bot.chat('/login GermanPass99');setTimeout(() => {bot.setQuickBarSlot(0);bot.activateItem(); // Open Compass}, 5000);}, 3000);});bot.on('windowOpen', async (window) => {const survivalSlot = window.slots.find(slot => slot && slot.nbt && JSON.stringify(slot.nbt).toLowerCase().includes('survival'));if (survivalSlot) {bot.clickWindow(survivalSlot.slot, 0, 0);} else {bot.clickWindow(12, 0, 0);}});// Combat Loop using the updated timingsetInterval(async () => {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) < 12);if (target) {if (Math.random() > 0.95) {const rage = await getGermanTrashTalk(target.username, "kill");bot.chat(rage);}bot.pvp.attack(target);} else if (!bot.pathfinder.isMoving()) {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));}}, 4000);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