1.2.3 • Published 6 months ago

@bedrock-oss/bedrock-boost v1.2.3

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

bedrock-boost

npm version

A utility library to streamline the development process for Minecraft Bedrock's Script API, providing essential tools for vector operations, polyfills, and time measurements.

Features

  • Vec3 Class: Simplify and enhance 3D vector operations. Documentation
  • Cache Module: Caches dimension lookups, dimension height ranges, and block permutations to reduce costly native calls. Documentation
  • Polyfills:
    • playerPolyfill: Adds applyImpulse and clearVelocity methods to the Player class.
    • consolePolyfill: Overrides console.log to send messages to game chat.
  • Profiling Utilities: addIdleDummy and clearIdleDummy improve profiling accuracy by grouping idle time. Documentation
  • Timings Class: Granular time measurement with begin() and end().
  • Logging System: Flexible logging with levels, tags, filters, and scriptevent commands. Documentation
  • ChatColor Class: Simplify chat color formatting.
  • ColorJSON Class: Generate colored JSON for chat messages. Documentation
  • Scheduling: PulseScheduler, TaskPulseScheduler, UniquePulseScheduler, EntityPulseScheduler, and PlayerPulseScheduler for distributed task execution. Documentation
  • Utility Modules: Common utilities including BlockUtils, CommandUtils, DirectionUtils, EntitySaver, ItemUtils, JobUtils, VersionUtils, and VariableSender.
  • Vanilla Wrappers: Constants and helpers such as VanillaBlockTags, VanillaItemTags, and TimeOfDay.

Installation

npm install @bedrock-oss/bedrock-boost

Usage

Vec3 Class

Documentation

import { Vec3 } from "@bedrock-oss/bedrock-boost";
import { world } from "@minecraft/server";

world.beforeEvents.itemUse.subscribe((event) => {
  event.source.applyImpulse(Vec3.from(event.source.getViewDirection()).setY(0).normalize().multiply(2));
})

Logger

Documentation

import { Logger } from "@bedrock-oss/bedrock-boost"

const log = Logger.getLogger("main", "tag1", "tag2");
log.info("Hello, Minecraft World!");

It also includes 2 commands to control the logging system:

scriptevent logging:level <level either as string or as a number>
# or
scriptevent log:level <level either as string or as a number>

scriptevent logging:filter <comma separated tags>
# or
scriptevent log:filter <comma separated tags>

ChatColor and ColorJSON classes

Documentation

import { Logger } from "@bedrock-oss/bedrock-boost"

const log = Logger.getLogger("main", "tag1", "tag2");
log.info("Hello, Minecraft World!");

playerPolyfill

import { Direction, world } from "@minecraft/server";
import { Vec3 } from "@bedrock-oss/bedrock-boost";
import { Polyfill } from "@bedrock-oss/bedrock-boost"

Polyfill.installPlayer();

world.getAllPlayers().forEach(player => {
  // Apply an impulse to the player
  player.applyImpulse(Vec3.from(Direction.Up).multiply(2));
});

consolePolyfill

import { Polyfill } from "@bedrock-oss/bedrock-boost"

Polyfill.installConsole();

// Log messages in the game world
console.log("Hello, Minecraft World!");

Timings Class

import { Timings } from "@bedrock-oss/bedrock-boost"

Timings.begin("big operation 1");
// Some operations...
// Beginning another operation will automatically end the previous one
Timings.begin("big operation 2");
// Some operations...
Timings.end();

PulseScheduler

import { PulseScheduler } from "@bedrock-oss/bedrock-boost"

// Define a processor function to apply an effect to an entity
const applyEffect = (entity) => {
    // Example function applying an effect to the entity
    console.log(`Applying effect to entity: ${entity}`);
};

// Create a PulseScheduler with a 100-tick interval
const entityEffectScheduler = new PulseScheduler(applyEffect, 100);

// Add entities to the scheduler
entityEffectScheduler.add("Entity1");
entityEffectScheduler.add("Entity2");

// Start the scheduler to begin processing entities
entityEffectScheduler.start();

Contributing

Feel free to raise an issue or submit a pull request if you have any improvements or features to suggest.

License

This project is licensed under the MIT License.

1.2.0

7 months ago

1.1.1

8 months ago

1.0.2

9 months ago

1.1.0

8 months ago

1.0.1

9 months ago

1.0.0

10 months ago

1.2.3

6 months ago

1.2.2

6 months ago

1.2.1

7 months ago

1.0.3

8 months ago

0.1.2

11 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.5

10 months ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.15

1 year ago

0.0.16

1 year ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago