Skip to content
/ chroma Public

Chroma provides a readable scripting interface for Minecraft text formatting.

License

Notifications You must be signed in to change notification settings

uspel/chroma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chroma

Chroma provides a readable scripting interface for Minecraft text formatting.

Contents

Features

  • Supports all Minecraft Bedrock formatting codes
  • Simple and readable chaining syntax
  • Concatenation and nesting support
  • Formatting presets
  • No dependencies

Installation

Set up a new creation with the Minepicker Creator CLI and then run the following command to install the latest version of Chroma:

minepicker use chroma

Usage

import { world } from "@minecraft/server";
import chroma from "chroma";

world.sendMessage(chroma.blue("Hello world!"));

Chaining

Formatting options can be chanined, with any conflicting options being overriden by the latest value in the chain.

chroma.bold.blue("Hello world!");

Concatenation & Nesting

Formatted text can be joined together and nested just like regular strings!

import { world } from "@minecraft/server";
import chroma from "chroma";

world.sendMessage(
  "This is " + chroma.bold("bold")
);

world.sendMessage(
  chroma.yellow.italic(
    `A ${chroma.bold("very")} important message`
  )
);

Presets

Assign Chroma instances to your own variables to shorten your code!

import { world } from "@minecraft/server";
import chroma from "chroma";

const info = chroma.blue;
const warning = chroma.italic.yellow;

world.sendMessage(info("Scripts loaded!"));

const message =
  "This script is " +
  chroma.bold("completely useless");

world.sendMessage(info("You have a warning:"));
world.sendMessage(warning(message));

Colors

Using the following properties on a Chroma instance will return a new instance with the appropriate color formatting applied:

  • aqua
  • black
  • blue
  • darkAqua
  • darkBlue
  • darkGray
  • darkGreen
  • darkPurple
  • darkRed
  • gold
  • gray
  • green
  • lightPurple
  • materialAmethyst
  • materialCopper
  • materialDiamond
  • materialEmerald
  • materialGold
  • materialIron
  • materialLapis
  • materialNetherite
  • materialQuartz
  • materialRedstone
  • minecoinGold
  • red
  • yellow
  • white

TextColor Enum

Alternatively, you may apply colors using the color method, providing a TextColor member as an argument:

import { world } from "@minecraft/server";
import chroma, { TextColor } from "chroma";

const error = chroma.bold.color(TextColor.Red);

world.sendMessage(
  error("Oh no! Something went wrong.")
);

Modifiers

Using the following properties on a Chroma instance will return a new instance with the appropriate modifier formatting applied:

  • bold
  • italic
  • obfuscated
  • reset (also resets all previously chained options)

Other Notes

Calling a Chroma instance will not only append a reset (§r) code to the end of the string, but also an additional §¬ code. This is done so that future Chroma calls on the string can identify the end of formatted sections to support format nesting. This §¬ code will not appear in the displayed text.

About

Chroma provides a readable scripting interface for Minecraft text formatting.

Resources

License

Stars

Watchers

Forks