About this
Minecraft Bedrock Commands compilations.
Example
import { scoreboard, say } from '@mcbe/command';
import { system } from '@mcbe/system_server';
async function asyncfunc()
{
scoreboard.objectives.add("test");
scoreboard.players.set("dummy_player", "test", 100);
scoreboard.players.add("dummy_player", "test", 100);
scoreboard.objectives.setDisplay("sidebar", "test");
const get_value = await scoreboard.players.get("dummy_player", "test");
say(get_value);
}
let counter = 0;
system.update = ()=>{
counter ++;
if (counter === 20*5)
{
asyncfunc();
}
if (counter === 20*10)
{
scoreboard.objectives.remove('test');
}
};
References
const scoreboard = {
testInvalidCharacter(name:string):void,
testInvalid(name:string):void,
players:{
list():Promise<string[]>,
listOf(player:string):Promise<Scores>,
get(player:string, objective:string):Promise<number|undefined>,
reset(player:string, objective?:string):Promise<void>,
set(player:string, objective:string, count:number):Promise<void>,
add(player:string, objective:string, count:number):Promise<number>,
remove(player:string, objective:string, count:number):Promise<number>,
},
objectives: {
list():Promise<Objective[]>,
add(objective:string):Promise<CommandResult>,
remove(objective:string):Promise<CommandResult>,
setDisplay(type:'list'|'sidebar', objective?:string, order?:'ascending'|'descending'),
clear():Promise<void>,
}
};
interface CommandResult
{
statusCode:number;
statusMessage:string;
}
function say(message:string):Promise<CommandResult>;
function list():Promise<string[]>;
function kill(name:string):Promise<boolean>;
function fill(from:VectorXYZ, to:VectorXYZ, type:Identifier, dataId?:number):Promise<boolean>;
function fillx(from:VectorXYZ, to:VectorXYZ, type:Identifier, dataId?:number):Promise<void>;
function fillReplace(from:VectorXYZ, to:VectorXYZ,
type:Identifier, dataId:number,
typeFrom:Identifier, dataIdFrom:number):Promise<number>;
function testforblock(pos:VectorXYZ, type:Identifier):Promise<boolean>;
function setblock(to:VectorXYZ, type:Identifier, data?:number, option?:'destroy'|'keep'):Promise<boolean>;
function replaceBlock(pos:VectorXYZ, from:Identifier, to:Identifier):Promise<boolean>;
function tp(name:string, to:VectorXYZ):Promise<boolean>;
function titleTimes(name:string, fadeIn:number, stay:number, fadeOut:number):Promise<boolean>;
function titleReset(name:string):Promise<boolean>;
function title(name:string, type:'title'|'subtitle'|'actionbar', message:string):Promise<boolean>;
function titleAll(type:'title'|'subtitle'|'actionbar', message:string):Promise<boolean>;
function clear(name:string, item:Identifier, data?:number, count?:number):Promise<number>;
function clears(name:string, item:Identifier, datas:number[], count?:number):Promise<number>;
function give(name:string, item:Identifier, count?:number, data?:number):Promise<void>;
function getDayTime():Promise<number>;
function getItemCount(name:string, item:Identifier, data:number):Promise<number>;
function getItemCounts(name:string, item:Identifier, datas:number[]):Promise<number>;
function killEntities(mask?:{type?:Identifier}):Promise<string[]>;
function particle(id:string, pos:VectorXYZ):Promise<CommandResult>;
function spawnpoint(player:string, pos:VectorXYZ):Promise<CommandResult>;
function execute(player:string):UserCommander;
function commandError(res:CommandResult):Error;
const commander:Commander;