Code Monkey home page Code Monkey logo

mineflayer-plasmovoice's Introduction

mineflayer-plasmovoice

A lightweight plugin for Mineflayer that allows use VoiceChat for PlasmoVoice plugin

Features

  • 🔥 Supports CommonJS and ES6
  • 🔈 Allows to send any soundfile formats using FFMPEG
  • 🔒 Works with AES-128-CBC and RSA Encryption
  • 👀 Almost exactly mimics the behavior of the original mod
  • 🖧 Using ProtoDef to assemble the packets
  • 📎 Supports "/vrc" command
  • ↗ Automatically reconnects in case of connection loss

Getting Started

Installation

  1. This plugin is built using Node and can be installed using: npm install mineflayer-plasmovoice --save

Simple Sound Player

A bot that sneaks will play a certain sound (/path/to/music.mp3) and get up.

const mineflayer = require("mineflayer")
const plasmo = require("mineflayer-plasmovoice")

const bot = mineflayer.createBot({
    "host": "localhost"
})

bot.loadPlugin(plasmo.plugin)

bot.on("plasmovoice_connected", () => {
    bot.setControlState("sneak", true)

    // Path to file with any audio format
    bot.plasmovoice.sendAudio("/path/to/music.mp3")
})

bot.on("plasmovoice_audio_end", () => {
    bot.setControlState("sneak", false)
})

Debugging

const plasmo = require("mineflayer-plasmovoice")

/** By default - 4, and these are warnings, errors and fatal errors */
plasmo.setLoggingLevel(0)

Listening players

An example of an event when some player is talking

  • Data format is pcm_s16le
  • Sequence number goes in order from zero, some packet may be skipped when using the UDP protocol
bot.on("plasmovoice_voice", (data) => {
    /*{
        player: string,
        distance: number
        sequenceNumber: BigInt
        data: Buffer
    }*/
})

An example of an event when some player stopped talking

bot.on("plasmovoice_voice_end", (data) => {
    /*{
        player: string,
        sequenceNumber: BigInt
    }*/
})

License

This project uses the MIT license.


Contributors:

  • ↗ Maks-gaming - The idea and implementation of the plugin structure;
  • 📎 CralixRaev - Helped to deal with ProtoDef;
  • 🔥 Plasmo R&D - helped to understand some things in the packet system;

This project is accepting PRs and Issues. See something you think can be improved? Go for it! Any and all help is highly appreciated!

For larger changes, it is recommended to discuss these changes in the issues tab before writing any code. It's also preferred to make many smaller PRs than one large one, where applicable.

Made with official PlasmoVoice resources (https://plasmovoice.com)

mineflayer-plasmovoice's People

Contributors

cralixraev avatar dependabot[bot] avatar maks-gaming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mineflayer-plasmovoice's Issues

the bot does not speak!

### I've installed everything I need. I took an example of your code and ran it, but for some reason there is an icon above the bot's head (photo attached). Please help me!!!
Снимок экрана 2024-05-03 205858
Also here is the code I used:
const mineflayer = require('mineflayer');
const plasmo = require('mineflayer-plasmovoice');

const bot = mineflayer.createBot({
port: 57873,
host: '',
username: '',
version: '1.16.5',
});

bot.loadPlugin(plasmo.plugin)

bot.on("plasmovoice_connected", () => {
bot.setControlState("sneak", true)

// Path to file with any audio format
bot.plasmovoice.sendAudio("C:\Users\fdewf\misc\1.mp3")
})

bot.on("plasmovoice_audio_end", () => {
bot.setControlState("sneak", false)
})
bot.on("login", () => {
bot.plasmovoice.enableDebug();
})

How do I get a bot to talk?

I want to play soundtrack with bot help, is it possible to implement this somehow using plasmovoice? The track is in the same file with the script: "music.mp3"

ERR_SOCKET_BAD_PORT

RangeError [ERR_SOCKET_BAD_PORT]: Port should be > 0 and < 65536. Received undefined.
at Socket.send (node:dgram:633:12)
at PingPacket.send (C:\Users\neverdie\node_modules\mineflayer-plasmovoice\lib\packet\socket\PacketSocketBase.js:28:46)
at C:\Users\neverdie\node_modules\mineflayer-plasmovoice\lib\packet\PacketSocketHandler.js:37:29
at node:dgram:442:9
at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
code: 'ERR_SOCKET_BAD_PORT'
}

Нужна помощь. Не могу даже установить.

