https://github.com/janispritzkau/mc-chat-format
Formats JSON chat components of Minecraft with the corresponding translation.
https://github.com/janispritzkau/mc-chat-format
chat format formatting json minecraft typescript
Last synced: about 1 year ago
JSON representation
Formats JSON chat components of Minecraft with the corresponding translation.
- Host: GitHub
- URL: https://github.com/janispritzkau/mc-chat-format
- Owner: janispritzkau
- Created: 2019-08-06T09:24:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-02-16T21:38:32.000Z (over 5 years ago)
- Last Synced: 2025-03-25T11:11:17.462Z (over 1 year ago)
- Topics: chat, format, formatting, json, minecraft, typescript
- Language: TypeScript
- Homepage:
- Size: 108 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mc-chat-format
Translate and convert Minecraft's chat components into plain text or a string component.
```js
import { format, convert, flatten } from "mc-chat-format"
format({
translate: "death.attack.player.item",
with: ["jeb_", "Notch", { translate: "item.minecraft.wooden_shovel" }]
})
// ⮡ 'jeb_ was slain by Notch using Wooden Shovel'
flatten({ text: "1 ", extra: [{ text: "2", extra: [{ text: " 3" }] }] })
// ⮡ [ { text: '1 ' }, { text: '2' }, { text: ' 3' } ]
convert({
translate: "block.minecraft.comparator",
bold: true,
insertion: "Test"
}, { stripNonText: true })
// ⮡ { text: 'Redstone Comparator', bold: true }
format({
text: "§bHello §cworld",
bold: true
}, { useAnsiCodes: true })
// ⮡ '\x1b[1m\x1b[38;2;85;255;255mHello \x1b[38;2;255;85;85mworld\x1b[0m'
```