UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

592 lines (591 loc) 18.5 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Block_1 = __importDefault(require("../minecraft/Block")); const Effect_1 = __importDefault(require("../minecraft/Effect")); const NavigationResult_1 = require("../minecraft/NavigationResult"); const Player_1 = __importDefault(require("../minecraft/Player")); /** * A simulated player can be used within GameTests to represent * how a player moves throughout the world and to support * testing of how entities and the environment will react to a * player. This type derives much of its structure and methods * from the {@link mojang-minecraft.Player} type. */ class SimulatedPlayer extends Player_1.default { /** * Rotation of the body in degrees. Range is between -180 and * 180 degrees. * @throws This property can throw when used. */ "bodyRotation"; /** * Dimension that the simulated player is currently within. * @throws This property can throw when used. */ "dimension"; /** * Rotation of the head across pitch and yaw angles. * @throws This property can throw when used. */ "headRotation"; /** * True if the player is currently using a sneaking movement. */ "isSneaking"; /** * Current location of the player. * @throws This property can throw when used. */ "location"; /** * Name of the player. * @throws This property can throw when used. */ "name"; /** * Optional name tag of the player. */ "nameTag"; /** * Manages the selected slot in the player's hotbar. */ "selectedSlot"; /** * Retrieves or sets an entity that is used as the target of * AI-related behaviors, like attacking. */ "target"; /** * Current speed of the player across X, Y, and Z dimensions. * @throws This property can throw when used. */ "velocity"; /** * @remarks * Adds an effect, like poison, to the entity. * @param effectType * Type of effect to add to the entity. * @param duration * Amount of time, in seconds, for the effect to apply. * @param amplifier * Optional amplification of the effect to apply. * @throws This function can throw errors. */ addEffect(effectType, duration, amplifier) { } /** * @remarks * Adds a specified tag to a simulated player. * @param tag * Content of the tag to add. * @throws This function can throw errors. */ addTag(tag) { return false; } /** * @remarks * Causes the simulated player to make an attack 'swipe'. * Returns true if the attack was performed - for example, the * player was not on cooldown and had a valid target. Target * selection is performed by raycasting from the player's head. * @throws This function can throw errors. */ attack() { return false; } /** * @remarks * Causes the simulated player to attack the provided target. * Returns true if the attack was performed - for example, the * player was not on cooldown and had a valid target. The * attack can be performed at any distance and does not require * line of sight to the target entity. * @param entity * @throws This function can throw errors. */ attackEntity(entity) { return false; } /** * @remarks * Destroys the block at blockLocation, respecting the rules of * the server player's game mode. The block will be hit until * broken, an item is used or stopBreakingBlock is called. * Returns true if the block at blockLocation is solid. * @param blockLocation * Location of the block to interact with. * @param direction * Direction to place the specified item within. * @throws This function can throw errors. */ breakBlock(blockLocation, direction) { return false; } /** * @remarks * Gets the first block that intersects with the vector of the * view of this entity. * @param options * Additional options for processing this raycast query. * @throws This function can throw errors. */ getBlockFromViewVector(options) { return new Block_1.default(); } /** * @remarks * Gets a component (that represents additional capabilities) * for an entity. * @param componentId * The identifier of the component (e.g., 'minecraft:rideable') * to retrieve. If no namespace prefix is specified, * 'minecraft:' is assumed. If the component is not present on * the entity, undefined is returned. */ getComponent(componentId) { return undefined; } /** * @remarks * Returns all components that are both present on this entity * and supported by the API. */ getComponents() { return []; } /** * @remarks * Returns the effect for the specified EffectType on the * entity, or undefined if the effect is not present. * @param effectType * @returns * Effect object for the specified effect, or undefined if the * effect is not present. * @throws This function can throw errors. */ getEffect(effectType) { return new Effect_1.default(); } /** * @remarks * Gets the first entity that intersects with the vector of the * view of this entity. * @param options * Additional options for processing this raycast query. * @throws This function can throw errors. */ getEntitiesFromViewVector(options) { return []; } /** * @remarks * Gets the current item cooldown time for a particular * cooldown category. * @param itemCategory * Specifies the cooldown category to retrieve the current * cooldown for. * @throws This function can throw errors. */ getItemCooldown(itemCategory) { return 0; } /** * @remarks * Returns all tags associated with this simulated player. * @throws This function can throw errors. */ getTags() { return []; } /** * @remarks * Gives the simulated player a particular item stack. * @param itemStack * Item to give. * @param selectSlot * Whether to set the selected slot once given. * @throws This function can throw errors. */ giveItem(itemStack, selectSlot) { return false; } /** * @remarks * Returns true if the specified component is present on this * entity. * @param componentId * The identifier of the component (e.g., 'minecraft:rideable') * to retrieve. If no namespace prefix is specified, * 'minecraft:' is assumed. */ hasComponent(componentId) { return false; } /** * @remarks * Tests whether a simulated player has a particular tag. * @param tag * Identifier of the tag to test for. * @throws This function can throw errors. */ hasTag(tag) { return false; } /** * @remarks * Performs a raycast from the player’s head and interacts with * the first intersected block or entity. Returns true if the * interaction was successful. Maximum range is 6 blocks. * @throws This function can throw errors. */ interact() { return false; } /** * @remarks * Causes the simulated player to interact with a block. The * block at the specified block location must be solid. Returns * true if the interaction was performed. * @param blockLocation * Location of the block to interact with. * @param direction * Direction to place the specified item within. * @throws This function can throw errors. */ interactWithBlock(blockLocation, direction) { return false; } /** * @remarks * Causes the simulated player to interact with a mob. Returns * true if the interaction was performed. * @param entity * Entity to interact with. * @throws This function can throw errors. */ interactWithEntity(entity) { return false; } /** * @remarks * Causes the simulated player to jump. * @returns * True if a jump was performed. * @throws This function can throw errors. */ jump() { return false; } /** * @remarks * Kills this entity. The entity will drop loot as normal. * @throws This function can throw errors. */ kill() { } /** * @remarks * Rotates the simulated player's head/body to look at the * given block location. * @param blockLocation * @throws This function can throw errors. */ lookAtBlock(blockLocation) { } /** * @remarks * Rotates the simulated player's head/body to look at the * given entity. * @param entity * @throws This function can throw errors. */ lookAtEntity(entity) { } /** * @remarks * Rotates the simulated player's head/body to look at the * given location. * @param location * @throws This function can throw errors. */ lookAtLocation(location) { } /** * @remarks * Orders the simulated player to walk in the given direction * relative to the GameTest. * @param westEast * @param northSouth * @param speed * @throws This function can throw errors. */ move(westEast, northSouth, speed) { } /** * @remarks * Orders the simulated player to walk in the given direction * relative to the player's current rotation. * @param leftRight * @param backwardForward * @param speed * @throws This function can throw errors. */ moveRelative(leftRight, backwardForward, speed) { } /** * @remarks * Orders the simulated player to move to the given block * location in a straight line. If a move or navigation is * already playing, this will override the last * move/navigation. * @param blockLocation * @param speed * @throws This function can throw errors. */ moveToBlock(blockLocation, speed) { } /** * @remarks * Orders the simulated player to move to the given location in * a straight line. If a move or navigation is already playing, * this will override the last move/navigation. * @param location * @param speed * @throws This function can throw errors. */ moveToLocation(location, speed) { } /** * @remarks * Orders the simulated player to move to a specific block * location using navigation. If a move or navigation is * already playing, this will override the last move/walk. Note * that if the simulated player gets stuck, that simulated * player will stop. The player must be touching the ground in * order to start navigation. * @param blockLocation * @param speed * @throws This function can throw errors. */ navigateToBlock(blockLocation, speed) { return new NavigationResult_1.NavigationResult(); } /** * @remarks * Will use navigation to follow the selected entity to within * a one block radius. If a move or navigation is already * playing, this will override the last move/navigation. * @param entity * @param speed * @throws This function can throw errors. */ navigateToEntity(entity, speed) { return new NavigationResult_1.NavigationResult(); } /** * @remarks * Orders the simulated player to move to a specific location * using navigation. If a move or navigation is already * playing, this will override the last move/walk. Note that if * the simulated player gets stuck, that simulated player will * stop. The player must be touching the ground in order to * start navigation. * @param location * @param speed * @throws This function can throw errors. */ navigateToLocation(location, speed) { return new NavigationResult_1.NavigationResult(); } /** * @remarks * Use navigation to follow the route provided via the * locations parameter. If a move or navigation is already * playing, this will override the last move/navigation. * @param locations * A list of locations to use for routing. * @param speed * Net speed to use for doing the navigation. * @throws This function can throw errors. */ navigateToLocations(locations, speed) { return; } /** * @remarks * Removes a specified tag from a simulated player. * @param tag * Content of the tag to remove. * @throws This function can throw errors. */ removeTag(tag) { return false; } /** * @remarks * Causes the simulated player to turn by the provided angle, * relative to the player's current rotation. * @param angleInDegrees * @throws This function can throw errors. */ rotateBody(angleInDegrees) { } /** * @remarks * Runs a particular command from the context of this simulated * player. * @param commandString * Command to run. Note that command strings should not start * with slash. * @returns * For commands that return data, returns a JSON structure with * command response values. * @throws This function can throw errors. * @example commands.js * ```typescript * player.runCommand("say You got a new high score!"); * player.runCommand("scoreboard players set @s score 10"); * * ``` */ runCommand(commandString) { return undefined; } /** * @remarks * Causes the simulated player to turn to face the provided * angle, relative to the GameTest. * @param angleInDegrees * @throws This function can throw errors. */ setBodyRotation(angleInDegrees) { } /** * @remarks * Sets the game mode that the simulated player is operating * under. * @param gameMode * Game mode to set. * @throws This function can throw errors. */ setGameMode(gameMode) { } /** * @remarks * Sets a particular item for the simulated player. * @param itemStack * Item to set. * @param slot * Slot to place the given item in. * @param selectSlot * Whether to set the selected slot once set. * @throws This function can throw errors. */ setItem(itemStack, slot, selectSlot) { return false; } /** * @remarks * Sets the item cooldown time for a particular cooldown * category. * @param itemCategory * Specifies the cooldown category to retrieve the current * cooldown for. * @param tickDuration * Duration in ticks of the item cooldown. * @throws This function can throw errors. */ startItemCooldown(itemCategory, tickDuration) { } /** * @remarks * Stops destroying the block that is currently being hit. * @throws This function can throw errors. */ stopBreakingBlock() { } /** * @remarks * Stops interacting with entities or blocks. * @throws This function can throw errors. */ stopInteracting() { } /** * @remarks * Stops moving/walking/following if the simulated player is * moving. * @throws This function can throw errors. */ stopMoving() { } /** * @remarks * Stops using the currently active item. * @throws This function can throw errors. */ stopUsingItem() { } /** * @remarks * Triggers an entity type event. For every entity, a number of * events are defined in an entities' definition for key entity * behaviors; for example, creepers have a * minecraft:start_exploding type event. * @param eventName * Name of the entity type event to trigger. If a namespace is * not specified, minecraft: is assumed. * @throws This function can throw errors. */ triggerEvent(eventName) { } /** * @remarks * Causes the simulated player to use an item. Does not consume * the item. Returns false if the item is on cooldown. * @param itemStack * Item to use. * @throws This function can throw errors. */ useItem(itemStack) { return false; } /** * @remarks * Causes the simulated player to hold and use an item in their * inventory. * @param slot * Index of the inventory slot. * @throws This function can throw errors. */ useItemInSlot(slot) { return false; } /** * @remarks * Causes the simulated player to use an item in their * inventory on a block. The block at the specified block * location must be solid. Returns true if the item was used. * @param slot * Index of the slot to use. * @param blockLocation * Location to use the item upon. * @param direction * Direction to place the specified item within. * @param faceLocationX * Block-face-relative X position where to place the item. * @param faceLocationY * Block-face-relative Y position where to place the item. * @throws This function can throw errors. */ useItemInSlotOnBlock(slot, blockLocation, direction, faceLocationX, faceLocationY) { return false; } /** * @remarks * Causes the simulated player to use an item on a block. The * block at the specified block location must be solid. Returns * true if the item was used. * @param itemStack * Item to use. * @param blockLocation * Location to use the item upon. * @param direction * Direction to place the specified item within. * @param faceLocationX * Block-face-relative X position where to place the item. * @param faceLocationY * Block-face-relative Y position where to place the item. * @throws This function can throw errors. */ useItemOnBlock(itemStack, blockLocation, direction, faceLocationX, faceLocationY) { return false; } } exports.default = SimulatedPlayer;