@bedrock-oss/stylish
Version:
A decorator package with for developing add-ons with Script API in Minecraft Bedrock Edition
40 lines (33 loc) • 1.26 kB
text/typescript
import { ItemComponentRegistry, BlockComponentRegistry } from '@minecraft/server';
/**
* Decorator – binds the method to the instance
* Equivalent to calling `this.method = this.method.bind(this);`
*/
declare function BindThis(_target: any, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
type ComponentCtor = {
componentId: string;
new (): any;
};
/**
* Decorator – attach to each component class to auto‐register it.
*/
declare function ItemComponent<T extends ComponentCtor>(ctor: T): void;
/**
* Decorator – attach to each component class to auto‐register it.
*/
declare function BlockComponent<T extends ComponentCtor>(ctor: T): void;
/**
* Registers V1 `worldInitialize` event and registers all components.
*/
declare function initV1(): void;
/**
* Registers V2 `startup` event and registers all components.
*/
declare function initV2(): void;
/**
* Registers all components.
* @param itemRegistry Item component registry
* @param blockRegistry Block component registry
*/
declare function registerAllComponents(itemRegistry: ItemComponentRegistry, blockRegistry: BlockComponentRegistry): void;
export { BindThis, BlockComponent, ItemComponent, initV1, initV2, registerAllComponents };