ReadonlycameraThis property can't be read in early-execution mode.
import { EasingType, system, world } from "@minecraft/server";
function runCutscene() {
for (const player of world.getPlayers()) {
const location = player.location;
player.camera.setCamera("minecraft:free", {
location: { x: location.x, y: location.y + 10, z: location.z },
rotation: { x: 90, y: 0 },
});
system.run(() => {
player.camera.setCamera("minecraft:free", {
location: player.getHeadLocation(),
rotation: player.getRotation(),
easeOptions: {
easeTime: 1.0,
easeType: EasingType.InCubic,
},
});
system.runTimeout(() => {
player.camera.clear();
player.runCommand("/inputpermission @s camera enabled");
player.runCommand("/inputpermission @s movement enabled");
}, 20);
});
player.runCommand("/inputpermission @s camera disabled");
player.runCommand("/inputpermission @s movement disabled");
}
}
runCutscene();
ReadonlyclientThis property can't be read in early-execution mode.
This property can't be edited in read-only mode.
This property can't be read in early-execution mode.
This is related to Operator Permission Levels (The op-permission-level setting in server.properties file in Minecraft Bedrock Dedicated Server).
This property determines the default permission level assigned to players when using the /op command. This affects which commands they can use unless explicitly set in permissions.json.
Allows only non-destructive, informational, and communication-related commands. Ideal for minimal permissions.
Example level 0 commands: /help, /tell
Adds access to gameplay-related commands such as gamemode changes, teleporting, and giving items. Suitable for creative players or minor helpers.
Example level 1 commands: /aimassist, /camera
Example level 2 commands: /op, /deop
Grants access to moderation tools like kicking and banning players. Useful for server moderators or staff.
Provides some access to server and management commands. This is the command permission level for the host when launching a Minecraft world from the client.
Example level 3 command: /setmaxplayers
Provides full access to all server and management commands. Intended only for server owners or trusted administrators.
Example level 4 commands: /changesetting, /stop
Additional info by Visual1mpact
ReadonlydimensionThis property can't be read in early-execution mode.
ReadonlygraphicsThis property can't be read in early-execution mode.
ReadonlyidReadonlyinputReadonlyinputReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
This property can't be edited in read-only mode.
This property can't be read in early-execution mode.
import { system, world } from "@minecraft/server";
system.runInterval(() => {
for (const entity of world.getDimension("overworld").getEntities()) {
// Force entity to not sneak
entity.isSneaking = false;
}
});
import { DimensionLocation, MolangVariableMap, Vector3, system, world } from "@minecraft/server";
function spawnConfetti(location: DimensionLocation) {
for (let i = 0; i < 100; i++) {
const molang = new MolangVariableMap();
molang.setColorRGB("variable.color", {
red: Math.random(),
green: Math.random(),
blue: Math.random(),
});
const newLocation: Vector3 = {
x: location.x + Math.floor(Math.random() * 8) - 4,
y: location.y + Math.floor(Math.random() * 8) - 4,
z: location.z + Math.floor(Math.random() * 8) - 4,
};
location.dimension.spawnParticle("minecraft:colored_flame_particle", newLocation, molang);
}
}
system.runInterval(() => {
for (const player of world.getPlayers()) {
if (player.isSneaking) {
spawnConfetti({
dimension: player.dimension,
x: player.location.x,
y: player.location.y,
z: player.location.z,
});
player.sendMessage("player is sneaking");
}
}
});
ReadonlyisThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
Readonlyisimport { system, world } from "@minecraft/server";
const zombie = world.getDimension("overworld").spawnEntity("minecraft:zombie", world.getDefaultSpawnLocation());
const id = system.runInterval(() => {
if (!zombie.isValid) {
system.clearRun(id);
return;
}
const location = zombie.location;
for (const player of world.getPlayers()) {
player.sendMessage(
`Zombie location: (${location.x.toFixed(2)}, ${location.y.toFixed(2)}, ${location.z.toFixed(2)})`
);
}
});
ReadonlylevelThis property can't be read in early-execution mode.
ReadonlylocalizationThis property can't be read in early-execution mode.
ReadonlylocationThis property can't be read in early-execution mode.
ReadonlynameThis property can't be read in early-execution mode.
This property can't be edited in read-only mode.
This property can't be read in early-execution mode.
ReadonlyonThis property can't be read in early-execution mode.
import { world } from "@minecraft/server";
for (const player of world.getAllPlayers()) {
player.onScreenDisplay.setActionBar("Hello World");
}
import { HudElement, world } from "@minecraft/server";
for (const player of world.getAllPlayers()) {
player.onScreenDisplay.hideAllExcept([HudElement.Hotbar]);
}
ReadonlyplayerThis property can't be read in early-execution mode.
Optional ReadonlyscoreboardThis property can't be edited in read-only mode.
This property can't be read in early-execution mode.
ReadonlytotalThis property can't be read in early-execution mode.
import { Player, system, world } from "@minecraft/server";
function countdownFromTen(player: Player) {
player.addLevels(-10000);
player.addLevels(11);
const id = system.runInterval(() => {
player.addExperience(Math.round(-player.totalXpNeededForNextLevel / 10));
if (player.getTotalXp() === 0) {
system.clearRun(id);
}
if (player.xpEarnedAtCurrentLevel == 0) {
player.addLevels(-1);
player.addExperience(player.totalXpNeededForNextLevel - 1);
}
}, 2);
}
for (const player of world.getPlayers()) {
countdownFromTen(player);
}
Readonlytypeimport { system, world } from "@minecraft/server";
// This event triggers when world is loaded
system.runInterval(() => {
const entity = world.getDimension("overworld").getEntities()[0];
// Finally, show that location as title
entity.runCommand(
`title @a actionbar X: ${Math.floor(entity.location.x)} | Y: ${Math.floor(entity.location.y)} | Z: ${Math.floor(
entity.location.z
)}`
);
});
ReadonlyxpThis property can't be read in early-execution mode.
Optionaloptions: EntityEffectOptionsThis function can't be called in read-only mode.
This function can throw errors.
minecraftcommon.ArgumentOutOfBoundsError
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { Player, world } from "@minecraft/server";
// Command equivalent to /xp player 100
function addExperience(player: Player) {
const xpAdded = player.addExperience(100);
console.log(`Player ${player.name} now has ${xpAdded} experience points.`);
}
for (const player of world.getPlayers()) {
addExperience(player);
}
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
The following example (updated of the above - bounceSkeleton.ts) spawns several mobs, then applies a knockback to all skeletons.
import { EntityQueryOptions, DimensionLocation } from "@minecraft/server";
function bounceSkeletons(targetLocation: DimensionLocation) {
const mobs = ["creeper", "skeleton", "sheep"];
const horizontalForce = { x: 5, z: 4 }; // horizontal knockback strength - xz vector
const verticalStrength = 0.3; // upward knockback strength
// Spawn 10 mobs in a pattern
for (let i = 0; i < 10; i++) {
targetLocation.dimension.spawnEntity(
mobs[i % mobs.length],
targetLocation
);
}
const eqo: EntityQueryOptions = { type: "skeleton" };
// Apply knockback to all skeletons in the area
for (const entity of targetLocation.dimension.getEntities(eqo)) {
entity.applyKnockback(horizontalForce, verticalStrength);
}
}
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionaluseEffects: booleanDefaults to: true
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: GetBlocksStandingOnOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: BlockRaycastOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { world } from "@minecraft/server";
for (const entity of world.getDimension("overworld").getEntities()) {
const blockHit = entity.getBlockFromViewDirection();
if (blockHit) {
console.log("Block Hit:");
console.log("Block:", blockHit.block);
console.log("Face:", blockHit.face);
console.log("Face Location:", JSON.stringify(blockHit.faceLocation));
} else {
console.log("No block in view direction.");
}
}
import { BlockPermutation, world } from "@minecraft/server";
const entity = world.getDimension("overworld").spawnEntity("minecraft:fox", { x: 0, y: 0, z: 0 });
const blockHit = entity.getBlockFromViewDirection();
if (blockHit) {
blockHit.block.setPermutation(BlockPermutation.resolve("minecraft:bedrock"));
} else {
console.log("No block in view direction.");
}
Optionaloptions: GetBlocksStandingOnOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { world } from "@minecraft/server";
for (const player of world.getPlayers()) {
const health = player.getComponent("health");
player.sendMessage("Your health is " + health.currentValue + "/" + health.effectiveMax);
health.setCurrentValue(15); // set player to 15 hp
health.resetToMaxValue(); // reset player to max hp
}
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { Vector3, system, world } from "@minecraft/server";
world.afterEvents.entitySpawn.subscribe((event) => {
event.entity.setDynamicProperty("spawn_location", event.entity.location); // set location spawn
});
world.beforeEvents.entityRemove.subscribe((event) => {
const location = event.removedEntity.getDynamicProperty("spawn_location") as Vector3; // get location spawn
const dimension = event.removedEntity.dimension;
system.run(() => {
dimension.spawnEntity<string>(event.removedEntity.typeId, location);
});
});
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { Player, system } from "@minecraft/server";
system.afterEvents.scriptEventReceive.subscribe((event) => {
// Type /scriptevent bp:entries to see this message
if (event.id === "bp:entries" && event.sourceEntity instanceof Player) {
event.sourceEntity.sendMessage("Here's your dynamic properties entries:");
// Display all dynamic properties
for (const id of event.sourceEntity.getDynamicPropertyIds()) {
event.sourceEntity.sendMessage(`- ${id}: ${event.sourceEntity.getDynamicProperty(id)}`);
}
}
});
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { Player, system } from "@minecraft/server";
system.afterEvents.scriptEventReceive.subscribe((event) => {
// Type /scriptevent dp:size to see this message
if (event.id === "dp:size" && event.sourceEntity instanceof Player) {
// Returns the total size, in bytes, of all the dynamic properties that are currently stored for this entity.
const byteCount = event.sourceEntity.getDynamicPropertyTotalByteCount();
// Send the byte count to the player
event.sourceEntity.sendMessage(`Dynamic Properties Byte Count: ${byteCount}`);
}
});
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { Player, world } from "@minecraft/server";
/**
@param {Player} player
/
function hasNightVision(player) {
const nightVision = player.getEffect("night_vision");
if (nightVision) {
return true;
} else return false;
}
for (const player of world.getAllPlayers()) {
if (hasNightVision(player)) {
player.sendMessage("You have night vision.");
} else {
player.sendMessage("You don't have night vision.");
}
}
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionaloptions: EntityRaycastOptionsThis function can't be called in read-only mode.
This function can throw errors.
minecraftcommon.InvalidArgumentError
minecraftcommon.UnsupportedFunctionalityError
This function can't be called in early-execution mode.
import type { EntityRaycastOptions } from "@minecraft/server";
import { world } from "@minecraft/server";
// Optional: Configure ray cast options
const raycastOptions: EntityRaycastOptions = {
maxDistance: 10, // Set your desired maximum distance
};
// Perform the ray cast
for (const entity of world.getDimension("overworld").getEntities()) {
const entitiesInView = entity.getEntitiesFromViewDirection(raycastOptions);
// Log the results
entitiesInView.forEach((hit) => {
console.log(`Entity hit at distance ${hit.distance} blocks.`);
console.log("Entity details:", hit.entity); // You can access properties/methods of the hit entity
});
}
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { world } from "@minecraft/server";
world.beforeEvents.chatSend.subscribe((event) => {
const message = event.message;
const player = event.sender;
if (message === "rotation get") {
event.cancel = true;
const rotation = player.getRotation();
player.sendMessage(`Spawn point location: ${rotation.x} ${rotation.y}`);
}
});
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { world } from "@minecraft/server";
world.beforeEvents.chatSend.subscribe((event) => {
const message = event.message;
const player = event.sender;
if (message === "spawnpoint get") {
event.cancel = true;
const spawnPoint = player.getSpawnPoint();
if (spawnPoint) {
player.sendMessage(
`Spawn point location: ${spawnPoint.x} ${spawnPoint.y} ${spawnPoint.z} at ${spawnPoint.dimension.id}`
);
} else {
player.sendMessage(`No spawn point set.`);
}
}
});
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can throw errors.
minecraftcommon.InvalidArgumentError
minecraftcommon.UnsupportedFunctionalityError
This function can't be called in early-execution mode.
import { GameMode, system, world } from "@minecraft/server";
system.runInterval(() => {
for (const player of world.getAllPlayers()) {
const isSpectating = player.matches({ gameMode: GameMode.Spectator });
if (isSpectating) {
player.onScreenDisplay.setActionBar("You are spectating");
}
}
});
Optionaloptions: PlayAnimationOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalmusicOptions: MusicOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalsoundOptions: PlayerSoundOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalmusicOptions: MusicOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { Player } from "@minecraft/server";
// Surely someone enjoy minecraft ambient music
const allMusic = [
"music.overworld.bamboo_jungle",
"music.overworld.bamboo_jungle",
"music.game.basalt_deltas",
"music.game_and_wild_equal_chance",
"music.game_and_wild_equal_chance",
"music.game_and_wild_favor_game",
"music.overworld.cherry_grove",
"music.game.creative",
"music.game.credits",
"music.game.crimson_forest",
"music.overworld.deep_dark",
"music.overworld.desert",
"music.overworld.desert",
"music.overworld.desert",
"music.overworld.dripstone_caves",
"music.game.end",
"music.game.endboss",
"music.overworld.flower_forest",
"music.game_and_wild_equal_chance",
"music.game.frozen_peaks",
"music.game",
"music.overworld.grove",
"music.game.nether_wastes",
"music.overworld.jagged_peaks",
"music.overworld.jungle",
"music.overworld.jungle_edge",
"music.overworld.jungle",
"music.overworld.jungle",
"music.game_and_wild_equal_chance",
"music.overworld.lush_caves",
"music.game.swamp_music",
"music.game.meadow",
"music.game_and_wild_favor_game",
"music.menu",
"music.overworld.mesa",
"music.overworld.mesa",
"music.overworld.mesa",
"music.game.nether",
"music.game_and_wild_favor_game",
"music.game_and_wild_favor_game",
"music.game_and_wild_equal_chance",
"music.game_and_wild_equal_chance",
"music.overworld.snowy_slopes",
"music.game.soulsand_valley",
"music.overworld.stony_peaks",
"music.game.swamp_music",
"music.game.swamp_music",
"music.game.water",
];
function queueAllMusic(player: Player) {
for (const musicTrackId of allMusic) {
player.queueMusic(musicTrackId, { fade: 1.0 });
}
}
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalcontrolScheme: ControlSchemeThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
Optionalvalue: string | number | boolean | Vector3This function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { Vector3, system, world } from "@minecraft/server";
world.afterEvents.entitySpawn.subscribe((event) => {
event.entity.setDynamicProperty("spawn_location", event.entity.location); // set location spawn
});
world.beforeEvents.entityRemove.subscribe((event) => {
const location = event.removedEntity.getDynamicProperty("spawn_location") as Vector3; // get location spawn
const dimension = event.removedEntity.dimension;
system.run(() => {
dimension.spawnEntity<string>(event.removedEntity.typeId, location);
});
});
OptionalgameMode: GameModeThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionaluseEffects: booleanDefaults to: true
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can throw errors.
minecraftcommon.ArgumentOutOfBoundsError
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalspawnPoint: DimensionLocationThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalmolangVariables: MolangVariableMapThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalteleportOptions: TeleportOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
import { system, world } from "@minecraft/server";
system.afterEvents.scriptEventReceive.subscribe(({ sourceEntity, message }) => {
if (!sourceEntity) return;
if (message === "tp:nether") {
sourceEntity.teleport({ x: 0, y: 0, z: 0 }, { dimension: world.getDimension("nether") });
}
});
import { system, world } from "@minecraft/server";
system.afterEvents.scriptEventReceive.subscribe(({ sourceEntity, message }) => {
if (!sourceEntity) return;
if (message === "tp:nether") {
sourceEntity.teleport(
{ x: 0, y: 0, z: 0 },
{
dimension: world.getDimension("nether"),
facingLocation: { x: 100, y: 100, z: 100 },
}
);
}
});
This function can't be called in read-only mode.
This function can't be called in early-execution mode.
OptionalteleportOptions: TeleportOptionsThis function can't be called in read-only mode.
This function can't be called in early-execution mode.
Example: messageEveryPlayer.js