Извиняюсь за то что пишу на русском потому что для вас это может быть не удобно. Но мне нужна помощь. Даже установить не могу выдаёт такие ошибки:
npm install mineflayer-plasmovoice --save>
npm WARN deprecated [email protected]: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm ERR! code 1
npm ERR! path C:\Users\fdewf\node_modules@discordjs\opus
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\fdewf\node_modules@discordjs\opus\prebuild\node-v115-napi-v3-win32-x64-unknown-unknown\opus.node --module_name=opus --module_path=C:\Users\fdewf\node_modules@discordjs\opus\prebuild\node-v115-napi-v3-win32-x64-unknown-unknown --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it
ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | win32 | x64
npm ERR! node-pre-gyp info check checked for "C:\Users\fdewf\node_modules@discordjs\opus\prebuild\node-v115-napi-v3-win32-x64-unknown-unknown\opus.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/discordjs/opus/releases/download/v0.9.0/opus-v0.9.0-node-v115-napi-v3-win32-x64-unknown-unknown.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.9.0/opus-v0.9.0-node-v115-napi-v3-win32-x64-unknown-unknown.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for @discordjs/[email protected] and [email protected] (node-v115 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.9.0/opus-v0.9.0-node-v115-napi-v3-win32-x64-unknown-unknown.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python
version 3.12.3 found at "C:\Python312\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not
set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not
set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:113:11)
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:69:17)
npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR! gyp ERR! stack at async createBuildDir (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:26)
npm ERR! gyp ERR! stack at async run (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js:81:18)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\Users\fdewf\node_modules\@discordjs\opus\prebuild\node-v115-napi-v3-win32-x64-unknown-unknown\opus.node" "--module_name=opus" "--module_path=C:\Users\fdewf\node_modules\@discordjs\opus\prebuild\node-v115-napi-v3-win32-x64-unknown-unknown" "--napi_version=9"
"--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd C:\Users\fdewf\node_modules@discordjs\opus
npm ERR! gyp ERR! node -v v20.12.2
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\fdewf\node_modules@discordjs\opus\prebuild\node-v115-napi-v3-win32-x64-unknown-unknown\opus.node --module_name=opus --module_path=C:\Users\fdewf\node_modules@discordjs\opus\prebuild\node-v115-napi-v3-win32-x64-unknown-unknown --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack at ChildProcess. (C:\Users\fdewf\node_modules@discordjs\node-pre-gyp\lib\util\compile.js:85:20)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:518:28)
npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1105:16)
npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.19045
npm ERR! node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\fdewf\node_modules\@discordjs\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd C:\Users\fdewf\node_modules@discordjs\opus
npm ERR! node-pre-gyp ERR! node -v v20.12.2npm ERR! node-pre-gyp ERR! node-pre-gyp -v
v0.4.5
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be
found in: C:\Users\fdewf\AppData\Local\npm-cache_logs\2024-04-28T22_21_56_650Z-debug-0.log

Readme Instructions are incorrect?

Still trying to learn how to use python and it's syntax so bare with me as I might not understand some things fully, just FYI. hah

I got mineflayer itself running eventually, the base of all of this and was able to get the bot to come on command. So, Eventually, working through adding modules and came across yours. Very interesting to add voice support to the bot I thought.

But, not being familiar with how modules work and using python instead of just javascript, putting me in a for a challenge for sure. Anyway, I finally figured out how to get your example setup in your readme to work to a point. But I am not fully sure why I need to add the .plugin after the plasmavoice variable to get it to load this plugin.

Your's is bot.loadPlugin(plasmo)

And I have to use: bot.loadPlugin(plasmovoice.plugin);

Working through the code it seems to be an issue with the index.ts and how exports work that I don't fully understand. I am not sure even if I am on the right track, but is to do with wanting something to do with this [ export function plugin(bot: Bot) { ] and/or [ export default plugin; ]

Thinking it was an issue with the python conversion to javascript wrapper I tried only using the javascript example without any changes and sure enough the same error.

node:assert:408
throw err;
^

AssertionError [ERR_ASSERTION]: plugin needs to be a function
at EventEmitter.loadPlugin (/home/jovyan/node_modules/mineflayer/lib/plugin_loader.js:16:12)
at Object. (/home/jovyan/work/testPlasmovoice.js:13:5)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}

Node.js v20.12.2

Might be an issue with my setup or something, I don't know but here is the code:

// testPlasmovoice.js
const mineflayer = require('mineflayer');
const plasmovoice = require('mineflayer-plasmovoice');
const path = require('path')
plasmovoice.setLoggingLevel(0)

const bot = mineflayer.createBot({
host: "host.docker.internal", // Minecraft server IP
port: 25565,
username: "bot"
});

bot.loadPlugin(plasmovoice);

And I ran this from the console terminal in my docker container:

node testPlasmovoice2.js

Thanks for your cool project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.