0.0.2 • Published 10 months ago

mineflayer-hologram v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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)
0.0.2

10 months ago

0.0.1

1 year ago