Utility functions for Minecraft Bedrock Edition mod development.
Install:
npm install @mcbe-mods/utilsimport { calcGameTicks, color, Experience, getRadiusRange, getRandomProbability, getRandomRangeValue, splitGroups } from '@mcbe-mods/utils'
// splitGroups - split items into stacks
splitGroups(65) // => [64, 1]
splitGroups(140) // => [64, 64, 12]
// color - Minecraft formatting codes
color.green.italic.bold('Dedicated Ser') + color.reset('ver') + color.red.obfuscated('!!!')
// => '§a§o§lDedicated Ser§rver§c§k!!!'
// Experience - player XP calculation
const exp = new Experience()
exp.addXP(100)
exp.getLevel() // => 7
// calcGameTicks - time to ticks
calcGameTicks(1000) // => 20
// getRadiusRange - block position range
getRadiusRange({ x: 0, y: 0, z: 0 }, 1) // => 27 positions| Function | Description |
|---|---|
splitGroups(sum, groupSize?) |
Split a number into groups of a given size |
color |
Minecraft color/formatting code stylizer |
Experience |
Player experience calculator (leveling up) |
calcGameTicks(ms?, ticksPerSec?, msPerSec?) |
Convert real time to game ticks |
getRadiusRange(location, radius?) |
Get block positions within a radius |
getRandomProbability(probability) |
Random chance with percentage |
getRandomRangeValue(min, max) |
Random integer within a range |