Skip to content

mcbe-mods/Utils

Repository files navigation

@mcbe-mods/utils

npm version npm downloads bundle License

Utility functions for Minecraft Bedrock Edition mod development.

Usage

Install:

npm install @mcbe-mods/utils
import { 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

API

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

License

MIT License © Lete114

About

Minecraft Bedrock Edition - Provide convenient and practical tools to improve the efficiency of mod development.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors