- Get the general position of a hologram
- Query holograms from text, regex or a position
- Extract text components from a hologram
- In your project root directory, install the module using NPM:
npm install mineflayer-hologram
class Vec3; // https://github.com/PrismarineJS/node-vec3
class ChatMessage; // https://github.com/PrismarineJS/prismarine-chat
class Hologram {
position: Vec3,
components: ChatMessage[]
}
const mineflayer = require("mineflayer")
const hologram = require("mineflayer-hologram").plugin
const bot = mineflayer.createBot( ... )
bot.loadPlugin(hologram)
/*
Creates structured data, allowing high level queries to be made
Arguments:
mobTypes (Object?) Key/value object mapping entity names to booleans (Entities used as holograms, defaults are "Armor Stand" and "Area Effect Cloud")
*/
const Query = new bot.hologram.Query(mobTypes?)
/*
Returns the first hologram matching the text. Returns null if nothing was found.
Arguments:
query (String | Regex): The text matching a hologram's text
colour (boolean?): If the query includes formatting codes
Returns: Hologram
*/
const hologram = Query.match(query, colour?)
/*
Returns the hologram at the coordinates specified. (x and z components only)
Arguments:
position (Vec3): The position of the hologram (x and z)
Returns: Hologram or null
*/
const hologram = Query.matchPos(position)
/*
Returns all holograms matching the text.
Arguments:
query (String | Regex): The text matching a hologram's text
colour (boolean?): If the query includes formatting codes
Returns: Hologram or null
*/
const holograms = Query.matchAll(query, colour?)
/*
Returns the hologram as a string without formatting.
*/
const string = hologram.toString()
/*
Returns the hologram as a string with formatting.
*/
const motd = hologram.toMotd()
/*
Returns the hologram as a string with console formatting.
*/
const ansi = hologram.toAnsi()
console.log(ansi)