Skip to content

Represent holograms in mineflayer with high-level functionality

License

Notifications You must be signed in to change notification settings

firejoust/mineflayer-hologram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mineflayer Hologram

Features

  • Get the general position of a hologram
  • Query holograms from text, regex or a position
  • Extract text components from a hologram

Installation

  • In your project root directory, install the module using NPM:
npm install mineflayer-hologram

API

Types

class Vec3;        // https://github.com/PrismarineJS/node-vec3
class ChatMessage; // https://github.com/PrismarineJS/prismarine-chat

class Hologram {
  position: Vec3,
  components: ChatMessage[]
}

Loading the plugin

const mineflayer = require("mineflayer")
const hologram = require("mineflayer-hologram").plugin

const bot = mineflayer.createBot( ... )

bot.loadPlugin(hologram)

Methods

/*
  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?)

Hologram Methods

/*
  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)

About

Represent holograms in mineflayer with high-level functionality

Resources

License

Stars

Watchers

Forks

Packages

No packages published