Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/protocol/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ export class Protocol {
return off
}

/** @deprecated Use `on` instead. */
onReceive(handler: (event: BedrockReceiveEvent) => void, options?: { sourceType?: ScriptEventSource }): () => void {
return options ? this.on(handler, options) : this.on(handler)
}

dispose(): void {
this.#subscriptions.clear()
if (this.#listener) {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export { Protocol } from '@mcbe-mods/protocol'
export type { BedrockReceiveEvent, ProtocolCipher, ProtocolOptions } from '@mcbe-mods/protocol'
export { RPC } from '@mcbe-mods/rpc'
export type { RPCOptions } from '@mcbe-mods/rpc'
export { Base64, calcGameTicks, Color, color, Experience, getCubeRange, getRadiusRange, getRandomProbability, getRandomRangeValue, getSphereRange, ms2ticks, splitGroups, unique, utf8Decode, utf8Encode } from '@mcbe-mods/utils'
export { Base64, Color, Experience, getCubeRange, getRandomProbability, getRandomRangeValue, getSphereRange, ms2ticks, splitGroups, unique, utf8Decode, utf8Encode } from '@mcbe-mods/utils'
export type { Location, StyleId, Stylizer } from '@mcbe-mods/utils'
3 changes: 0 additions & 3 deletions packages/utils/src/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,3 @@ function createStylizer(extend: string[]): Stylizer {
* ```
*/
export const Color = /* #__PURE__ */ createStylizer([])

/** @deprecated Use `Color` instead. */
export const color = Color
5 changes: 0 additions & 5 deletions packages/utils/src/getRadiusRange.ts

This file was deleted.

5 changes: 2 additions & 3 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
export { Base64 } from './base64'
export { Color, color } from './color'
export { Color } from './color'
export type { StyleId, Stylizer } from './color'
export { Experience } from './Experience'
export { getCubeRange, getSphereRange } from './getCubeRange'
export type { Location } from './getCubeRange'
export { getRadiusRange } from './getRadiusRange'
export { getRandomProbability } from './getRandomProbability'
export { getRandomRangeValue } from './getRandomRangeValue'
export { calcGameTicks, ms2ticks } from './ms2ticks'
export { ms2ticks } from './ms2ticks'
export { splitGroups } from './splitGroups'
export { utf8Decode, utf8Encode } from './textCodec'
export { unique } from './unique'
3 changes: 0 additions & 3 deletions packages/utils/src/ms2ticks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@
export function ms2ticks(milliseconds: number = 1000, gameTicksPerSecond: number = 20, millisecondsPerSecond: number = 1000): number {
return Math.floor(milliseconds * gameTicksPerSecond / millisecondsPerSecond)
}

/** @deprecated Use `ms2ticks` instead. */
export const calcGameTicks = ms2ticks
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,5 @@ export declare function utf8Encode(_: string): Uint8Array;
// #endregion

// #region Variables
export declare const calcGameTicks: typeof ms2ticks;
export declare const color: Stylizer;
export declare const Color: Stylizer;
export declare const getRadiusRange: typeof getCubeRange;
// #endregion
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,5 @@ export function utf8Encode(_) {}
// #endregion

// #region Variables
export var calcGameTicks /* const */
export var color /* const */
export var Color /* const */
export var getRadiusRange /* const */
// #endregion
18 changes: 9 additions & 9 deletions packages/utils/test/color.test.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { describe, expect, it } from 'vitest'
import { color } from '../src/index'
import { Color } from '../src/index'

describe('color', () => {
describe('Color', () => {
it('single color', () => {
expect(color.green('hello')).toBe('§ahello')
expect(Color.green('hello')).toBe('§ahello')
})

it('color + style chaining', () => {
expect(color.green.italic.bold('hello')).toBe('§a§o§lhello')
expect(Color.green.italic.bold('hello')).toBe('§a§o§lhello')
})

it('multiple arguments', () => {
expect(color.green('hello', ' world')).toBe('§ahello world')
expect(Color.green('hello', ' world')).toBe('§ahello world')
})

it('with reset', () => {
expect(color.green.italic.bold('Dedicated Ser') + color.reset('ver') + color.red.obfuscated('!!!'))
expect(Color.green.italic.bold('Dedicated Ser') + Color.reset('ver') + Color.red.obfuscated('!!!'))
.toBe('§a§o§lDedicated Ser§rver§c§k!!!')
})

it('starts a new chain after calling', () => {
const red = color.red
const green = color.green
const red = Color.red
const green = Color.green
expect(red('a')).toBe('§ca')
expect(green('b')).toBe('§ab')
})

it('unknown property access returns undefined', () => {
expect((color as any).unknown).toBeUndefined()
expect((Color as any).unknown).toBeUndefined()
})
})
8 changes: 1 addition & 7 deletions packages/utils/test/getRadiusRange.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { getCubeRange, getRadiusRange, getSphereRange } from '../src/index'
import { getCubeRange, getSphereRange } from '../src/index'

describe('getCubeRange', () => {
it('radius 0 returns only center', () => {
Expand Down Expand Up @@ -34,12 +34,6 @@ describe('getCubeRange', () => {
const keys = positions.map(p => `${p.x},${p.y},${p.z}`)
expect(new Set(keys).size).toBe(positions.length)
})

it('getRadiusRange is a deprecated alias', () => {
expect(getRadiusRange).toBe(getCubeRange)
const result = getRadiusRange({ x: 1, y: 2, z: 3 }, 1)
expect(result).toHaveLength(27)
})
})

describe('getSphereRange', () => {
Expand Down
Loading