lazuli-api
Version:
Add some useful instances for Minecraft Bedrock Edition
93 lines (88 loc) • 2.43 kB
text/typescript
import { ItemUseAfterEvent } from "@minecraft/server";
/**
* A simple prop *(an item that can be used)* , can only be used once.
* @category Need Registry
*/
export class Prop {
constructor(
/**
* Identifier of the type of items for the stack. If a namespace is not specified, 'minecraft:' is assumed.
*/
readonly typeId: string,
/**
* The event when an item is successfully used by a player.
*/
public useEvent?: (arg: ItemUseAfterEvent) => void
) {}
/**
* Registry the prop.
* @deprecated Use `Register.propRegistry()` to registry the prop
*/
protected register() {
console.warn("[Lazuli] The register method was deprecated!");
}
}
/**
* A prop *(an item that can be used)* , Its durability is consumed after use.
* @category Need Registry
*/
export class DurabilityLimitedProp extends Prop {
constructor(
/**
* Identifier of the type of items for the stack. If a namespace is not specified, 'minecraft:' is assumed.
*/
readonly typeId: string,
/**
* The durability to be consumed.
*/
public durabilityValue: number,
/**
* The event when an item is successfully used by a player.
*/
public useEvent?: (arg: ItemUseAfterEvent) => void
) {
super(typeId, useEvent);
}
}
/**
* A prop *(an item that can be used)* , it has a limited number of uses.
* @category Need Registry
*/
export class NumberLimitedProp extends Prop {
constructor(
/**
* Identifier of the type of items for the stack. If a namespace is not specified, 'minecraft:' is assumed.
*/
readonly typeId: string,
/**
* Options of the prop.
*/
public options: NumberLimitedPropOptions,
/**
* The event when an item is successfully used by a player.
*/
public useEvent?: (arg: ItemUseAfterEvent) => void
) {
super(typeId, useEvent);
}
/**
* Registry the prop.
* @deprecated Use `Register.propRegistry()` to registry the prop.
*/
protected register() {
console.warn("[Lazuli] The register method was deprecated!");
}
}
/**
* Options of the prop.
*/
export interface NumberLimitedPropOptions {
/**
* The maximum use value of the item.
*/
maxUse: number;
/**
* Consumed use value when use the item, default is `1`.
*/
onceConsumed?: number;
}