# Minecraft Bedrock Edition Script API - Detailed Guide
This document is a comprehensive guide to the Minecraft Bedrock Edition Script APIs.
It provides developers with a detailed understanding of the core elements, including enumerations, classes, methods, and practical examples.
You will find organized explanations, additional insights, and an extended breakdown of each feature, making it easier to implement these APIs effectively.
To get started, ensure that your environment is set up with the correct imports as shown below.
### Imports and Setup
// Type definitions for Minecraft Bedrock Edition script APIs
import * as minecraftcommon from '@minecraft/common';
* import { world } from "@minecraft/server";
* import { world, MinecraftBlockTypes, Items, ItemStack } from "@minecraft/server";
* import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server';
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
* import { world } from "@minecraft/server";
* import { DimensionLocation, BlockPermutation } from '@minecraft/server';
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
* import {
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
* import {
* import { DimensionLocation, BlockPermutation, BlockComponentTypes } from '@minecraft/server';
* import { MinecraftBlockTypes } from '@minecraft/vanilla-data';
* import {
* import { world, ButtonPushAfterEvent, system } from '@minecraft/server';
* import { world, ButtonPushAfterEvent, system } from '@minecraft/server';
* import { Player, EntityInventoryComponent, ItemStack } from '@minecraft/server';
* import { Player, EntityComponentTypes } from '@minecraft/server';
* import { Player, EntityComponentTypes } from '@minecraft/server';
* import { Player, EntityComponentTypes } from '@minecraft/server';
* import { DimensionLocation } from '@minecraft/server';
* import { DimensionLocation, EntityComponentTypes } from "@minecraft/server";
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
* import { DimensionLocation } from '@minecraft/server';
* import { DimensionLocation } from '@minecraft/server';
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
* import { ItemStack, DimensionLocation } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { world, MolangVariableMap, DimensionLocation, Vector3 } from '@minecraft/server';
* import {
* import { MinecraftEffectTypes } from '@minecraft/vanilla-data';
* import { DimensionLocation } from '@minecraft/server';
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
* import { Entity, EntityComponentTypes, system, world } from '@minecraft/server';
* import { Entity } from '@minecraft/server';
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
* import { Entity } from '@minecraft/server';
* import { world, Entity, EntityComponentTypes, system } from "@minecraft/server";
* import { DimensionLocation, system, world } from '@minecraft/server';
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
* import { EntityQueryOptions, DimensionLocation } from '@minecraft/server';
* import { world, Entity, EntityComponentTypes, system } from "@minecraft/server";
* import { world, system } from '@minecraft/server';
* import { DimensionLocation } from '@minecraft/server';
* import { MinecraftEntityTypes } from '@minecraft/vanilla-data';
* import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { Entity, EntityComponentTypes, system, world } from '@minecraft/server';
* import { DimensionLocation, EntityComponentTypes } from "@minecraft/server";
* import { world, Entity, EntityComponentTypes, system } from "@minecraft/server";
* import { world, Vector3 } from '@minecraft/server';
* import { world, EntitySpawnAfterEvent } from '@minecraft/server';
* import { world, EntitySpawnAfterEvent } from '@minecraft/server';
* import { EnchantmentType, ItemComponentTypes, ItemStack, Player } from '@minecraft/server';
* import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data';
* import { EnchantmentType, ItemComponentTypes, ItemStack, Player } from '@minecraft/server';
* import { MinecraftItemTypes, MinecraftEnchantmentTypes } from '@minecraft/vanilla-data';
* import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { ItemStack, DimensionLocation } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { ItemStack, Player, ItemComponentTypes, EntityComponentTypes } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { ItemStack, Player } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { ItemStack, Player, EntityComponentTypes } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { EntityComponentTypes, ItemStack, Player } from '@minecraft/server';
* import { MinecraftItemTypes } from '@minecraft/vanilla-data';
* import { world, system, LeverActionAfterEvent } from '@minecraft/server';
* import { world, system, LeverActionAfterEvent } from '@minecraft/server';
* import { world, system, PistonActivateAfterEvent } from '@minecraft/server';
* import { world, system, PistonActivateAfterEvent } from '@minecraft/server';
* import { Player } from "@minecraft/server";
* import { world, MolangVariableMap, Vector3 } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import { world, system } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import { world, system } from '@minecraft/server';
* import { system, world } from '@minecraft/server';
* import { system, world } from '@minecraft/server';
* import { BlockPermutation, DimensionLocation, world, ButtonPushAfterEvent, system } from '@minecraft/server';
* import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server';
* import { Vector3, world, BlockPermutation, TripWireTripAfterEvent, system } from '@minecraft/server';
* import * as mc from '@minecraft/server';
* import * as mc from '@minecraft/server';
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server';
* import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, Vector3 } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import { world } from '@minecraft/server';
* import * as mc from '@minecraft/server';
* import * as mc from '@minecraft/server';
* import { Dimension } from '@minecraft/server';
* import { Dimension } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { world, EntityQueryOptions } from '@minecraft/server';
* import { Dimension } from '@minecraft/server';
* import { Dimension, world } from '@minecraft/server';
* import { Dimension } from '@minecraft/server';
* import { DimensionLocation } from '@minecraft/server';
* import { DimensionLocation, world, BlockPermutation, BlockComponentTypes } from '@minecraft/server';
* import { world, Player } from '@minecraft/server';
* import { MessageFormData, MessageFormResponse } from '@minecraft/server-ui';
* import { world, system } from '@minecraft/server';
### Detailed Sections
This document is a fully human-readable guide to the Minecraft Bedrock Edition Script APIs.
It provides detailed explanations for all aspects, with practical examples and comprehensive descriptions.
Code examples are retained in their original format, while all other content is rewritten for clarity.
=========================
Overview
=========================
The Minecraft Bedrock Edition Script API allows developers to interact with the game world through programming.
It includes various enumerations, classes, and methods that define behaviors and interactions within the Minecraft environment.
This document covers every feature described in the original definitions.
// Project: https://docs.microsoft.com/minecraft/creator/
// Definitions by: Jake Shirley <https://github.com/JakeShirley>
// Mike Ammerlaan <https://github.com/mammerla>
/* *****************************************************************************
Copyright (c) Microsoft Corporation.
***************************************************************************** */
/**
* @packageDocumentation
* Contains many types related to manipulating a Minecraft
* world, including entities, blocks, dimensions, and more.
*
* Manifest Details
* ```json
* {
* "module_name": "@minecraft/server",
* "version": "1.10.0"
* }
* ```
*
*/
### Enumeration: BlockComponentTypes
This section details the purpose, properties, methods, and code examples for `Enumeration: BlockComponentTypes` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `BlockComponentTypes` contains predefined values for a specific purpose in Minecraft.
Inventory = 'minecraft:inventory',
LavaContainer = 'minecraft:lavaContainer',
Piston = 'minecraft:piston',
PotionContainer = 'minecraft:potionContainer',
RecordPlayer = 'minecraft:recordPlayer',
Sign = 'minecraft:sign',
SnowContainer = 'minecraft:snowContainer',
WaterContainer = 'minecraft:waterContainer',
}
/**
* An enumeration describing the state of a block piston.
*/
### Enumeration: BlockPistonState
This section details the purpose, properties, methods, and code examples for `Enumeration: BlockPistonState` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `BlockPistonState` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Whether the piston is fully expanded.
*
*/
Expanded = 'Expanded',
/**
- Explanation:
* Whether the piston is in the process of expanding.
*
*/
Expanding = 'Expanding',
/**
- Explanation:
* Whether the piston is fully retracted.
*
*/
Retracted = 'Retracted',
/**
- Explanation:
* Whether the piston is in the process of retracting.
*
*/
Retracting = 'Retracting',
}
/**
* @beta
* Description of the resulting intersection test on two
* BlockVolume objects
*/
### Enumeration: BlockVolumeIntersection
This section details the purpose, properties, methods, and code examples for `Enumeration: BlockVolumeIntersection` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `BlockVolumeIntersection` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* Volume B has no intersection points with Volume A
*
*/
Disjoint = 0,
/**
* @beta
- Explanation:
* Volume B resides completely inside Volume A
*
*/
Contains = 1,
/**
* @beta
- Explanation:
* Volume B partially intersects Volume A
*
*/
Intersects = 2,
}
/**
* @beta
* The Action enum determines how the CompoundBlockVolume
* considers the associated CompoundBlockVolumeItem when
* performing inside/outside calculations.
*/
### Enumeration: CompoundBlockVolumeAction
This section details the purpose, properties, methods, and code examples for `Enumeration: CompoundBlockVolumeAction` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `CompoundBlockVolumeAction` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* The associated BlockVolume is considered a positive space,
* and any intersection tests are considered hits
*
*/
Add = 0,
/**
* @beta
- Explanation:
* The associated BlockVolume is considered a negative or void
* space, and any intersection tests are considered misses.
* Using the Subtract action, it is possible to `punch holes`
* in block volumes so that any intersection tests may pass
* through such spaces
*
*/
Subtract = 1,
}
/**
* @beta
* An enum describing the relativity of the
* CompoundBlockVolumeItem, relative to the parent
* CompoundVolume.
*/
### Enumeration: CompoundBlockVolumePositionRelativity
This section details the purpose, properties, methods, and code examples for `Enumeration: CompoundBlockVolumePositionRelativity` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `CompoundBlockVolumePositionRelativity` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* The locations within the associated BlockVolume are relative
* to the CompoundBlockVolume to which they were added
*
*/
Relative = 0,
/**
* @beta
- Explanation:
* The locations within the associated BlockVolume are in
* absolute world space
*
*/
Absolute = 1,
}
/**
* @beta
* An enumeration for the various difficulty levels of
* Minecraft.
*/
### Enumeration: Difficulty
This section details the purpose, properties, methods, and code examples for `Enumeration: Difficulty` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `Difficulty` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* Peaceful difficulty level.
*
*/
Peaceful = 0,
/**
* @beta
- Explanation:
* Easy difficulty level.
*
*/
Easy = 1,
/**
* @beta
- Explanation:
* Normal difficulty level.
*
*/
Normal = 2,
/**
* @beta
- Explanation:
* Hard difficulty level.
*
*/
Hard = 3,
}
/**
* A general purpose relative direction enumeration.
*/
### Enumeration: Direction
This section details the purpose, properties, methods, and code examples for `Enumeration: Direction` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `Direction` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Returns the {@link Block} beneath (y - 1) of this item.
*
*/
Down = 'Down',
/**
- Explanation:
* Returns the {@link Block} to the east (x + 1) of this item.
*
*/
East = 'East',
/**
- Explanation:
* Returns the {@link Block} to the east (z + 1) of this item.
*
*/
North = 'North',
/**
- Explanation:
* Returns the {@link Block} to the south (z - 1) of this item.
*
*/
South = 'South',
/**
- Explanation:
* Returns the {@link Block} above (y + 1) of this item.
*
*/
Up = 'Up',
/**
- Explanation:
* Returns the {@link Block} to the west (x - 1) of this item.
*
*/
West = 'West',
}
/**
* Specifies a mechanism for displaying scores on a scoreboard.
*/
### Enumeration: DisplaySlotId
This section details the purpose, properties, methods, and code examples for `Enumeration: DisplaySlotId` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `DisplaySlotId` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Displays the score below the player's name.
*
*/
BelowName = 'BelowName',
/**
- Explanation:
* Displays the score as a list on the pause screen.
*
*/
List = 'List',
/**
- Explanation:
* Displays the score on the side of the player's screen.
*
*/
Sidebar = 'Sidebar',
}
/**
* Specifies different colors for use as dye.
*/
### Enumeration: DyeColor
This section details the purpose, properties, methods, and code examples for `Enumeration: DyeColor` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `DyeColor` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Black dye color.
*
*/
Black = 'Black',
/**
- Explanation:
* Blue dye color.
*
*/
Blue = 'Blue',
/**
- Explanation:
* Brown dye color.
*
*/
Brown = 'Brown',
/**
- Explanation:
* Cyan dye color.
*
*/
Cyan = 'Cyan',
/**
- Explanation:
* Gray dye color.
*
*/
Gray = 'Gray',
/**
- Explanation:
* Green dye color.
*
*/
Green = 'Green',
/**
- Explanation:
* Light blue dye color.
*
*/
LightBlue = 'LightBlue',
/**
- Explanation:
* Lime dye color.
*
*/
Lime = 'Lime',
/**
- Explanation:
* Magenta dye color.
*
*/
Magenta = 'Magenta',
/**
- Explanation:
* Orange dye color.
*
*/
Orange = 'Orange',
/**
- Explanation:
* Pink dye color.
*
*/
Pink = 'Pink',
/**
- Explanation:
* Purple dye color.
*
*/
Purple = 'Purple',
/**
- Explanation:
* Red dye color.
*
*/
Red = 'Red',
/**
- Explanation:
* Silver dye color.
*
*/
Silver = 'Silver',
/**
- Explanation:
* White dye color.
*
*/
White = 'White',
/**
- Explanation:
* Yellow dye color.
*
*/
Yellow = 'Yellow',
}
### Enumeration: EasingType
This section details the purpose, properties, methods, and code examples for `Enumeration: EasingType` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `EasingType` contains predefined values for a specific purpose in Minecraft.
InBack = 'InBack',
InBounce = 'InBounce',
InCirc = 'InCirc',
InCubic = 'InCubic',
InElastic = 'InElastic',
InExpo = 'InExpo',
InOutBack = 'InOutBack',
InOutBounce = 'InOutBounce',
InOutCirc = 'InOutCirc',
InOutCubic = 'InOutCubic',
InOutElastic = 'InOutElastic',
InOutExpo = 'InOutExpo',
InOutQuad = 'InOutQuad',
InOutQuart = 'InOutQuart',
InOutQuint = 'InOutQuint',
InOutSine = 'InOutSine',
InQuad = 'InQuad',
InQuart = 'InQuart',
InQuint = 'InQuint',
InSine = 'InSine',
Linear = 'Linear',
OutBack = 'OutBack',
OutBounce = 'OutBounce',
OutCirc = 'OutCirc',
OutCubic = 'OutCubic',
OutElastic = 'OutElastic',
OutExpo = 'OutExpo',
OutQuad = 'OutQuad',
OutQuart = 'OutQuart',
OutQuint = 'OutQuint',
OutSine = 'OutSine',
Spring = 'Spring',
}
/**
* @beta
*/
### Enumeration: EnchantmentSlot
This section details the purpose, properties, methods, and code examples for `Enumeration: EnchantmentSlot` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `EnchantmentSlot` contains predefined values for a specific purpose in Minecraft.
ArmorFeet = 'ArmorFeet',
ArmorHead = 'ArmorHead',
ArmorLegs = 'ArmorLegs',
ArmorTorso = 'ArmorTorso',
Axe = 'Axe',
Bow = 'Bow',
CarrotStick = 'CarrotStick',
CosmeticHead = 'CosmeticHead',
Crossbow = 'Crossbow',
Elytra = 'Elytra',
FishingRod = 'FishingRod',
Flintsteel = 'Flintsteel',
Hoe = 'Hoe',
Pickaxe = 'Pickaxe',
Shears = 'Shears',
Shield = 'Shield',
Shovel = 'Shovel',
Spear = 'Spear',
Sword = 'Sword',
}
### Enumeration: EntityComponentTypes
This section details the purpose, properties, methods, and code examples for `Enumeration: EntityComponentTypes` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `EntityComponentTypes` contains predefined values for a specific purpose in Minecraft.
AddRider = 'minecraft:addrider',
Ageable = 'minecraft:ageable',
Breathable = 'minecraft:breathable',
CanClimb = 'minecraft:can_climb',
CanFly = 'minecraft:can_fly',
CanPowerJump = 'minecraft:can_power_jump',
Color = 'minecraft:color',
Color2 = 'minecraft:color2',
Equippable = 'minecraft:equippable',
FireImmune = 'minecraft:fire_immune',
FloatsInLiquid = 'minecraft:floats_in_liquid',
FlyingSpeed = 'minecraft:flying_speed',
FrictionModifier = 'minecraft:friction_modifier',
GroundOffset = 'minecraft:ground_offset',
Healable = 'minecraft:healable',
Health = 'minecraft:health',
Inventory = 'minecraft:inventory',
IsBaby = 'minecraft:is_baby',
IsCharged = 'minecraft:is_charged',
IsChested = 'minecraft:is_chested',
IsDyeable = 'minecraft:is_dyeable',
IsHiddenWhenInvisible = 'minecraft:is_hidden_when_invisible',
IsIgnited = 'minecraft:is_ignited',
IsIllagerCaptain = 'minecraft:is_illager_captain',
IsSaddled = 'minecraft:is_saddled',
IsShaking = 'minecraft:is_shaking',
IsSheared = 'minecraft:is_sheared',
IsStackable = 'minecraft:is_stackable',
IsStunned = 'minecraft:is_stunned',
IsTamed = 'minecraft:is_tamed',
Item = 'minecraft:item',
LavaMovement = 'minecraft:lava_movement',
Leashable = 'minecraft:leashable',
MarkVariant = 'minecraft:mark_variant',
Movement = 'minecraft:movement',
MovementAmphibious = 'minecraft:movement.amphibious',
MovementBasic = 'minecraft:movement.basic',
MovementFly = 'minecraft:movement.fly',
MovementGeneric = 'minecraft:movement.generic',
MovementGlide = 'minecraft:movement.glide',
MovementHover = 'minecraft:movement.hover',
MovementJump = 'minecraft:movement.jump',
MovementSkip = 'minecraft:movement.skip',
MovementSway = 'minecraft:movement.sway',
NavigationClimb = 'minecraft:navigation.climb',
NavigationFloat = 'minecraft:navigation.float',
NavigationFly = 'minecraft:navigation.fly',
NavigationGeneric = 'minecraft:navigation.generic',
NavigationHover = 'minecraft:navigation.hover',
NavigationWalk = 'minecraft:navigation.walk',
Npc = 'minecraft:npc',
OnFire = 'minecraft:onfire',
Projectile = 'minecraft:projectile',
PushThrough = 'minecraft:push_through',
Rideable = 'minecraft:rideable',
Riding = 'minecraft:riding',
Scale = 'minecraft:scale',
SkinId = 'minecraft:skin_id',
Strength = 'minecraft:strength',
Tameable = 'minecraft:tameable',
TameMount = 'minecraft:tamemount',
TypeFamily = 'minecraft:type_family',
UnderwaterMovement = 'minecraft:underwater_movement',
Variant = 'minecraft:variant',
WantsJockey = 'minecraft:wants_jockey',
}
/**
* Describes the source of damage from an Entity.
*/
### Enumeration: EntityDamageCause
This section details the purpose, properties, methods, and code examples for `Enumeration: EntityDamageCause` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `EntityDamageCause` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Damage caused by a falling anvil.
*
*/
anvil = 'anvil',
/**
- Explanation:
* Damage caused from a non-Entity explosion. For example, an
* exploding bed.
*
*/
blockExplosion = 'blockExplosion',
campfire = 'campfire',
/**
- Explanation:
* Unused.
*
*/
charging = 'charging',
/**
- Explanation:
* Damage caused by physically touching an Entity or Block. For
* example, touching a Sweet Berry bush or Pufferfish.
*
*/
contact = 'contact',
/**
- Explanation:
* Damage caused by an Entity being out of air and inside a
* liquid block.
*
*/
drowning = 'drowning',
/**
- Explanation:
* Damage caused by an Entity attack.
*
*/
entityAttack = 'entityAttack',
/**
- Explanation:
* Damage caused by an Entity explosion. For example, a Creeper
* or Wither.
*
*/
entityExplosion = 'entityExplosion',
/**
- Explanation:
* Damage caused by falling onto the ground.
*
*/
fall = 'fall',
/**
- Explanation:
* Damage caused by falling blocks. Note: Anvils and
* Stalactites have their own damage causes.
*
*/
fallingBlock = 'fallingBlock',
/**
- Explanation:
* Damage caused by catching on fire.
*
*/
fire = 'fire',
/**
- Explanation:
* Damage caused by burning over time.
*
*/
fireTick = 'fireTick',
/**
- Explanation:
* Damage caused by fireworks.
*
*/
fireworks = 'fireworks',
/**
- Explanation:
* Damage caused by flying into a wall at high speed while
* gliding with Elytra.
*
*/
flyIntoWall = 'flyIntoWall',
/**
- Explanation:
* Damage caused by staying inside a Powder Snow block.
*
*/
freezing = 'freezing',
/**
- Explanation:
* Damage caused by touching a Lava block.
*
*/
lava = 'lava',
/**
- Explanation:
* Damage caused by being struck by lightning.
*
*/
lightning = 'lightning',
/**
- Explanation:
* Damage caused by magical attacks. For example, Evoker Fang
* or Conduit Block.
*
*/
magic = 'magic',
/**
- Explanation:
* Damage caused by touching a Magma block.
*
*/
magma = 'magma',
/**
- Explanation:
* Damage caused by no source. For example, from a command or
* script.
*
*/
none = 'none',
/**
- Explanation:
* Damage caused by an indirect source. For example, setting a
* mob's health to 0 in a behavior pack.
*
*/
override = 'override',
/**
- Explanation:
* Damage caused by a Piston.
*
*/
piston = 'piston',
/**
- Explanation:
* Damage caused by a projectile.
*
*/
projectile = 'projectile',
ramAttack = 'ramAttack',
selfDestruct = 'selfDestruct',
sonicBoom = 'sonicBoom',
soulCampfire = 'soulCampfire',
/**
- Explanation:
* Damage caused by a falling Stalactite block.
*
*/
stalactite = 'stalactite',
/**
- Explanation:
* Damage caused by touching a Stalagmite block.
*
*/
stalagmite = 'stalagmite',
/**
- Explanation:
* Damage caused over time by having an empty hunger bar.
*
*/
starve = 'starve',
/**
- Explanation:
* Damage caused by an Entity being out of air and inside a
* non-liquid block.
*
*/
suffocation = 'suffocation',
/**
- Explanation:
* Damage caused by an Entity killing itself. For example, from
* the /kill command.
*
*/
suicide = 'suicide',
/**
- Explanation:
* Damage caused by an Entity being in an inhabitable climate.
* For example, a Snow Golem in a biome with a temperature
* greater than 1.
*
*/
temperature = 'temperature',
/**
- Explanation:
* Damage caused by the Thorns armor enchantment and by the
* Guardian thorns effect.
*
*/
thorns = 'thorns',
/**
- Explanation:
* Damage caused over time by falling into the void.
*
*/
'void' = 'void',
/**
- Explanation:
* Damage caused by the Wither effect. For example, from
* touching a Wither Rose.
*
*/
wither = 'wither',
}
/**
* An enumeration describing initialization cause of an entity.
*/
### Enumeration: EntityInitializationCause
This section details the purpose, properties, methods, and code examples for `Enumeration: EntityInitializationCause` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `EntityInitializationCause` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Case when an entity is created as child of other entity or
* entities, e.g., cows making a cow or slimes making smaller
* slimes after dying.
*
*/
Born = 'Born',
/**
- Explanation:
* Case when an entity is created by an event, e.g., a
* Wandering trader spawning llamas.
*
*/
Event = 'Event',
/**
- Explanation:
* Case when an entity is loaded into the world.
*
*/
Loaded = 'Loaded',
/**
- Explanation:
* Case when an entity is naturally spawned in the world.
*
*/
Spawned = 'Spawned',
/**
- Explanation:
* Case when an entity is transformed into another entity.
*
*/
Transformed = 'Transformed',
}
/**
* @beta
* Describes the lifetime state of an Entity. For example,
* Entities can be loaded or unloaded depending on whether
* their chunks are loaded or when they move across dimensions.
*/
### Enumeration: EntityLifetimeState
This section details the purpose, properties, methods, and code examples for `Enumeration: EntityLifetimeState` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `EntityLifetimeState` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* Corresponding object is loaded.
*
*/
Loaded = 'Loaded',
/**
* @beta
- Explanation:
* Corresponding object is now unloaded. Unloaded entities
* cannot be manipulated. However, if an unloaded Entity later
* reloads, it becomes valid and can once again be manipulated.
*
*/
Unloaded = 'Unloaded',
}
/**
* The equipment slot of the mob. This includes armor, offhand
* and mainhand slots.
*/
### Enumeration: EquipmentSlot
This section details the purpose, properties, methods, and code examples for `Enumeration: EquipmentSlot` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `EquipmentSlot` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* The chest slot. This slot is used to hold items such as
* Chestplate or Elytra.
*
*/
Chest = 'Chest',
/**
- Explanation:
* The feet slot. This slot is used to hold items such as
* Boots.
*
*/
Feet = 'Feet',
/**
- Explanation:
* The head slot. This slot is used to hold items such as
* Helmets or Carved Pumpkins.
*
*/
Head = 'Head',
/**
- Explanation:
* The legs slot. This slot is used to hold items such as
* Leggings.
*
*/
Legs = 'Legs',
/**
- Explanation:
* The mainhand slot. For players, the mainhand slot refers to
* the currently active hotbar slot.
*
*/
Mainhand = 'Mainhand',
/**
- Explanation:
* The offhand slot. This slot is used to hold items such as
* shields and maps.
*
*/
Offhand = 'Offhand',
}
/**
* Represents the type of fluid for use within a fluid
* containing block, like a cauldron.
*/
### Enumeration: FluidType
This section details the purpose, properties, methods, and code examples for `Enumeration: FluidType` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `FluidType` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Represents lava as a type of fluid.
*
*/
Lava = 'Lava',
/**
- Explanation:
* Represents a potion as a type of fluid.
*
*/
Potion = 'Potion',
/**
- Explanation:
* Represents powder snow as a type of fluid.
*
*/
PowderSnow = 'PowderSnow',
/**
- Explanation:
* Represents water as a type of fluida.
*
*/
Water = 'Water',
}
/**
* Represents a game mode for the current world experience.
*/
### Enumeration: GameMode
This section details the purpose, properties, methods, and code examples for `Enumeration: GameMode` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `GameMode` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* World is in a more locked-down experience, where blocks may
* not be manipulated.
*
*/
adventure = 'adventure',
/**
- Explanation:
* World is in a full creative mode. In creative mode, the
* player has all the resources available in the item selection
* tabs and the survival selection tab. They can also destroy
* blocks instantly including those which would normally be
* indestructible. Command and structure blocks can also be
* used in creative mode. Items also do not lose durability or
* disappear.
*
*/
creative = 'creative',
/**
- Explanation:
* World is in spectator mode. In spectator mode, spectators
* are always flying and cannot become grounded. Spectators can
* pass through solid blocks and entities without any
* collisions, and cannot use items or interact with blocks or
* mobs. Spectators cannot be seen by mobs or other players,
* except for other spectators; spectators appear as a
* transparent floating head.
*
*/
spectator = 'spectator',
/**
- Explanation:
* World is in a survival mode, where players can take damage
* and entities may not be peaceful. Survival mode is where the
* player must collect resources, build structures while
* surviving in their generated world. Activities can, over
* time, chip away at player health and hunger bar.
*
*/
survival = 'survival',
}
/**
* @beta
*/
### Enumeration: GameRule
This section details the purpose, properties, methods, and code examples for `Enumeration: GameRule` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `GameRule` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* Whether command blocks should notify admins when they
* perform commands.
*
*/
CommandBlockOutput = 'commandBlockOutput',
/**
* @beta
- Explanation:
* Controls whether command blocks can execute commands.
*
*/
CommandBlocksEnabled = 'commandBlocksEnabled',
/**
* @beta
- Explanation:
* Controls whether the day and night cycles progress.
*
*/
DoDayLightCycle = 'doDayLightCycle',
/**
* @beta
- Explanation:
* Controls whether non-mob entities do drops. ie. Item Frame
*
*/
DoEntityDrops = 'doEntityDrops',
/**
* @beta
- Explanation:
* Controls whether fire spreads.
*
*/
DoFireTick = 'doFireTick',
/**
* @beta
- Explanation:
* Controls whether players immediately respawn or are shown
* the death screen.
*
*/
DoImmediateRespawn = 'doImmediateRespawn',
/**
* @beta
- Explanation:
* Controls whether players deal with the effects of not
* sleeping (such as Phantom spawning).
*
*/
DoInsomnia = 'doInsomnia',
/**
* @beta
- Explanation:
* Determines whether players should be able to craft only
* those recipes that they've unlocked first - when
* dolimitedcrafting is set to true.
*
*/
DoLimitedCrafting = 'doLimitedCrafting',
/**
* @beta
- Explanation:
* Controls whether mobs drop loot.
*
*/
DoMobLoot = 'doMobLoot',
/**
* @beta
- Explanation:
* Controls whether mobs spawn naturally in the world.
*
*/
DoMobSpawning = 'doMobSpawning',
/**
* @beta
- Explanation:
* Controls whether blocks drop items when destroyed.
*
*/
DoTileDrops = 'doTileDrops',
/**
* @beta
- Explanation:
* Controls whether the weather can change naturally.
*
*/
DoWeatherCycle = 'doWeatherCycle',
/**
* @beta
- Explanation:
* Controls whether entities take damage from drowning.
*
*/
DrowningDamage = 'drowningDamage',
/**
* @beta
- Explanation:
* Controls whether entities take damage from falling.
*
*/
FallDamage = 'fallDamage',
/**
* @beta
- Explanation:
* Controls whether entities take damage from fire.
*
*/
FireDamage = 'fireDamage',
/**
* @beta
- Explanation:
* Controls whether there is damage from freezing.
*
*/
FreezeDamage = 'freezeDamage',
/**
* @beta
- Explanation:
* The maximum number of commands that can be executed
* simultaneously by the /function command.
*
*/
FunctionCommandLimit = 'functionCommandLimit',
/**
* @beta
- Explanation:
* Controls whether players keep their inventories when they
* die.
*
*/
KeepInventory = 'keepInventory',
/**
* @beta
- Explanation:
* The maximum number of chained commands that can execute per
* tick.
*
*/
MaxCommandChainLength = 'maxCommandChainLength',
/**
* @beta
- Explanation:
* Controls whether mob griefing can happen in the world.
* Example: A Creeper explosion destroying blocks.
*
*/
MobGriefing = 'mobGriefing',
/**
* @beta
- Explanation:
* Controls whether players can regenerate health.
*
*/
NaturalRegeneration = 'naturalRegeneration',
/**
* @beta
- Explanation:
* The percentage of players required to be sleeping in order
* to advance to the next day.
*
*/
PlayersSleepingPercentage = 'playersSleepingPercentage',
/**
* @beta
- Explanation:
* Controls whether projectiles (entities with a projectile
* component, like Arrows, thrown Tridents or Fireworks) can
* destroy certain blocks that support this interaction (such
* as Chorus Fruit, Dripstone or Decorated Pots). Restrictions
* on which projectiles can destroy certain blocks apply.
*
*/
ProjectilesCanBreakBlocks = 'projectilesCanBreakBlocks',
/**
* @beta
- Explanation:
* Controls whether players can damage each other.
*
*/
Pvp = 'pvp',
/**
* @beta
- Explanation:
* Controls how frequently random ticks occur. A value of 0 or
* less will disable random ticks. The default value is 1.
*
*/
RandomTickSpeed = 'randomTickSpeed',
/**
* @beta
- Explanation:
* Controls whether built-in (vanilla) recipes automatically
* unlock as the player progresses through the game (one
* alternative to this is to use the /recipe command based on
* custom gameplay logic.)
*
*/
RecipesUnlock = 'recipesUnlock',
/**
* @beta
- Explanation:
* Controls whether respawn blocks (e.g. Bed, Respawn Anchor)
* explode in other dimensions.
*
*/
RespawnBlocksExplode = 'respawnBlocksExplode',
/**
* @beta
- Explanation:
* Controls whether command output is displayed to players.
* Also controls whether Command Block output is stored by
* default.
*
*/
SendCommandFeedback = 'sendCommandFeedback',
/**
* @beta
- Explanation:
* Controls whether Border Block effects are shown.
*
*/
ShowBorderEffect = 'showBorderEffect',
/**
* @beta
- Explanation:
* Controls whether player coordinates are displayed.
*
*/
ShowCoordinates = 'showCoordinates',
ShowDaysPlayed = 'showDaysPlayed',
/**
* @beta
- Explanation:
* Controls whether death messages are displayed in chat.
*
*/
ShowDeathMessages = 'showDeathMessages',
/**
* @beta
- Explanation:
* Controls whether standard player notifications for recipes
* will show. When set to false, 'player unlocked recipes' are
* no longer sent as player notifications.
*
*/
ShowRecipeMessages = 'showRecipeMessages',
/**
* @beta
- Explanation:
* Controls whether item tags are shown. E.g. 'Can Place On',
* 'Can Destroy', item lock icons, etc.
*
*/
ShowTags = 'showTags',
/**
* @beta
- Explanation:
* The block radius from world spawn that a player is allowed
* to spawn in. Does not affect Adventure mode. The default
* value is 10 blocks.
*
*/
SpawnRadius = 'spawnRadius',
/**
* @beta
- Explanation:
* Affects whether TNT blocks can be lit.
*
*/
TntExplodes = 'tntExplodes',
TntExplosionDropDecay = 'tntExplosionDropDecay',
}
/**
* @beta
*/
### Enumeration: HudElement
This section details the purpose, properties, methods, and code examples for `Enumeration: HudElement` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `HudElement` contains predefined values for a specific purpose in Minecraft.
PaperDoll = 0,
Armor = 1,
ToolTips = 2,
TouchControls = 3,
Crosshair = 4,
Hotbar = 5,
Health = 6,
ProgressBar = 7,
Hunger = 8,
AirBubbles = 9,
HorseHealth = 10,
StatusEffects = 11,
ItemText = 12,
}
/**
* @beta
*/
### Enumeration: HudVisibility
This section details the purpose, properties, methods, and code examples for `Enumeration: HudVisibility` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `HudVisibility` contains predefined values for a specific purpose in Minecraft.
Hide = 0,
Reset = 1,
}
/**
* @beta
*/
### Enumeration: InputPermissionCategory
This section details the purpose, properties, methods, and code examples for `Enumeration: InputPermissionCategory` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `InputPermissionCategory` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* Player input relating to camera movement.
*
*/
Camera = 1,
/**
* @beta
- Explanation:
* Player input relating to movement.
*
*/
Movement = 2,
}
/**
* The types of item components that are accessible via
* function ItemStack.getComponent.
*/
### Enumeration: ItemComponentTypes
This section details the purpose, properties, methods, and code examples for `Enumeration: ItemComponentTypes` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `ItemComponentTypes` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* The minecraft:cooldown component.
*
*/
Cooldown = 'minecraft:cooldown',
/**
- Explanation:
* The minecraft:durability component.
*
*/
Durability = 'minecraft:durability',
/**
- Explanation:
* The minecraft:enchantable component.
*
*/
Enchantable = 'minecraft:enchantable',
/**
- Explanation:
* The minecraft:food component.
*
*/
Food = 'minecraft:food',
}
/**
* Describes how an an item can be moved within a container.
*/
### Enumeration: ItemLockMode
This section details the purpose, properties, methods, and code examples for `Enumeration: ItemLockMode` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `ItemLockMode` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* The item cannot be dropped or crafted with.
*
*/
inventory = 'inventory',
/**
- Explanation:
* The item has no container restrictions.
*
*/
none = 'none',
/**
- Explanation:
* The item cannot be moved from its slot, dropped or crafted
* with.
*
*/
slot = 'slot',
}
/**
* Enum containing the different phases of the moon based on
* the current day.,Obtain the current MoonPhase using
* world.getMoonPhase.
*
* The fullness of the moon controls various mob behaviors such
* as the number of slimes that spawn in Swamp biomes, the
* chance skeletons and zombies have to spawn with armor, as
* well as the chance for spiders to spawn with certain status
* effects.
*/
### Enumeration: MoonPhase
This section details the purpose, properties, methods, and code examples for `Enumeration: MoonPhase` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `MoonPhase` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* The brightest moon phase. During this phase, cats have a 50%
* chance of spawning as black cats.
*
*/
FullMoon = 0,
/**
- Explanation:
* The phase following the Full Moon.
*
*/
WaningGibbous = 1,
/**
- Explanation:
* The phase following the Waxing Crescent.
*
*/
FirstQuarter = 2,
/**
- Explanation:
* The phase following the Last Quarter.
*
*/
WaningCrescent = 3,
/**
- Explanation:
* The darkest moon phase.
*
*/
NewMoon = 4,
/**
- Explanation:
* The phase following the New Moon.
*
*/
WaxingCrescent = 5,
/**
- Explanation:
* The phase following the Waning Gibbous.
*
*/
LastQuarter = 6,
/**
- Explanation:
* The phase following the First Quarter.
*
*/
WaxingGibbous = 7,
}
/**
* Used for specifying a sort order for how to display an
* objective and its list of participants.
*/
### Enumeration: ObjectiveSortOrder
This section details the purpose, properties, methods, and code examples for `Enumeration: ObjectiveSortOrder` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `ObjectiveSortOrder` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Objective participant list is displayed in ascending (e.g.,
* A-Z) order.
*
*/
Ascending = 0,
/**
- Explanation:
* Objective participant list is displayed in descending (e.g.,
* Z-A) order.
*
*/
Descending = 1,
}
/**
* @beta
*/
### Enumeration: PaletteColor
This section details the purpose, properties, methods, and code examples for `Enumeration: PaletteColor` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `PaletteColor` contains predefined values for a specific purpose in Minecraft.
White = 0,
Orange = 1,
Magenta = 2,
LightBlue = 3,
Yellow = 4,
Lime = 5,
Pink = 6,
Gray = 7,
Silver = 8,
Cyan = 9,
Purple = 10,
Blue = 11,
Brown = 12,
Green = 13,
Red = 14,
Black = 15,
}
/**
* Contains objectives and participants for the scoreboard.
*/
### Enumeration: ScoreboardIdentityType
This section details the purpose, properties, methods, and code examples for `Enumeration: ScoreboardIdentityType` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `ScoreboardIdentityType` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* This scoreboard participant is tied to an entity.
*
*/
Entity = 'Entity',
/**
- Explanation:
* This scoreboard participant is tied to a pseudo player
* entity - typically this is used to store scores as data or
* as abstract progress.
*
*/
FakePlayer = 'FakePlayer',
/**
- Explanation:
* This scoreboard participant is tied to a player.
*
*/
Player = 'Player',
}
/**
* Describes where the script event originated from.
*/
### Enumeration: ScriptEventSource
This section details the purpose, properties, methods, and code examples for `Enumeration: ScriptEventSource` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `ScriptEventSource` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* The script event originated from a Block such as a Command
* Block.
*
*/
Block = 'Block',
/**
- Explanation:
* The script event originated from an Entity such as a Player,
* Command Block Minecart or Animation Controller.
*
*/
Entity = 'Entity',
/**
- Explanation:
* The script event originated from an NPC dialogue.
*
*/
NPCDialogue = 'NPCDialogue',
/**
- Explanation:
* The script event originated from the server, such as from a
* runCommand API call or a dedicated server console.
*
*/
Server = 'Server',
}
/**
* Represents a side of a sign.
*/
### Enumeration: SignSide
This section details the purpose, properties, methods, and code examples for `Enumeration: SignSide` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `SignSide` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* The back of the sign.
*
*/
Back = 'Back',
/**
- Explanation:
* The front of the sign.
*
*/
Front = 'Front',
}
### Enumeration: StructureAnimationMode
This section details the purpose, properties, methods, and code examples for `Enumeration: StructureAnimationMode` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `StructureAnimationMode` contains predefined values for a specific purpose in Minecraft.
Blocks = 'Blocks',
Layers = 'Layers',
None = 'None',
}
### Enumeration: StructureMirrorAxis
This section details the purpose, properties, methods, and code examples for `Enumeration: StructureMirrorAxis` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `StructureMirrorAxis` contains predefined values for a specific purpose in Minecraft.
None = 'None',
X = 'X',
XZ = 'XZ',
Z = 'Z',
}
### Enumeration: StructureRotation
This section details the purpose, properties, methods, and code examples for `Enumeration: StructureRotation` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `StructureRotation` contains predefined values for a specific purpose in Minecraft.
None = 'None',
Rotate180 = 'Rotate180',
Rotate270 = 'Rotate270',
Rotate90 = 'Rotate90',
}
### Enumeration: StructureSaveMode
This section details the purpose, properties, methods, and code examples for `Enumeration: StructureSaveMode` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `StructureSaveMode` contains predefined values for a specific purpose in Minecraft.
Memory = 'Memory',
World = 'World',
}
/**
* Provides numeric values for common periods in the Minecraft
* day.
*/
### Enumeration: TimeOfDay
This section details the purpose, properties, methods, and code examples for `Enumeration: TimeOfDay` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `TimeOfDay` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Sets the time to the start of the day, which is time of the
* day 1,000 (or the equivalent of 7am) in Minecraft.
*
*/
Day = 1000,
/**
- Explanation:
* Sets the time to noon, which is time of the day 6,000 in
* Minecraft.
*
*/
Noon = 6000,
/**
- Explanation:
* Sets the time to sunset, which is time of the day 12,000 (or
* the equivalent of 6pm) in Minecraft.
*
*/
Sunset = 12000,
/**
- Explanation:
* Sets the time to night, which is time of the day 13,000 (or
* the equivalent of 7:00pm) in Minecraft.
*
*/
Night = 13000,
/**
- Explanation:
* Sets the time to midnight, which is time of the day 18,000
* (or the equivalent of 12:00am) in Minecraft.
*
*/
Midnight = 18000,
/**
- Explanation:
* Sets the time to sunrise, which is time of the day 23,000
* (or the equivalent of 5am) in Minecraft.
*
*/
Sunrise = 23000,
}
/**
* @beta
* An enumeration with the reason that a watchdog is deciding
* to terminate execution of a behavior packs' script.
*/
### Enumeration: WatchdogTerminateReason
This section details the purpose, properties, methods, and code examples for `Enumeration: WatchdogTerminateReason` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `WatchdogTerminateReason` contains predefined values for a specific purpose in Minecraft.
/**
* @beta
- Explanation:
* Script runtime for a behavior pack is terminated due to
* non-responsiveness from script (a hang or infinite loop).
*
*/
Hang = 'Hang',
/**
* @beta
- Explanation:
* Script runtime for a behavior pack is terminated due to a
* stack overflow (a long, and potentially infinite) chain of
* function calls.
*
*/
StackOverflow = 'StackOverflow',
}
/**
* Used to specify the type of weather condition within the
* world.
*/
### Enumeration: WeatherType
This section details the purpose, properties, methods, and code examples for `Enumeration: WeatherType` in the Minecraft Bedrock Edition Script API.
An enumeration defines a fixed set of related constants. `WeatherType` contains predefined values for a specific purpose in Minecraft.
/**
- Explanation:
* Specifies a clear weather condition.
*
*/
Clear = 'Clear',
/**
- Explanation:
* Specifies a rain weather condition.
*
*/
Rain = 'Rain',
/**
- Explanation:
* Specifies a rain and thunder weather condition.
*
*/
Thunder = 'Thunder',
}
/**
* @beta
*/
export type BlockComponentTypeMap = {
inventory: BlockInventoryComponent;
lavaContainer: BlockLavaContainerComponent;
'minecraft:inventory': BlockInventoryComponent;
'minecraft:lavaContainer': BlockLavaContainerComponent;
'minecraft:piston': BlockPistonComponent;
'minecraft:potionContainer': BlockPotionContainerComponent;
'minecraft:recordPlayer': BlockRecordPlayerComponent;
'minecraft:sign': BlockSignComponent;
'minecraft:snowContainer': BlockSnowContainerComponent;
'minecraft:waterContainer': BlockWaterContainerComponent;
piston: BlockPistonComponent;
potionContainer: BlockPotionContainerComponent;
recordPlayer: BlockRecordPlayerComponent;
sign: BlockSignComponent;
snowContainer: BlockSnowContainerComponent;
waterContainer: BlockWaterContainerComponent;
};
/**
* @beta
*/
export type EntityComponentTypeMap = {
addrider: EntityAddRiderComponent;
ageable: EntityAgeableComponent;
breathable: EntityBreathableComponent;
can_climb: EntityCanClimbComponent;
can_fly: EntityCanFlyComponent;
can_power_jump: EntityCanPowerJumpComponent;
color: EntityColorComponent;
color2: EntityColor2Component;
equippable: EntityEquippableComponent;
fire_immune: EntityFireImmuneComponent;
floats_in_liquid: EntityFloatsInLiquidComponent;
flying_speed: EntityFlyingSpeedComponent;
friction_modifier: EntityFrictionModifierComponent;
ground_offset: EntityGroundOffsetComponent;
healable: EntityHealableComponent;
health: EntityHealthComponent;
inventory: EntityInventoryComponent;
is_baby: EntityIsBabyComponent;
is_charged: EntityIsChargedComponent;
is_chested: EntityIsChestedComponent;
is_dyeable: EntityIsDyeableComponent;
is_hidden_when_invisible: EntityIsHiddenWhenInvisibleComponent;
is_ignited: EntityIsIgnitedComponent;
is_illager_captain: EntityIsIllagerCaptainComponent;
is_saddled: EntityIsSaddledComponent;
is_shaking: EntityIsShakingComponent;
is_sheared: EntityIsShearedComponent;
is_stackable: EntityIsStackableComponent;
is_stunned: EntityIsStunnedComponent;
is_tamed: EntityIsTamedComponent;
item: EntityItemComponent;
lava_movement: EntityLavaMovementComponent;
leashable: EntityLeashableComponent;
mark_variant: EntityMarkVariantComponent;
'minecraft:addrider': EntityAddRiderComponent;
'minecraft:ageable': EntityAgeableComponent;
'minecraft:breathable': EntityBreathableComponent;
'minecraft:can_climb': EntityCanClimbComponent;
'minecraft:can_fly': EntityCanFlyComponent;
'minecraft:can_power_jump': EntityCanPowerJumpComponent;
'minecraft:color': EntityColorComponent;
'minecraft:color2': EntityColor2Component;
'minecraft:equippable': EntityEquippableComponent;
'minecraft:fire_immune': EntityFireImmuneComponent;
'minecraft:floats_in_liquid': EntityFloatsInLiquidComponent;
'minecraft:flying_speed': EntityFlyingSpeedComponent;
'minecraft:friction_modifier': EntityFrictionModifierComponent;
'minecraft:ground_offset': EntityGroundOffsetComponent;
'minecraft:healable': EntityHealableComponent;
'minecraft:health': EntityHealthComponent;
'minecraft:inventory': EntityInventoryComponent;
'minecraft:is_baby': EntityIsBabyComponent;
'minecraft:is_charged': EntityIsChargedComponent;
'minecraft:is_chested': EntityIsChestedComponent;
'minecraft:is_dyeable': EntityIsDyeableComponent;
'minecraft:is_hidden_when_invisible': EntityIsHiddenWhenInvisibleComponent;
'minecraft:is_ignited': EntityIsIgnitedComponent;
'minecraft:is_illager_captain': EntityIsIllagerCaptainComponent;
'minecraft:is_saddled': EntityIsSaddledComponent;
'minecraft:is_shaking': EntityIsShakingComponent;
'minecraft:is_sheared': EntityIsShearedComponent;
'minecraft:is_stackable': EntityIsStackableComponent;
'minecraft:is_stunned': EntityIsStunnedComponent;
'minecraft:is_tamed': EntityIsTamedComponent;
'minecraft:item': EntityItemComponent;
'minecraft:lava_movement': EntityLavaMovementComponent;
'minecraft:leashable': EntityLeashableComponent;
'minecraft:mark_variant': EntityMarkVariantComponent;
'minecraft:movement': EntityMovementComponent;
'minecraft:movement.amphibious': EntityMovementAmphibiousComponent;
'minecraft:movement.basic': EntityMovementBasicComponent;
'minecraft:movement.fly': EntityMovementFlyComponent;
'minecraft:movement.generic': EntityMovementGenericComponent;
'minecraft:movement.glide': EntityMovementGlideComponent;
'minecraft:movement.hover': EntityMovementHoverComponent;
'minecraft:movement.jump': EntityMovementJumpComponent;
'minecraft:movement.skip': EntityMovementSkipComponent;
'minecraft:movement.sway': EntityMovementSwayComponent;
'minecraft:navigation.climb': EntityNavigationClimbComponent;
'minecraft:navigation.float': EntityNavigationFloatComponent;
'minecraft:navigation.fly': EntityNavigationFlyComponent;
'minecraft:navigation.generic': EntityNavigationGenericComponent;
'minecraft:navigation.hover': EntityNavigationHoverComponent;
'minecraft:navigation.walk': EntityNavigationWalkComponent;
'minecraft:npc': EntityNpcComponent;
'minecraft:onfire': EntityOnFireComponent;
'minecraft:projectile': EntityProjectileComponent;
'minecraft:push_through': EntityPushThroughComponent;
'minecraft:rideable': EntityRideableComponent;
'minecraft:riding': EntityRidingComponent;
'minecraft:scale': EntityScaleComponent;
'minecraft:skin_id': EntitySkinIdComponent;
'minecraft:strength': EntityStrengthComponent;
'minecraft:tameable': EntityTameableComponent;
'minecraft:tamemount': EntityTameMountComponent;
'minecraft:type_family': EntityTypeFamilyComponent;
'minecraft:underwater_movement': EntityUnderwaterMovementComponent;
'minecraft:variant': EntityVariantComponent;
'minecraft:wants_jockey': EntityWantsJockeyComponent;
movement: EntityMovementComponent;
'movement.amphibious': EntityMovementAmphibiousComponent;
'movement.basic': EntityMovementBasicComponent;
'movement.fly': EntityMovementFlyComponent;
'movement.generic': EntityMovementGenericComponent;
'movement.glide': EntityMovementGlideComponent;
'movement.hover': EntityMovementHoverComponent;
'movement.jump': EntityMovementJumpComponent;
'movement.skip': EntityMovementSkipComponent;
'movement.sway': EntityMovementSwayComponent;
'navigation.climb': EntityNavigationClimbComponent;
'navigation.float': EntityNavigationFloatComponent;
'navigation.fly': EntityNavigationFlyComponent;
'navigation.generic': EntityNavigationGenericComponent;
'navigation.hover': EntityNavigationHoverComponent;
'navigation.walk': EntityNavigationWalkComponent;
npc: EntityNpcComponent;
onfire: EntityOnFireComponent;
projectile: EntityProjectileComponent;
push_through: EntityPushThroughComponent;
rideable: EntityRideableComponent;
riding: EntityRidingComponent;
scale: EntityScaleComponent;
skin_id: EntitySkinIdComponent;
strength: EntityStrengthComponent;
tameable: EntityTameableComponent;
tamemount: EntityTameMountComponent;
type_family: EntityTypeFamilyComponent;
underwater_movement: EntityUnderwaterMovementComponent;
variant: EntityVariantComponent;
wants_jockey: EntityWantsJockeyComponent;
};
/**
* @beta
*/
export type ItemComponentTypeMap = {
cooldown: ItemCooldownComponent;
durability: ItemDurabilityComponent;
enchantable: ItemEnchantableComponent;
food: ItemFoodComponent;
'minecraft:cooldown': ItemCooldownComponent;
'minecraft:durability': ItemDurabilityComponent;
'minecraft:enchantable': ItemEnchantableComponent;
'minecraft:food': ItemFoodComponent;
};
/**
* @beta
* Describes a type of biome.
*/
### Class: BiomeType
This section details the purpose, properties, methods, and code examples for `Class: BiomeType` in the Minecraft Bedrock Edition Script API.
The `BiomeType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Identifier of the biome type.
*
*/
readonly id: string;
}
/**
* @beta
* Supports a catalog of available biome types registered
* within Minecraft.
*/
### Class: BiomeTypes
This section details the purpose, properties, methods, and code examples for `Class: BiomeTypes` in the Minecraft Bedrock Edition Script API.
The `BiomeTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns a specific biome type.
*
* @param typeName
* Identifier of the biome. Generally, namespaced identifiers
* (e.g., minecraft:frozen_peaks) should be used.
* @returns
* If the biome exists, a BiomeType object is returned. If not,
* undefined is returned.
*/
static get(typeName: string): BiomeType | undefined;
/**
- Explanation:
* Returns all registered biome types within Minecraft
*
*/
static getAll(): BiomeType[];
}
/**
* Represents a block in a dimension. A block represents a
* unique X, Y, and Z within a dimension and get/sets the state
* of the block at that location. This type was significantly
* updated in version 1.17.10.21.
*/
### Class: Block
This section details the purpose, properties, methods, and code examples for `Class: Block` in the Minecraft Bedrock Edition Script API.
The `Block` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the dimension that the block is within.
*
*/
readonly dimension: Dimension;
/**
- Explanation:
* Returns true if this block is an air block (i.e., empty
* space).
*
* @throws This property can throw when used.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
readonly isAir: boolean;
/**
- Explanation:
* Returns true if this block is a liquid block - (e.g., a
* water block and a lava block are liquid, while an air block
* and a stone block are not. Water logged blocks are not
* liquid blocks).
*
* @throws This property can throw when used.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
readonly isLiquid: boolean;
/**
* @beta
- Explanation:
* Returns true if this block is solid and impassible - (e.g.,
* a cobblestone block and a diamond block are solid, while a
* ladder block and a fence block are not).
*
* @throws This property can throw when used.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
readonly isSolid: boolean;
/**
* @beta
- Explanation:
* Returns or sets whether this block has a liquid on it.
*
* @throws This property can throw when used.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
readonly isWaterlogged: boolean;
/**
- Explanation:
* Coordinates of the specified block.
*
* @throws This property can throw when used.
*/
readonly location: Vector3;
/**
- Explanation:
* Additional block configuration data that describes the
* block.
*
* @throws This property can throw when used.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
readonly permutation: BlockPermutation;
/**
* @beta
- Explanation:
* Gets the type of block.
*
* @throws This property can throw when used.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
readonly 'type': BlockType;
/**
* @beta
- Explanation:
* Identifier of the type of block for this block.
*
* @throws This property can throw when used.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
readonly typeId: string;
/**
- Explanation:
* X coordinate of the block.
*
*/
readonly x: number;
/**
- Explanation:
* Y coordinate of the block.
*
*/
readonly y: number;
/**
- Explanation:
* Z coordinate of the block.
*
*/
readonly z: number;
/**
- Explanation:
* Returns the {@link Block} above this block (positive in the
* Y direction).
*
* @param steps
* Number of steps above to step before returning.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
above(steps?: number): Block | undefined;
/**
- Explanation:
* Returns the {@link Block} below this block (negative in the
* Y direction).
*
* @param steps
* Number of steps below to step before returning.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
below(steps?: number): Block | undefined;
/**
- Explanation:
* Returns the {@link @minecraft/server.Location} of the center
* of this block on the X and Z axis.
*
*/
bottomCenter(): Vector3;
/**
* @beta
- Explanation:
* Checks to see whether it is valid to place the specified
* block type or block permutation, on a specified face on this
* block
*
* @param blockToPlace
* Block type or block permutation to check placement for.
* @param faceToPlaceOn
* Optional specific face of this block to check placement
* against.
* @returns
* Returns `true` if the block type or permutation can be
* placed on this block, else `false`.
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
canPlace(blockToPlace: BlockPermutation | BlockType | string, faceToPlaceOn?: Direction): boolean;
/**
- Explanation:
* Returns the {@link @minecraft/server.Location} of the center
* of this block on the X, Y, and Z axis.
*
*/
center(): Vector3;
/**
- Explanation:
* Returns the {@link Block} to the east of this block
* (positive in the X direction).
*
* @param steps
* Number of steps to the east to step before returning.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
east(steps?: number): Block | undefined;
/**
- Explanation:
* Gets a component (that represents additional capabilities)
* for a block - for example, an inventory component of a chest
* block.
*
* @param componentId
* The identifier of the component (e.g.,
* 'minecraft:inventory'). If no namespace prefix is specified,
* 'minecraft:' is assumed. Available component IDs can be
* found as part of the {@link BlockComponentTypes} enum.
* @returns
* Returns the component if it exists on the block, otherwise
* undefined.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
getComponent<T extends keyof BlockComponentTypeMap>(componentId: T): BlockComponentTypeMap[T] | undefined;
/**
- Explanation:
* Creates a prototype item stack based on this block that can
* be used with Container/ContainerSlot APIs.
*
* @param amount
* Number of instances of this block to place in the item
* stack.
* @param withData
* Whether additional data facets of the item stack are
* included.
* @returns
* An itemStack with the specified amount of items and data.
* Returns undefined if block type is incompatible.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
getItemStack(amount?: number, withData?: boolean): ItemStack | undefined;
/**
* @beta
- Explanation:
* Returns the net redstone power of this block.
*
* @returns
* Returns undefined if redstone power is not applicable to
* this block.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
getRedstonePower(): number | undefined;
/**
- Explanation:
* Returns a set of tags for a block.
*
* @returns
* The list of tags that the block has.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
getTags(): string[];
/**
- Explanation:
* Checks to see if the permutation of this block has a
* specific tag.
*
* @param tag
* Tag to check for.
* @returns
* Returns `true` if the permutation of this block has the tag,
* else `false`.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Fetch the block
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
*
* console.log(`Block is dirt: ${block.hasTag("dirt")}`);
* console.log(`Block is wood: ${block.hasTag("wood")}`);
* console.log(`Block is stone: ${block.hasTag("stone")}`);
* ```
*/
hasTag(tag: string): boolean;
/**
- Explanation:
* Returns true if this reference to a block is still valid
* (for example, if the block is unloaded, references to that
* block will no longer be valid.)
*
* @returns
* True if this block object is still working and valid.
*/
isValid(): boolean;
/**
* @beta
- Explanation:
* Tests whether this block matches a specific criteria.
*
* @param blockName
* Block type identifier to match this API against.
* @param states
* Optional set of block states to test this block against.
* @returns
* Returns true if the block matches the specified criteria.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
matches(blockName: string, states?: Record<string, boolean | number | string>): boolean;
/**
- Explanation:
* Returns the {@link Block} to the north of this block
* (negative in the Z direction).
*
* @param steps
* Number of steps to the north to step before returning.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
north(steps?: number): Block | undefined;
/**
- Explanation:
* Returns a block at an offset relative vector to this block.
*
* @param offset
* The offset vector. For example, an offset of 0, 1, 0 will
* return the block above the current block.
* @returns
* Block at the specified offset, or undefined if that block
* could not be retrieved (for example, the block and its
* relative chunk is not loaded yet.)
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
offset(offset: Vector3): Block | undefined;
/**
- Explanation:
* Sets the block in the dimension to the state of the
* permutation.
*
* This function can't be called in read-only mode.
*
* @param permutation
* Permutation that contains a set of property states for the
* Block.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
setPermutation(permutation: BlockPermutation): void;
/**
* @beta
- Explanation:
* Sets the type of block.
*
* This function can't be called in read-only mode.
*
* @param blockType
* Identifier of the type of block to apply - for example,
* minecraft:powered_repeater.
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
setType(blockType: BlockType | string): void;
/**
* @beta
- Explanation:
* Sets whether this block has a water logged state - for
* example, whether stairs are submerged within water.
*
* This function can't be called in read-only mode.
*
* @param isWaterlogged
* true if the block should have water within it.
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
setWaterlogged(isWaterlogged: boolean): void;
/**
- Explanation:
* Returns the {@link Block} to the south of this block
* (positive in the Z direction).
*
* @param steps
* Number of steps to the south to step before returning.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
south(steps?: number): Block | undefined;
/**
* @beta
- Explanation:
* Tries to set the block in the dimension to the state of the
* permutation by first checking if the placement is valid.
*
* This function can't be called in read-only mode.
*
* @param permutation
* Permutation that contains a set of property states for the
* Block.
* @returns
* Returns `true` if the block permutation data was
* successfully set, else `false`.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
trySetPermutation(permutation: BlockPermutation): boolean;
/**
- Explanation:
* Returns the {@link Block} to the west of this block
* (negative in the X direction).
*
* @param steps
* Number of steps to the west to step before returning.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
west(steps?: number): Block | undefined;
}
/**
* Base type for components associated with blocks.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponent` in the Minecraft Bedrock Edition Script API.
The `BlockComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Block instance that this component pertains to.
*
*/
readonly block: Block;
}
/**
* @beta
* Contains information regarding an entity falling onto a
* specific block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentEntityFallOnEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentEntityFallOnEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentEntityFallOnEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The entity that fell onto the block.
*
*/
readonly entity?: Entity;
/**
- Explanation:
* The distance that the entity fell onto this block with.
*
*/
readonly fallDistance: number;
}
/**
* @beta
* Contains information regarding a specific block that was
* placed.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentOnPlaceEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentOnPlaceEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentOnPlaceEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Previous block at this location that was replaced.
*
*/
readonly previousBlock: BlockPermutation;
}
/**
* @beta
* Contains information regarding a specific block being
* destroyed.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentPlayerDestroyEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentPlayerDestroyEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentPlayerDestroyEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns permutation information about this block before it
* was destroyed.
*
*/
readonly destroyedBlockPermutation: BlockPermutation;
/**
- Explanation:
* The player that destroyed this block.
*
*/
readonly player?: Player;
}
/**
* @beta
* Contains information regarding a specific block being
* interacted with.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentPlayerInteractEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentPlayerInteractEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentPlayerInteractEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block face that was interacted with.
*
*/
readonly face: Direction;
/**
- Explanation:
* Location relative to the bottom north-west corner of the
* block that the player interacted with.
*
*/
readonly faceLocation?: Vector3;
/**
- Explanation:
* The player that interacted with this block.
*
*/
readonly player?: Player;
}
/**
* @beta
* Contains information regarding an event before a player
* places a block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentPlayerPlaceBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentPlayerPlaceBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentPlayerPlaceBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true, cancels the block place event.
*
*/
cancel: boolean;
/**
- Explanation:
* The block face that was placed onto.
*
*/
readonly face: Direction;
/**
- Explanation:
* The block permutation that will be placed if the event is
* not cancelled. If set to a different block permutation, that
* permutation will be placed instead.
*
*/
permutationToPlace: BlockPermutation;
/**
- Explanation:
* The player that is placing this block.
*
*/
readonly player?: Player;
}
/**
* @beta
* Contains information regarding a specific block randomly
* ticking.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentRandomTickEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentRandomTickEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentRandomTickEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
### Class: BlockComponentRegistry
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentRegistry` in the Minecraft Bedrock Edition Script API.
The `BlockComponentRegistry` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @throws This function can throw errors.
*
* {@link minecraftcommon.EngineError}
*
* {@link Error}
*/
registerCustomComponent(name: string, customComponent: BlockCustomComponent): void;
}
/**
* @beta
* Contains information regarding an entity stepping off a
* specific block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentStepOffEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentStepOffEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentStepOffEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The entity that stepped off the block.
*
*/
readonly entity?: Entity;
}
/**
* @beta
* Contains information regarding an entity stepping onto a
* specific block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentStepOnEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentStepOnEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentStepOnEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The entity that stepped on the block.
*
*/
readonly entity?: Entity;
}
/**
* @beta
* Contains information regarding a specific block ticking.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockComponentTickEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockComponentTickEvent` in the Minecraft Bedrock Edition Script API.
The `BlockComponentTickEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Contains information regarding an event that impacts a
* specific block.
*/
### Class: BlockEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockEvent` in the Minecraft Bedrock Edition Script API.
The `BlockEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Block impacted by this event.
*
*/
readonly block: Block;
/**
- Explanation:
* Dimension that contains the block that is the subject of
* this event.
*
*/
readonly dimension: Dimension;
}
/**
* @beta
* Contains information regarding an explosion that has
* occurred for a specific block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockExplodeAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: BlockExplodeAfterEvent` in the Minecraft Bedrock Edition Script API.
The `BlockExplodeAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Description of the block that has exploded.
*
*/
readonly explodedBlockPermutation: BlockPermutation;
/**
- Explanation:
* Optional source of the explosion.
*
*/
readonly source?: Entity;
}
/**
* @beta
* Manages callbacks that are connected to when an explosion
* occurs, as it impacts individual blocks.
*/
### Class: BlockExplodeAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: BlockExplodeAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `BlockExplodeAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an explosion
* occurs, as it impacts individual blocks.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: BlockExplodeAfterEvent) => void): (arg: BlockExplodeAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an explosion
* occurs, as it impacts individual blocks.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: BlockExplodeAfterEvent) => void): void;
}
/**
* Represents the inventory of a block in the world. Used with
* blocks like chests.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Fetch block
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
*
* // Make it a chest
* block.setType(MinecraftBlockTypes.chest);
*
* // Get the inventory
* const inventoryComponent = block.getComponent("inventory");
* const inventoryContainer = inventoryComponent.container;
*
* // Set slot 0 to a stack of 10 apples
* inventoryContainer.setItem(0, new ItemStack(Items.apple, 10, 0));
*
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockInventoryComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockInventoryComponent` in the Minecraft Bedrock Edition Script API.
The `BlockInventoryComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The container which holds an {@link ItemStack}.
*
* @throws This property can throw when used.
*/
readonly container?: Container;
static readonly componentId = 'minecraft:inventory';
}
/**
* @beta
* Represents a fluid container block that currently contains
* lava.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockLavaContainerComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockLavaContainerComponent` in the Minecraft Bedrock Edition Script API.
The `BlockLavaContainerComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:lavaContainer';
}
/**
* @beta
* For blocks that can contain a liquid (e.g., a cauldron),
* this is a base component for liquid containers.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockLiquidContainerComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockLiquidContainerComponent` in the Minecraft Bedrock Edition Script API.
The `BlockLiquidContainerComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Relative fill level of the liquid container.
*
* This property can't be edited in read-only mode.
*
*/
fillLevel: number;
/**
- Explanation:
* Returns true if this reference to a liquid container is
* still valid and contains the liquid of the type you have a
* reference for (for example, if the block is unloaded, no
* longer a liquid container or contains lava when you have a
* potion container component, isValidLiquid will not be true.)
*
* @returns
* True if this liquid container still exists, is valid and
* contains the expected liquid type.
*/
isValidLiquid(): boolean;
}
/**
* @beta
* A BlockLocationIterator returns the next block location of
* the block volume across which it is iterating.
* The BlockLocationIterator is used to abstract the shape of
* the block volume it was fetched from (so it can represent
* all the block locations that make up rectangles, cubes,
* spheres, lines and complex shapes).
* Each iteration pass returns the next valid block location in
* the parent shape.
* Unless otherwise specified by the parent shape - the
* BlockLocationIterator will iterate over a 3D space in the
* order of increasing X, followed by increasing Z followed by
* increasing Y.
* (Effectively stepping across the XZ plane, and when all the
* locations in that plane are exhausted, increasing the Y
* coordinate to the next XZ slice)
*/
### Class: BlockLocationIterator
This section details the purpose, properties, methods, and code examples for `Class: BlockLocationIterator` in the Minecraft Bedrock Edition Script API.
The `BlockLocationIterator` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
[Symbol.iterator](): Iterator<Vector3>;
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
next(): IteratorResult<Vector3>;
}
/**
* Contains the combination of type {@link BlockType} and
* properties (also sometimes called block state) which
* describe a block (but does not belong to a specific {@link
* Block}).
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function the creates a sign at the specified location with the specified text
*
* function createSignAt(location: DimensionLocation) {
* const signBlock = location.dimension.getBlock(location);
*
* if (!signBlock) {
* console.warn('Could not find a block at specified location.');
* return;
* }
*
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
* signBlock.setPermutation(signPerm); // Update block to be a sign
*
* // Update the sign block's text
* // with "Steve's Head"
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign);
* if (signComponent) {
* signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] });
* }
* }
* ```
*/
### Class: BlockPermutation
This section details the purpose, properties, methods, and code examples for `Class: BlockPermutation` in the Minecraft Bedrock Edition Script API.
The `BlockPermutation` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @beta
- Explanation:
* The {@link BlockType} that the permutation has.
*
*/
readonly 'type': BlockType;
/**
- Explanation:
* Returns all available block states associated with this
* block.
*
* @returns
* Returns the list of all of the block states that the
* permutation has.
*/
getAllStates(): Record<string, boolean | number | string>;
/**
- Explanation:
* Retrieves a prototype item stack based on this block
* permutation that can be used with item
* Container/ContainerSlot APIs.
*
* @param amount
* Number of instances of this block to place in the prototype
* item stack.
*/
getItemStack(amount?: number): ItemStack | undefined;
/**
- Explanation:
* Gets a state for the permutation.
*
* @param stateName
* Name of the block state who's value is to be returned.
* @returns
* Returns the state if the permutation has it, else
* `undefined`.
*/
getState(stateName: string): boolean | number | string | undefined;
/**
* @beta
- Explanation:
* Creates a copy of the permutation.
*
*/
getTags(): string[];
/**
* @beta
- Explanation:
* Checks to see if the permutation has a specific tag.
*
* @returns
* Returns `true` if the permutation has the tag, else `false`.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Fetch the block
* const block = world.getDimension("overworld").getBlock({ x: 1, y: 2, z: 3 });
* const blockPerm = block.getPermutation();
*
* console.log(`Block is dirt: ${blockPerm.hasTag("dirt")}`);
* console.log(`Block is wood: ${blockPerm.hasTag("wood")}`);
* console.log(`Block is stone: ${blockPerm.hasTag("stone")}`);
* ```
*/
hasTag(tag: string): boolean;
/**
- Explanation:
* Returns a boolean whether a specified permutation matches
* this permutation. If states is not specified, matches checks
* against the set of types more broadly.
*
* @param blockName
* An optional set of states to compare against.
*/
matches(blockName: string, states?: Record<string, boolean | number | string>): boolean;
/**
- Explanation:
* Returns a derived BlockPermutation with a specific property
* set.
*
* @param name
* Identifier of the block property.
* @param value
* Value of the block property.
* @throws This function can throw errors.
*/
withState(name: string, value: boolean | number | string): BlockPermutation;
/**
- Explanation:
* Given a type identifier and an optional set of properties,
* will return a BlockPermutation object that is usable in
* other block APIs (e.g., block.setPermutation)
*
* @param blockName
* Identifier of the block to check.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const allWoolBlocks: string[] = [
* MinecraftBlockTypes.WhiteWool,
* MinecraftBlockTypes.OrangeWool,
* MinecraftBlockTypes.MagentaWool,
* MinecraftBlockTypes.LightBlueWool,
* MinecraftBlockTypes.YellowWool,
* MinecraftBlockTypes.LimeWool,
* MinecraftBlockTypes.PinkWool,
* MinecraftBlockTypes.GrayWool,
* MinecraftBlockTypes.LightGrayWool,
* MinecraftBlockTypes.CyanWool,
* MinecraftBlockTypes.PurpleWool,
* MinecraftBlockTypes.BlueWool,
* MinecraftBlockTypes.BrownWool,
* MinecraftBlockTypes.GreenWool,
* MinecraftBlockTypes.RedWool,
* MinecraftBlockTypes.BlackWool,
* ];
*
* const cubeDim = 7;
*
* function placeRainbowCube(location: DimensionLocation) {
* let colorIndex = 0;
* for (let x = 0; x <= cubeDim; x++) {
* for (let y = 0; y <= cubeDim; y++) {
* for (let z = 0; z <= cubeDim; z++) {
* colorIndex++;
* location.dimension
* .getBlock({ x: location.x + x, y: location.y + y, z: location.z + z })
* ?.setPermutation(BlockPermutation.resolve(allWoolBlocks[colorIndex % allWoolBlocks.length]));
* }
* }
* }
* }
* ```
*/
static resolve(blockName: string, states?: Record<string, boolean | number | string>): BlockPermutation;
}
/**
* When present, this block has piston-like behavior. Contains
* additional properties for discovering block piston state.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockPistonComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockPistonComponent` in the Minecraft Bedrock Edition Script API.
The `BlockPistonComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Whether the piston is in the process of expanding or
* retracting.
*
* @throws This property can throw when used.
*/
readonly isMoving: boolean;
/**
- Explanation:
* The current state of the piston.
*
* @throws This property can throw when used.
*/
readonly state: BlockPistonState;
static readonly componentId = 'minecraft:piston';
/**
- Explanation:
* Retrieves a set of blocks that this piston is connected
* with.
*
* @throws This function can throw errors.
*/
getAttachedBlocks(): Block[];
/**
- Explanation:
* Retrieves a set of block locations that this piston is
* connected with.
*
* @throws This function can throw errors.
*/
getAttachedBlocksLocations(): Vector3[];
}
/**
* @beta
* Represents a fluid container block that currently contains a
* potion.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockPotionContainerComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockPotionContainerComponent` in the Minecraft Bedrock Edition Script API.
The `BlockPotionContainerComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:potionContainer';
/**
- Explanation:
* Sets the potion type based on an item stack.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setPotionType(itemStack: ItemStack): void;
}
/**
* @beta
* Represents a block that can play a record.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockRecordPlayerComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockRecordPlayerComponent` in the Minecraft Bedrock Edition Script API.
The `BlockRecordPlayerComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:recordPlayer';
/**
- Explanation:
* Clears the currently playing record of this record-playing
* block.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
clearRecord(): void;
/**
- Explanation:
* Returns true if the record-playing block is currently
* playing a record.
*
* @throws This function can throw errors.
*/
isPlaying(): boolean;
/**
- Explanation:
* Sets and plays a record based on an item type.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setRecord(recordItemType: ItemType | string): void;
}
/**
* Represents a block that can display text on it.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function the creates a sign at the specified location with text on both sides and dye colors
* DimensionLocation,
* BlockPermutation,
* BlockSignComponent,
* BlockComponentTypes,
* DyeColor,
* SignSide,
* } from '@minecraft/server';
*
* function createSignAt(location: DimensionLocation) {
* const block = location.dimension.getBlock(location);
* if (!block) {
* console.warn('Could not find a block at specified location.');
* return;
* }
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, {
* ground_sign_direction: 8,
* });
* block.setPermutation(signPerm);
* const sign = block.getComponent(BlockComponentTypes.Sign);
*
* if (sign !== undefined) {
* sign.setText(`Party Sign!\nThis is green on the front.`);
* sign.setText(`Party Sign!\nThis is red on the back.`, SignSide.Back);
* sign.setTextDyeColor(DyeColor.Green);
* sign.setTextDyeColor(DyeColor.Red, SignSide.Back);
*
* // players cannot edit sign!
* sign.setWaxed(true);
* } else {
* console.warn('Could not find a sign component on the block.');
* }
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* BlockComponentTypes,
* DimensionLocation,
* RawMessage,
* RawText,
* } from '@minecraft/server';
*
* // Function which updates a sign blocks text to raw text
* function updateSignText(signLocation: DimensionLocation) {
* const block = signLocation.dimension.getBlock(signLocation);
* if (!block) {
* console.warn('Could not find a block at specified location.');
* return;
* }
*
* const sign = block.getComponent(BlockComponentTypes.Sign);
* if (sign) {
* // RawMessage
* const helloWorldMessage: RawMessage = { text: 'Hello World' };
* sign.setText(helloWorldMessage);
*
* // RawText
* const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
* sign.setText(helloWorldText);
*
* // Regular string
* sign.setText('Hello World');
* } else {
* console.warn('Could not find a sign component on the block.');
* }
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function the creates a sign at the specified location with the specified text
*
* function createSignAt(location: DimensionLocation) {
* const signBlock = location.dimension.getBlock(location);
*
* if (!signBlock) {
* console.warn('Could not find a block at specified location.');
* return;
* }
*
* const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 });
* signBlock.setPermutation(signPerm); // Update block to be a sign
*
* // Update the sign block's text
* // with "Steve's Head"
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign);
* if (signComponent) {
* signComponent.setText({ translate: 'item.skull.player.name', with: ['Steve'] });
* }
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockSignComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockSignComponent` in the Minecraft Bedrock Edition Script API.
The `BlockSignComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Whether or not players can edit the sign. This happens if a
* sign has had a honeycomb used on it or `setWaxed` was called
* on the sign.
*
* @throws This property can throw when used.
*/
readonly isWaxed: boolean;
static readonly componentId = 'minecraft:sign';
/**
- Explanation:
* Returns the RawText of the sign if `setText` was called with
* a RawMessage or a RawText object, otherwise returns
* undefined.
*
* @param side
* The side of the sign to read the message from. If not
* provided, this will return the message from the front side
* of the sign.
* @throws This function can throw errors.
*/
getRawText(side?: SignSide): RawText | undefined;
/**
- Explanation:
* Returns the text of the sign if `setText` was called with a
* string, otherwise returns undefined.
*
* @param side
* The side of the sign to read the message from. If not
* provided, this will return the message from the front side
* of the sign.
* @throws This function can throw errors.
*/
getText(side?: SignSide): string | undefined;
/**
- Explanation:
* Gets the dye that is on the text or undefined if the sign
* has not been dyed.
*
* @param side
* The side of the sign to read the dye from. If not provided,
* this will return the dye on the front side of the sign.
* @throws This function can throw errors.
*/
getTextDyeColor(side?: SignSide): DyeColor | undefined;
/**
- Explanation:
* Sets the text of the sign component.
*
* This function can't be called in read-only mode.
*
* @param message
* The message to set on the sign. If set to a string, then
* call `getText` to read that string. If set to a RawMessage,
* then calling `getRawText` will return a RawText. If set to a
* RawText, then calling `getRawText` will return the same
* object that was passed in.
* @param side
* The side of the sign the message will be set on. If not
* provided, the message will be set on the front side of the
* sign.
* @throws
* Throws if the provided message is greater than 512
* characters in length.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* BlockComponentTypes,
* DimensionLocation,
* RawMessage,
* RawText,
* } from '@minecraft/server';
*
* // Function which updates a sign blocks text to raw text
* function updateSignText(signLocation: DimensionLocation) {
* const block = signLocation.dimension.getBlock(signLocation);
* if (!block) {
* console.warn('Could not find a block at specified location.');
* return;
* }
*
* const sign = block.getComponent(BlockComponentTypes.Sign);
* if (sign) {
* // RawMessage
* const helloWorldMessage: RawMessage = { text: 'Hello World' };
* sign.setText(helloWorldMessage);
*
* // RawText
* const helloWorldText: RawText = { rawtext: [{ text: 'Hello World' }] };
* sign.setText(helloWorldText);
*
* // Regular string
* sign.setText('Hello World');
* } else {
* console.warn('Could not find a sign component on the block.');
* }
* }
* ```
*/
setText(message: RawMessage | RawText | string, side?: SignSide): void;
/**
- Explanation:
* Sets the dye color of the text.
*
* This function can't be called in read-only mode.
*
* @param color
* The dye color to apply to the sign or undefined to clear the
* dye on the sign.
* @param side
* The side of the sign the color will be set on. If not
* provided, the color will be set on the front side of the
* sign.
* @throws This function can throw errors.
*/
setTextDyeColor(color?: DyeColor, side?: SignSide): void;
/**
- Explanation:
* Makes it so players cannot edit this sign.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setWaxed(waxed: boolean): void;
}
/**
* @beta
* Represents a fluid container block that currently contains
* snow.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockSnowContainerComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockSnowContainerComponent` in the Minecraft Bedrock Edition Script API.
The `BlockSnowContainerComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:snowContainer';
}
/**
* Enumerates all {@link BlockStateType}s.
*/
### Class: BlockStates
This section details the purpose, properties, methods, and code examples for `Class: BlockStates` in the Minecraft Bedrock Edition Script API.
The `BlockStates` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Retrieves a specific block state instance.
*
* @returns
* Returns the {@link Block} state instance if it is found. If
* the block state instance is not found returns undefined.
*/
static get(stateName: string): BlockStateType | undefined;
/**
- Explanation:
* Retrieves a set of all available block states.
*
*/
static getAll(): BlockStateType[];
}
/**
* Represents a configurable state value of a block instance.
* For example, the facing direction of stairs is accessible as
* a block state.
*/
### Class: BlockStateType
This section details the purpose, properties, methods, and code examples for `Class: BlockStateType` in the Minecraft Bedrock Edition Script API.
The `BlockStateType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Identifier of the block property.
*
*/
readonly id: string;
/**
- Explanation:
* A set of valid values for the block property.
*
*/
readonly validValues: (boolean | number | string)[];
}
/**
* The type (or template) of a block. Does not contain
* permutation data (state) other than the type of block it
* represents. This type was introduced as of version
* 1.17.10.21.
*/
### Class: BlockType
This section details the purpose, properties, methods, and code examples for `Class: BlockType` in the Minecraft Bedrock Edition Script API.
The `BlockType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @beta
- Explanation:
* Represents whether this type of block can be waterlogged.
*
*/
readonly canBeWaterlogged: boolean;
/**
* @beta
- Explanation:
* Block type name - for example, `minecraft:acacia_stairs`.
*
*/
readonly id: string;
}
/**
* @beta
* Contains a catalog of Minecraft Block Types that are
* available in this world.
*/
### Class: BlockTypes
This section details the purpose, properties, methods, and code examples for `Class: BlockTypes` in the Minecraft Bedrock Edition Script API.
The `BlockTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns a BlockType object for the specified identifier.
*
* @param typeName
* Identifier of the block type. Should follow a namespace:id
* pattern, such as minecraft:dirt.
* @returns
* BlockType object, or undefined if the block type is not
* available within this world.
*/
static get(typeName: string): BlockType | undefined;
/**
- Explanation:
* Returns a collection of all available block types.
*
*/
static getAll(): BlockType[];
}
/**
* @beta
* A BlockVolume is a simple interface to an object which
* represents a 3D rectangle of a given size (in blocks) at a
* world block location.
* Note that these are not analogous to "min" and "max" values,
* in that the vector components are not guaranteed to be in
* any order.
* In addition, these vector positions are not interchangeable
* with BlockLocation.
* If you want to get this volume represented as range of of
* BlockLocations, you can use the getBoundingBox utility
* function.
* This volume class will maintain the ordering of the corner
* indexes as initially set. imagine that each corner is
* assigned in Editor - as you move the corner around
* (potentially inverting the min/max relationship of the
* bounds) - what
* you had originally selected as the top/left corner would
* traditionally become the bottom/right.
* When manually editing these kinds of volumes, you need to
* maintain the identity of the corner as you edit - the
* BlockVolume utility functions do this.
*
* Important to note that this measures block sizes (to/from) -
* a normal AABB (0,0,0) to (0,0,0) would traditionally be of
* size (0,0,0)
* However, because we're measuring blocks - the size or span
* of a BlockVolume would actually be (1,1,1)
*
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockVolume
This section details the purpose, properties, methods, and code examples for `Class: BlockVolume` in the Minecraft Bedrock Edition Script API.
The `BlockVolume` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
/**
- Explanation:
* A world block location that represents a corner in a 3D
* rectangle
*
* This property can't be edited in read-only mode.
*
*/
'from': Vector3;
/**
- Explanation:
* A world block location that represents the opposite corner
* in a 3D rectangle
*
* This property can't be edited in read-only mode.
*
*/
to: Vector3;
constructor(from: Vector3, to: Vector3);
/**
- Explanation:
* Check to see if the given location is directly adjacent to
* the outer surface of a BlockVolume.
*
*
* This function can't be called in read-only mode.
*
* @param pos
* The world block location to test
* @returns
* If the location is either inside or more than 0 blocks away,
* the function will return false.
* If the location is directly contacting the outer surface of
* the BlockVolume, the function will return true.
*/
doesLocationTouchFaces(pos: Vector3): boolean;
/**
- Explanation:
* Check to see if a two block volumes are directly adjacent
* and two faces touch.
*
* This function can't be called in read-only mode.
*
* @param other
* The volume to test
* @returns
* If the outer faces of both block volumes touch and are
* directly adjacent at any point, return true.
*/
doesVolumeTouchFaces(other: BlockVolume): boolean;
/**
- Explanation:
* Return an enumeration which represents the intersection
* between two BlockVolume objects
*
* This function can't be called in read-only mode.
*
*/
intersects(other: BlockVolume): BlockVolumeIntersection;
}
/**
* @beta
* Base type for BlockVolumes.
*/
### Class: BlockVolumeBase
This section details the purpose, properties, methods, and code examples for `Class: BlockVolumeBase` in the Minecraft Bedrock Edition Script API.
The `BlockVolumeBase` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Fetch a {@link BlockLocationIterator} that represents all of
* the block world locations within the specified volume
*
* This function can't be called in read-only mode.
*
*/
getBlockLocationIterator(): BlockLocationIterator;
/**
* @beta
- Explanation:
* Return a {@link BoundingBox} object which represents the
* validated min and max coordinates of the volume
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
getBoundingBox(): BoundingBox;
/**
- Explanation:
* Return the capacity (volume) of the BlockVolume (W*D*H)
*
* This function can't be called in read-only mode.
*
*/
getCapacity(): number;
/**
- Explanation:
* Get the largest corner position of the volume (guaranteed to
* be >= min)
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
getMax(): Vector3;
/**
- Explanation:
* Get the smallest corner position of the volume (guaranteed
* to be <= max)
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
getMin(): Vector3;
/**
- Explanation:
* Get a {@link Vector3} object where each component represents
* the number of blocks along that axis
*
* This function can't be called in read-only mode.
*
*/
getSpan(): Vector3;
/**
- Explanation:
* Check to see if a given world block location is inside a
* BlockVolume
*
* This function can't be called in read-only mode.
*
*/
isInside(location: Vector3): boolean;
/**
- Explanation:
* Move a BlockVolume by a specified amount
*
* This function can't be called in read-only mode.
*
* @param delta
* Amount of blocks to move by
*/
translate(delta: Vector3): void;
}
/**
* @beta
* Represents a fluid container block that currently contains
* water.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: BlockWaterContainerComponent
This section details the purpose, properties, methods, and code examples for `Class: BlockWaterContainerComponent` in the Minecraft Bedrock Edition Script API.
The `BlockWaterContainerComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:waterContainer';
/**
- Explanation:
* Adds an item and colors the water based on a dye item type.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
addDye(itemType: ItemType): void;
/**
- Explanation:
* Retrieves a custom base color used for the sign text.
*
* @returns
* Color that is used as the base color for sign text.
* @throws This function can throw errors.
*/
getCustomColor(): RGBA;
/**
- Explanation:
* Sets a custom base color used for the sign text.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setCustomColor(color: RGBA): void;
}
/**
* @beta
* Bounding Box Utils is a utility class that provides a number
* of useful functions for the creation and utility of {@link
* @minecraft-server.BoundingBox} objects
*/
### Class: BoundingBoxUtils
This section details the purpose, properties, methods, and code examples for `Class: BoundingBoxUtils` in the Minecraft Bedrock Edition Script API.
The `BoundingBoxUtils` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Create a validated instance of a {@link
* @minecraft-server.BoundingBox} where the min and max
* components are guaranteed to be (min <= max)
*
* This function can't be called in read-only mode.
*
* @param min
* A corner world location
* @param max
* A corner world location diametrically opposite
*/
static createValid(min: Vector3, max: Vector3): BoundingBox;
/**
- Explanation:
* Expand a {@link @minecraft-server.BoundingBox} by a given
* amount along each axis.
* Sizes can be negative to perform contraction.
* Note: corners can be inverted if the contraction size is
* greater than the span, but the min/max relationship will
* remain correct
*
* This function can't be called in read-only mode.
*
* @returns
* Return a new {@link @minecraft-server.BoundingBox} object
* representing the changes
*/
static dilate(box: BoundingBox, size: Vector3): BoundingBox;
/**
- Explanation:
* Check if two {@link @minecraft-server.BoundingBox} objects
* are identical
*
* This function can't be called in read-only mode.
*
*/
static equals(box: BoundingBox, other: BoundingBox): boolean;
/**
- Explanation:
* Expand the initial box object bounds to include the 2nd box
* argument. The resultant {@link
* @minecraft-server.BoundingBox} object will be a BoundingBox
* which exactly encompasses the two boxes.
*
* This function can't be called in read-only mode.
*
* @returns
* A new {@link @minecraft-server.BoundingBox} instance
* representing the smallest possible bounding box which can
* encompass both
*/
static expand(box: BoundingBox, other: BoundingBox): BoundingBox;
/**
- Explanation:
* Calculate the center block of a given {@link
* @minecraft-server.BoundingBox} object.
*
* This function can't be called in read-only mode.
*
* @returns
* Note that {@link @minecraft-server.BoundingBox} objects
* represent whole blocks, so the center of boxes which have
* odd numbered bounds are not mathematically centered...
* i.e. a BoundingBox( 0,0,0 -> 3,3,3 ) would have a center of
* (1,1,1) (not (1.5, 1.5, 1.5) as expected)
*/
static getCenter(box: BoundingBox): Vector3;
/**
- Explanation:
* Calculate the BoundingBox which represents the union area of
* two intersecting BoundingBoxes
*
* This function can't be called in read-only mode.
*
*/
static getIntersection(box: BoundingBox, other: BoundingBox): BoundingBox | undefined;
/**
- Explanation:
* Get the Span of each of the BoundingBox Axis components
*
* This function can't be called in read-only mode.
*
*/
static getSpan(box: BoundingBox): Vector3;
/**
- Explanation:
* Check to see if two BoundingBox objects intersect
*
* This function can't be called in read-only mode.
*
*/
static intersects(box: BoundingBox, other: BoundingBox): boolean;
/**
- Explanation:
* Check to see if a given coordinate is inside a BoundingBox
*
* This function can't be called in read-only mode.
*
*/
static isInside(box: BoundingBox, pos: Vector3): boolean;
/**
- Explanation:
* Check to see if a BoundingBox is valid (i.e. (min <= max))
*
* This function can't be called in read-only mode.
*
*/
static isValid(box: BoundingBox): boolean;
/**
- Explanation:
* Move a BoundingBox by a given amount
*
* This function can't be called in read-only mode.
*
* @returns
* Return a new BoundingBox object which represents the change
*/
static translate(box: BoundingBox, delta: Vector3): BoundingBox;
}
/**
* Contains information related to changes to a button push.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
* const eventLoc = buttonPushEvent.block.location;
*
* world.sendMessage(
* `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`,
* );
* });
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ButtonPushAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ButtonPushAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ButtonPushAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Optional source that triggered the button push.
*
*/
readonly source: Entity;
}
/**
* Manages callbacks that are connected to when a button is
* pushed.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
* const eventLoc = buttonPushEvent.block.location;
*
* world.sendMessage(
* `Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`,
* );
* });
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ButtonPushAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ButtonPushAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ButtonPushAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Contains methods relating to the active camera for the
* specified player.
*/
### Class: Camera
This section details the purpose, properties, methods, and code examples for `Class: Camera` in the Minecraft Bedrock Edition Script API.
The `Camera` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Clears the active camera for the specified player. Causes
* the specified players to end any in-progress camera
* perspectives, including any eased camera motions, and return
* to their normal perspective.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
clear(): void;
/**
- Explanation:
* Begins a camera fade transition. A fade transition is a
* full-screen color that fades-in, holds, and then fades-out.
*
* This function can't be called in read-only mode.
*
* @param fadeCameraOptions
* Additional options around camera fade operations.
* @throws This function can throw errors.
*/
fade(fadeCameraOptions?: CameraFadeOptions): void;
/**
- Explanation:
* Sets the current active camera for the specified player.
*
* This function can't be called in read-only mode.
*
* @param cameraPreset
* Identifier of a camera preset file defined within JSON.
* @param setOptions
* Additional options for the camera.
* @throws This function can throw errors.
*/
setCamera(
cameraPreset: string,
setOptions?:
| CameraDefaultOptions
| CameraSetFacingOptions
| CameraSetLocationOptions
| CameraSetPosOptions
| CameraSetRotOptions,
): void;
}
/**
* @beta
* An event that fires as players enter chat messages.
*/
### Class: ChatSendAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ChatSendAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ChatSendAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Message that is being broadcast.
*
*/
readonly message: string;
/**
- Explanation:
* Player that sent the chat message.
*
*/
readonly sender: Player;
/**
- Explanation:
* Optional list of players that will receive this message. If
* defined, this message is directly targeted to one or more
* players (i.e., is not broadcast.)
*
*/
readonly targets?: Player[];
}
/**
* @beta
* Manages callbacks that are connected to chat messages being
* sent.
*/
### Class: ChatSendAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ChatSendAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ChatSendAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when new chat messages
* are sent.
*
* This function can't be called in read-only mode.
*
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* const chatCallback = World.beforeEvents.chatSend.subscribe((eventData) => {
* if (eventData.message.includes("cancel")) {
* // Cancel event if the message contains "cancel"
* eventData.canceled = true;
* } else {
* // Modify chat message being sent
* eventData.message = `Modified '${eventData.message}'`;
* }
* });
* ```
*/
subscribe(callback: (arg: ChatSendAfterEvent) => void): (arg: ChatSendAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when new chat messages
* are sent.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ChatSendAfterEvent) => void): void;
}
/**
* @beta
* An event that fires as players enter chat messages.
*/
### Class: ChatSendBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: ChatSendBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `ChatSendBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true in a beforeChat event handler, this message
* is not broadcast out.
*
*/
cancel: boolean;
/**
- Explanation:
* Message that is being broadcast.
*
*/
readonly message: string;
/**
- Explanation:
* Player that sent the chat message.
*
*/
readonly sender: Player;
/**
- Explanation:
* Optional list of players that will receive this message. If
* defined, this message is directly targeted to one or more
* players (i.e., is not broadcast.)
*
*/
readonly targets?: Player[];
}
/**
* @beta
* Manages callbacks that are connected to an event that fires
* before chat messages are sent.
*/
### Class: ChatSendBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ChatSendBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `ChatSendBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before new chat messages
* are sent.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ChatSendBeforeEvent) => void): (arg: ChatSendBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before new chat
* messages are sent.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ChatSendBeforeEvent) => void): void;
}
/**
* Contains return data on the result of a command execution.
*/
### Class: CommandResult
This section details the purpose, properties, methods, and code examples for `Class: CommandResult` in the Minecraft Bedrock Edition Script API.
The `CommandResult` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If the command operates against a number of entities,
* blocks, or items, this returns the number of successful
* applications of this command.
*
*/
readonly successCount: number;
}
/**
* Base class for downstream Component implementations.
*/
### Class: Component
This section details the purpose, properties, methods, and code examples for `Class: Component` in the Minecraft Bedrock Edition Script API.
The `Component` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Identifier of the component.
*
*/
readonly typeId: string;
/**
- Explanation:
* Returns whether the component is valid. A component is
* considered valid if its owner is valid, in addition to any
* addition to any additional validation required by the
* component.
*
* @returns
* Whether the component is valid.
*/
isValid(): boolean;
}
/**
* @beta
* The Compound Block Volume is a collection of individual
* block volume definitions which, as a collection, define a
* larger volume of (sometimes non-contiguous) irregular
* shapes.
* This class is loosely based on the concept of CSG
* (Computational Solid Geometry) and allows a user to create
* complex volumes by building a stack of volumes and voids to
* make a larger single volume.
* For example - normally a creator would create a hollow cube
* by creating 6 "wall" surfaces for each face.
* With a Compound Block Volume, a creator can define a hollow
* cube by creating a single outer solid cube, and then
* defining a further single 'void' cube inside the larger one.
* Similarly, the Compound Block Volume can represent irregular
* shaped volumes (e.g. a tree consists of a trunk and lots of
* leaf cubes which are not necessarily contiguously placed).
* Each of the volumes added to the CompoundBlockVolume are (by
* default) relative to the origin set (either at construction
* or via one of the set functions).
* However, it is also possible to push volumes to the compound
* collection which are absolute in nature and are not affected
* by origin changes.
*/
### Class: CompoundBlockVolume
This section details the purpose, properties, methods, and code examples for `Class: CompoundBlockVolume` in the Minecraft Bedrock Edition Script API.
The `CompoundBlockVolume` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
/**
- Explanation:
* Return the 'capacity' of the bounding rectangle which
* represents the collection of volumes in the stack
*
*/
readonly capacity: number;
readonly items: CompoundBlockVolumeItem[];
readonly itemsAbsolute: CompoundBlockVolumeItem[];
/**
- Explanation:
* Return the number of volumes (positive and negative) in the
* volume stack
*
*/
readonly volumeCount: number;
/**
- Explanation:
* Create a CompoundBlockVolume object
*
* @param origin
* An optional world space origin on which to center the
* compound volume.
* If not specified, the origin is set to (0,0,0)
*/
constructor(origin?: Vector3);
/**
- Explanation:
* Clear the contents of the volume stack
*
* This function can't be called in read-only mode.
*
*/
clear(): void;
/**
- Explanation:
* Fetch a Block Location Iterator for the Compound Block
* Volume. This iterator will allow a creator to iterate
* across all of the selected volumes within the larger
* bounding area.
* Areas of a volume which have been overridden by a
* subtractive volume will not be included in the iterator
* step.
* (i.e. if you push a cube to the stack, and then push a
* subtractive volume to the same location, then the iterator
* will step over the initial volume because it is considered
* negative space)
* Note that the Block Locations returned by this iterator are
* in absolute world space (irrespective of whether the
* compound volume items pushed are absolute or relative)
*
* This function can't be called in read-only mode.
*
*/
getBlockLocationIterator(): BlockLocationIterator;
/**
- Explanation:
* Get the largest bounding box that represents a container for
* all of the volumes on the stack
* Note that the bounding box returned is represented in
* absolute world space (irrespective of whether the compound
* volume items pushed are absolute or relative)
*
* This function can't be called in read-only mode.
*
*/
getBoundingBox(): BoundingBox;
/**
- Explanation:
* Get the max block location of the outermost bounding
* rectangle which represents the volumes on the stack.
* Note that the max location returned is in absolute world
* space (irrespective of whether the compound volume items
* pushed are absolute or relative)
*
* This function can't be called in read-only mode.
*
*/
getMax(): Vector3;
/**
- Explanation:
* Get the min block location of the outermost bounding
* rectangle which represents the volumes on the stack.
* Note that the min location returned is in absolute world
* space (irrespective of whether the compound volume items
* pushed are absolute or relative)
*
* This function can't be called in read-only mode.
*
*/
getMin(): Vector3;
/**
- Explanation:
* Fetch the origin in world space of the compound volume
*
* This function can't be called in read-only mode.
*
*/
getOrigin(): Vector3;
/**
- Explanation:
* Return a boolean which signals if there are any volume items
* pushed to the volume
*
* This function can't be called in read-only mode.
*
*/
isEmpty(): boolean;
/**
- Explanation:
* Return a boolean representing whether or not a given
* absolute world space block location is inside a positive
* block volume.
* E.g. if the stack contains a large cube followed by a
* slightly smaller negative cube, and the test location is
* within the negative cube - the function will return false
* because it's not 'inside' a volume (it IS inside the
* bounding rectangle, but it is not inside a positively
* defined location)
*
* This function can't be called in read-only mode.
*
*/
isInside(worldLocation: Vector3): boolean;
/**
- Explanation:
* Inspect the last entry pushed to the volume stack without
* affecting the stack contents.
*
* This function can't be called in read-only mode.
*
* @param forceRelativity
* Determine whether the function returns a
* CompoundBlockVolumeItem which is forced into either relative
* or absolute coordinate system.
* `true` = force returned item to be relative to volume origin
* `false` = force returned item to be absolute world space
* location
*
* If no flag is specified, the item returned retains whatever
* relativity it had when it was pushed
* @returns
* Returns undefined if the stack is empty
*/
peekLastVolume(forceRelativity?: CompoundBlockVolumePositionRelativity): CompoundBlockVolumeItem | undefined;
/**
- Explanation:
* Remove the last entry from the volume stack. This will
* reduce the stack size by one
*
* This function can't be called in read-only mode.
*
*/
popVolume(): boolean;
/**
- Explanation:
* Push a volume item to the stack. The volume item contains
* an 'action' parameter which determines whether this volume
* is a positive or negative space.
* The item also contains a `locationRelativity` which
* determines whether it is relative or absolute to the
* compound volume origin
*
* This function can't be called in read-only mode.
*
* @param item
* Item to push to the end of the stack
*/
pushVolume(item: CompoundBlockVolumeItem): void;
/**
- Explanation:
* If the volume stack is empty, this function will push the
* specified item to the stack.
* If the volume stack is NOT empty, this function will replace
* the last item on the stack with the new item.
*
* This function can't be called in read-only mode.
*
* @param item
* Item to add or replace
*/
replaceOrAddLastVolume(item: CompoundBlockVolumeItem): boolean;
/**
- Explanation:
* Set the origin of the compound volume to an absolute world
* space location
*
* This function can't be called in read-only mode.
*
* @param preserveExistingVolumes
* This optional boolean flag determines whether the relative
* `CompoundBlockVolumeItem`'s are frozen in place, or are
* affected by the new origin.
* Imagine a scenario where you have a series of relative
* locations around an origin which make up a sphere; all of
* these locations are in the range of -2 to 2.
* Push each of these locations to the compound volume as
* relative items.
* Now, move the origin and all of the locations representing
* the sphere move accordingly.
* However, let's say you want to add a 2nd sphere next to the
* 1st.
* In this case, set the new origin a few locations over, but
* 'preserveExistingVolumes' = true.
* This will set a new origin, but the existing sphere
* locations will remain relative to the original origin.
* Now, you can push the relative sphere locations again (this
* time they will be relative to the new origin) - resulting in
* 2 spheres next to each other.
*/
setOrigin(position: Vector3, preserveExistingVolumes?: boolean): void;
/**
- Explanation:
* Similar to {@link
* @minecraft-server/CompoundBlockVolume.setOrigin} - this
* function will translate the origin by a given delta to a new
* position
*
* This function can't be called in read-only mode.
*
* @param preserveExistingVolumes
* See the description for the arguments to {@link
* @minecraft-server/CompoundBlockVolume.setOrigin}
*/
translateOrigin(delta: Vector3, preserveExistingVolumes?: boolean): void;
}
/**
* Represents a container that can hold sets of items. Used
* with entities such as Players, Chest Minecarts, Llamas, and
* more.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* let leftLocation = test.worldLocation({ x: 2, y: 2, z: 2 }); // left chest location
* let rightLocation = test.worldLocation({ x: 4, y: 2, z: 2 }); // right chest location
*
* const chestCart = test.spawn("chest_minecart", { x: 6, y: 2, z: 2 });
*
* let leftChestBlock = defaultDimension.getBlock(leftLocation);
* let rightChestBlock = defaultDimension.getBlock(rightLocation);
*
* leftChestBlock.setType(MinecraftBlockTypes.chest);
* rightChestBlock.setType(MinecraftBlockTypes.chest);
*
* const rightChestInventoryComp = rightChestBlock.getComponent("inventory");
* const leftChestInventoryComp = leftChestBlock.getComponent("inventory");
* const chestCartInventoryComp = chestCart.getComponent("inventory");
*
* const rightChestContainer = rightChestInventoryComp.container;
* const leftChestContainer = leftChestInventoryComp.container;
* const chestCartContainer = chestCartInventoryComp.container;
*
* rightChestContainer.setItem(0, new ItemStack(Items.apple, 10, 0));
* test.assert(rightChestContainer.getItem(0).id === "apple", "Expected apple in right container slot index 0");
*
* rightChestContainer.setItem(1, new ItemStack(Items.emerald, 10, 0));
* test.assert(rightChestContainer.getItem(1).id === "emerald", "Expected emerald in right container slot index 1");
*
* test.assert(rightChestContainer.size === 27, "Unexpected size: " + rightChestContainer.size);
* test.assert(
* rightChestContainer.emptySlotsCount === 25,
* "Unexpected emptySlotsCount: " + rightChestContainer.emptySlotsCount
* );
*
* const itemStack = rightChestContainer.getItem(0);
* test.assert(itemStack.id === "apple", "Expected apple");
* test.assert(itemStack.amount === 10, "Expected 10 apples");
* test.assert(itemStack.data === 0, "Expected 0 data");
*
* leftChestContainer.setItem(0, new ItemStack(Items.cake, 10, 0));
*
* rightChestContainer.transferItem(0, 4, chestCartContainer); // transfer the apple from the right chest to a chest cart
* rightChestContainer.swapItems(1, 0, leftChestContainer); // swap the cake and emerald
*
* test.assert(chestCartContainer.getItem(4).id === "apple", "Expected apple in left container slot index 4");
* test.assert(leftChestContainer.getItem(0).id === "emerald", "Expected emerald in left container slot index 0");
* test.assert(rightChestContainer.getItem(1).id === "cake", "Expected cake in right container slot index 1");
*
* ```
*/
### Class: Container
This section details the purpose, properties, methods, and code examples for `Class: Container` in the Minecraft Bedrock Edition Script API.
The `Container` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Count of the slots in the container that are empty.
*
* @throws
* Throws if the container is invalid.
*/
readonly emptySlotsCount: number;
/**
- Explanation:
* The number of slots in this container. For example, a
* standard single-block chest has a size of 27. Note, a
* player's inventory container contains a total of 36 slots, 9
* hotbar slots plus 27 inventory slots.
*
* @throws
* Throws if the container is invalid.
*/
readonly size: number;
/**
- Explanation:
* Adds an item to the container. The item is placed in the
* first available slot(s) and can be stacked with existing
* items of the same type. Note, use {@link Container.setItem}
* if you wish to set the item in a particular slot.
*
* This function can't be called in read-only mode.
*
* @param itemStack
* The stack of items to add.
* @throws This function can throw errors.
*/
addItem(itemStack: ItemStack): ItemStack | undefined;
/**
- Explanation:
* Clears all inventory items in the container.
*
* This function can't be called in read-only mode.
*
* @throws
* Throws if the container is invalid.
*/
clearAll(): void;
/**
- Explanation:
* Gets an {@link ItemStack} of the item at the specified slot.
* If the slot is empty, returns `undefined`. This method does
* not change or clear the contents of the specified slot. To
* get a reference to a particular slot, see {@link
* Container.getSlot}.
*
* @param slot
* Zero-based index of the slot to retrieve items from.
* @throws
* Throws if the container is invalid or if the `slot` index is
* out of bounds.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that gets a copy of the first item in the player's hotbar
*
* function getFirstHotbarItem(player: Player): ItemStack | undefined {
* const inventory = player.getComponent(EntityInventoryComponent.componentId);
* if (inventory && inventory.container) {
* return inventory.container.getItem(0);
* }
* return undefined;
* }
* ```
*/
getItem(slot: number): ItemStack | undefined;
/**
- Explanation:
* Returns a container slot. This acts as a reference to a slot
* at the given index for this container.
*
* @param slot
* The index of the slot to return. This index must be within
* the bounds of the container.
* @throws
* Throws if the container is invalid or if the `slot` index is
* out of bounds.
*/
getSlot(slot: number): ContainerSlot;
/**
- Explanation:
* Returns whether a container object (or the entity or block
* that this container is associated with) is still available
* for use in this context.
*
*/
isValid(): boolean;
/**
- Explanation:
* Moves an item from one slot to another, potentially across
* containers.
*
* This function can't be called in read-only mode.
*
* @param fromSlot
* Zero-based index of the slot to transfer an item from, on
* this container.
* @param toSlot
* Zero-based index of the slot to transfer an item to, on
* `toContainer`.
* @param toContainer
* Target container to transfer to. Note this can be the same
* container as the source.
* @throws
* Throws if either this container or `toContainer` are invalid
* or if the `fromSlot` or `toSlot` indices out of bounds.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that moves an item from one slot of the player's inventory to another player's inventory
*
* function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) {
* const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory);
* const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory);
*
* if (fromInventory && toInventory && fromInventory.container && toInventory.container) {
* fromInventory.container.moveItem(slotId, slotId, toInventory.container);
* }
* }
* ```
*/
moveItem(fromSlot: number, toSlot: number, toContainer: Container): void;
/**
- Explanation:
* Sets an item stack within a particular slot.
*
* This function can't be called in read-only mode.
*
* @param slot
* Zero-based index of the slot to set an item at.
* @param itemStack
* Stack of items to place within the specified slot. Setting
* `itemStack` to undefined will clear the slot.
* @throws
* Throws if the container is invalid or if the `slot` index is
* out of bounds.
*/
setItem(slot: number, itemStack?: ItemStack): void;
/**
- Explanation:
* Swaps items between two different slots within containers.
*
* This function can't be called in read-only mode.
*
* @param slot
* Zero-based index of the slot to swap from this container.
* @param otherSlot
* Zero-based index of the slot to swap with.
* @param otherContainer
* Target container to swap with. Note this can be the same
* container as this source.
* @throws
* Throws if either this container or `otherContainer` are
* invalid or if the `slot` or `otherSlot` are out of bounds.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that swaps an item from one slot of the player's inventory to another player's inventory
*
* function swapBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) {
* const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory);
* const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory);
*
* if (fromInventory && toInventory && fromInventory.container && toInventory.container) {
* fromInventory.container.swapItems(slotId, slotId, toInventory.container);
* }
* }
* ```
*/
swapItems(slot: number, otherSlot: number, otherContainer: Container): void;
/**
- Explanation:
* Moves an item from one slot to another container, or to the
* first available slot in the same container.
*
* This function can't be called in read-only mode.
*
* @param fromSlot
* Zero-based index of the slot to transfer an item from, on
* this container.
* @param toContainer
* Target container to transfer to. Note this can be the same
* container as the source.
* @returns
* An itemStack with the items that couldn't be transferred.
* Returns undefined if all items were transferred.
* @throws
* Throws if either this container or `toContainer` are invalid
* or if the `fromSlot` or `toSlot` indices out of bounds.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that moves an item from one slot of the player's inventory to another player's inventory
*
* function moveBetweenPlayers(slotId: number, fromPlayer: Player, toPlayer: Player) {
* const fromInventory = fromPlayer.getComponent(EntityComponentTypes.Inventory);
* const toInventory = toPlayer.getComponent(EntityComponentTypes.Inventory);
*
* if (fromInventory && toInventory && fromInventory.container && toInventory.container) {
* fromInventory.container.transferItem(slotId, toInventory.container);
* }
* }
* ```
*/
transferItem(fromSlot: number, toContainer: Container): ItemStack | undefined;
}
/**
* Represents a slot within a broader container (e.g., entity
* inventory.)
*/
### Class: ContainerSlot
This section details the purpose, properties, methods, and code examples for `Class: ContainerSlot` in the Minecraft Bedrock Edition Script API.
The `ContainerSlot` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Number of the items in the stack. Valid values range between
* 1-255. The provided value will be clamped to the item's
* maximum stack size.
*
* This property can't be edited in read-only mode.
*
* @throws
* Throws if the value is outside the range of 1-255.
*/
amount: number;
/**
- Explanation:
* Returns whether the item is stackable. An item is considered
* stackable if the item's maximum stack size is greater than 1
* and the item does not contain any custom data or properties.
*
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
readonly isStackable: boolean;
/**
- Explanation:
* Gets or sets whether the item is kept on death.
*
* This property can't be edited in read-only mode.
*
* @throws
* Throws if the slot's container is invalid.
*/
keepOnDeath: boolean;
/**
- Explanation:
* Gets or sets the item's lock mode. The default value is
* `ItemLockMode.none`.
*
* This property can't be edited in read-only mode.
*
* @throws
* Throws if the slot's container is invalid.
*/
lockMode: ItemLockMode;
/**
- Explanation:
* The maximum stack size. This value varies depending on the
* type of item. For example, torches have a maximum stack size
* of 64, while eggs have a maximum stack size of 16.
*
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
readonly maxAmount: number;
/**
- Explanation:
* Given name of this stack of items. The name tag is displayed
* when hovering over the item. Setting the name tag to an
* empty string or `undefined` will remove the name tag.
*
* This property can't be edited in read-only mode.
*
* @throws
* Throws if the slot's container is invalid. Also throws if
* the length exceeds 255 characters.
*/
nameTag?: string;
/**
- Explanation:
* The type of the item.
*
* @throws
* Throws if the slot's container is invalid.
*
* {@link minecraftcommon.EngineError}
*
* {@link InvalidContainerSlotError}
*/
readonly 'type': ItemType;
/**
- Explanation:
* Identifier of the type of items for the stack. If a
* namespace is not specified, 'minecraft:' is assumed.
* Examples include 'wheat' or 'apple'.
*
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
readonly typeId: string;
/**
- Explanation:
* Clears all dynamic properties that have been set on this
* item stack.
*
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
clearDynamicProperties(): void;
/**
* @throws This function can throw errors.
*
* {@link InvalidContainerSlotError}
*/
getCanDestroy(): string[];
/**
* @throws This function can throw errors.
*
* {@link InvalidContainerSlotError}
*/
getCanPlaceOn(): string[];
/**
- Explanation:
* Returns a property value.
*
* @param identifier
* The property identifier.
* @returns
* Returns the value for the property, or undefined if the
* property has not been set.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined;
/**
- Explanation:
* Returns the available set of dynamic property identifiers
* that have been used on this item stack.
*
* @returns
* A string array of the dynamic properties set on this entity.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
getDynamicPropertyIds(): string[];
/**
- Explanation:
* Returns the total size, in bytes, of all the dynamic
* properties that are currently stored for this entity. This
* includes the size of both the key and the value. This can
* be useful for diagnosing performance warning signs - if, for
* example, an entity has many megabytes of associated dynamic
* properties, it may be slow to load on various devices.
*
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
getDynamicPropertyTotalByteCount(): number;
/**
- Explanation:
* Creates an exact copy of the item stack, including any
* custom data or properties.
*
* @returns
* Returns a copy of the item in the slot. Returns undefined if
* the slot is empty.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
getItem(): ItemStack | undefined;
/**
- Explanation:
* Returns the lore value - a secondary display string - for an
* ItemStack.
*
* @returns
* An array of lore strings. If the item does not have lore,
* returns an empty array.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
getLore(): string[];
/**
- Explanation:
* Returns all tags for the item in the slot.
*
* @returns
* Returns all tags for the item in the slot. Return an empty
* array if the the slot is empty.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
getTags(): string[];
/**
* @throws This function can throw errors.
*
* {@link InvalidContainerSlotError}
*/
hasItem(): boolean;
/**
- Explanation:
* Returns whether the item in the slot slot has the given tag.
*
* @param tag
* The item tag.
* @returns
* Returns false when the slot is empty or the item in the slot
* does not have the given tag.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
hasTag(tag: string): boolean;
/**
- Explanation:
* Returns whether this item stack can be stacked with the
* given `itemStack`. This is determined by comparing the item
* type and any custom data and properties associated with the
* item stacks. The amount of each item stack is not taken into
* consideration.
*
* @param itemStack
* The ItemStack that is being compared.
* @returns
* Returns whether this item stack can be stacked with the
* given `itemStack`.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
isStackableWith(itemStack: ItemStack): boolean;
/**
- Explanation:
* Returns whether the ContainerSlot is valid. The container
* slot is valid if the container exists and is loaded, and the
* slot index is valid.
*
*/
isValid(): boolean;
/**
- Explanation:
* The list of block types this item can break in Adventure
* mode. The block names are displayed in the item's tooltip.
* Setting the value to undefined will clear the list.
*
* This function can't be called in read-only mode.
*
* @param blockIdentifiers
* The list of blocks, given by their identifiers.
* @throws
* Throws if the slot's container is invalid. Also throws if
* any of the provided block identifiers are invalid.
*
* {@link Error}
*
* {@link InvalidContainerSlotError}
*/
setCanDestroy(blockIdentifiers?: string[]): void;
/**
- Explanation:
* The list of block types this item can be placed on in
* Adventure mode. This is only applicable to block items. The
* block names are displayed in the item's tooltip. Setting the
* value to undefined will clear the list.
*
* This function can't be called in read-only mode.
*
* @param blockIdentifiers
* The list of blocks, given by their identifiers.
* @throws
* Throws if the slot's container is invalid. Also throws if
* any of the provided block identifiers are invalid.
*
* {@link Error}
*
* {@link InvalidContainerSlotError}
*/
setCanPlaceOn(blockIdentifiers?: string[]): void;
/**
- Explanation:
* Sets a specified property to a value.
*
* @param identifier
* The property identifier.
* @param value
* Data value of the property to set.
* @throws
* Throws if the slot's container is invalid.
*
* {@link Error}
*
* {@link InvalidContainerSlotError}
*/
setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void;
/**
- Explanation:
* Sets the given ItemStack in the slot, replacing any existing
* item.
*
* This function can't be called in read-only mode.
*
* @param itemStack
* The ItemStack to be placed in the slot.
* @throws
* Throws if the slot's container is invalid.
*
* {@link InvalidContainerSlotError}
*/
setItem(itemStack?: ItemStack): void;
/**
- Explanation:
* Sets the lore value - a secondary display string - for an
* ItemStack.
*
* This function can't be called in read-only mode.
*
* @param loreList
* A list of lore strings. Setting this argument to undefined
* will clear the lore.
* @throws
* Throws if the slot's container is invalid.
*
* {@link Error}
*
* {@link InvalidContainerSlotError}
*/
setLore(loreList?: string[]): void;
}
/**
* Contains information related to firing of a data driven
* entity event - for example, the minecraft:ageable_grow_up
* event on a chicken.
*/
### Class: DataDrivenEntityTriggerAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: DataDrivenEntityTriggerAfterEvent` in the Minecraft Bedrock Edition Script API.
The `DataDrivenEntityTriggerAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Entity that the event triggered on.
*
*/
readonly entity: Entity;
/**
- Explanation:
* Name of the data driven event being triggered.
*
*/
readonly eventId: string;
/**
- Explanation:
* An updateable list of modifications to component state that
* are the effect of this triggered event.
*
*/
getModifiers(): DefinitionModifier[];
}
/**
* Contains event registration related to firing of a data
* driven entity event - for example, the
* minecraft:ageable_grow_up event on a chicken.
*/
### Class: DataDrivenEntityTriggerAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: DataDrivenEntityTriggerAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `DataDrivenEntityTriggerAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called after a data driven
* entity event is triggered.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: DataDrivenEntityTriggerAfterEvent) => void,
options?: EntityDataDrivenTriggerEventOptions,
): (arg: DataDrivenEntityTriggerAfterEvent) => void;
/**
- Explanation:
* Removes a callback that will be called after a data driven
* entity event is triggered.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: DataDrivenEntityTriggerAfterEvent) => void): void;
}
/**
* A class that represents a particular dimension (e.g., The
* End) within a world.
*/
### Class: Dimension
This section details the purpose, properties, methods, and code examples for `Class: Dimension` in the Minecraft Bedrock Edition Script API.
The `Dimension` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Height range of the dimension.
*
* @throws This property can throw when used.
*/
readonly heightRange: minecraftcommon.NumberRange;
/**
- Explanation:
* Identifier of the dimension.
*
*/
readonly id: string;
/**
* @beta
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link UnloadedChunksError}
*/
containsBlock(volume: BlockVolumeBase, filter: BlockFilter, allowUnloadedChunks?: boolean): boolean;
/**
- Explanation:
* Creates an explosion at the specified location.
*
* This function can't be called in read-only mode.
*
* @param location
* The location of the explosion.
* @param radius
* Radius, in blocks, of the explosion to create.
* @param explosionOptions
* Additional configurable options for the explosion.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Creates an explosion of radius 15 that does not break blocks
*
* function createExplosions(location: DimensionLocation) {
* // Creates an explosion of radius 15 that does not break blocks
* location.dimension.createExplosion(location, 15, { breaksBlocks: false });
*
* // Creates an explosion of radius 15 that does not cause fire
* location.dimension.createExplosion(location, 15, { causesFire: true });
*
* // Creates an explosion of radius 10 that can go underwater
* location.dimension.createExplosion(location, 10, { allowUnderwater: true });
* }
* ```
*/
createExplosion(location: Vector3, radius: number, explosionOptions?: ExplosionOptions): boolean;
/**
* @beta
- Explanation:
* Fills an area between begin and end with block of type
* block.
*
* This function can't be called in read-only mode.
*
* @param block
* Type of block to fill the volume with.
* @param options
* A set of additional options, such as a matching block to
* potentially replace this fill block with.
* @returns
* Returns number of blocks placed.
* @throws This function can throw errors.
*
* {@link minecraftcommon.EngineError}
*
* {@link Error}
*
* {@link UnloadedChunksError}
*/
fillBlocks(
volume: BlockVolumeBase | CompoundBlockVolume,
block: BlockPermutation | BlockType | string,
options?: BlockFillOptions,
): ListBlockVolume;
/**
* @beta
- Explanation:
* Finds the location of the closest biome of a particular
* type. Note that the findClosestBiome operation can take some
* time to complete, so avoid using many of these calls within
* a particular tick.
*
* This function can't be called in read-only mode.
*
* @param pos
* Starting location to look for a biome to find.
* @param biomeToFind
* Identifier of the biome to look for.
* @param options
* Additional selection criteria for a biome search.
* @returns
* Returns a location of the biome, or undefined if a biome
* could not be found.
* @throws This function can throw errors.
*
* {@link minecraftcommon.EngineError}
*
* {@link Error}
*/
findClosestBiome(pos: Vector3, biomeToFind: BiomeType | string, options?: BiomeSearchOptions): Vector3 | undefined;
/**
- Explanation:
* Returns a block instance at the given location.
*
* @param location
* The location at which to return a block.
* @returns
* Block at the specified location, or 'undefined' if asking
* for a block at an unloaded chunk.
* @throws
* PositionInUnloadedChunkError: Exception thrown when trying
* to interact with a Block object that isn't in a loaded and
* ticking chunk anymore
*
* PositionOutOfWorldBoundariesError: Exception thrown when
* trying to interact with a position outside of dimension
* height range
*
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
getBlock(location: Vector3): Block | undefined;
/**
- Explanation:
* Gets the first block that intersects with a vector emanating
* from a location.
*
* @param location
* Location from where to initiate the ray check.
* @param direction
* Vector direction to cast the ray.
* @param options
* Additional options for processing this raycast query.
* @throws This function can throw errors.
*/
getBlockFromRay(location: Vector3, direction: Vector3, options?: BlockRaycastOptions): BlockRaycastHit | undefined;
/**
* @beta
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link UnloadedChunksError}
*/
getBlocks(volume: BlockVolumeBase, filter: BlockFilter, allowUnloadedChunks?: boolean): ListBlockVolume;
/**
- Explanation:
* Returns a set of entities based on a set of conditions
* defined via the EntityQueryOptions set of filter criteria.
*
* @param options
* Additional options that can be used to filter the set of
* entities returned.
* @returns
* An entity array.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Returns true if a feather item entity is within 'distance' blocks of 'location'.
* function isFeatherNear(location: DimensionLocation, distance: number): boolean {
* const items = location.dimension.getEntities({
* location: location,
* maxDistance: 20,
* });
*
* for (const item of items) {
* const itemComp = item.getComponent(EntityComponentTypes.Item);
*
* if (itemComp) {
* if (itemComp.itemStack.typeId.endsWith('feather')) {
* return true;
* }
* }
* }
*
* return false;
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function mobParty(targetLocation: DimensionLocation) {
* const mobs = ['creeper', 'skeleton', 'sheep'];
*
* // create some sample mob data
* for (let i = 0; i < 10; i++) {
* const mobTypeId = mobs[i % mobs.length];
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
* entity.addTag('mobparty.' + mobTypeId);
* }
*
* const eqo: EntityQueryOptions = {
* tags: ['mobparty.skeleton'],
* };
*
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
* entity.kill();
* }
* }
* ```
*/
getEntities(options?: EntityQueryOptions): Entity[];
/**
- Explanation:
* Returns a set of entities at a particular location.
*
* @param location
* The location at which to return entities.
* @returns
* Zero or more entities at the specified location.
*/
getEntitiesAtBlockLocation(location: Vector3): Entity[];
/**
- Explanation:
* Gets entities that intersect with a specified vector
* emanating from a location.
*
* @param options
* Additional options for processing this raycast query.
* @throws This function can throw errors.
*/
getEntitiesFromRay(location: Vector3, direction: Vector3, options?: EntityRaycastOptions): EntityRaycastHit[];
/**
- Explanation:
* Returns a set of players based on a set of conditions
* defined via the EntityQueryOptions set of filter criteria.
*
* @param options
* Additional options that can be used to filter the set of
* players returned.
* @returns
* A player array.
* @throws This function can throw errors.
*/
getPlayers(options?: EntityQueryOptions): Player[];
/**
* @beta
- Explanation:
* Returns the current weather.
*
* This function can't be called in read-only mode.
*
* @returns
* Returns a WeatherType that explains the broad category of
* weather that is currently going on.
*/
getWeather(): WeatherType;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
playSound(soundId: string, location: Vector3, soundOptions?: WorldSoundOptions): void;
/**
- Explanation:
* Runs a command synchronously using the context of the
* broader dimenion.
*
* This function can't be called in read-only mode.
*
* @param commandString
* Command to run. Note that command strings should not start
* with slash.
* @returns
* Returns a command result with a count of successful values
* from the command.
* @throws
* Throws an exception if the command fails due to incorrect
* parameters or command syntax, or in erroneous cases for the
* command. Note that in many cases, if the command does not
* operate (e.g., a target selector found no matches), this
* method will not throw an exception.
*
* {@link CommandError}
*/
runCommand(commandString: string): CommandResult;
/**
- Explanation:
* Runs a particular command asynchronously from the context of
* the broader dimension. Note that there is a maximum queue
* of 128 asynchronous commands that can be run in a given
* tick.
*
* @param commandString
* Command to run. Note that command strings should not start
* with slash.
* @returns
* For commands that return data, returns a CommandResult with
* an indicator of command results.
* @throws
* Throws an exception if the command fails due to incorrect
* parameters or command syntax, or in erroneous cases for the
* command. Note that in many cases, if the command does not
* operate (e.g., a target selector found no matches), this
* method will not throw an exception.
*/
runCommandAsync(commandString: string): Promise<CommandResult>;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
setBlockPermutation(location: Vector3, permutation: BlockPermutation): void;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
*/
setBlockType(location: Vector3, blockType: BlockType | string): void;
/**
- Explanation:
* Sets the current weather within the dimension
*
* This function can't be called in read-only mode.
*
* @param weatherType
* Set the type of weather to apply.
* @param duration
* Sets the duration of the weather (in ticks). If no duration
* is provided, the duration will be set to a random duration
* between 300 and 900 seconds.
* @throws This function can throw errors.
*/
setWeather(weatherType: WeatherType, duration?: number): void;
/**
- Explanation:
* Creates a new entity (e.g., a mob) at the specified
* location.
*
* This function can't be called in read-only mode.
*
* @param identifier
* Identifier of the type of entity to spawn. If no namespace
* is specified, 'minecraft:' is assumed.
* @param location
* The location at which to create the entity.
* @returns
* Newly created entity at the specified location.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns an adult horse
*
* function spawnAdultHorse(location: DimensionLocation) {
* // Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult
* location.dimension.spawnEntity('minecraft:horse<minecraft:ageable_grow_up>', location);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns a fox over a dog
*
* function spawnAdultHorse(location: DimensionLocation) {
* // Create fox (our quick brown fox)
* const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, {
* x: location.x,
* y: location.y + 2,
* z: location.z,
* });
*
* fox.addEffect('speed', 10, {
* amplifier: 2,
* });
*
* // Create wolf (our lazy dog)
* const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location);
* wolf.addEffect('slowness', 10, {
* amplifier: 2,
* });
* wolf.isSneaking = true;
* }
* ```
*/
spawnEntity(identifier: string, location: Vector3, options?: SpawnEntityOptions): Entity;
/**
- Explanation:
* Creates a new item stack as an entity at the specified
* location.
*
* This function can't be called in read-only mode.
*
* @param location
* The location at which to create the item stack.
* @returns
* Newly created item stack entity at the specified location.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns a feather at a location
*
* function spawnFeather(location: DimensionLocation) {
* const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1);
* location.dimension.spawnItem(featherItem, location);
* }
* ```
*/
spawnItem(itemStack: ItemStack, location: Vector3): Entity;
/**
- Explanation:
* Creates a new particle emitter at a specified location in
* the world.
*
* This function can't be called in read-only mode.
*
* @param effectName
* Identifier of the particle to create.
* @param location
* The location at which to create the particle emitter.
* @param molangVariables
* A set of optional, customizable variables that can be
* adjusted for this particle.
* @throws This function can throw errors.
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that spawns a particle at a random location near the target location for all players in the 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);
* }
* }
* ```
*/
spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void;
}
/**
* Represents a type of dimension.
*/
### Class: DimensionType
This section details the purpose, properties, methods, and code examples for `Class: DimensionType` in the Minecraft Bedrock Edition Script API.
The `DimensionType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Identifier of the dimension type.
*
*/
readonly typeId: string;
}
/**
* Used for accessing all available dimension types.
*/
### Class: DimensionTypes
This section details the purpose, properties, methods, and code examples for `Class: DimensionTypes` in the Minecraft Bedrock Edition Script API.
The `DimensionTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Retrieves a dimension type using a string-based identifier.
*
*/
static get(dimensionTypeId: string): DimensionType | undefined;
/**
- Explanation:
* Retrieves an array of all dimension types.
*
*/
static getAll(): DimensionType[];
}
/**
* Represents an effect - like poison - that has been added to
* an Entity.
*/
### Class: Effect
This section details the purpose, properties, methods, and code examples for `Class: Effect` in the Minecraft Bedrock Edition Script API.
The `Effect` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Gets an amplifier that may have been applied to this effect.
* Sample values range typically from 0 to 4. Example: The
* effect 'Jump Boost II' will have an amplifier value of 1.
*
* @throws This property can throw when used.
*/
readonly amplifier: number;
/**
- Explanation:
* Gets the player-friendly name of this effect.
*
* @throws This property can throw when used.
*/
readonly displayName: string;
/**
- Explanation:
* Gets the entire specified duration, in ticks, of this
* effect. There are 20 ticks per second. Use {@link
* TicksPerSecond} constant to convert between ticks and
* seconds.
*
* @throws This property can throw when used.
*/
readonly duration: number;
/**
- Explanation:
* Gets the type id of this effect.
*
* @throws This property can throw when used.
*/
readonly typeId: string;
/**
- Explanation:
* Returns whether an effect instance is available for use in
* this context.
*
*/
isValid(): boolean;
}
/**
* Contains information related to changes to an effect - like
* poison - being added to an entity.
*/
### Class: EffectAddAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EffectAddAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EffectAddAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Additional properties and details of the effect.
*
*/
readonly effect: Effect;
/**
- Explanation:
* Entity that the effect is being added to.
*
*/
readonly entity: Entity;
}
/**
* Manages callbacks that are connected to when an effect is
* added to an entity.
*/
### Class: EffectAddAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EffectAddAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EffectAddAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an effect is added
* to an entity.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: EffectAddAfterEvent) => void,
options?: EntityEventOptions,
): (arg: EffectAddAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an effect is added
* to an entity.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: EffectAddAfterEvent) => void): void;
}
/**
* Contains information related to changes to an effect - like
* poison - being added to an entity.
*/
### Class: EffectAddBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: EffectAddBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `EffectAddBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* When set to true will cancel the event.
*
*/
cancel: boolean;
/**
- Explanation:
* Effect duration.
*
*/
duration: number;
/**
- Explanation:
* The type of the effect that is being added.
*
*/
readonly effectType: string;
/**
- Explanation:
* Entity that the effect is being added to.
*
*/
readonly entity: Entity;
}
/**
* Manages callbacks that are connected to when an effect is
* added to an entity.
*/
### Class: EffectAddBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EffectAddBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `EffectAddBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an effect is added
* to an entity.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: EffectAddBeforeEvent) => void): (arg: EffectAddBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an effect is added
* to an entity.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: EffectAddBeforeEvent) => void): void;
}
/**
* Represents a type of effect - like poison - that can be
* applied to an entity.
*/
### Class: EffectType
This section details the purpose, properties, methods, and code examples for `Class: EffectType` in the Minecraft Bedrock Edition Script API.
The `EffectType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Identifier name of this effect type.
*
* @returns
* Identifier of the effect type.
*/
getName(): string;
}
/**
* Represents a type of effect - like poison - that can be
* applied to an entity.
*/
### Class: EffectTypes
This section details the purpose, properties, methods, and code examples for `Class: EffectTypes` in the Minecraft Bedrock Edition Script API.
The `EffectTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Effect type for the given identifier.
*
* This function can't be called in read-only mode.
*
* @returns
* Effect type for the given identifier or undefined if the
* effect does not exist.
*/
static get(identifier: string): EffectType | undefined;
/**
- Explanation:
* Gets all effects.
*
* This function can't be called in read-only mode.
*
* @returns
* A list of all effects.
*/
static getAll(): EffectType[];
}
/**
* @beta
* Contains information on a type of enchantment.
*/
### Class: EnchantmentType
This section details the purpose, properties, methods, and code examples for `Class: EnchantmentType` in the Minecraft Bedrock Edition Script API.
The `EnchantmentType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
/**
- Explanation:
* The name of the enchantment type.
*
*/
readonly id: string;
/**
- Explanation:
* The maximum level this type of enchantment can have.
*
*/
readonly maxLevel: number;
/**
* @throws This function can throw errors.
*/
constructor(enchantmentType: string);
}
/**
* @beta
* Contains a catalog of Minecraft Enchantment Types that are
* available in this world.
*/
### Class: EnchantmentTypes
This section details the purpose, properties, methods, and code examples for `Class: EnchantmentTypes` in the Minecraft Bedrock Edition Script API.
The `EnchantmentTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Retrieves an enchantment with the specified identifier.
*
* @param enchantmentId
* Identifier of the enchantment. For example,
* "minecraft:flame".
* @returns
* If available, returns an EnchantmentType object that
* represents the specified enchantment.
*/
static get(enchantmentId: string): EnchantmentType | undefined;
/**
* @beta
- Explanation:
* Returns a collection of all available enchantment types.
*
*/
static getAll(): EnchantmentType[];
}
/**
* Represents the state of an entity (a mob, the player, or
* other moving objects like minecarts) in the world.
*/
### Class: Entity
This section details the purpose, properties, methods, and code examples for `Class: Entity` in the Minecraft Bedrock Edition Script API.
The `Entity` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Dimension that the entity is currently within.
*
* @throws This property can throw when used.
*/
readonly dimension: Dimension;
/**
* @beta
- Explanation:
* The distance an entity has fallen. The value is reset when
* the entity is teleported. The value is always 1 when gliding
* with Elytra.
*
* @throws This property can throw when used.
*/
readonly fallDistance: number;
/**
- Explanation:
* Unique identifier of the entity. This identifier is intended
* to be consistent across loads of a world instance. No
* meaning should be inferred from the value and structure of
* this unique identifier - do not parse or interpret it. This
* property is accessible even if {@link Entity.isValid} is
* false.
*
*/
readonly id: string;
/**
- Explanation:
* Whether the entity is touching a climbable block. For
* example, a player next to a ladder or a spider next to a
* stone wall.
*
* @throws This property can throw when used.
*/
readonly isClimbing: boolean;
/**
- Explanation:
* Whether the entity has a fall distance greater than 0, or
* greater than 1 while gliding.
*
* @throws This property can throw when used.
*/
readonly isFalling: boolean;
/**
- Explanation:
* Whether any part of the entity is inside a water block.
*
* @throws This property can throw when used.
*/
readonly isInWater: boolean;
/**
- Explanation:
* Whether the entity is on top of a solid block. This property
* may behave in unexpected ways. This property will always be
* true when an Entity is first spawned, and if the Entity has
* no gravity this property may be incorrect.
*
* @throws This property can throw when used.
*/
readonly isOnGround: boolean;
/**
- Explanation:
* If true, the entity is currently sleeping.
*
* @throws This property can throw when used.
*/
readonly isSleeping: boolean;
/**
- Explanation:
* Whether the entity is sneaking - that is, moving more slowly
* and more quietly.
*
* This property can't be edited in read-only mode.
*
*/
isSneaking: boolean;
/**
- Explanation:
* Whether the entity is sprinting. For example, a player using
* the sprint action, an ocelot running away or a pig boosting
* with Carrot on a Stick.
*
* @throws This property can throw when used.
*/
readonly isSprinting: boolean;
/**
- Explanation:
* Whether the entity is in the swimming state. For example, a
* player using the swim action or a fish in water.
*
* @throws This property can throw when used.
*/
readonly isSwimming: boolean;
/**
* @beta
- Explanation:
* Whether the entity reference that you have is valid or not.
* For example, an entity may be unloaded if it moves into a
* chunk that is unloaded, but may be reactivated if the chunk
* it is within gets reloaded.
*
*/
readonly lifetimeState: EntityLifetimeState;
/**
- Explanation:
* Current location of the entity.
*
* @throws This property can throw when used.
*/
readonly location: Vector3;
/**
- Explanation:
* Given name of the entity.
*
* This property can't be edited in read-only mode.
*
*/
nameTag: string;
/**
- Explanation:
* Returns a scoreboard identity that represents this entity.
* Will remain valid when the entity is killed.
*
*/
readonly scoreboardIdentity?: ScoreboardIdentity;
/**
* @beta
- Explanation:
* Retrieves or sets an entity that is used as the target of
* AI-related behaviors, like attacking. If the entity
* currently has no target returns undefined.
*
* @throws This property can throw when used.
*/
readonly target?: Entity;
/**
- Explanation:
* Identifier of the type of the entity - for example,
* 'minecraft:skeleton'. This property is accessible even if
* {@link Entity.isValid} is false.
*
*/
readonly typeId: string;
/**
- Explanation:
* Adds or updates an effect, like poison, to the entity.
*
* This function can't be called in read-only mode.
*
* @param effectType
* Type of effect to add to the entity.
* @param duration
* Amount of time, in ticks, for the effect to apply. There are
* 20 ticks per second. Use {@link TicksPerSecond} constant to
* convert between ticks and seconds. The value must be within
* the range [0, 20000000].
* @param options
* Additional options for the effect.
* @returns
* Returns nothing if the effect was added or updated
* successfully. This can throw an error if the duration or
* amplifier are outside of the valid ranges, or if the effect
* does not exist.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns a villager and gives it the poison effect
* DimensionLocation,
* } from '@minecraft/server';
*
* function spawnPoisonedVillager(location: DimensionLocation) {
* const villagerType = 'minecraft:villager_v2<minecraft:ageable_grow_up>';
* const villager = location.dimension.spawnEntity(villagerType, location);
* const duration = 20;
*
* villager.addEffect(MinecraftEffectTypes.Poison, duration, { amplifier: 1 });
* }
*
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns a fox over a dog
*
* function spawnAdultHorse(location: DimensionLocation) {
* // Create fox (our quick brown fox)
* const fox = location.dimension.spawnEntity(MinecraftEntityTypes.Fox, {
* x: location.x,
* y: location.y + 2,
* z: location.z,
* });
*
* fox.addEffect('speed', 10, {
* amplifier: 2,
* });
*
* // Create wolf (our lazy dog)
* const wolf = location.dimension.spawnEntity(MinecraftEntityTypes.Wolf, location);
* wolf.addEffect('slowness', 10, {
* amplifier: 2,
* });
* wolf.isSneaking = true;
* }
* ```
*/
addEffect(effectType: EffectType | string, duration: number, options?: EntityEffectOptions): Effect | undefined;
/**
- Explanation:
* Adds a specified tag to an entity.
*
* This function can't be called in read-only mode.
*
* @param tag
* Content of the tag to add. The tag must be less than 256
* characters.
* @returns
* Returns true if the tag was added successfully. This can
* fail if the tag already exists on the entity.
* @throws This function can throw errors.
*/
addTag(tag: string): boolean;
/**
- Explanation:
* Applies a set of damage to an entity.
*
* This function can't be called in read-only mode.
*
* @param amount
* Amount of damage to apply.
* @param options
* Additional options about the source of damage, which may add
* additional effects or spur additional behaviors on this
* entity.
* @returns
* Whether the entity takes any damage. This can return false
* if the entity is invulnerable or if the damage applied is
* less than or equal to 0.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that applies damage and then heals the entity
*
* function applyDamageAndHeal(entity: Entity) {
* entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob
*
* system.runTimeout(() => {
* const health = entity.getComponent(EntityComponentTypes.Health);
* if (health) {
* world.sendMessage(`Entity health before heal: ${health.currentValue}`);
*
* health.resetToMaxValue();
*
* world.sendMessage(`Entity after before heal: ${health.currentValue}`);
* } else {
* console.warn('Entity does not have health component');
* }
* }, 40); // Run in a few seconds (40 ticks)
* }
* ```
*/
applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean;
/**
- Explanation:
* Applies impulse vector to the current velocity of the
* entity.
*
* This function can't be called in read-only mode.
*
* @param vector
* Impulse vector.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that throws entities up in the air
*
* function yeetEntity(entity: Entity) {
*
* // Zero out the entity's velocity before applying impulse
* entity.clearVelocity();
*
* // throw the zombie up in the air
* entity.applyImpulse({ x: 0, y: 15, z: 0 });
* }
* ```
*/
applyImpulse(vector: Vector3): void;
/**
- Explanation:
* Applies impulse vector to the current velocity of the
* entity.
*
* This function can't be called in read-only mode.
*
* @param directionX
* X direction in horizontal plane.
* @param directionZ
* Z direction in horizontal plane.
* @param horizontalStrength
* Knockback strength for the horizontal vector.
* @param verticalStrength
* Knockback strength for the vertical vector.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function mobParty(targetLocation: DimensionLocation) {
* const mobs = ['creeper', 'skeleton', 'sheep'];
*
* // create some sample mob data
* for (let i = 0; i < 10; i++) {
* targetLocation.dimension.spawnEntity(mobs[i % mobs.length], targetLocation);
* }
*
* const eqo: EntityQueryOptions = {
* type: 'skeleton',
* };
*
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
* entity.applyKnockback(0, 0, 0, 1);
* }
* }
* ```
*/
applyKnockback(directionX: number, directionZ: number, horizontalStrength: number, verticalStrength: number): void;
/**
- Explanation:
* Clears all dynamic properties that have been set on this
* entity.
*
* @throws This function can throw errors.
*/
clearDynamicProperties(): void;
/**
- Explanation:
* Sets the current velocity of the Entity to zero. Note that
* this method may not have an impact on Players.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that throws entities up in the air
*
* function yeetEntity(entity: Entity) {
*
* // Zero out the entity's velocity before applying impulse
* entity.clearVelocity();
*
* // throw the zombie up in the air
* entity.applyImpulse({ x: 0, y: 15, z: 0 });
* }
* ```
*/
clearVelocity(): void;
/**
- Explanation:
* Extinguishes the fire if the entity is on fire. Note that
* you can call getComponent('minecraft:onfire') and, if
* present, the entity is on fire.
*
* This function can't be called in read-only mode.
*
* @param useEffects
* Whether to show any visual effects connected to the
* extinguishing.
* @returns
* Returns whether the entity was on fire.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function setAblaze(entity: Entity) {
* entity.setOnFire(20, true);
*
* system.runTimeout(() => {
* const onfire = entity.getComponent(EntityComponentTypes.OnFire);
* if (onfire) {
* world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`);
* }
* // This will extinguish the entity
* entity.extinguishFire(true);
* }, 30); // Run in 30 ticks or ~1.5 seconds
*
* }
* ```
*/
extinguishFire(useEffects?: boolean): boolean;
/**
- Explanation:
* Returns the first intersecting block from the direction that
* this entity is looking at.
*
* @param options
* Additional configuration options for the ray cast.
* @returns
* Returns the first intersecting block from the direction that
* this entity is looking at.
* @throws This function can throw errors.
*/
getBlockFromViewDirection(options?: BlockRaycastOptions): BlockRaycastHit | undefined;
/**
- Explanation:
* Gets a component (that represents additional capabilities)
* for an entity.
*
* @param componentId
* The identifier of the component (e.g., 'minecraft:health').
* If no namespace prefix is specified, 'minecraft:' is
* assumed. Available component IDs can be found as part of the
* {@link EntityComponentTypes} enum.
* @returns
* Returns the component if it exists on the entity, otherwise
* undefined.
*/
getComponent<T extends keyof EntityComponentTypeMap>(componentId: T): EntityComponentTypeMap[T] | undefined;
/**
- Explanation:
* Returns all components that are both present on this entity
* and supported by the API.
*
* @returns
* Returns all components that are both present on this entity
* and supported by the API.
*/
getComponents(): EntityComponent[];
/**
- Explanation:
* Returns a property value.
*
* @param identifier
* The property identifier.
* @returns
* Returns the value for the property, or undefined if the
* property has not been set.
* @throws This function can throw errors.
*/
getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined;
/**
- Explanation:
* Returns the available set of dynamic property identifiers
* that have been used on this entity.
*
* @returns
* A string array of the dynamic properties set on this entity.
* @throws This function can throw errors.
*/
getDynamicPropertyIds(): string[];
/**
- Explanation:
* Returns the total size, in bytes, of all the dynamic
* properties that are currently stored for this entity. This
* includes the size of both the key and the value. This can
* be useful for diagnosing performance warning signs - if, for
* example, an entity has many megabytes of associated dynamic
* properties, it may be slow to load on various devices.
*
* @throws This function can throw errors.
*/
getDynamicPropertyTotalByteCount(): number;
/**
- Explanation:
* Returns the effect for the specified EffectType on the
* entity, undefined if the effect is not present, or throws an
* error if the effect does not exist.
*
* @param effectType
* The effect identifier.
* @returns
* Effect object for the specified effect, undefined if the
* effect is not present, or throws an error if the effect does
* not exist.
* @throws This function can throw errors.
*/
getEffect(effectType: EffectType | string): Effect | undefined;
/**
- Explanation:
* Returns a set of effects applied to this entity.
*
* @returns
* List of effects.
* @throws This function can throw errors.
*/
getEffects(): Effect[];
/**
- Explanation:
* Gets the entities that this entity is looking at by
* performing a ray cast from the view of this entity.
*
* @param options
* Additional configuration options for the ray cast.
* @returns
* Returns a set of entities from the direction that this
* entity is looking at.
* @throws This function can throw errors.
*/
getEntitiesFromViewDirection(options?: EntityRaycastOptions): EntityRaycastHit[];
/**
- Explanation:
* Returns the current location of the head component of this
* entity.
*
* @returns
* Returns the current location of the head component of this
* entity.
* @throws This function can throw errors.
*/
getHeadLocation(): Vector3;
/**
- Explanation:
* Gets an entity Property value. If the property was set using
* the setProperty function within the same tick, the updated
* value will not be reflected until the subsequent tick.
*
* @param identifier
* The entity Property identifier.
* @returns
* Returns the current property value. For enum properties, a
* string is returned. For float and int properties, a number
* is returned. For undefined properties, undefined is
* returned.
* @throws
* Throws if the entity is invalid.
*/
getProperty(identifier: string): boolean | number | string | undefined;
/**
- Explanation:
* Returns the current rotation component of this entity.
*
* @returns
* Returns a Vec2 containing the rotation of this entity (in
* degrees).
* @throws This function can throw errors.
*/
getRotation(): Vector2;
/**
- Explanation:
* Returns all tags associated with the entity.
*
* @returns
* An array containing all tags as strings.
* @throws This function can throw errors.
*/
getTags(): string[];
/**
- Explanation:
* Returns the current velocity vector of the entity.
*
* @returns
* Returns the current velocity vector of the entity.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that spawns fireworks and logs their velocity after 5 ticks
*
* function spawnFireworks(location: DimensionLocation) {
* const fireworkRocket = location.dimension.spawnEntity(MinecraftEntityTypes.FireworksRocket, location);
*
* system.runTimeout(() => {
* const velocity = fireworkRocket.getVelocity();
*
* world.sendMessage(`Velocity of firework is: ${velocity.x}, ${velocity.y}, ${velocity.z}`);
* }, 5);
* }
* ```
*/
getVelocity(): Vector3;
/**
- Explanation:
* Returns the current view direction of the entity.
*
* @returns
* Returns the current view direction of the entity.
* @throws This function can throw errors.
*/
getViewDirection(): Vector3;
/**
- Explanation:
* 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.
* @returns
* Returns true if the specified component is present on this
* entity.
*/
hasComponent(componentId: string): boolean;
/**
- Explanation:
* Returns whether an entity has a particular tag.
*
* @param tag
* Identifier of the tag to test for.
* @returns
* Returns whether an entity has a particular tag.
* @throws This function can throw errors.
*/
hasTag(tag: string): boolean;
/**
- Explanation:
* Returns whether the entity can be manipulated by script. A
* Player is considered valid when it's EntityLifetimeState is
* set to Loaded.
*
* @returns
* Whether the entity is valid.
*/
isValid(): boolean;
/**
- Explanation:
* Kills this entity. The entity will drop loot as normal.
*
* This function can't be called in read-only mode.
*
* @returns
* Returns true if entity can be killed (even if it is already
* dead), otherwise it returns false.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function mobParty(targetLocation: DimensionLocation) {
* const mobs = ['creeper', 'skeleton', 'sheep'];
*
* // create some sample mob data
* for (let i = 0; i < 10; i++) {
* const mobTypeId = mobs[i % mobs.length];
* const entity = targetLocation.dimension.spawnEntity(mobTypeId, targetLocation);
* entity.addTag('mobparty.' + mobTypeId);
* }
*
* const eqo: EntityQueryOptions = {
* tags: ['mobparty.skeleton'],
* };
*
* for (const entity of targetLocation.dimension.getEntities(eqo)) {
* entity.kill();
* }
* }
* ```
*/
kill(): boolean;
/**
- Explanation:
* Matches the entity against the passed in options. Uses the
* location of the entity for matching if the location is not
* specified in the passed in EntityQueryOptions.
*
* @param options
* The query to perform the match against.
* @returns
* Returns true if the entity matches the criteria in the
* passed in EntityQueryOptions, otherwise it returns false.
* @throws
* Throws if the query options are misconfigured.
*/
matches(options: EntityQueryOptions): boolean;
/**
- Explanation:
* Cause the entity to play the given animation.
*
* This function can't be called in read-only mode.
*
* @param animationName
* The animation identifier. e.g. animation.creeper.swelling
* @param options
* Additional options to control the playback and transitions
* of the animation.
* @throws This function can throw errors.
*/
playAnimation(animationName: string, options?: PlayAnimationOptions): void;
/**
- Explanation:
* Immediately removes the entity from the world. The removed
* entity will not perform a death animation or drop loot upon
* removal.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
remove(): void;
/**
- Explanation:
* Removes the specified EffectType on the entity, or returns
* false if the effect is not present.
*
* This function can't be called in read-only mode.
*
* @param effectType
* The effect identifier.
* @returns
* Returns true if the effect has been removed. Returns false
* if the effect is not found or does not exist.
* @throws This function can throw errors.
*/
removeEffect(effectType: EffectType | string): boolean;
/**
- Explanation:
* Removes a specified tag from an entity.
*
* This function can't be called in read-only mode.
*
* @param tag
* Content of the tag to remove.
* @returns
* Returns whether the tag existed on the entity.
* @throws This function can throw errors.
*/
removeTag(tag: string): boolean;
/**
- Explanation:
* Resets an Entity Property back to its default value, as
* specified in the Entity's definition. This property change
* is not applied until the next tick.
*
* This function can't be called in read-only mode.
*
* @param identifier
* The Entity Property identifier.
* @returns
* Returns the default property value. For enum properties, a
* string is returned. For float and int properties, a number
* is returned. For undefined properties, undefined is
* returned.
* @throws
* Throws if the entity is invalid.
*
* {@link minecraftcommon.EngineError}
*
* {@link Error}
*/
resetProperty(identifier: string): boolean | number | string;
/**
- Explanation:
* Runs a synchronous command on the entity.
*
* This function can't be called in read-only mode.
*
* @param commandString
* The command string. Note: This should not include a leading
* forward slash.
* @returns
* A command result containing whether the command was
* successful.
* @throws This function can throw errors.
*
* {@link CommandError}
*
* {@link Error}
*/
runCommand(commandString: string): CommandResult;
/**
- Explanation:
* Runs a particular command asynchronously from the context of
* this entity. Note that there is a maximum queue of 128
* asynchronous commands that can be run in a given tick.
*
* @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.
*/
runCommandAsync(commandString: string): Promise<CommandResult>;
/**
- Explanation:
* Sets a specified property to a value.
*
* @param identifier
* The property identifier.
* @param value
* Data value of the property to set.
* @throws This function can throw errors.
*/
setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void;
/**
- Explanation:
* Sets an entity on fire (if it is not in water or rain). Note
* that you can call getComponent('minecraft:onfire') and, if
* present, the entity is on fire.
*
* This function can't be called in read-only mode.
*
* @param seconds
* Length of time to set the entity on fire.
* @param useEffects
* Whether side-effects should be applied (e.g. thawing freeze)
* and other conditions such as rain or fire protection should
* be taken into consideration.
* @returns
* Whether the entity was set on fire. This can fail if seconds
* is less than or equal to zero, the entity is wet or the
* entity is immune to fire.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function setAblaze(entity: Entity) {
* entity.setOnFire(20, true);
*
* system.runTimeout(() => {
* const onfire = entity.getComponent(EntityComponentTypes.OnFire);
* if (onfire) {
* world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`);
* }
* // This will extinguish the entity
* entity.extinguishFire(true);
* }, 30); // Run in 30 ticks or ~1.5 seconds
*
* }
* ```
*/
setOnFire(seconds: number, useEffects?: boolean): boolean;
/**
- Explanation:
* Sets an Entity Property to the provided value. This property
* change is not applied until the next tick.
*
* This function can't be called in read-only mode.
*
* @param identifier
* The Entity Property identifier.
* @param value
* The property value. The provided type must be compatible
* with the type specified in the entity's definition.
* @throws
* Throws if the entity is invalid.
* Throws if an invalid identifier is provided.
* Throws if the provided value type does not match the
* property type.
* Throws if the provided value is outside the expected range
* (int, float properties).
* Throws if the provided string value does not match the set
* of accepted enum values (enum properties
*/
setProperty(identifier: string, value: boolean | number | string): void;
/**
- Explanation:
* Sets the main rotation of the entity.
*
* This function can't be called in read-only mode.
*
* @param rotation
* The x and y rotation of the entity (in degrees). For most
* mobs, the x rotation controls the head tilt and the y
* rotation controls the body rotation.
* @throws This function can throw errors.
*/
setRotation(rotation: Vector2): void;
/**
- Explanation:
* Teleports the selected entity to a new location
*
* This function can't be called in read-only mode.
*
* @param location
* New location for the entity.
* @param teleportOptions
* Options regarding the teleport operation.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const overworld = world.getDimension('overworld');
* const targetLocation = { x: 0, y: 0, z: 0 };
*
* const pig = overworld.spawnEntity('minecraft:pig', targetLocation);
*
* let inc = 1;
* const runId = system.runInterval(() => {
* pig.teleport(
* { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 },
* {
* facingLocation: targetLocation,
* },
* );
*
* if (inc > 100) {
* system.clearRun(runId);
* }
* inc++;
* }, 4);
* ```
*/
teleport(location: Vector3, teleportOptions?: TeleportOptions): void;
/**
- Explanation:
* 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.
*
* This function can't be called in read-only mode.
*
* @param eventName
* Name of the entity type event to trigger. If a namespace is
* not specified, minecraft: is assumed.
* @throws
* If the event is not defined in the definition of the entity,
* an error will be thrown.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that spawns a creeper and triggers it to explode immediately
*
* function spawnExplodingCreeper(location: DimensionLocation) {
* const creeper = location.dimension.spawnEntity(MinecraftEntityTypes.Creeper, location);
*
* creeper.triggerEvent('minecraft:start_exploding_forced');
* }
* ```
*/
triggerEvent(eventName: string): void;
/**
- Explanation:
* Attempts to try a teleport, but may not complete the
* teleport operation (for example, if there are blocks at the
* destination.)
*
* This function can't be called in read-only mode.
*
* @param location
* Location to teleport the entity to.
* @param teleportOptions
* Options regarding the teleport operation.
* @returns
* Returns whether the teleport succeeded. This can fail if the
* destination chunk is unloaded or if the teleport would
* result in intersecting with blocks.
* @throws This function can throw errors.
*/
tryTeleport(location: Vector3, teleportOptions?: TeleportOptions): boolean;
}
/**
* @beta
* When added, this component makes the entity spawn with a
* rider of the specified entityType.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityAddRiderComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityAddRiderComponent` in the Minecraft Bedrock Edition Script API.
The `EntityAddRiderComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The type of entity that is added as a rider for this entity
* when spawned under certain conditions.
*
* @throws This property can throw when used.
*/
readonly entityType: string;
/**
- Explanation:
* Optional spawn event to trigger on the rider when that rider
* is spawned for this entity.
*
* @throws This property can throw when used.
*/
readonly spawnEvent: string;
static readonly componentId = 'minecraft:addrider';
}
/**
* @beta
* Adds a timer for the entity to grow up. It can be
* accelerated by giving the entity the items it likes as
* defined by feedItems.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityAgeableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityAgeableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityAgeableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Amount of time before the entity grows up, -1 for always a
* baby.
*
* @throws This property can throw when used.
*/
readonly duration: number;
/**
- Explanation:
* Event that runs when this entity grows up.
*
* @throws This property can throw when used.
*/
readonly growUp: Trigger;
/**
- Explanation:
* The feed item used will transform into this item upon
* successful interaction.
*
* @throws This property can throw when used.
*/
readonly transformToItem: string;
static readonly componentId = 'minecraft:ageable';
/**
- Explanation:
* List of items that the entity drops when it grows up.
*
* @throws This function can throw errors.
*/
getDropItems(): string[];
/**
- Explanation:
* List of items that can be fed to the entity. Includes 'item'
* for the item name and 'growth' to define how much time it
* grows up by.
*
* @throws This function can throw errors.
*/
getFeedItems(): EntityDefinitionFeedItem[];
}
/**
* This is a base abstract class for any entity component that
* centers around a number and can have a minimum, maximum, and
* default defined value.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityAttributeComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityAttributeComponent` in the Minecraft Bedrock Edition Script API.
The `EntityAttributeComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Current value of this attribute for this instance.
*
* @throws This property can throw when used.
*/
readonly currentValue: number;
/**
- Explanation:
* Returns the default defined value for this attribute.
*
* @throws This property can throw when used.
*/
readonly defaultValue: number;
/**
- Explanation:
* Returns the effective max of this attribute given any other
* ambient components or factors.
*
* @throws This property can throw when used.
*/
readonly effectiveMax: number;
/**
- Explanation:
* Returns the effective min of this attribute given any other
* ambient components or factors.
*
* @throws This property can throw when used.
*/
readonly effectiveMin: number;
/**
- Explanation:
* Resets the current value of this attribute to the defined
* default value.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
resetToDefaultValue(): void;
/**
- Explanation:
* Resets the current value of this attribute to the maximum
* defined value.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
resetToMaxValue(): void;
/**
- Explanation:
* Resets the current value of this attribute to the minimum
* defined value.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
resetToMinValue(): void;
/**
- Explanation:
* Sets the current value of this attribute.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setCurrentValue(value: number): boolean;
}
/**
* Base class for a family of entity movement events.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityBaseMovementComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityBaseMovementComponent` in the Minecraft Bedrock Edition Script API.
The `EntityBaseMovementComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Maximum turn rate for this movement modality of the mob.
*
* @throws This property can throw when used.
*/
readonly maxTurn: number;
}
/**
* @beta
* Defines what blocks this entity can breathe in and gives
* them the ability to suffocate.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityBreathableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityBreathableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityBreathableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If true, this entity can breathe in air.
*
* @throws This property can throw when used.
*/
readonly breathesAir: boolean;
/**
- Explanation:
* If true, this entity can breathe in lava.
*
* @throws This property can throw when used.
*/
readonly breathesLava: boolean;
/**
- Explanation:
* If true, this entity can breathe in solid blocks.
*
* @throws This property can throw when used.
*/
readonly breathesSolids: boolean;
/**
- Explanation:
* If true, this entity can breathe in water.
*
* @throws This property can throw when used.
*/
readonly breathesWater: boolean;
/**
- Explanation:
* If true, this entity will have visible bubbles while in
* water.
*
* @throws This property can throw when used.
*/
readonly generatesBubbles: boolean;
/**
- Explanation:
* Time in seconds to recover breath to maximum.
*
* @throws This property can throw when used.
*/
readonly inhaleTime: number;
/**
- Explanation:
* Time in seconds between suffocation damage.
*
* @throws This property can throw when used.
*/
readonly suffocateTime: number;
/**
- Explanation:
* Time in seconds the entity can hold its breath.
*
* @throws This property can throw when used.
*/
readonly totalSupply: number;
static readonly componentId = 'minecraft:breathable';
/**
- Explanation:
* List of blocks this entity can breathe in, in addition to
* the separate properties for classes of blocks.
*
* @throws This function can throw errors.
*/
getBreatheBlocks(): BlockPermutation[];
/**
- Explanation:
* List of blocks this entity can't breathe in.
*
* @throws This function can throw errors.
*/
getNonBreatheBlocks(): BlockPermutation[];
/**
- Explanation:
* Sets the current air supply of the entity.
*
* @param value
* New air supply for the entity.
* @throws This function can throw errors.
*/
setAirSupply(value: number): void;
}
/**
* When added, this component signifies that the entity can
* climb up ladders.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityCanClimbComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityCanClimbComponent` in the Minecraft Bedrock Edition Script API.
The `EntityCanClimbComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:can_climb';
}
/**
* When added, this component signifies that the entity can
* fly, and the pathfinder won't be restricted to paths where a
* solid block is required underneath it.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityCanFlyComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityCanFlyComponent` in the Minecraft Bedrock Edition Script API.
The `EntityCanFlyComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:can_fly';
}
/**
* When added, this component signifies that the entity can
* power jump like the horse does within Minecraft.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityCanPowerJumpComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityCanPowerJumpComponent` in the Minecraft Bedrock Edition Script API.
The `EntityCanPowerJumpComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:can_power_jump';
}
/**
* @beta
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityColor2Component
This section details the purpose, properties, methods, and code examples for `Class: EntityColor2Component` in the Minecraft Bedrock Edition Script API.
The `EntityColor2Component` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @throws This property can throw when used.
*/
readonly value: PaletteColor;
static readonly componentId = 'minecraft:color2';
}
/**
* Defines the entity's color. Only works on certain entities
* that have predefined color values (e.g., sheep, llama,
* shulker).
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityColorComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityColorComponent` in the Minecraft Bedrock Edition Script API.
The `EntityColorComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Value of this particular color.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:color';
}
/**
* Base class for downstream entity components.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityComponent` in the Minecraft Bedrock Edition Script API.
The `EntityComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @beta
- Explanation:
* The entity that owns this component. The entity will be
* undefined if it has been removed.
*
*/
readonly entity: Entity;
}
/**
* @beta
* As part of the Ageable component, represents a set of items
* that can be fed to an entity and the rate at which that
* causes them to grow.
*/
### Class: EntityDefinitionFeedItem
This section details the purpose, properties, methods, and code examples for `Class: EntityDefinitionFeedItem` in the Minecraft Bedrock Edition Script API.
The `EntityDefinitionFeedItem` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The amount by which an entity's age will increase when fed
* this item. Values usually range between 0 and 1.
*
*/
readonly growth: number;
/**
- Explanation:
* Identifier of type of item that can be fed. If a namespace
* is not specified, 'minecraft:' is assumed. Example values
* include 'wheat' or 'golden_apple'.
*
*/
readonly item: string;
}
/**
* Contains data related to the death of an entity in the game.
*/
### Class: EntityDieAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityDieAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntityDieAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If specified, provides more information on the source of
* damage that caused the death of this entity.
*
*/
readonly damageSource: EntityDamageSource;
/**
- Explanation:
* Now-dead entity object.
*
*/
readonly deadEntity: Entity;
}
/**
* Supports registering for an event that fires after an entity
* has died.
*/
### Class: EntityDieAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityDieAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityDieAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Subscribes to an event that fires when an entity dies.
*
* This function can't be called in read-only mode.
*
* @param callback
* Function to call when an entity dies.
* @param options
* Additional filtering options for when the subscription
* fires.
* @returns
* Returns the closure that can be used in future downstream
* calls to unsubscribe.
*/
subscribe(
callback: (arg: EntityDieAfterEvent) => void,
options?: EntityEventOptions,
): (arg: EntityDieAfterEvent) => void;
/**
- Explanation:
* Stops this event from calling your function when an entity
* dies.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: EntityDieAfterEvent) => void): void;
}
/**
* Provides access to a mob's equipment slots. This component
* exists for all mob entities.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Gives the player Elytra
*
* function giveEquipment(player: Player) {
* const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
* if (equipmentCompPlayer) {
* equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.Elytra));
* }
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Gives the player some equipment
*
* function giveEquipment(player: Player) {
* const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
* if (equipmentCompPlayer) {
* equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield));
* } else {
* console.warn('No equipment component found on player');
* }
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityEquippableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityEquippableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityEquippableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:equippable';
/**
- Explanation:
* Gets the equipped item for the given EquipmentSlot.
*
* @param equipmentSlot
* The equipment slot. e.g. "head", "chest", "offhand"
* @returns
* Returns the item equipped to the given EquipmentSlot. If
* empty, returns undefined.
* @throws This function can throw errors.
*/
getEquipment(equipmentSlot: EquipmentSlot): ItemStack | undefined;
/**
- Explanation:
* Gets the ContainerSlot corresponding to the given
* EquipmentSlot.
*
* @param equipmentSlot
* The equipment slot. e.g. "head", "chest", "offhand".
* @returns
* Returns the ContainerSlot corresponding to the given
* EquipmentSlot.
* @throws This function can throw errors.
*/
getEquipmentSlot(equipmentSlot: EquipmentSlot): ContainerSlot;
/**
- Explanation:
* Replaces the item in the given EquipmentSlot.
*
* This function can't be called in read-only mode.
*
* @param equipmentSlot
* The equipment slot. e.g. "head", "chest", "offhand".
* @param itemStack
* The item to equip. If undefined, clears the slot.
* @throws This function can throw errors.
*/
setEquipment(equipmentSlot: EquipmentSlot, itemStack?: ItemStack): boolean;
}
/**
* When added, this component signifies that this entity
* doesn't take damage from fire.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityFireImmuneComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityFireImmuneComponent` in the Minecraft Bedrock Edition Script API.
The `EntityFireImmuneComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:fire_immune';
}
/**
* When added, this component signifies that this entity can
* float in liquid blocks.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityFloatsInLiquidComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityFloatsInLiquidComponent` in the Minecraft Bedrock Edition Script API.
The `EntityFloatsInLiquidComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:floats_in_liquid';
}
/**
* Represents the flying speed of an entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityFlyingSpeedComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityFlyingSpeedComponent` in the Minecraft Bedrock Edition Script API.
The `EntityFlyingSpeedComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Current value of the flying speed of the associated entity.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:flying_speed';
}
/**
* Defines how much friction affects this entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityFrictionModifierComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityFrictionModifierComponent` in the Minecraft Bedrock Edition Script API.
The `EntityFrictionModifierComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Current value of the friction modifier of the associated
* entity.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:friction_modifier';
}
/**
* Sets the offset from the ground that the entity is actually
* at.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityGroundOffsetComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityGroundOffsetComponent` in the Minecraft Bedrock Edition Script API.
The `EntityGroundOffsetComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Value of this particular ground offset. Note that this value
* is effectively read only; setting the ground offset value
* will not have an impact on the related entity.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:ground_offset';
}
/**
* Defines the interactions with this entity for healing it.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityHealableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityHealableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityHealableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Determines if an item can be used regardless of the entity
* being at full health.
*
* @throws This property can throw when used.
*/
readonly forceUse: boolean;
static readonly componentId = 'minecraft:healable';
/**
- Explanation:
* A set of items that can specifically heal this entity.
*
* @returns
* Entity that this component is associated with.
* @throws This function can throw errors.
*/
getFeedItems(): FeedItem[];
}
/**
* Contains information related to an entity when its health
* changes. Warning: don't change the health of an entity in
* this event, or it will cause an infinite loop!
*/
### Class: EntityHealthChangedAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityHealthChangedAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntityHealthChangedAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Entity whose health changed.
*
*/
readonly entity: Entity;
/**
- Explanation:
* New health value of the entity.
*
*/
readonly newValue: number;
/**
- Explanation:
* Old health value of the entity.
*
*/
readonly oldValue: number;
}
/**
* Manages callbacks that are connected to when the health of
* an entity changes.
*/
### Class: EntityHealthChangedAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityHealthChangedAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityHealthChangedAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when the health of an
* entity changes.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: EntityHealthChangedAfterEvent) => void,
options?: EntityEventOptions,
): (arg: EntityHealthChangedAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when the health of an
* entity changes.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: EntityHealthChangedAfterEvent) => void): void;
}
/**
* Defines the health properties of an entity.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // A function that applies damage and then heals the entity
*
* function applyDamageAndHeal(entity: Entity) {
* entity.applyDamage(19); // Many mobs have max damage of 20 so this is a near-death mob
*
* system.runTimeout(() => {
* const health = entity.getComponent(EntityComponentTypes.Health);
* if (health) {
* world.sendMessage(`Entity health before heal: ${health.currentValue}`);
*
* health.resetToMaxValue();
*
* world.sendMessage(`Entity after before heal: ${health.currentValue}`);
* } else {
* console.warn('Entity does not have health component');
* }
* }, 40); // Run in a few seconds (40 ticks)
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityHealthComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityHealthComponent` in the Minecraft Bedrock Edition Script API.
The `EntityHealthComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:health';
}
/**
* Contains information related to an entity hitting a block.
*/
### Class: EntityHitBlockAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityHitBlockAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntityHitBlockAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Face of the block that was hit.
*
*/
readonly blockFace: Direction;
/**
- Explanation:
* Entity that made the attack.
*
*/
readonly damagingEntity: Entity;
/**
- Explanation:
* Block that was hit by the attack.
*
*/
readonly hitBlock: Block;
/**
* @beta
- Explanation:
* Block permutation that was hit by the attack.
*
*/
readonly hitBlockPermutation: BlockPermutation;
}
/**
* Manages callbacks that are connected to when an entity hits
* a block.
*/
### Class: EntityHitBlockAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityHitBlockAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityHitBlockAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an entity hits a
* block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: EntityHitBlockAfterEvent) => void,
options?: EntityEventOptions,
): (arg: EntityHitBlockAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an entity hits a
* block.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: EntityHitBlockAfterEvent) => void): void;
}
/**
* Contains information related to an entity hitting (melee
* attacking) another entity.
*/
### Class: EntityHitEntityAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityHitEntityAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntityHitEntityAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Entity that made a hit/melee attack.
*
*/
readonly damagingEntity: Entity;
/**
- Explanation:
* Entity that was hit by the attack.
*
*/
readonly hitEntity: Entity;
}
/**
* Manages callbacks that are connected to when an entity makes
* a melee attack on another entity.
*/
### Class: EntityHitEntityAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityHitEntityAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityHitEntityAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an entity hits
* another entity.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: EntityHitEntityAfterEvent) => void,
options?: EntityEventOptions,
): (arg: EntityHitEntityAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an entity makes a
* melee attack on another entity.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: EntityHitEntityAfterEvent) => void): void;
}
/**
* Contains information related to an entity getting hurt.
*/
### Class: EntityHurtAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityHurtAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntityHurtAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Describes the amount of damage caused.
*
*/
readonly damage: number;
/**
- Explanation:
* Source information on the entity that may have applied this
* damage.
*
*/
readonly damageSource: EntityDamageSource;
/**
- Explanation:
* Entity that was hurt.
*
*/
readonly hurtEntity: Entity;
}
/**
* Manages callbacks that are connected to when an entity is
* hurt.
*/
### Class: EntityHurtAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityHurtAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityHurtAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an entity is hurt.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: EntityHurtAfterEvent) => void,
options?: EntityEventOptions,
): (arg: EntityHurtAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an entity is hurt.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: EntityHurtAfterEvent) => void): void;
}
/**
* Defines this entity's inventory properties.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityInventoryComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityInventoryComponent` in the Minecraft Bedrock Edition Script API.
The `EntityInventoryComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Number of slots that this entity can gain per extra
* strength.
*
* @throws This property can throw when used.
*/
readonly additionalSlotsPerStrength: number;
/**
- Explanation:
* If true, the contents of this inventory can be removed by a
* hopper.
*
* @throws This property can throw when used.
*/
readonly canBeSiphonedFrom: boolean;
/**
- Explanation:
* Defines the container for this entity. The container will be
* undefined if the entity has been removed.
*
* @throws This property can throw when used.
*/
readonly container?: Container;
/**
- Explanation:
* Type of container this entity has.
*
* @throws This property can throw when used.
*/
readonly containerType: string;
/**
- Explanation:
* Number of slots the container has.
*
* @throws This property can throw when used.
*/
readonly inventorySize: number;
/**
- Explanation:
* If true, the entity will not drop it's inventory on death.
*
* @throws This property can throw when used.
*/
readonly 'private': boolean;
/**
- Explanation:
* If true, the entity's inventory can only be accessed by its
* owner or itself.
*
* @throws This property can throw when used.
*/
readonly restrictToOwner: boolean;
static readonly componentId = 'minecraft:inventory';
}
/**
* When added, this component signifies that this entity is a
* baby.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsBabyComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsBabyComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsBabyComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_baby';
}
/**
* When added, this component signifies that this entity is
* charged.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsChargedComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsChargedComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsChargedComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_charged';
}
/**
* When added, this component signifies that this entity is
* currently carrying a chest.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsChestedComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsChestedComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsChestedComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_chested';
}
/**
* When added, this component signifies that dyes can be used
* on this entity to change its color.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsDyeableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsDyeableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsDyeableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_dyeable';
}
/**
* When added, this component signifies that this entity can
* hide from hostile mobs while invisible.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsHiddenWhenInvisibleComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsHiddenWhenInvisibleComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsHiddenWhenInvisibleComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_hidden_when_invisible';
}
/**
* When added, this component signifies that this entity this
* currently on fire.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsIgnitedComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsIgnitedComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsIgnitedComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_ignited';
}
/**
* When added, this component signifies that this entity is an
* illager captain.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsIllagerCaptainComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsIllagerCaptainComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsIllagerCaptainComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_illager_captain';
}
/**
* When added, this component signifies that this entity is
* currently saddled.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsSaddledComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsSaddledComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsSaddledComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_saddled';
}
/**
* When added, this component signifies that this entity is
* currently shaking.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsShakingComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsShakingComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsShakingComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_shaking';
}
/**
* When added, this component signifies that this entity is
* currently sheared.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsShearedComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsShearedComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsShearedComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_sheared';
}
/**
* When added, this component signifies that this entity can be
* stacked.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsStackableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsStackableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsStackableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_stackable';
}
/**
* When added, this component signifies that this entity is
* currently stunned.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsStunnedComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsStunnedComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsStunnedComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_stunned';
}
/**
* When added, this component signifies that this entity is
* currently tamed.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityIsTamedComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityIsTamedComponent` in the Minecraft Bedrock Edition Script API.
The `EntityIsTamedComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:is_tamed';
}
/**
* If added onto the entity, this indicates that the entity
* represents a free-floating item in the world. Lets you
* retrieve the actual item stack contents via the itemStack
* property.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Returns true if a feather item entity is within 'distance' blocks of 'location'.
* function isFeatherNear(location: DimensionLocation, distance: number): boolean {
* const items = location.dimension.getEntities({
* location: location,
* maxDistance: 20,
* });
*
* for (const item of items) {
* const itemComp = item.getComponent(EntityComponentTypes.Item);
*
* if (itemComp) {
* if (itemComp.itemStack.typeId.endsWith('feather')) {
* return true;
* }
* }
* }
*
* return false;
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityItemComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityItemComponent` in the Minecraft Bedrock Edition Script API.
The `EntityItemComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Item stack represented by this entity in the world.
*
* @throws This property can throw when used.
*/
readonly itemStack: ItemStack;
static readonly componentId = 'minecraft:item';
}
/**
* @beta
* This type is usable for iterating over a set of entities.
* This means it can be used in statements like for...of
* statements, Array.from(iterator), and more.
*/
### Class: EntityIterator
This section details the purpose, properties, methods, and code examples for `Class: EntityIterator` in the Minecraft Bedrock Edition Script API.
The `EntityIterator` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
[Symbol.iterator](): Iterator<Entity>;
/**
- Explanation:
* Retrieves the next item in this iteration. The resulting
* IteratorResult contains .done and .value properties which
* can be used to see the next Entity in the iteration.
*
* This function can't be called in read-only mode.
*
*/
next(): IteratorResult<Entity>;
}
/**
* @beta
* Defines the base movement speed in lava of this entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityLavaMovementComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityLavaMovementComponent` in the Minecraft Bedrock Edition Script API.
The `EntityLavaMovementComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:lava_movement';
}
/**
* @beta
* Allows this entity to be leashed and defines the conditions
* and events for this entity when is leashed.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityLeashableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityLeashableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityLeashableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Distance in blocks at which the 'spring' effect starts
* acting to keep this entity close to the entity that leashed
* it.
*
* @throws This property can throw when used.
*/
readonly softDistance: number;
static readonly componentId = 'minecraft:leashable';
/**
- Explanation:
* Leashes this entity to another entity.
*
* This function can't be called in read-only mode.
*
* @param leashHolder
* The entity to leash this entity to.
* @throws This function can throw errors.
*/
leash(leashHolder: Entity): void;
/**
- Explanation:
* Unleashes this entity if it is leashed to another entity.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unleash(): void;
}
/**
* Contains data related to an entity loaded within the world.
* This could happen when an unloaded chunk is reloaded, or
* when an entity changes dimensions.
*/
### Class: EntityLoadAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityLoadAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntityLoadAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Entity that was loaded.
*
* This property can't be edited in read-only mode.
*
*/
entity: Entity;
}
/**
* Registers a script-based event handler for handling what
* happens when an entity loads.
*/
### Class: EntityLoadAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityLoadAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityLoadAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Method to register an event handler for what happens when an
* entity loads.
*
* This function can't be called in read-only mode.
*
* @param callback
* Function that handles the load event.
*/
subscribe(callback: (arg: EntityLoadAfterEvent) => void): (arg: EntityLoadAfterEvent) => void;
/**
- Explanation:
* Unregisters a method that was previously subscribed to the
* subscription event.
*
* This function can't be called in read-only mode.
*
* @param callback
* Original function that was passed into the subscribe event,
* that is to be unregistered.
*/
unsubscribe(callback: (arg: EntityLoadAfterEvent) => void): void;
}
/**
* Additional variant value. Can be used to further
* differentiate variants.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMarkVariantComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMarkVariantComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMarkVariantComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Value of the mark variant value for this entity.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:mark_variant';
}
/**
* When added, this movement control allows the mob to swim in
* water and walk on land.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementAmphibiousComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementAmphibiousComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementAmphibiousComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement.amphibious';
}
/**
* This component accents the movement of an entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementBasicComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementBasicComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementBasicComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement.basic';
}
/**
* @beta
* Defines the general movement speed of this entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement';
}
/**
* When added, this move control causes the mob to fly.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementFlyComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementFlyComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementFlyComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement.fly';
}
/**
* When added, this move control allows a mob to fly, swim,
* climb, etc.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementGenericComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementGenericComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementGenericComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement.generic';
}
/**
* @beta
* When added, this movement control allows the mob to glide.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementGlideComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementGlideComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementGlideComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Speed in effect when the entity is turning.
*
* @throws This property can throw when used.
*/
readonly speedWhenTurning: number;
/**
- Explanation:
* Start speed during a glide.
*
* @throws This property can throw when used.
*/
readonly startSpeed: number;
static readonly componentId = 'minecraft:movement.glide';
}
/**
* When added, this move control causes the mob to hover.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementHoverComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementHoverComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementHoverComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement.hover';
}
/**
* Move control that causes the mob to jump as it moves with a
* specified delay between jumps.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementJumpComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementJumpComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementJumpComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement.jump';
}
/**
* When added, this move control causes the mob to hop as it
* moves.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementSkipComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementSkipComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementSkipComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:movement.skip';
}
/**
* @beta
* When added, this move control causes the mob to sway side to
* side giving the impression it is swimming.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityMovementSwayComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityMovementSwayComponent` in the Minecraft Bedrock Edition Script API.
The `EntityMovementSwayComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Amplitude of the sway motion.
*
* @throws This property can throw when used.
*/
readonly swayAmplitude: number;
/**
- Explanation:
* Amount of sway frequency.
*
* @throws This property can throw when used.
*/
readonly swayFrequency: number;
static readonly componentId = 'minecraft:movement.sway';
}
/**
* @beta
* Allows this entity to generate paths that include vertical
* walls (for example, like Minecraft spiders do.)
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNavigationClimbComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNavigationClimbComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNavigationClimbComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:navigation.climb';
}
/**
* @beta
* Allows this entity to generate paths that include vertical
* walls (for example, like Minecraft spiders do.)
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNavigationComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNavigationComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNavigationComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Tells the pathfinder to avoid blocks that cause damage when
* finding a path.
*
* @throws This property can throw when used.
*/
readonly avoidDamageBlocks: boolean;
/**
- Explanation:
* Tells the pathfinder to avoid portals (like nether portals)
* when finding a path.
*
* @throws This property can throw when used.
*/
readonly avoidPortals: boolean;
/**
- Explanation:
* Whether or not the pathfinder should avoid tiles that are
* exposed to the sun when creating paths.
*
* @throws This property can throw when used.
*/
readonly avoidSun: boolean;
/**
- Explanation:
* Tells the pathfinder to avoid water when creating a path.
*
* @throws This property can throw when used.
*/
readonly avoidWater: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can jump out of water
* (like a dolphin).
*
* @throws This property can throw when used.
*/
readonly canBreach: boolean;
/**
- Explanation:
* Tells the pathfinder that it can path through a closed door
* and break it.
*
* @throws This property can throw when used.
*/
readonly canBreakDoors: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can float.
*
* @throws This property can throw when used.
*/
readonly canFloat: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can jump up blocks.
*
* @throws This property can throw when used.
*/
readonly canJump: boolean;
/**
- Explanation:
* Tells the pathfinder that it can path through a closed door
* assuming the AI will open the door.
*
* @throws This property can throw when used.
*/
readonly canOpenDoors: boolean;
/**
- Explanation:
* Tells the pathfinder that it can path through a closed iron
* door assuming the AI will open the door.
*
* @throws This property can throw when used.
*/
readonly canOpenIronDoors: boolean;
/**
- Explanation:
* Whether a path can be created through a door.
*
* @throws This property can throw when used.
*/
readonly canPassDoors: boolean;
/**
- Explanation:
* Tells the pathfinder that it can start pathing when in the
* air.
*
* @throws This property can throw when used.
*/
readonly canPathFromAir: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can travel on the
* surface of the lava.
*
* @throws This property can throw when used.
*/
readonly canPathOverLava: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can travel on the
* surface of the water.
*
* @throws This property can throw when used.
*/
readonly canPathOverWater: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it will be pulled down
* by gravity while in water.
*
* @throws This property can throw when used.
*/
readonly canSink: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can path anywhere
* through water and plays swimming animation along that path.
*
* @throws This property can throw when used.
*/
readonly canSwim: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can walk on the
* ground outside water.
*
* @throws This property can throw when used.
*/
readonly canWalk: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can travel in lava
* like walking on ground.
*
* @throws This property can throw when used.
*/
readonly canWalkInLava: boolean;
/**
- Explanation:
* Tells the pathfinder whether or not it can walk on the
* ground or go underwater.
*
* @throws This property can throw when used.
*/
readonly isAmphibious: boolean;
}
/**
* @beta
* Allows this entity to generate paths by flying around the
* air like the regular Ghast.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNavigationFloatComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNavigationFloatComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNavigationFloatComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:navigation.float';
}
/**
* @beta
* Allows this entity to generate paths in the air (for
* example, like Minecraft parrots do.)
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNavigationFlyComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNavigationFlyComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNavigationFlyComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:navigation.fly';
}
/**
* @beta
* Allows this entity to generate paths by walking, swimming,
* flying and/or climbing around and jumping up and down a
* block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNavigationGenericComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNavigationGenericComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNavigationGenericComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:navigation.generic';
}
/**
* @beta
* Allows this entity to generate paths in the air (for
* example, like the Minecraft Bees do.) Keeps them from
* falling out of the skies and doing predictive movement.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNavigationHoverComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNavigationHoverComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNavigationHoverComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:navigation.hover';
}
/**
* @beta
* Allows this entity to generate paths by walking around and
* jumping up and down a block like regular mobs.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNavigationWalkComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNavigationWalkComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNavigationWalkComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:navigation.walk';
}
/**
* @beta
* Adds NPC capabilities to an entity such as custom skin,
* name, and dialogue interactions.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityNpcComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityNpcComponent` in the Minecraft Bedrock Edition Script API.
The `EntityNpcComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The DialogueScene that is opened when players first interact
* with the NPC.
*
* This property can't be edited in read-only mode.
*
*/
defaultScene: string;
/**
- Explanation:
* The name of the NPC as it is displayed to players.
*
* This property can't be edited in read-only mode.
*
*/
name: string;
/**
- Explanation:
* The index of the skin the NPC will use.
*
* This property can't be edited in read-only mode.
*
*/
skinIndex: number;
static readonly componentId = 'minecraft:npc';
}
/**
* When present on an entity, this entity is on fire.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function setAblaze(entity: Entity) {
* entity.setOnFire(20, true);
*
* system.runTimeout(() => {
* const onfire = entity.getComponent(EntityComponentTypes.OnFire);
* if (onfire) {
* world.sendMessage(`${onfire.onFireTicksRemaining} fire ticks remaining, extinguishing the entity.`);
* }
* // This will extinguish the entity
* entity.extinguishFire(true);
* }, 30); // Run in 30 ticks or ~1.5 seconds
*
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityOnFireComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityOnFireComponent` in the Minecraft Bedrock Edition Script API.
The `EntityOnFireComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The number of ticks remaining before the fire goes out.
*
*/
readonly onFireTicksRemaining: number;
static readonly componentId = 'minecraft:onfire';
}
/**
* The projectile component controls the properties of a
* projectile entity and allows it to be shot in a given
* direction.
* This component is present when the entity has the
* minecraft:projectile component.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const location: Vector3 = { x: 0, y: -59, z: 0 }; // Replace with the coordinates of where you want to spawn the arrow
* const velocity: Vector3 = { x: 0, y: 0, z: 5 };
* const arrow = world.getDimension('overworld').spawnEntity('minecraft:arrow', location);
* const projectileComp = arrow.getComponent('minecraft:projectile');
* projectileComp?.shoot(velocity);
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityProjectileComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityProjectileComponent` in the Minecraft Bedrock Edition Script API.
The `EntityProjectileComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The fraction of the projectile's speed maintained every tick
* while traveling through air.
*
* This property can't be edited in read-only mode.
*
*/
airInertia: number;
/**
- Explanation:
* If true, the entity will be set on fire when hurt. The
* default burn duration is 5 seconds. This duration can be
* modified via the onFireTime property. The entity will not
* catch fire if immune or if the entity is wet.
*
* This property can't be edited in read-only mode.
*
*/
catchFireOnHurt: boolean;
/**
- Explanation:
* If true, the projectile will spawn crit particles when hit
* by a player. E.g. Player attacking a Shulker bullet.
*
* This property can't be edited in read-only mode.
*
*/
critParticlesOnProjectileHurt: boolean;
/**
- Explanation:
* If true, the projectile will be destroyed when it takes
* damage. E.g. Player attacking a Shulker bullet.
*
* This property can't be edited in read-only mode.
*
*/
destroyOnProjectileHurt: boolean;
/**
- Explanation:
* The gravity applied to the projectile. When the entity is
* not on the ground, subtracts this amount from the
* projectile’s change in vertical position every tick. The
* higher the value, the faster the projectile falls. If
* negative, the entity will rise instead of fall.
*
* This property can't be edited in read-only mode.
*
*/
gravity: number;
/**
- Explanation:
* The sound that plays when the projectile hits an entity.
*
* This property can't be edited in read-only mode.
*
*/
hitEntitySound?: string;
/**
- Explanation:
* The sound that plays when the projectile hits a block.
*
* This property can't be edited in read-only mode.
*
*/
hitGroundSound?: string;
/**
- Explanation:
* The particle that spawns when the projectile hits something.
*
* This property can't be edited in read-only mode.
*
*/
hitParticle?: string;
/**
- Explanation:
* If true and the weather is thunder and the entity has line
* of sight to the sky, the entity will be struck by lightning
* when hit. E.g. A thrown Trident with the Channeling
* enchantment.
*
* This property can't be edited in read-only mode.
*
*/
lightningStrikeOnHit: boolean;
/**
- Explanation:
* The fraction of the projectile's speed maintained every tick
* while traveling through a liquid.
*
* This property can't be edited in read-only mode.
*
*/
liquidInertia: number;
/**
- Explanation:
* Duration in seconds that the entity hit will be on fire for
* when catchFireOnHurt is set to true.
*
* This property can't be edited in read-only mode.
*
*/
onFireTime: number;
/**
- Explanation:
* The owner of the projectile. This is used to determine what
* the projectile can collide with and damage. It also
* determines which entity is assigned as the attacker.
*
* This property can't be edited in read-only mode.
*
*/
owner?: Entity;
/**
- Explanation:
* If true, the projectile will bounce off mobs when no damage
* is taken. E.g. A spawning wither.
*
* This property can't be edited in read-only mode.
*
*/
shouldBounceOnHit: boolean;
/**
- Explanation:
* If true, the projectile will stop moving when an entity is
* hit as thought it had been blocked. E.g. Thrown trident on
* hit behavior.
*
* This property can't be edited in read-only mode.
*
*/
stopOnHit: boolean;
static readonly componentId = 'minecraft:projectile';
/**
- Explanation:
* Shoots the projectile with a given velocity. The projectile
* will be shot from its current location.
*
* This function can't be called in read-only mode.
*
* @param velocity
* The velocity to fire the projectile. This controls both the
* speed and direction which which the projectile will be shot.
* @param options
* Optional configuration for the shoot.
* @throws
* Throws if the component or entity no longer exist.
*/
shoot(velocity: Vector3, options?: ProjectileShootOptions): void;
}
/**
* Sets the distance through which the entity can push through.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityPushThroughComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityPushThroughComponent` in the Minecraft Bedrock Edition Script API.
The `EntityPushThroughComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Value of the push through distances of this entity.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:push_through';
}
/**
* Data for an event that happens when an entity is removed
* from the world (for example, the entity is unloaded because
* it is not close to players.)
*/
### Class: EntityRemoveAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityRemoveAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntityRemoveAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Id of the entity that was removed.
*
*/
readonly removedEntityId: string;
/**
- Explanation:
* Identifier of the type of the entity removed - for example,
* 'minecraft:skeleton'.
*
*/
readonly typeId: string;
}
/**
* Allows registration for an event that fires when an entity
* is removed from the game (for example, unloaded, or a few
* seconds after they are dead.)
*/
### Class: EntityRemoveAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityRemoveAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityRemoveAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Will call your function every time an entity is removed from
* the game.
*
* This function can't be called in read-only mode.
*
* @param callback
* Function to call.
* @param options
* Additional filtering options for this event.
* @returns
* Returns a closure that can be used in subsequent unsubscribe
* operations.
*/
subscribe(
callback: (arg: EntityRemoveAfterEvent) => void,
options?: EntityEventOptions,
): (arg: EntityRemoveAfterEvent) => void;
/**
- Explanation:
* Unsubscribes your function from subsequent calls when an
* entity is removed.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: EntityRemoveAfterEvent) => void): void;
}
/**
* Data for an event that happens when an entity is being
* removed from the world (for example, the entity is unloaded
* because it is not close to players.)
*/
### Class: EntityRemoveBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: EntityRemoveBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `EntityRemoveBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Reference to an entity that is being removed.
*
*/
readonly removedEntity: Entity;
}
/**
* Allows registration for an event that fires when an entity
* is being removed from the game (for example, unloaded, or a
* few seconds after they are dead.)
*/
### Class: EntityRemoveBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntityRemoveBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntityRemoveBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Will call your function every time an entity is being
* removed from the game.
*
* This function can't be called in read-only mode.
*
* @param callback
* Function to call.
* @returns
* Returns a closure that can be used in subsequent unsubscribe
* operations.
*/
subscribe(callback: (arg: EntityRemoveBeforeEvent) => void): (arg: EntityRemoveBeforeEvent) => void;
/**
- Explanation:
* Unsubscribes your function from subsequent calls when an
* entity is being removed.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: EntityRemoveBeforeEvent) => void): void;
}
/**
* @beta
* When added, this component adds the capability that an
* entity can be ridden by another entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityRideableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityRideableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityRideableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Zero-based index of the seat that can used to control this
* entity.
*
* @throws This property can throw when used.
*/
readonly controllingSeat: number;
/**
- Explanation:
* Determines whether interactions are not supported if the
* entity is crouching.
*
* @throws This property can throw when used.
*/
readonly crouchingSkipInteract: boolean;
/**
- Explanation:
* Set of text that should be displayed when a player is
* looking to ride on this entity (commonly with touch-screen
* controls).
*
* @throws This property can throw when used.
*/
readonly interactText: string;
/**
- Explanation:
* The max width a mob can be to be a passenger.
*
* @throws This property can throw when used.
*/
readonly passengerMaxWidth: number;
/**
- Explanation:
* If true, this entity will pull in entities that are in the
* correct family_types into any available seat.
*
* @throws This property can throw when used.
*/
readonly pullInEntities: boolean;
/**
- Explanation:
* If true, this entity will be picked when looked at by the
* rider.
*
* @throws This property can throw when used.
*/
readonly riderCanInteract: boolean;
/**
- Explanation:
* Number of seats for riders defined for this entity.
*
* @throws This property can throw when used.
*/
readonly seatCount: number;
static readonly componentId = 'minecraft:rideable';
/**
- Explanation:
* Adds an entity to this entity as a rider.
*
* This function can't be called in read-only mode.
*
* @param rider
* Entity that will become the rider of this entity.
* @returns
* True if the rider entity was successfully added.
* @throws This function can throw errors.
*/
addRider(rider: Entity): boolean;
/**
- Explanation:
* Ejects the specified rider of this entity.
*
* This function can't be called in read-only mode.
*
* @param rider
* Entity that should be ejected from this entity.
* @throws This function can throw errors.
*/
ejectRider(rider: Entity): void;
/**
- Explanation:
* Ejects all riders of this entity.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
ejectRiders(): void;
/**
- Explanation:
* A string-list of entity types that this entity can support
* as riders.
*
* @throws This function can throw errors.
*/
getFamilyTypes(): string[];
/**
- Explanation:
* Gets a list of the all the entities currently riding this
* entity.
*
* @throws This function can throw errors.
*/
getRiders(): Entity[];
/**
- Explanation:
* Gets a list of positions and number of riders for each
* position for entities riding this entity.
*
* @throws This function can throw errors.
*/
getSeats(): Seat[];
}
/**
* @beta
* This component is added to any entity when it is riding
* another entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityRidingComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityRidingComponent` in the Minecraft Bedrock Edition Script API.
The `EntityRidingComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The entity this entity is currently riding on.
*
* @throws This property can throw when used.
*/
readonly entityRidingOn: Entity;
static readonly componentId = 'minecraft:riding';
}
/**
* Sets the entity's visual size.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityScaleComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityScaleComponent` in the Minecraft Bedrock Edition Script API.
The `EntityScaleComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Current value for the scale property set on entities.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:scale';
}
/**
* Skin Id value. Can be used to differentiate skins, such as
* base skins for villagers.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntitySkinIdComponent
This section details the purpose, properties, methods, and code examples for `Class: EntitySkinIdComponent` in the Minecraft Bedrock Edition Script API.
The `EntitySkinIdComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the value of the skin Id identifier of the entity.
*
* This property can't be edited in read-only mode.
*
*/
value: number;
static readonly componentId = 'minecraft:skin_id';
}
/**
* Contains data related to an entity spawning within the
* world.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Register a new function that is called when a new entity is created.
*
* world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => {
* const spawnLocation = entityEvent.entity.location;
* world.sendMessage(
* `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`,
* );
* });
* ```
*/
### Class: EntitySpawnAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: EntitySpawnAfterEvent` in the Minecraft Bedrock Edition Script API.
The `EntitySpawnAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Initialization cause (Spawned, Born ...).
*
*/
readonly cause: EntityInitializationCause;
/**
- Explanation:
* Entity that was spawned.
*
* This property can't be edited in read-only mode.
*
*/
entity: Entity;
}
/**
* Registers a script-based event handler for handling what
* happens when an entity spawns.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Register a new function that is called when a new entity is created.
*
* world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => {
* const spawnLocation = entityEvent.entity.location;
* world.sendMessage(
* `New entity of type '${entityEvent.entity.typeId}' spawned at ${spawnLocation.x}, ${spawnLocation.y}, ${spawnLocation.z}!`,
* );
* });
* ```
*/
### Class: EntitySpawnAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: EntitySpawnAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `EntitySpawnAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Method to register an event handler for what happens when an
* entity spawns.
*
* This function can't be called in read-only mode.
*
* @param callback
* Function that handles the spawn event.
*/
subscribe(callback: (arg: EntitySpawnAfterEvent) => void): (arg: EntitySpawnAfterEvent) => void;
/**
- Explanation:
* Unregisters a method that was previously subscribed to the
* subscription event.
*
* This function can't be called in read-only mode.
*
* @param callback
* Original function that was passed into the subscribe event,
* that is to be unregistered.
*/
unsubscribe(callback: (arg: EntitySpawnAfterEvent) => void): void;
}
/**
* @beta
* Defines the entity's strength to carry items.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityStrengthComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityStrengthComponent` in the Minecraft Bedrock Edition Script API.
The `EntityStrengthComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Maximum strength of this entity, as defined in the entity
* type definition.
*
* @throws This property can throw when used.
*/
readonly max: number;
/**
- Explanation:
* Current value of the strength component that has been set
* for entities.
*
* @throws This property can throw when used.
*/
readonly value: number;
static readonly componentId = 'minecraft:strength';
}
/**
* @beta
* Defines the rules for an entity to be tamed by the player.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityTameableComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityTameableComponent` in the Minecraft Bedrock Edition Script API.
The `EntityTameableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns a set of items that can be used to tame this entity.
*
* @throws This property can throw when used.
*/
readonly getTameItems: ItemStack[];
/**
* @throws This property can throw when used.
*/
readonly isTamed: boolean;
/**
- Explanation:
* The chance of taming the entity with each item use between
* 0.0 and 1.0, where 1.0 is 100%
*
* @throws This property can throw when used.
*/
readonly probability: number;
/**
* @throws This property can throw when used.
*/
readonly tamedToPlayer?: Player;
/**
* @throws This property can throw when used.
*/
readonly tamedToPlayerId?: string;
static readonly componentId = 'minecraft:tameable';
/**
- Explanation:
* Tames this entity.
*
* This function can't be called in read-only mode.
*
* @returns
* Returns true if the entity was tamed.
* @throws This function can throw errors.
*/
tame(player: Player): boolean;
}
/**
* @beta
* Contains options for taming a rideable entity based on the
* entity that mounts it.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityTameMountComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityTameMountComponent` in the Minecraft Bedrock Edition Script API.
The `EntityTameMountComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @throws This property can throw when used.
*/
readonly isTamed: boolean;
/**
* @throws This property can throw when used.
*/
readonly isTamedToPlayer: boolean;
/**
* @throws This property can throw when used.
*/
readonly tamedToPlayer?: Player;
/**
* @throws This property can throw when used.
*/
readonly tamedToPlayerId?: string;
static readonly componentId = 'minecraft:tamemount';
/**
- Explanation:
* Sets this rideable entity as tamed.
*
* This function can't be called in read-only mode.
*
* @param showParticles
* Whether to show effect particles when this entity is tamed.
* @throws This function can throw errors.
*/
tame(showParticles: boolean): void;
/**
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
tameToPlayer(showParticles: boolean, player: Player): boolean;
}
/**
* Represents information about a type of entity.
*/
### Class: EntityType
This section details the purpose, properties, methods, and code examples for `Class: EntityType` in the Minecraft Bedrock Edition Script API.
The `EntityType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Identifier of this entity type - for example,
* 'minecraft:skeleton'.
*
*/
readonly id: string;
}
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityTypeFamilyComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityTypeFamilyComponent` in the Minecraft Bedrock Edition Script API.
The `EntityTypeFamilyComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:type_family';
/**
* @throws This function can throw errors.
*/
getTypeFamilies(): string[];
/**
* @throws This function can throw errors.
*/
hasTypeFamily(typeFamily: string): boolean;
}
/**
* @beta
* An iterator that loops through available entity types.
*/
### Class: EntityTypeIterator
This section details the purpose, properties, methods, and code examples for `Class: EntityTypeIterator` in the Minecraft Bedrock Edition Script API.
The `EntityTypeIterator` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
[Symbol.iterator](): Iterator<EntityType>;
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
next(): IteratorResult<EntityType>;
}
/**
* Used for accessing all entity types currently available for
* use within the world.
*/
### Class: EntityTypes
This section details the purpose, properties, methods, and code examples for `Class: EntityTypes` in the Minecraft Bedrock Edition Script API.
The `EntityTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Retrieves an entity type using a string-based identifier.
*
*/
static get(identifier: string): EntityType | undefined;
/**
- Explanation:
* Retrieves a set of all entity types within this world.
*
*/
static getAll(): EntityType[];
}
/**
* @beta
* Defines the general movement speed underwater of this
* entity.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityUnderwaterMovementComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityUnderwaterMovementComponent` in the Minecraft Bedrock Edition Script API.
The `EntityUnderwaterMovementComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:underwater_movement';
}
/**
* Used to differentiate the component group of a variant of an
* entity from others. (e.g. ocelot, villager).
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityVariantComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityVariantComponent` in the Minecraft Bedrock Edition Script API.
The `EntityVariantComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Current value for variant for this entity, as specified via
* components.
*
* @throws This property can throw when used.
*/
readonly value: number;
static readonly componentId = 'minecraft:variant';
}
/**
* When added, this component signifies that this entity wants
* to become a jockey.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EntityWantsJockeyComponent
This section details the purpose, properties, methods, and code examples for `Class: EntityWantsJockeyComponent` in the Minecraft Bedrock Edition Script API.
The `EntityWantsJockeyComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
static readonly componentId = 'minecraft:wants_jockey';
}
/**
* Contains information regarding an explosion that has
* happened.
*/
### Class: ExplosionAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ExplosionAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ExplosionAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Dimension where the explosion has occurred.
*
*/
readonly dimension: Dimension;
/**
- Explanation:
* Optional source of the explosion.
*
*/
readonly source?: Entity;
/**
- Explanation:
* A collection of blocks impacted by this explosion event.
*
*/
getImpactedBlocks(): Block[];
}
/**
* Manages callbacks that are connected to when an explosion
* occurs.
*/
### Class: ExplosionAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ExplosionAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ExplosionAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an explosion
* occurs.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ExplosionAfterEvent) => void): (arg: ExplosionAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an explosion
* occurs.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ExplosionAfterEvent) => void): void;
}
/**
* Contains information regarding an explosion that has
* happened.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ExplosionBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: ExplosionBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `ExplosionBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true, cancels the explosion event.
*
*/
cancel: boolean;
/**
- Explanation:
* Updates a collection of blocks impacted by this explosion
* event.
*
* @param blocks
* New list of blocks that are impacted by this explosion.
*/
setImpactedBlocks(blocks: Block[]): void;
}
/**
* Manages callbacks that are connected to before an explosion
* occurs.
*/
### Class: ExplosionBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ExplosionBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `ExplosionBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when before an explosion
* occurs. The callback can optionally change or cancel
* explosion behavior.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ExplosionBeforeEvent) => void): (arg: ExplosionBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called from before when an
* explosion would occur.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ExplosionBeforeEvent) => void): void;
}
/**
* As part of the Healable component, represents a specific
* item that can be fed to an entity to cause health effects.
*/
### Class: FeedItem
This section details the purpose, properties, methods, and code examples for `Class: FeedItem` in the Minecraft Bedrock Edition Script API.
The `FeedItem` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The amount of health this entity gains when fed this item.
* This number is an integer starting at 0. Sample values can
* go as high as 40.
*
*/
readonly healAmount: number;
/**
- Explanation:
* Identifier of type of item that can be fed. If a namespace
* is not specified, 'minecraft:' is assumed. Example values
* include 'wheat' or 'golden_apple'.
*
*/
readonly item: string;
/**
- Explanation:
* As part of the Healable component, an optional collection of
* side effects that can occur from being fed an item.
*
*/
getEffects(): FeedItemEffect[];
}
/**
* Represents an effect that is applied as a result of a food
* item being fed to an entity.
*/
### Class: FeedItemEffect
This section details the purpose, properties, methods, and code examples for `Class: FeedItemEffect` in the Minecraft Bedrock Edition Script API.
The `FeedItemEffect` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Gets an amplifier that may have been applied to this effect.
* Valid values are integers starting at 0 and up - but usually
* ranging between 0 and 4.
*
*/
readonly amplifier: number;
/**
- Explanation:
* Chance that this effect is applied as a result of the entity
* being fed this item. Valid values range between 0 and 1.
*
*/
readonly chance: number;
/**
- Explanation:
* Gets the duration, in ticks, of this effect.
*
*/
readonly duration: number;
/**
- Explanation:
* Gets the identifier of the effect to apply. Example values
* include 'fire_resistance' or 'regeneration'.
*
*/
readonly name: string;
}
/**
* @beta
* Represents a set of filters for when an event should occur.
*/
### Class: FilterGroup
This section details the purpose, properties, methods, and code examples for `Class: FilterGroup` in the Minecraft Bedrock Edition Script API.
The `FilterGroup` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
* Represents constants related to fluid containers.
*/
### Class: FluidContainer
This section details the purpose, properties, methods, and code examples for `Class: FluidContainer` in the Minecraft Bedrock Edition Script API.
The `FluidContainer` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Constant that represents the maximum fill level of a fluid
* container.
*
*/
static readonly maxFillLevel = 6;
/**
- Explanation:
* Constant that represents the minimum fill level of a fluid
* container.
*
*/
static readonly minFillLevel = 0;
}
/**
* @beta
* Contains information regarding a changed world.gameRules
* property.
*/
### Class: GameRuleChangeAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: GameRuleChangeAfterEvent` in the Minecraft Bedrock Edition Script API.
The `GameRuleChangeAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The rule identifier pertaining to the changed
* world.gameRules property.
*
*/
readonly rule: GameRule;
/**
- Explanation:
* The value of the world.gameRules property after being
* changed.
*
*/
readonly value: boolean | number;
}
/**
* @beta
* Manages callbacks that are connected to when a
* world.gameRules property has changed.
*/
### Class: GameRuleChangeAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: GameRuleChangeAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `GameRuleChangeAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a world.gameRules
* property is changed.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: GameRuleChangeAfterEvent) => void): (arg: GameRuleChangeAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a world.gameRules
* property is changed.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: GameRuleChangeAfterEvent) => void): void;
}
/**
* @beta
* Represents the game rules for a world experience.
*/
### Class: GameRules
This section details the purpose, properties, methods, and code examples for `Class: GameRules` in the Minecraft Bedrock Edition Script API.
The `GameRules` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
commandBlockOutput: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
commandBlocksEnabled: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doDayLightCycle: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doEntityDrops: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doFireTick: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doImmediateRespawn: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doInsomnia: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doLimitedCrafting: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doMobLoot: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doMobSpawning: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doTileDrops: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
doWeatherCycle: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
drowningDamage: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
fallDamage: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
fireDamage: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
freezeDamage: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
functionCommandLimit: number;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
keepInventory: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
maxCommandChainLength: number;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
mobGriefing: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
naturalRegeneration: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
playersSleepingPercentage: number;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
projectilesCanBreakBlocks: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
pvp: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
randomTickSpeed: number;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
recipesUnlock: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
respawnBlocksExplode: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
sendCommandFeedback: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
showBorderEffect: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
showCoordinates: boolean;
/**
* @beta
- Explanation:
* This property can't be edited in read-only mode.
*
*/
showDaysPlayed: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
showDeathMessages: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
showRecipeMessages: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
showTags: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
spawnRadius: number;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
tntExplodes: boolean;
/**
- Explanation:
* This property can't be edited in read-only mode.
*
*/
tntExplosionDropDecay: boolean;
}
/**
* Provides an adaptable interface for callers to subscribe to
* an event that fires when a button is pushed.
*/
### Class: IButtonPushAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: IButtonPushAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `IButtonPushAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Subscribes to the event.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ButtonPushAfterEvent) => void): (arg: ButtonPushAfterEvent) => void;
/**
- Explanation:
* Unsubscribes from the event.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ButtonPushAfterEvent) => void): void;
}
/**
* Provides an adaptable interface for callers to subscribe to
* an event that fires after a lever is used.
*/
### Class: ILeverActionAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ILeverActionAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ILeverActionAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Subscribes to the event.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: LeverActionAfterEvent) => void): (arg: LeverActionAfterEvent) => void;
/**
- Explanation:
* Unsubscribes from the event.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: LeverActionAfterEvent) => void): void;
}
/**
* Provides an adaptable interface for callers to subscribe to
* an event that fires after a player joins a world.
*/
### Class: IPlayerJoinAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: IPlayerJoinAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `IPlayerJoinAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Subscribes to the event.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PlayerJoinAfterEvent) => void): (arg: PlayerJoinAfterEvent) => void;
/**
- Explanation:
* Unsubscribes from the event.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerJoinAfterEvent) => void): void;
}
/**
* Provides an adaptable interface for callers to subscribe to
* an event that fires after a player leaves a world.
*/
### Class: IPlayerLeaveAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: IPlayerLeaveAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `IPlayerLeaveAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Subscribes to the event.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PlayerLeaveAfterEvent) => void): (arg: PlayerLeaveAfterEvent) => void;
/**
- Explanation:
* Unsubscribes from the event.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerLeaveAfterEvent) => void): void;
}
/**
* Provides an adaptable interface for callers to subscribe to
* an event that fires after a player spawns.
*/
### Class: IPlayerSpawnAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: IPlayerSpawnAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `IPlayerSpawnAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Subscribes to the event.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PlayerSpawnAfterEvent) => void): (arg: PlayerSpawnAfterEvent) => void;
/**
- Explanation:
* Unsubscribes from the event.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerSpawnAfterEvent) => void): void;
}
/**
* Contains information related to a chargeable item completing
* being charged.
*/
### Class: ItemCompleteUseAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemCompleteUseAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemCompleteUseAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the item stack that has completed charging.
*
*/
readonly itemStack: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
/**
- Explanation:
* Returns the time, in ticks, for the remaining duration left
* before the charge completes its cycle.
*
*/
readonly useDuration: number;
}
/**
* Manages callbacks that are connected to the completion of
* charging for a chargeable item.
*/
### Class: ItemCompleteUseAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemCompleteUseAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemCompleteUseAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a chargeable item
* completes charging.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): (arg: ItemCompleteUseAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a chargeable item
* completes charging.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemCompleteUseAfterEvent) => void): void;
}
/**
* @beta
*/
### Class: ItemCompleteUseEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemCompleteUseEvent` in the Minecraft Bedrock Edition Script API.
The `ItemCompleteUseEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
readonly itemStack: ItemStack;
readonly source: Player;
}
/**
* Base class for item components.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemComponent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponent` in the Minecraft Bedrock Edition Script API.
The `ItemComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
* Contains information regarding an item before it is damaged
* from hitting an entity.
*/
### Class: ItemComponentBeforeDurabilityDamageEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentBeforeDurabilityDamageEvent` in the Minecraft Bedrock Edition Script API.
The `ItemComponentBeforeDurabilityDamageEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The attacking entity.
*
*/
readonly attackingEntity: Entity;
/**
- Explanation:
* The damage applied to the item's durability when the event
* occurs.
*
*/
durabilityDamage: number;
/**
- Explanation:
* The entity being hit.
*
*/
readonly hitEntity: Entity;
/**
- Explanation:
* The item stack used to hit the entity.
*
*/
itemStack?: ItemStack;
}
/**
* @beta
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemComponentCompleteUseEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentCompleteUseEvent` in the Minecraft Bedrock Edition Script API.
The `ItemComponentCompleteUseEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
### Class: ItemComponentConsumeEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentConsumeEvent` in the Minecraft Bedrock Edition Script API.
The `ItemComponentConsumeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
readonly itemStack: ItemStack;
readonly source: Entity;
}
/**
* @beta
* Contains information regarding when an item is used to hit
* an entity.
*/
### Class: ItemComponentHitEntityEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentHitEntityEvent` in the Minecraft Bedrock Edition Script API.
The `ItemComponentHitEntityEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The attacking entity.
*
*/
readonly attackingEntity: Entity;
/**
- Explanation:
* Whether the hit landed or had any effect.
*
*/
readonly hadEffect: boolean;
/**
- Explanation:
* The entity being hit.
*
*/
readonly hitEntity: Entity;
/**
- Explanation:
* The item stack used to hit the entity.
*
*/
readonly itemStack?: ItemStack;
}
/**
* @beta
* Contains information regarding the mining of a block using
* an item.
*/
### Class: ItemComponentMineBlockEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentMineBlockEvent` in the Minecraft Bedrock Edition Script API.
The `ItemComponentMineBlockEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block impacted by this event.
*
*/
readonly block: Block;
/**
- Explanation:
* The item stack used to mine the block.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* The block permutation that was mined.
*
*/
readonly minedBlockPermutation: BlockPermutation;
/**
- Explanation:
* The entity that mined the block.
*
*/
readonly source: Entity;
}
/**
* @beta
* Provides the functionality for registering custom components
* for items.
*/
### Class: ItemComponentRegistry
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentRegistry` in the Minecraft Bedrock Edition Script API.
The `ItemComponentRegistry` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Registers an item custom component that can be used in item
* JSON configuration.
*
* @param name
* The id that represents this custom component. Must have a
* namespace. This id can be specified in a item's JSON
* configuration under the 'minecraft:custom_components' item
* component.
* @param itemCustomComponent
* The collection of event functions that will be called when
* the event occurs on an item using this custom component id.
* @throws This function can throw errors.
*
* {@link ItemCustomComponentAlreadyRegisteredError}
*
* {@link ItemCustomComponentNameError}
*
* {@link ItemCustomComponentReloadNewComponentError}
*
* {@link ItemCustomComponentReloadNewEventError}
*
* {@link ItemCustomComponentReloadVersionError}
*/
registerCustomComponent(name: string, itemCustomComponent: ItemCustomComponent): void;
}
/**
* @beta
* Contains information regarding the use of an item.
*/
### Class: ItemComponentUseEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentUseEvent` in the Minecraft Bedrock Edition Script API.
The `ItemComponentUseEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The item stack when the item was used.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* The player who used the item.
*
*/
readonly source: Player;
}
/**
* @beta
* Contains information regarding the use of an item on a block
* via a component.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemComponentUseOnEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemComponentUseOnEvent` in the Minecraft Bedrock Edition Script API.
The `ItemComponentUseOnEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The entity that used the item on the block.
*
*/
readonly source: Entity;
/**
- Explanation:
* The block permutation that the item was used on.
*
*/
readonly usedOnBlockPermutation: BlockPermutation;
}
/**
* When present on an item, this item has a cooldown effect
* when used by entities.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemCooldownComponent
This section details the purpose, properties, methods, and code examples for `Class: ItemCooldownComponent` in the Minecraft Bedrock Edition Script API.
The `ItemCooldownComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Represents the cooldown category that this item is
* associated with.
*
* @throws This property can throw when used.
*/
readonly cooldownCategory: string;
/**
- Explanation:
* Amount of time, in ticks, it will take this item to
* cooldown.
*
* @throws This property can throw when used.
*/
readonly cooldownTicks: number;
static readonly componentId = 'minecraft:cooldown';
/**
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
getCooldownTicksRemaining(player: Player): number;
/**
- Explanation:
* Will return true if the item is the cooldown category passed
* in and false otherwise.
*
* This function can't be called in read-only mode.
*
* @param cooldownCategory
* The cooldown category that might be associated with this
* item.
* @returns
* True if the item is the given cooldown category.
* @throws This function can throw errors.
*/
isCooldownCategory(cooldownCategory: string): boolean;
/**
- Explanation:
* Starts a new cooldown period for this item.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
startCooldown(player: Player): void;
}
/**
* When present on an item, this item can take damage in the
* process of being used. Note that this component only applies
* to data-driven items.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemDurabilityComponent
This section details the purpose, properties, methods, and code examples for `Class: ItemDurabilityComponent` in the Minecraft Bedrock Edition Script API.
The `ItemDurabilityComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the current damage level of this particular item.
*
* This property can't be edited in read-only mode.
*
*/
damage: number;
/**
- Explanation:
* Represents the amount of damage that this item can take
* before breaking.
*
* @throws This property can throw when used.
*/
readonly maxDurability: number;
static readonly componentId = 'minecraft:durability';
/**
- Explanation:
* Returns the maximum chance that this item would be damaged
* using the damageRange property, given an unbreaking
* enchantment level.
*
* This function can't be called in read-only mode.
*
* @param unbreakingEnchantmentLevel
* Unbreaking factor to consider in factoring the damage
* chance. Incoming unbreaking parameter must be within the
* range [0, 3].
* @throws This function can throw errors.
*/
getDamageChance(unbreakingEnchantmentLevel?: number): number;
/**
- Explanation:
* A range of numbers that is used to calculate the damage
* chance for an item. The damage chance will fall within this
* range.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
getDamageChanceRange(): minecraftcommon.NumberRange;
}
/**
* @beta
* When present on an item, this item can have enchantments
* applied to it.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns a bunch of item stacks
*
* function giveFireSword(player: Player) {
* const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1);
*
* const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable);
* if (enchantments) {
* enchantments.addEnchantment({ type: new EnchantmentType(MinecraftEnchantmentTypes.FireAspect), level: 1 });
* }
*
* const inventory = player.getComponent('minecraft:inventory');
* if (inventory === undefined || inventory.container === undefined) {
* return;
* }
* inventory.container.setItem(0, ironFireSword);
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemEnchantableComponent
This section details the purpose, properties, methods, and code examples for `Class: ItemEnchantableComponent` in the Minecraft Bedrock Edition Script API.
The `ItemEnchantableComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @throws This property can throw when used.
*/
readonly slots: EnchantmentSlot[];
static readonly componentId = 'minecraft:enchantable';
/**
- Explanation:
* Adds an enchantment to the item stack.
*
* This function can't be called in read-only mode.
*
* @param enchantment
* The enchantment interface to be added.
* @throws
* ScriptItemEnchantmentUnknownIdError: Exception thrown if the
* enchantment type does not exist.
*
* ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown
* if the enchantment level is outside the allowable range for
* the given enchantment type.
*
* ScriptItemEnchantmentTypeNotCompatibleError: Exception
* thrown if the enchantment is not compatible with the item
* stack.
*
*
* {@link EnchantmentLevelOutOfBoundsError}
*
* {@link EnchantmentTypeNotCompatibleError}
*
* {@link EnchantmentTypeUnknownIdError}
*
* {@link Error}
*/
addEnchantment(enchantment: Enchantment): void;
/**
- Explanation:
* Adds a list of enchantments to the item stack.
*
* This function can't be called in read-only mode.
*
* @param enchantments
* The list of enchantments to be added.
* @throws
* ScriptItemEnchantmentUnknownIdError: Exception thrown if any
* enchantment type does not exist.
*
* ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown
* if any enchantment level is outside the allowable range for
* the given enchantment type.
*
* ScriptItemEnchantmentTypeNotCompatibleError: Exception
* thrown if any enchantment is not compatible with the item
* stack.
*
*
* {@link EnchantmentLevelOutOfBoundsError}
*
* {@link EnchantmentTypeNotCompatibleError}
*
* {@link EnchantmentTypeUnknownIdError}
*
* {@link Error}
*/
addEnchantments(enchantments: Enchantment[]): void;
/**
- Explanation:
* Checks whether an enchantment can be added to the item
* stack.
*
* @param enchantment
* The enchantment interface to be added.
* @returns
* Returns true if the enchantment can be added to the item
* stack.
* @throws
* ScriptItemEnchantmentUnknownIdError: Exception thrown if the
* enchantment type does not exist.
*
* ScriptItemEnchantmentLevelOutOfBoundsError: Exception thrown
* if the enchantment level is outside the allowable range for
* the given enchantment type.
*
*
* {@link EnchantmentLevelOutOfBoundsError}
*
* {@link EnchantmentTypeUnknownIdError}
*/
canAddEnchantment(enchantment: Enchantment): boolean;
/**
- Explanation:
* Gets the enchantment of a given type from the item stack.
*
* @param enchantmentType
* The enchantment type to get.
* @returns
* Returns the enchantment if it exists on the item stack.
* @throws
* ScriptItemEnchantmentUnknownIdError: Exception thrown if the
* enchantment type does not exist.
*
*
* {@link EnchantmentTypeUnknownIdError}
*/
getEnchantment(enchantmentType: EnchantmentType | string): Enchantment | undefined;
/**
- Explanation:
* Gets all enchantments on the item stack.
*
* @returns
* Returns a list of enchantments on the item stack.
* @throws This function can throw errors.
*/
getEnchantments(): Enchantment[];
/**
- Explanation:
* Checks whether an item stack has a given enchantment type.
*
* @param enchantmentType
* The enchantment type to check for.
* @returns
* Returns true if the item stack has the enchantment type.
* @throws
* ScriptItemEnchantmentUnknownIdError: Exception thrown if the
* enchantment type does not exist.
*
*
* {@link EnchantmentTypeUnknownIdError}
*/
hasEnchantment(enchantmentType: EnchantmentType | string): boolean;
/**
- Explanation:
* Removes all enchantments applied to this item stack.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
removeAllEnchantments(): void;
/**
- Explanation:
* Removes an enchantment of the given type.
*
* This function can't be called in read-only mode.
*
* @param enchantmentType
* The enchantment type to remove.
* @throws
* ScriptItemEnchantmentUnknownIdError: Exception thrown if the
* enchantment type does not exist.
*
*
* {@link EnchantmentTypeUnknownIdError}
*
* {@link Error}
*/
removeEnchantment(enchantmentType: EnchantmentType | string): void;
}
/**
* When present on an item, this item is consumable by
* entities. Note that this component only applies to
* data-driven items.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemFoodComponent
This section details the purpose, properties, methods, and code examples for `Class: ItemFoodComponent` in the Minecraft Bedrock Edition Script API.
The `ItemFoodComponent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If true, the player can always eat this item (even when not
* hungry).
*
* @throws This property can throw when used.
*/
readonly canAlwaysEat: boolean;
/**
- Explanation:
* Represents how much nutrition this food item will give an
* entity when eaten.
*
* @throws This property can throw when used.
*/
readonly nutrition: number;
/**
- Explanation:
* When an item is eaten, this value is used according to this
* formula (nutrition * saturation_modifier * 2) to apply a
* saturation buff.
*
* @throws This property can throw when used.
*/
readonly saturationModifier: number;
/**
- Explanation:
* When specified, converts the active item to the one
* specified by this property.
*
* @throws This property can throw when used.
*/
readonly usingConvertsTo: string;
static readonly componentId = 'minecraft:food';
}
/**
* Contains information related to a chargeable item when the
* player has finished using the item and released the build
* action.
*/
### Class: ItemReleaseUseAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemReleaseUseAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemReleaseUseAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the item stack that triggered this item event.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
/**
- Explanation:
* Returns the time, in ticks, for the remaining duration left
* before the charge completes its cycle.
*
*/
readonly useDuration: number;
}
/**
* Manages callbacks that are connected to the releasing of
* charging for a chargeable item.
*/
### Class: ItemReleaseUseAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemReleaseUseAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemReleaseUseAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a chargeable item
* is released from charging.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): (arg: ItemReleaseUseAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a chargeable item
* is released from charging.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemReleaseUseAfterEvent) => void): void;
}
/**
* Defines a collection of items.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns a bunch of item stacks
*
* function giveFireSword(player: Player) {
* const ironFireSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1);
*
* const enchantments = ironFireSword?.getComponent(ItemComponentTypes.Enchantable);
* if (enchantments) {
* enchantments.addEnchantment({ type: new EnchantmentType(MinecraftEnchantmentTypes.FireAspect), level: 1 });
* }
*
* const inventory = player.getComponent('minecraft:inventory');
* if (inventory === undefined || inventory.container === undefined) {
* return;
* }
* inventory.container.setItem(0, ironFireSword);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Gives the player some equipment
*
* function giveEquipment(player: Player) {
* const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable);
* if (equipmentCompPlayer) {
* equipmentCompPlayer.setEquipment(EquipmentSlot.Head, new ItemStack(MinecraftItemTypes.GoldenHelmet));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.IronChestplate));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Legs, new ItemStack(MinecraftItemTypes.DiamondLeggings));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Feet, new ItemStack(MinecraftItemTypes.NetheriteBoots));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Mainhand, new ItemStack(MinecraftItemTypes.WoodenSword));
* equipmentCompPlayer.setEquipment(EquipmentSlot.Offhand, new ItemStack(MinecraftItemTypes.Shield));
* } else {
* console.warn('No equipment component found on player');
* }
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Spawns a feather at a location
*
* function spawnFeather(location: DimensionLocation) {
* const featherItem = new ItemStack(MinecraftItemTypes.Feather, 1);
* location.dimension.spawnItem(featherItem, location);
* }
* ```
*/
### Class: ItemStack
This section details the purpose, properties, methods, and code examples for `Class: ItemStack` in the Minecraft Bedrock Edition Script API.
The `ItemStack` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
/**
- Explanation:
* Number of the items in the stack. Valid values range between
* 1-255. The provided value will be clamped to the item's
* maximum stack size.
*
* This property can't be edited in read-only mode.
*
* @throws
* Throws if the value is outside the range of 1-255.
*/
amount: number;
/**
- Explanation:
* Returns whether the item is stackable. An item is considered
* stackable if the item's maximum stack size is greater than 1
* and the item does not contain any custom data or properties.
*
*/
readonly isStackable: boolean;
/**
- Explanation:
* Gets or sets whether the item is kept on death.
*
* This property can't be edited in read-only mode.
*
*/
keepOnDeath: boolean;
/**
- Explanation:
* Gets or sets the item's lock mode. The default value is
* `ItemLockMode.none`.
*
* This property can't be edited in read-only mode.
*
*/
lockMode: ItemLockMode;
/**
- Explanation:
* The maximum stack size. This value varies depending on the
* type of item. For example, torches have a maximum stack size
* of 64, while eggs have a maximum stack size of 16.
*
*/
readonly maxAmount: number;
/**
- Explanation:
* Given name of this stack of items. The name tag is displayed
* when hovering over the item. Setting the name tag to an
* empty string or `undefined` will remove the name tag.
*
* This property can't be edited in read-only mode.
*
* @throws
* Throws if the length exceeds 255 characters.
*/
nameTag?: string;
/**
- Explanation:
* The type of the item.
*
*/
readonly 'type': ItemType;
/**
- Explanation:
* Identifier of the type of items for the stack. If a
* namespace is not specified, 'minecraft:' is assumed.
* Examples include 'wheat' or 'apple'.
*
*/
readonly typeId: string;
/**
- Explanation:
* Creates a new instance of a stack of items for use in the
* world.
*
* @param itemType
* Type of item to create. See the {@link
* @minecraft/vanilla-data.MinecraftItemTypes} enumeration for
* a list of standard item types in Minecraft experiences.
* @param amount
* Number of items to place in the stack, between 1-255. The
* provided value will be clamped to the item's maximum stack
* size. Note that certain items can only have one item in the
* stack.
* @throws
* Throws if `itemType` is invalid, or if `amount` is outside
* the range of 1-255.
*/
constructor(itemType: ItemType | string, amount?: number);
/**
- Explanation:
* Clears all dynamic properties that have been set on this
* item stack.
*
*/
clearDynamicProperties(): void;
/**
- Explanation:
* Creates an exact copy of the item stack, including any
* custom data or properties.
*
* @returns
* Returns a copy of this item stack.
*/
clone(): ItemStack;
/**
- Explanation:
* Get the list of block types this item can break in Adventure
* mode.
*
* This function can't be called in read-only mode.
*
*/
getCanDestroy(): string[];
/**
- Explanation:
* Get the list of block types this item can be placed on in
* Adventure mode.
*
* This function can't be called in read-only mode.
*
*/
getCanPlaceOn(): string[];
/**
- Explanation:
* Gets a component (that represents additional capabilities)
* for an item stack.
*
* @param componentId
* The identifier of the component (e.g., 'minecraft:food'). If
* no namespace prefix is specified, 'minecraft:' is assumed.
* Available component IDs can be found as part of the {@link
* ItemComponentTypes} enum.
* @returns
* Returns the component if it exists on the item stack,
* otherwise undefined.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Gives a player a half-damaged diamond sword
*
* function giveHurtDiamondSword(player: Player) {
* const hurtDiamondSword = new ItemStack(MinecraftItemTypes.DiamondSword);
* const durabilityComponent = hurtDiamondSword.getComponent(ItemComponentTypes.Durability);
* if (durabilityComponent !== undefined) {
* durabilityComponent.damage = durabilityComponent.maxDurability / 2;
* }
*
* const inventory = player.getComponent(EntityComponentTypes.Inventory);
* if (inventory === undefined || inventory.container === undefined) {
* return;
* }
*
* inventory.container.addItem(hurtDiamondSword);
* }
* ```
*/
getComponent<T extends keyof ItemComponentTypeMap>(componentId: T): ItemComponentTypeMap[T] | undefined;
/**
- Explanation:
* Returns all components that are both present on this item
* stack and supported by the API.
*
*/
getComponents(): ItemComponent[];
/**
- Explanation:
* Returns a property value.
*
* @param identifier
* The property identifier.
* @returns
* Returns the value for the property, or undefined if the
* property has not been set.
*/
getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined;
/**
- Explanation:
* Returns the available set of dynamic property identifiers
* that have been used on this entity.
*
* @returns
* A string array of the dynamic properties set on this entity.
*/
getDynamicPropertyIds(): string[];
/**
- Explanation:
* Returns the total size, in bytes, of all the dynamic
* properties that are currently stored for this entity. This
* includes the size of both the key and the value. This can
* be useful for diagnosing performance warning signs - if, for
* example, an entity has many megabytes of associated dynamic
* properties, it may be slow to load on various devices.
*
*/
getDynamicPropertyTotalByteCount(): number;
/**
- Explanation:
* Returns the lore value - a secondary display string - for an
* ItemStack.
*
* @returns
* An array of lore lines. If the item does not have lore,
* returns an empty array.
*/
getLore(): string[];
/**
- Explanation:
* Returns a set of tags associated with this item stack.
*
*/
getTags(): string[];
/**
- Explanation:
* Returns true if the specified component is present on this
* item stack.
*
* @param componentId
* The identifier of the component (e.g., 'minecraft:food') to
* retrieve. If no namespace prefix is specified, 'minecraft:'
* is assumed.
*/
hasComponent(componentId: string): boolean;
/**
- Explanation:
* Checks whether this item stack has a particular tag
* associated with it.
*
* @param tag
* Tag to search for.
* @returns
* True if the Item Stack has the tag associated with it, else
* false.
*/
hasTag(tag: string): boolean;
/**
- Explanation:
* Returns whether this item stack can be stacked with the
* given `itemStack`. This is determined by comparing the item
* type and any custom data and properties associated with the
* item stacks. The amount of each item stack is not taken into
* consideration.
*
* @param itemStack
* ItemStack to check stacking compatability with.
* @returns
* True if the Item Stack is stackable with the itemStack
* passed in.
*/
isStackableWith(itemStack: ItemStack): boolean;
/**
* @beta
- Explanation:
* Version safe way of checking if an item matches.
*
* @param itemName
* Identifier of the item.
* @param states
* Applicable only for blocks. An optional set of states to
* compare against. If states is not specified, matches checks
* against the set of types more broadly.
* @returns
* Returns a boolean whether the specified item matches.
*/
matches(itemName: string, states?: Record<string, boolean | number | string>): boolean;
/**
- Explanation:
* The list of block types this item can break in Adventure
* mode. The block names are displayed in the item's tooltip.
* Setting the value to undefined will clear the list.
*
* This function can't be called in read-only mode.
*
* @param blockIdentifiers
* String list of block types that the item can destroy.
* @throws
* Throws if any of the provided block identifiers are invalid.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* const specialPickaxe = new ItemStack('minecraft:diamond_pickaxe');
* specialPickaxe.setCanDestroy(['minecraft:cobblestone', 'minecraft:obsidian']);
*
* // Creates a diamond pickaxe that can destroy cobblestone and obsidian
*
* function giveRestrictedPickaxe(player: Player) {
* const specialPickaxe = new ItemStack(MinecraftItemTypes.DiamondPickaxe);
* specialPickaxe.setCanPlaceOn([MinecraftItemTypes.Cobblestone, MinecraftItemTypes.Obsidian]);
*
* const inventory = player.getComponent('inventory');
* if (inventory === undefined || inventory.container === undefined) {
* return;
* }
*
* inventory.container.addItem(specialPickaxe);
* }
* ```
*/
setCanDestroy(blockIdentifiers?: string[]): void;
/**
- Explanation:
* The list of block types this item can be placed on in
* Adventure mode. This is only applicable to block items. The
* block names are displayed in the item's tooltip. Setting the
* value to undefined will clear the list.
*
* This function can't be called in read-only mode.
*
* @param blockIdentifiers
* String list of block types that the item can be placed on.
* @throws
* Throws if any of the provided block identifiers are invalid.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Creates a gold block that can be placed on grass and dirt
*
* function giveRestrictedGoldBlock(player: Player) {
* const specialGoldBlock = new ItemStack(MinecraftItemTypes.GoldBlock);
* specialGoldBlock.setCanPlaceOn([MinecraftItemTypes.Grass, MinecraftItemTypes.Dirt]);
*
* const inventory = player.getComponent(EntityComponentTypes.Inventory);
* if (inventory === undefined || inventory.container === undefined) {
* return;
* }
*
* inventory.container.addItem(specialGoldBlock);
* }
* ```
*/
setCanPlaceOn(blockIdentifiers?: string[]): void;
/**
- Explanation:
* Sets a specified property to a value. Note: This function
* only works with non-stackable items.
*
* @param identifier
* The property identifier.
* @param value
* Data value of the property to set.
* @throws
* Throws if the item stack is stackable.
*/
setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void;
/**
- Explanation:
* Sets the lore value - a secondary display string - for an
* ItemStack. The lore list is cleared if set to an empty
* string or undefined.
*
* This function can't be called in read-only mode.
*
* @param loreList
* List of lore lines. Each element in the list represents a
* new line. The maximum lore line count is 20. The maximum
* lore line length is 50 characters.
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function giveAwesomeSword(player: Player) {
* const diamondAwesomeSword = new ItemStack(MinecraftItemTypes.DiamondSword, 1);
* diamondAwesomeSword.setLore([
* '§c§lDiamond Sword of Awesome§r',
* '+10 coolness', '§p+4 shiny§r'
* ]);
*
* // hover over/select the item in your inventory to see the lore.
* const inventory = player.getComponent(EntityComponentTypes.Inventory);
* if (inventory === undefined || inventory.container === undefined) {
* return;
* }
*
* inventory.container.setItem(0, diamondAwesomeSword);
* }
* ```
*/
setLore(loreList?: string[]): void;
}
/**
* Contains information related to a chargeable item starting
* to be charged.
*/
### Class: ItemStartUseAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemStartUseAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemStartUseAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The impacted item stack that is starting to be charged.
*
*/
readonly itemStack: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
/**
- Explanation:
* Returns the time, in ticks, for the remaining duration left
* before the charge completes its cycle.
*
*/
readonly useDuration: number;
}
/**
* Manages callbacks that are connected to the start of
* charging for a chargeable item.
*/
### Class: ItemStartUseAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemStartUseAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemStartUseAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a chargeable item
* starts charging.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemStartUseAfterEvent) => void): (arg: ItemStartUseAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a chargeable item
* starts charging.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemStartUseAfterEvent) => void): void;
}
/**
* Contains information related to an item being used on a
* block. This event fires when a player presses the the Use
* Item / Place Block button to successfully use an item or
* place a block. Fires for the first block that is interacted
* with when performing a build action. Note: This event cannot
* be used with Hoe or Axe items.
*/
### Class: ItemStartUseOnAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemStartUseOnAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemStartUseOnAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block that the item is used on.
*
*/
readonly block: Block;
/**
- Explanation:
* The face of the block that an item is being used on.
*
*/
readonly blockFace: Direction;
/**
- Explanation:
* The impacted item stack that is starting to be used. Can be
* undefined in some gameplay scenarios like pushing a button
* with an empty hand.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
}
/**
* Manages callbacks that are connected to an item starting
* being used on a block event.
*/
### Class: ItemStartUseOnAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemStartUseOnAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemStartUseOnAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an item is used on
* a block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): (arg: ItemStartUseOnAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an item is used on
* a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemStartUseOnAfterEvent) => void): void;
}
/**
* Contains information related to a chargeable item has
* finished an items use cycle, or when the player has released
* the use action with the item.
*/
### Class: ItemStopUseAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemStopUseAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemStopUseAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The impacted item stack that is stopping being charged.
* ItemStopUseAfterEvent can be called when teleporting to a
* different dimension and this can be undefined.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
/**
- Explanation:
* Returns the time, in ticks, for the remaining duration left
* before the charge completes its cycle.
*
*/
readonly useDuration: number;
}
/**
* Manages callbacks that are connected to the stopping of
* charging for an item that has a registered
* minecraft:chargeable component.
*/
### Class: ItemStopUseAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemStopUseAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemStopUseAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a chargeable item
* stops charging.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemStopUseAfterEvent) => void): (arg: ItemStopUseAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a chargeable item
* stops charging.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemStopUseAfterEvent) => void): void;
}
/**
* Contains information related to an item that has stopped
* being used on a block. This event fires when a player
* successfully uses an item or places a block by pressing the
* Use Item / Place Block button. If multiple blocks are
* placed, this event will only occur once at the beginning of
* the block placement. Note: This event cannot be used with
* Hoe or Axe items.
*/
### Class: ItemStopUseOnAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemStopUseOnAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemStopUseOnAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block that the item is used on.
*
*/
readonly block: Block;
/**
- Explanation:
* The impacted item stack that is being used on a block.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
}
/**
* Manages callbacks that are connected to an item stops used
* on a block event.
*/
### Class: ItemStopUseOnAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemStopUseOnAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemStopUseOnAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an item stops being
* used on a block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): (arg: ItemStopUseOnAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an item is used on
* a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemStopUseOnAfterEvent) => void): void;
}
/**
* Represents the type of an item - for example, Wool.
*/
### Class: ItemType
This section details the purpose, properties, methods, and code examples for `Class: ItemType` in the Minecraft Bedrock Edition Script API.
The `ItemType` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the identifier of the item type - for example,
* 'minecraft:apple'.
*
*/
readonly id: string;
}
/**
* @beta
* Returns the set of item types registered within Minecraft.
*/
### Class: ItemTypes
This section details the purpose, properties, methods, and code examples for `Class: ItemTypes` in the Minecraft Bedrock Edition Script API.
The `ItemTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns a specific item type, if available within Minecraft.
*
*/
static get(itemId: string): ItemType | undefined;
/**
- Explanation:
* Retrieves all available item types registered within
* Minecraft.
*
*/
static getAll(): ItemType[];
}
/**
* Contains information related to an item being used on a
* block. This event fires when an item used by a player
* successfully triggers an entity interaction.
*/
### Class: ItemUseAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemUseAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemUseAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The impacted item stack that is being used.
*
*/
itemStack: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
}
/**
* Manages callbacks that are connected to an item use event.
*/
### Class: ItemUseAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemUseAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemUseAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an item is used.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemUseAfterEvent) => void): (arg: ItemUseAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an item is used.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemUseAfterEvent) => void): void;
}
/**
* Contains information related to an item being used.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemUseBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemUseBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `ItemUseBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true, this will cancel the item use behavior.
*
*/
cancel: boolean;
}
/**
* Manages callbacks that fire before an item is used.
*/
### Class: ItemUseBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemUseBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemUseBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before an item is used.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemUseBeforeEvent) => void): (arg: ItemUseBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before an item is used.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemUseBeforeEvent) => void): void;
}
/**
* Contains information related to an item being used on a
* block. This event fires when an item used by a player
* successfully triggers a block interaction.
*/
### Class: ItemUseOnAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemUseOnAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ItemUseOnAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block that the item is used on.
*
*/
readonly block: Block;
/**
- Explanation:
* The face of the block that an item is being used on.
*
*/
readonly blockFace: Direction;
/**
- Explanation:
* Location relative to the bottom north-west corner of the
* block where the item is placed.
*
*/
readonly faceLocation: Vector3;
/**
- Explanation:
* The impacted item stack that is being used on a block.
*
*/
readonly itemStack: ItemStack;
/**
- Explanation:
* Returns the source entity that triggered this item event.
*
*/
readonly source: Player;
}
/**
* Manages callbacks that are connected to an item being used
* on a block event.
*/
### Class: ItemUseOnAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemUseOnAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemUseOnAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an item is used on
* a block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemUseOnAfterEvent) => void): (arg: ItemUseOnAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an item is used on
* a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemUseOnAfterEvent) => void): void;
}
/**
* Contains information related to an item being used on a
* block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemUseOnBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemUseOnBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `ItemUseOnBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true, this will cancel the item use behavior.
*
*/
cancel: boolean;
}
/**
* Manages callbacks that fire before an item being used on a
* block event.
*/
### Class: ItemUseOnBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ItemUseOnBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `ItemUseOnBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before an item is used
* on a block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ItemUseOnBeforeEvent) => void): (arg: ItemUseOnBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before an item is used
* on a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ItemUseOnBeforeEvent) => void): void;
}
/**
* @beta
* Contains information regarding the use of an item on a
* block.
*/
### Class: ItemUseOnEvent
This section details the purpose, properties, methods, and code examples for `Class: ItemUseOnEvent` in the Minecraft Bedrock Edition Script API.
The `ItemUseOnEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block impacted by this event.
*
*/
readonly block: Block;
/**
- Explanation:
* The face of the block that the item was used on.
*
*/
readonly blockFace: Direction;
/**
- Explanation:
* Location relative to the bottom north-west corner of the
* block that the item was used on.
*
*/
readonly faceLocation: Vector3;
/**
- Explanation:
* The item stack used on the block.
*
*/
readonly itemStack: ItemStack;
}
/**
* Contains information related to changes to a lever
* activating or deactivating.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => {
* console.warn(
* `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`,
* );
* });
*
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: LeverActionAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: LeverActionAfterEvent` in the Minecraft Bedrock Edition Script API.
The `LeverActionAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* True if the lever is activated (that is, transmitting
* power).
*
*/
readonly isPowered: boolean;
/**
- Explanation:
* Optional player that triggered the lever activation.
*
*/
readonly player: Player;
}
/**
* Manages callbacks that are connected to lever moves
* (activates or deactivates).
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.leverAction.subscribe((leverActivateEvent: LeverActionAfterEvent) => {
* console.warn(
* `Lever event at ${system.currentTick} with power: ${leverActivateEvent.block.getRedstonePower()}`,
* );
* });
*
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: LeverActionAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: LeverActionAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `LeverActionAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ListBlockVolume
This section details the purpose, properties, methods, and code examples for `Class: ListBlockVolume` in the Minecraft Bedrock Edition Script API.
The `ListBlockVolume` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
constructor(locations: Vector3[]);
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
add(locations: Vector3[]): void;
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
remove(locations: Vector3[]): void;
}
/**
* @beta
* A specific currently-internal event used for passing
* messages from client to server.
*/
### Class: MessageReceiveAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: MessageReceiveAfterEvent` in the Minecraft Bedrock Edition Script API.
The `MessageReceiveAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The message identifier.
*
*/
readonly id: string;
/**
- Explanation:
* The message.
*
*/
readonly message: string;
/**
- Explanation:
* The player who sent the message.
*
*/
readonly player: Player;
}
/**
* DEPRECATED
* Use @minecraft/vanilla-data.MinecraftDimensionTypes
* A collection of default Minecraft dimension types.
*/
### Class: MinecraftDimensionTypes
This section details the purpose, properties, methods, and code examples for `Class: MinecraftDimensionTypes` in the Minecraft Bedrock Edition Script API.
The `MinecraftDimensionTypes` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The Nether is a collection of biomes separate from the
* Overworld, including Soul Sand Valleys and Crimson forests.
* Nether fortresses contain exclusive resources. Mobs such as
* Blaze, Hoglins, Piglins, and Ghasts congregate here.
*
*/
static readonly nether = 'minecraft:nether';
/**
- Explanation:
* The overworld is a collection of biomes, including forests,
* plains, jungles, mountains, deserts, taiga, and more. This
* is the default starter dimension for Minecraft. Mobs such as
* Axolotl, Cows, Creepers, and Zombies congregate here.
*
*/
static readonly overworld = 'minecraft:overworld';
/**
- Explanation:
* The End is separate from the Overworld and the Nether and is
* generated whenever you create an End portal. Here, a giant
* center island is surrounded by several smaller areas and
* islands. You can find Endermen here. End midlands are larger
* areas that transition you from the center to the outer edges
* of the End. They contain Shulkers, Endermen, End gateway
* portals, and End cities. End gateway portals are commonly
* found at the outermost edge of the void. You usually find
* End barrens toward the edges of the main areas or land in
* the End.
*
*/
static readonly theEnd = 'minecraft:the_end';
}
/**
* Contains a set of additional variable values for further
* defining how rendering and animations function.
*/
### Class: MolangVariableMap
This section details the purpose, properties, methods, and code examples for `Class: MolangVariableMap` in the Minecraft Bedrock Edition Script API.
The `MolangVariableMap` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
/**
- Explanation:
* Adds the following variables to Molang:
* - `<variable_name>.r` - Red color value [0-1]
* - `<variable_name>.g` - Green color value [0-1]
* - `<variable_name>.b` - Blue color value [0-1]
*
* @throws This function can throw errors.
*/
setColorRGB(variableName: string, color: RGB): void;
/**
- Explanation:
* Adds the following variables to Molang:
* - `<variable_name>.r` - Red color value [0-1]
* - `<variable_name>.g` - Green color value [0-1]
* - `<variable_name>.b` - Blue color value [0-1]
* - `<variable_name>.a` - Alpha (transparency) color value
* [0-1]
*
* @throws This function can throw errors.
*/
setColorRGBA(variableName: string, color: RGBA): void;
/**
- Explanation:
* Sets a numeric (decimal) value within the Molang variable
* map.
*
* @param variableName
* Name of the float-based number to set.
* @param number
* Value for the Molang-based variable to set.
* @throws This function can throw errors.
*/
setFloat(variableName: string, number: number): void;
/**
- Explanation:
* Adds the following variables to Molang:
* - `<variable_name>.speed` - Speed number provided
* - `<variable_name>.direction_x` - X value from the {@link
* Vector3} provided
* - `<variable_name>.direction_y` - Y value from the {@link
* Vector3} provided
* - `<variable_name>.direction_z` - Z value from the {@link
* Vector3} provided
*
* @throws This function can throw errors.
*/
setSpeedAndDirection(variableName: string, speed: number, direction: Vector3): void;
/**
- Explanation:
* Adds the following variables to Molang:
* - `<variable_name>.x` - X value from the {@link Vector3}
* provided
* - `<variable_name>.y` - Y value from the {@link Vector3}
* provided
* - `<variable_name>.z` - Z value from the {@link Vector3}
* provided
*
* @throws This function can throw errors.
*/
setVector3(variableName: string, vector: Vector3): void;
}
/**
* Contains information related to changes to a piston
* expanding or retracting.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
* console.warn(
* `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`,
* );
* });
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PistonActivateAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PistonActivateAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PistonActivateAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* True if the piston is the process of expanding.
*
*/
readonly isExpanding: boolean;
/**
- Explanation:
* Contains additional properties and details of the piston.
*
*/
readonly piston: BlockPistonComponent;
}
/**
* Manages callbacks that are connected to piston activations.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
* console.warn(
* `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`,
* );
* });
* ```
*/
### Class: PistonActivateAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PistonActivateAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PistonActivateAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PistonActivateAfterEvent) => void): (arg: PistonActivateAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a piston expands
* or retracts.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PistonActivateAfterEvent) => void): void;
}
/**
* Represents a player within the world.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: Player
This section details the purpose, properties, methods, and code examples for `Class: Player` in the Minecraft Bedrock Edition Script API.
The `Player` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The player's Camera.
*
* @throws This property can throw when used.
*/
readonly camera: Camera;
/**
* @beta
- Explanation:
* Input permissions of the player.
*
*/
readonly inputPermissions: PlayerInputPermissions;
/**
- Explanation:
* If true, the player is currently emoting.
*
* @throws This property can throw when used.
*/
readonly isEmoting: boolean;
/**
- Explanation:
* Whether the player is flying. For example, in Creative or
* Spectator mode.
*
* @throws This property can throw when used.
*/
readonly isFlying: boolean;
/**
- Explanation:
* Whether the player is gliding with Elytra.
*
* @throws This property can throw when used.
*/
readonly isGliding: boolean;
/**
- Explanation:
* Whether the player is jumping. This will remain true while
* the player is holding the jump action.
*
* @throws This property can throw when used.
*/
readonly isJumping: boolean;
/**
- Explanation:
* The current overall level for the player, based on their
* experience.
*
* @throws This property can throw when used.
*/
readonly level: number;
/**
- Explanation:
* Name of the player.
*
* @throws This property can throw when used.
*/
readonly name: string;
/**
- Explanation:
* Contains methods for manipulating the on-screen display of a
* Player.
*
* @throws This property can throw when used.
*/
readonly onScreenDisplay: ScreenDisplay;
/**
* @beta
- Explanation:
* This property can't be edited in read-only mode.
*
*/
selectedSlotIndex: number;
/**
- Explanation:
* The overall total set of experience needed to achieve the
* next level for a player.
*
* @throws This property can throw when used.
*/
readonly totalXpNeededForNextLevel: number;
/**
- Explanation:
* The current set of experience achieved for the player.
*
* @throws This property can throw when used.
*/
readonly xpEarnedAtCurrentLevel: number;
/**
- Explanation:
* Adds/removes experience to/from the Player and returns the
* current experience of the Player.
*
* This function can't be called in read-only mode.
*
* @param amount
* Amount of experience to add. Note that this can be negative.
* Min/max bounds at -2^24 ~ 2^24
* @returns
* Returns the current experience of the Player.
* @throws This function can throw errors.
*/
addExperience(amount: number): number;
/**
- Explanation:
* Adds/removes level to/from the Player and returns the
* current level of the Player.
*
* This function can't be called in read-only mode.
*
* @param amount
* Amount to add to the player. Min/max bounds at -2^24 ~ 2^24
* @returns
* Returns the current level of the Player.
* @throws This function can throw errors.
*/
addLevels(amount: number): number;
/**
* @beta
- Explanation:
* Eats an item, providing the item's hunger and saturation
* effects to the player. Can only be used on food items.
*
* This function can't be called in read-only mode.
*
* @param itemStack
* The item to eat.
* @throws
* Throws if the item is not a food item.
*/
eatItem(itemStack: ItemStack): void;
/**
* @beta
* @throws This function can throw errors.
*/
getGameMode(): GameMode;
/**
* @beta
- Explanation:
* Gets the current item cooldown time for a particular
* cooldown category.
*
* @param cooldownCategory
* Specifies the cooldown category to retrieve the current
* cooldown for.
* @throws This function can throw errors.
*/
getItemCooldown(cooldownCategory: string): number;
/**
- Explanation:
* Gets the current spawn point of the player.
*
* @throws This function can throw errors.
*/
getSpawnPoint(): DimensionLocation | undefined;
/**
- Explanation:
* Gets the total experience of the Player.
*
* @throws This function can throw errors.
*/
getTotalXp(): number;
/**
* @beta
- Explanation:
* Returns true if this player has operator-level permissions.
*
* @throws This function can throw errors.
*/
isOp(): boolean;
/**
- Explanation:
* Plays a music track that only this particular player can
* hear.
*
* This function can't be called in read-only mode.
*
* @param trackId
* Identifier of the music track to play.
* @param musicOptions
* Additional options for the music track.
* @throws This function can throw errors.
*/
playMusic(trackId: string, musicOptions?: MusicOptions): void;
/**
- Explanation:
* Plays a sound that only this particular player can hear.
*
* This function can't be called in read-only mode.
*
* @param soundOptions
* Additional optional options for the sound.
* @throws This function can throw errors.
*/
playSound(soundId: string, soundOptions?: PlayerSoundOptions): void;
/**
* @beta
- Explanation:
* This is an internal-facing method for posting a system
* message to downstream clients.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
postClientMessage(id: string, value: string): void;
/**
- Explanation:
* Queues an additional music track that only this particular
* player can hear. If a track is not playing, a music track
* will play.
*
* This function can't be called in read-only mode.
*
* @param trackId
* Identifier of the music track to play.
* @param musicOptions
* Additional options for the music track.
* @throws
* An error will be thrown if volume is less than 0.0.
* An error will be thrown if fade is less than 0.0.
*
*/
queueMusic(trackId: string, musicOptions?: MusicOptions): void;
/**
- Explanation:
* Resets the level of the player.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
resetLevel(): void;
/**
- Explanation:
* Sends a message to the player.
*
* @param message
* The message to be displayed.
* @throws
* This method can throw if the provided {@link RawMessage} is
* in an invalid format. For example, if an empty `name` string
* is provided to `score`.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function sendPlayerMessages(player: Player) {
* // Displays "First or Second"
* const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] };
* player.sendMessage(rawMessage);
*
* // Displays "Hello, world!"
* player.sendMessage('Hello, world!');
*
* // Displays "Welcome, Amazing Player 1!"
* player.sendMessage({ translate: 'authentication.welcome', with: ['Amazing Player 1'] });
*
* // Displays the player's score for objective "obj". Each player will see their own score.
* const rawMessageWithScore = { score: { name: '*', objective: 'obj' } };
* player.sendMessage(rawMessageWithScore);
*
* // Displays "Apple or Coal"
* const rawMessageWithNestedTranslations = {
* translate: 'accessibility.list.or.two',
* with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] },
* };
* player.sendMessage(rawMessageWithNestedTranslations);
* }
* ```
*/
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setGameMode(gameMode?: GameMode): void;
/**
* @beta
- Explanation:
* Will change the specified players permissions, and whether
* they are operator or not.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setOp(isOp: boolean): void;
/**
- Explanation:
* Sets the current starting spawn point for this particular
* player.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link LocationOutOfWorldBoundariesError}
*/
setSpawnPoint(spawnPoint?: DimensionLocation): void;
/**
* @beta
- Explanation:
* Creates a new particle emitter at a specified location in
* the world. Only visible to the target player.
*
* This function can't be called in read-only mode.
*
* @param effectName
* Identifier of the particle to create.
* @param location
* The location at which to create the particle emitter.
* @param molangVariables
* A set of optional, customizable variables that can be
* adjusted for this particle.
* @throws This function can throw errors.
*
* {@link Error}
*
* {@link LocationInUnloadedChunkError}
*
* {@link LocationOutOfWorldBoundariesError}
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.playerSpawn.subscribe(event => {
* const targetLocation = event.player.location;
* 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: targetLocation.x + Math.floor(Math.random() * 8) - 4,
* y: targetLocation.y + Math.floor(Math.random() * 8) - 4,
* z: targetLocation.z + Math.floor(Math.random() * 8) - 4,
* };
* event.player.spawnParticle('minecraft:colored_flame_particle', newLocation, molang);
* }
* });
* ```
*/
spawnParticle(effectName: string, location: Vector3, molangVariables?: MolangVariableMap): void;
/**
* @beta
- Explanation:
* Sets the item cooldown time for a particular cooldown
* category.
*
* This function can't be called in read-only mode.
*
* @param cooldownCategory
* 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(cooldownCategory: string, tickDuration: number): void;
/**
- Explanation:
* Stops any music tracks from playing for this particular
* player.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
stopMusic(): void;
}
/**
* Contains information regarding an event after a player
* breaks a block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PlayerBreakBlockAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerBreakBlockAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerBreakBlockAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns permutation information about this block before it
* was broken.
*
*/
readonly brokenBlockPermutation: BlockPermutation;
/**
- Explanation:
* The item stack that was used to break the block after the
* block was broken, or undefined if empty hand.
*
*/
readonly itemStackAfterBreak?: ItemStack;
/**
- Explanation:
* The item stack that was used to break the block before the
* block was broken, or undefined if empty hand.
*
*/
readonly itemStackBeforeBreak?: ItemStack;
/**
- Explanation:
* Player that broke the block for this event.
*
*/
readonly player: Player;
}
/**
* Manages callbacks that are connected to when a player breaks
* a block.
*/
### Class: PlayerBreakBlockAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerBreakBlockAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerBreakBlockAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a block is broken
* by a player.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerBreakBlockAfterEvent) => void,
options?: BlockEventOptions,
): (arg: PlayerBreakBlockAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a player breaks a
* block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerBreakBlockAfterEvent) => void): void;
}
/**
* Contains information regarding an event before a player
* breaks a block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PlayerBreakBlockBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerBreakBlockBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerBreakBlockBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true, cancels the block break event.
*
*/
cancel: boolean;
/**
- Explanation:
* The item stack that is being used to break the block, or
* undefined if empty hand.
*
*/
itemStack?: ItemStack;
/**
- Explanation:
* Player breaking the block for this event.
*
*/
readonly player: Player;
}
/**
* Manages callbacks that are connected to before a player
* breaks a block.
*/
### Class: PlayerBreakBlockBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerBreakBlockBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerBreakBlockBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before a block is broken
* by a player.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerBreakBlockBeforeEvent) => void,
options?: BlockEventOptions,
): (arg: PlayerBreakBlockBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before a player breaks
* a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerBreakBlockBeforeEvent) => void): void;
}
/**
* Contains information related to changes to a player's
* dimension having been changed.
*/
### Class: PlayerDimensionChangeAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerDimensionChangeAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerDimensionChangeAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The dimension the player is changing from.
*
*/
readonly fromDimension: Dimension;
/**
- Explanation:
* The location the player was at before changing dimensions.
*
*/
readonly fromLocation: Vector3;
/**
- Explanation:
* Handle to the player that is changing dimensions.
*
*/
readonly player: Player;
/**
- Explanation:
* The dimension that the player is changing to.
*
*/
readonly toDimension: Dimension;
/**
- Explanation:
* The location the player will spawn to after changing
* dimensions.
*
*/
readonly toLocation: Vector3;
}
/**
* Manages callbacks that are connected to successful player
* dimension changes.
*/
### Class: PlayerDimensionChangeAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerDimensionChangeAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerDimensionChangeAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Subscribes the specified callback to a player dimension
* change after event.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PlayerDimensionChangeAfterEvent) => void): (arg: PlayerDimensionChangeAfterEvent) => void;
/**
- Explanation:
* Removes the specified callback from a player dimension
* change after event.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerDimensionChangeAfterEvent) => void): void;
}
/**
* @beta
*/
### Class: PlayerGameModeChangeAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerGameModeChangeAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerGameModeChangeAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
readonly fromGameMode: GameMode;
readonly player: Player;
readonly toGameMode: GameMode;
}
/**
* @beta
*/
### Class: PlayerGameModeChangeAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerGameModeChangeAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerGameModeChangeAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): (arg: PlayerGameModeChangeAfterEvent) => void;
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerGameModeChangeAfterEvent) => void): void;
}
/**
* @beta
*/
### Class: PlayerGameModeChangeBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerGameModeChangeBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerGameModeChangeBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
cancel: boolean;
readonly fromGameMode: GameMode;
readonly player: Player;
toGameMode: GameMode;
}
/**
* @beta
*/
### Class: PlayerGameModeChangeBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerGameModeChangeBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerGameModeChangeBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): (arg: PlayerGameModeChangeBeforeEvent) => void;
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerGameModeChangeBeforeEvent) => void): void;
}
/**
* @beta
* Contains information regarding an event after a players
* input permissions change.
*/
### Class: PlayerInputPermissionCategoryChangeAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerInputPermissionCategoryChangeAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerInputPermissionCategoryChangeAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The category of input permissions that have changed.
*
*/
readonly category: InputPermissionCategory;
/**
- Explanation:
* The enabled/disabled state of the players input permissions.
*
*/
readonly enabled: boolean;
/**
- Explanation:
* The player that has had their input permissions changed.
*
*/
readonly player: Player;
}
/**
* @beta
* Manages callbacks that are connected to after a players
* input permissions change.
*/
### Class: PlayerInputPermissionCategoryChangeAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerInputPermissionCategoryChangeAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerInputPermissionCategoryChangeAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called after a players input
* permissions change.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerInputPermissionCategoryChangeAfterEvent) => void,
): (arg: PlayerInputPermissionCategoryChangeAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called after a players input
* permissions change.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerInputPermissionCategoryChangeAfterEvent) => void): void;
}
/**
* @beta
*/
### Class: PlayerInputPermissions
This section details the purpose, properties, methods, and code examples for `Class: PlayerInputPermissions` in the Minecraft Bedrock Edition Script API.
The `PlayerInputPermissions` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
cameraEnabled: boolean;
movementEnabled: boolean;
}
/**
* Contains information regarding an event after a player
* interacts with a block.
*/
### Class: PlayerInteractWithBlockAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithBlockAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithBlockAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block that will be interacted with.
*
*/
readonly block: Block;
/**
- Explanation:
* The face of the block that is being interacted with.
*
*/
readonly blockFace: Direction;
/**
- Explanation:
* Location relative to the bottom north-west corner of the
* block where the item is placed.
*
*/
readonly faceLocation: Vector3;
/**
- Explanation:
* The item stack that is being used in the interaction, or
* undefined if empty hand.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Source Player for this event.
*
*/
readonly player: Player;
}
/**
* Manages callbacks that are connected to after a player
* interacts with a block.
*/
### Class: PlayerInteractWithBlockAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithBlockAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithBlockAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called after a player interacts
* with a block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerInteractWithBlockAfterEvent) => void,
): (arg: PlayerInteractWithBlockAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called after a player
* interacts with a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerInteractWithBlockAfterEvent) => void): void;
}
/**
* Contains information regarding an event before a player
* interacts with a block.
*/
### Class: PlayerInteractWithBlockBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithBlockBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithBlockBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The block that will be interacted with.
*
*/
readonly block: Block;
/**
- Explanation:
* The face of the block that is being interacted with.
*
*/
readonly blockFace: Direction;
/**
- Explanation:
* If set to true the interaction will be cancelled.
*
*/
cancel: boolean;
/**
- Explanation:
* Location relative to the bottom north-west corner of the
* block where the item is placed.
*
*/
readonly faceLocation: Vector3;
/**
- Explanation:
* The item stack that is being used in the interaction, or
* undefined if empty hand.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Source Player for this event.
*
*/
readonly player: Player;
}
/**
* Manages callbacks that are connected to before a player
* interacts with a block.
*/
### Class: PlayerInteractWithBlockBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithBlockBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithBlockBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before a player
* interacts with a block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerInteractWithBlockBeforeEvent) => void,
): (arg: PlayerInteractWithBlockBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before a player
* interacts with a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerInteractWithBlockBeforeEvent) => void): void;
}
/**
* Contains information regarding an event after a player
* interacts with an entity.
*/
### Class: PlayerInteractWithEntityAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithEntityAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithEntityAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The item stack that is being used in the interaction, or
* undefined if empty hand.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Source Player for this event.
*
*/
readonly player: Player;
/**
- Explanation:
* The entity that will be interacted with.
*
*/
readonly target: Entity;
}
/**
* Manages callbacks that are connected to after a player
* interacts with an entity.
*/
### Class: PlayerInteractWithEntityAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithEntityAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithEntityAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called after a player interacts
* with an entity.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerInteractWithEntityAfterEvent) => void,
): (arg: PlayerInteractWithEntityAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called after a player
* interacts with an entity.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerInteractWithEntityAfterEvent) => void): void;
}
/**
* Contains information regarding an event before a player
* interacts with an entity.
*/
### Class: PlayerInteractWithEntityBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithEntityBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithEntityBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true the interaction will be cancelled.
*
*/
cancel: boolean;
/**
- Explanation:
* The item stack that is being used in the interaction, or
* undefined if empty hand.
*
*/
readonly itemStack?: ItemStack;
/**
- Explanation:
* Source Player for this event.
*
*/
readonly player: Player;
/**
- Explanation:
* The entity that will be interacted with.
*
*/
readonly target: Entity;
}
/**
* Manages callbacks that are connected to before a player
* interacts with an entity.
*/
### Class: PlayerInteractWithEntityBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerInteractWithEntityBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerInteractWithEntityBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before a player
* interacts with an entity.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerInteractWithEntityBeforeEvent) => void,
): (arg: PlayerInteractWithEntityBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before a player
* interacts with an entity.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerInteractWithEntityBeforeEvent) => void): void;
}
/**
* @beta
* This type is usable for iterating over a set of players.
* This means it can be used in statements like for...of
* statements, Array.from(iterator), and more.
*/
### Class: PlayerIterator
This section details the purpose, properties, methods, and code examples for `Class: PlayerIterator` in the Minecraft Bedrock Edition Script API.
The `PlayerIterator` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This function can't be called in read-only mode.
*
*/
[Symbol.iterator](): Iterator<Player>;
/**
- Explanation:
* Retrieves the next item in this iteration. The resulting
* IteratorResult contains .done and .value properties which
* can be used to see the next Player in the iteration.
*
* This function can't be called in read-only mode.
*
*/
next(): IteratorResult<Player>;
}
/**
* Contains information regarding a player that has joined.
* See the playerSpawn event for more detailed information that
* could be returned after the first time a player has spawned
* within the game.
*/
### Class: PlayerJoinAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerJoinAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerJoinAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Opaque string identifier of the player that joined the game.
*
*/
readonly playerId: string;
/**
- Explanation:
* Name of the player that has joined.
*
*/
readonly playerName: string;
}
/**
* Manages callbacks that are connected to a player joining the
* world.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PlayerJoinAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerJoinAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerJoinAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Contains information regarding a player that has left the
* world.
*/
### Class: PlayerLeaveAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerLeaveAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerLeaveAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Opaque string identifier of the player that has left the
* event.
*
*/
readonly playerId: string;
/**
- Explanation:
* Player that has left the world.
*
*/
readonly playerName: string;
}
/**
* Manages callbacks that are connected to a player leaving the
* world.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PlayerLeaveAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerLeaveAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerLeaveAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Contains information regarding a player that is leaving the
* world.
*/
### Class: PlayerLeaveBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerLeaveBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerLeaveBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The leaving player.
*
*/
readonly player: Player;
}
/**
* Manages callbacks that are connected to a player leaving the
* world.
*/
### Class: PlayerLeaveBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerLeaveBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerLeaveBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a player leaves the
* world.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PlayerLeaveBeforeEvent) => void): (arg: PlayerLeaveBeforeEvent) => void;
/**
- Explanation:
* Removes a callback that will be called when a player leaves
* the world.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerLeaveBeforeEvent) => void): void;
}
/**
* Contains information regarding an event where a player
* places a block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PlayerPlaceBlockAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerPlaceBlockAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerPlaceBlockAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Player that placed the block for this event.
*
*/
readonly player: Player;
}
/**
* Manages callbacks that are connected to when a block is
* placed by a player.
*/
### Class: PlayerPlaceBlockAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerPlaceBlockAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerPlaceBlockAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a block is placed
* by a player.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerPlaceBlockAfterEvent) => void,
options?: BlockEventOptions,
): (arg: PlayerPlaceBlockAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an block is placed
* by a player.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerPlaceBlockAfterEvent) => void): void;
}
/**
* @beta
* Contains information regarding an event before a player
* places a block.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PlayerPlaceBlockBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerPlaceBlockBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerPlaceBlockBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true, cancels the block place event.
*
*/
cancel: boolean;
/**
- Explanation:
* The face of the block that the new block is being placed on.
*
*/
readonly face: Direction;
/**
- Explanation:
* Location relative to the bottom north-west corner of the
* block where the new block is being placed onto.
*
*/
readonly faceLocation: Vector3;
/**
- Explanation:
* The block permutation that is being placed.
*
*/
readonly permutationBeingPlaced: BlockPermutation;
/**
- Explanation:
* Player that is placing the block for this event.
*
*/
readonly player: Player;
}
/**
* @beta
* Manages callbacks that are connected to before a block is
* placed by a player.
*/
### Class: PlayerPlaceBlockBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerPlaceBlockBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerPlaceBlockBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before a block is placed
* by a player.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: PlayerPlaceBlockBeforeEvent) => void,
options?: BlockEventOptions,
): (arg: PlayerPlaceBlockBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before an block is
* placed by a player.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PlayerPlaceBlockBeforeEvent) => void): void;
}
/**
* An event that contains more information about a player
* spawning.
*/
### Class: PlayerSpawnAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PlayerSpawnAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PlayerSpawnAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If true, this is the initial spawn of a player after joining
* the game.
*
* This property can't be edited in read-only mode.
*
*/
initialSpawn: boolean;
/**
- Explanation:
* Object that represents the player that joined the game.
*
* This property can't be edited in read-only mode.
*
*/
player: Player;
}
/**
* Registers an event when a player is spawned (or re-spawned
* after death) and fully ready within the world.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PlayerSpawnAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PlayerSpawnAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PlayerSpawnAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Contains information related to changes to a pressure plate
* pop.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PressurePlatePopAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PressurePlatePopAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PressurePlatePopAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The redstone power of the pressure plate before it was
* popped.
*
*/
readonly previousRedstonePower: number;
/**
- Explanation:
* The redstone power of the pressure plate at the time of the
* pop.
*
*/
readonly redstonePower: number;
}
/**
* Manages callbacks that are connected to when a pressure
* plate is popped.
*/
### Class: PressurePlatePopAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PressurePlatePopAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PressurePlatePopAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a pressure plate is
* popped.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PressurePlatePopAfterEvent) => void): (arg: PressurePlatePopAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a pressure plate
* is popped.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PressurePlatePopAfterEvent) => void): void;
}
/**
* Contains information related to changes to a pressure plate
* push.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: PressurePlatePushAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: PressurePlatePushAfterEvent` in the Minecraft Bedrock Edition Script API.
The `PressurePlatePushAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The redstone power of the pressure plate before it was
* pushed.
*
*/
readonly previousRedstonePower: number;
/**
- Explanation:
* The redstone power of the pressure plate at the time of the
* push.
*
*/
readonly redstonePower: number;
/**
- Explanation:
* Source that triggered the pressure plate push.
*
*/
readonly source: Entity;
}
/**
* Manages callbacks that are connected to when a pressure
* plate is pushed.
*/
### Class: PressurePlatePushAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: PressurePlatePushAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `PressurePlatePushAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a pressure plate is
* pushed.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: PressurePlatePushAfterEvent) => void): (arg: PressurePlatePushAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a pressure plate
* is pushed.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: PressurePlatePushAfterEvent) => void): void;
}
/**
* Contains information related to a projectile hitting a
* block.
*/
### Class: ProjectileHitBlockAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ProjectileHitBlockAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ProjectileHitBlockAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Dimension where this projectile hit took place.
*
*/
readonly dimension: Dimension;
/**
- Explanation:
* Direction vector of the projectile as it hit a block.
*
*/
readonly hitVector: Vector3;
/**
- Explanation:
* Location where the projectile hit occurred.
*
*/
readonly location: Vector3;
/**
- Explanation:
* Entity for the projectile that hit a block.
*
*/
readonly projectile: Entity;
/**
- Explanation:
* Optional source entity that fired the projectile.
*
*/
readonly source?: Entity;
/**
- Explanation:
* Contains additional information about the block that was hit
* by the projectile.
*
* This function can't be called in read-only mode.
*
*/
getBlockHit(): BlockHitInformation;
}
/**
* Manages callbacks that are connected to when a projectile
* hits a block.
*/
### Class: ProjectileHitBlockAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ProjectileHitBlockAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ProjectileHitBlockAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a projectile hits a
* block.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): (arg: ProjectileHitBlockAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a projectile hits
* a block.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ProjectileHitBlockAfterEvent) => void): void;
}
/**
* Contains information related to a projectile hitting an
* entity.
*/
### Class: ProjectileHitEntityAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ProjectileHitEntityAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ProjectileHitEntityAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Dimension where this projectile hit took place.
*
*/
readonly dimension: Dimension;
/**
- Explanation:
* Direction vector of the projectile as it hit an entity.
*
*/
readonly hitVector: Vector3;
/**
- Explanation:
* Location where the projectile hit occurred.
*
*/
readonly location: Vector3;
/**
- Explanation:
* Entity for the projectile that hit an entity.
*
*/
readonly projectile: Entity;
/**
- Explanation:
* Optional source entity that fired the projectile.
*
*/
readonly source?: Entity;
/**
- Explanation:
* Contains additional information about an entity that was
* hit.
*
* This function can't be called in read-only mode.
*
*/
getEntityHit(): EntityHitInformation;
}
/**
* Manages callbacks that are connected to when a projectile
* hits an entity.
*/
### Class: ProjectileHitEntityAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ProjectileHitEntityAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ProjectileHitEntityAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a projectile hits
* an entity.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): (arg: ProjectileHitEntityAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a projectile hits
* an entity.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: ProjectileHitEntityAfterEvent) => void): void;
}
/**
* Contains objectives and participants for the scoreboard.
*/
### Class: Scoreboard
This section details the purpose, properties, methods, and code examples for `Class: Scoreboard` in the Minecraft Bedrock Edition Script API.
The `Scoreboard` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a new objective to the scoreboard.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
addObjective(objectiveId: string, displayName?: string): ScoreboardObjective;
/**
- Explanation:
* Clears the objective that occupies a display slot.
*
* This function can't be called in read-only mode.
*
*/
clearObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjective | undefined;
/**
- Explanation:
* Returns a specific objective (by id).
*
* @param objectiveId
* Identifier of the objective.
*/
getObjective(objectiveId: string): ScoreboardObjective | undefined;
/**
- Explanation:
* Returns an objective that occupies the specified display
* slot.
*
*/
getObjectiveAtDisplaySlot(displaySlotId: DisplaySlotId): ScoreboardObjectiveDisplayOptions | undefined;
/**
- Explanation:
* Returns all defined objectives.
*
*/
getObjectives(): ScoreboardObjective[];
/**
- Explanation:
* Returns all defined scoreboard identities.
*
*/
getParticipants(): ScoreboardIdentity[];
/**
- Explanation:
* Removes an objective from the scoreboard.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
removeObjective(objectiveId: ScoreboardObjective | string): boolean;
/**
- Explanation:
* Sets an objective into a display slot with specified
* additional display settings.
*
* This function can't be called in read-only mode.
*
* @returns
* Returns the previous `ScoreboardObjective` set at the
* display slot, if no objective was previously set it returns
* `undefined`.
* @throws This function can throw errors.
*/
setObjectiveAtDisplaySlot(
displaySlotId: DisplaySlotId,
objectiveDisplaySetting: ScoreboardObjectiveDisplayOptions,
): ScoreboardObjective | undefined;
}
/**
* Contains an identity of the scoreboard item.
*/
### Class: ScoreboardIdentity
This section details the purpose, properties, methods, and code examples for `Class: ScoreboardIdentity` in the Minecraft Bedrock Edition Script API.
The `ScoreboardIdentity` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the player-visible name of this identity.
*
*/
readonly displayName: string;
/**
- Explanation:
* Identifier of the scoreboard identity.
*
*/
readonly id: number;
/**
- Explanation:
* Type of the scoreboard identity.
*
*/
readonly 'type': ScoreboardIdentityType;
/**
- Explanation:
* If the scoreboard identity is an entity or player, returns
* the entity that this scoreboard item corresponds to.
*
* @throws This function can throw errors.
*/
getEntity(): Entity | undefined;
/**
- Explanation:
* Returns true if the ScoreboardIdentity reference is still
* valid.
*
*/
isValid(): boolean;
}
/**
* Contains objectives and participants for the scoreboard.
*/
### Class: ScoreboardObjective
This section details the purpose, properties, methods, and code examples for `Class: ScoreboardObjective` in the Minecraft Bedrock Edition Script API.
The `ScoreboardObjective` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns the player-visible name of this scoreboard
* objective.
*
* @throws This property can throw when used.
*/
readonly displayName: string;
/**
- Explanation:
* Identifier of the scoreboard objective.
*
* @throws This property can throw when used.
*/
readonly id: string;
/**
- Explanation:
* Adds a score to the given participant and objective.
*
* This function can't be called in read-only mode.
*
* @param participant
* Participant to apply the scoreboard value addition to.
* @throws This function can throw errors.
*/
addScore(participant: Entity | ScoreboardIdentity | string, scoreToAdd: number): number;
/**
- Explanation:
* Returns all objective participant identities.
*
* @throws This function can throw errors.
*/
getParticipants(): ScoreboardIdentity[];
/**
- Explanation:
* Returns a specific score for a participant.
*
* @param participant
* Identifier of the participant to retrieve a score for.
* @throws This function can throw errors.
*/
getScore(participant: Entity | ScoreboardIdentity | string): number | undefined;
/**
- Explanation:
* Returns specific scores for this objective for all
* participants.
*
* @throws This function can throw errors.
*/
getScores(): ScoreboardScoreInfo[];
/**
- Explanation:
* Returns if the specified identity is a participant of the
* scoreboard objective.
*
* @throws This function can throw errors.
*/
hasParticipant(participant: Entity | ScoreboardIdentity | string): boolean;
/**
- Explanation:
* Returns true if the ScoreboardObjective reference is still
* valid.
*
*/
isValid(): boolean;
/**
- Explanation:
* Removes a participant from this scoreboard objective.
*
* This function can't be called in read-only mode.
*
* @param participant
* Participant to remove from being tracked with this
* objective.
* @throws This function can throw errors.
*/
removeParticipant(participant: Entity | ScoreboardIdentity | string): boolean;
/**
- Explanation:
* Sets a score for a participant.
*
* This function can't be called in read-only mode.
*
* @param participant
* Identity of the participant.
* @param score
* New value of the score.
* @throws This function can throw errors.
*/
setScore(participant: Entity | ScoreboardIdentity | string, score: number): void;
}
/**
* Contains a pair of a scoreboard participant and its
* respective score.
*/
### Class: ScoreboardScoreInfo
This section details the purpose, properties, methods, and code examples for `Class: ScoreboardScoreInfo` in the Minecraft Bedrock Edition Script API.
The `ScoreboardScoreInfo` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* This scoreboard participant for this score.
*
*/
readonly participant: ScoreboardIdentity;
/**
- Explanation:
* Score value of the identity for this objective.
*
*/
readonly score: number;
}
/**
* Contains information about user interface elements that are
* showing up on the screen.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.playerSpawn.subscribe((event) => {
* event.player.onScreenDisplay.setTitle('§o§6You respawned!§r');
* });
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.playerSpawn.subscribe((event) => {
* event.player.onScreenDisplay.setTitle('You respawned', {
* stayDuration: 100,
* fadeInDuration: 2,
* fadeOutDuration: 4,
* subtitle: 'Try not to die next time!',
* });
* });
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.playerSpawn.subscribe(event => {
* event.player.onScreenDisplay.setTitle('Get ready!', {
* stayDuration: 220,
* fadeInDuration: 2,
* fadeOutDuration: 4,
* subtitle: '10',
* });
*
* let countdown = 10;
*
* const intervalId = system.runInterval(() => {
* countdown--;
* event.player.onScreenDisplay.updateSubtitle(countdown.toString());
*
* if (countdown == 0) {
* system.clearRun(intervalId);
* }
* }, 20);
* });
* ```
*/
### Class: ScreenDisplay
This section details the purpose, properties, methods, and code examples for `Class: ScreenDisplay` in the Minecraft Bedrock Edition Script API.
The `ScreenDisplay` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
getHiddenHudElements(): HudElement[];
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
hideAllExcept(hudElements?: HudElement[]): void;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
isForcedHidden(hudElement: HudElement): boolean;
/**
- Explanation:
* Returns true if the current reference to this screen display
* manager object is valid and functional.
*
*/
isValid(): boolean;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
resetHudElements(): void;
/**
- Explanation:
* Set the action bar text - a piece of text that displays
* beneath the title and above the hot-bar.
*
* This function can't be called in read-only mode.
*
* @param text
* New value for the action bar text.
* @throws This function can throw errors.
*/
setActionBar(text: (RawMessage | string)[] | RawMessage | string): void;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
setHudVisibility(visible: HudVisibility, hudElements?: HudElement[]): void;
/**
- Explanation:
* Will cause a title to show up on the player's on screen
* display. Will clear the title if set to empty string. You
* can optionally specify an additional subtitle as well as
* fade in, stay and fade out times.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.playerSpawn.subscribe((event) => {
* event.player.onScreenDisplay.setTitle('§o§6You respawned!§r');
* });
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.playerSpawn.subscribe((event) => {
* event.player.onScreenDisplay.setTitle('You respawned', {
* stayDuration: 100,
* fadeInDuration: 2,
* fadeOutDuration: 4,
* subtitle: 'Try not to die next time!',
* });
* });
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* world.afterEvents.playerSpawn.subscribe(event => {
* event.player.onScreenDisplay.setTitle('Get ready!', {
* stayDuration: 220,
* fadeInDuration: 2,
* fadeOutDuration: 4,
* subtitle: '10',
* });
*
* let countdown = 10;
*
* const intervalId = system.runInterval(() => {
* countdown--;
* event.player.onScreenDisplay.updateSubtitle(countdown.toString());
*
* if (countdown == 0) {
* system.clearRun(intervalId);
* }
* }, 20);
* });
* ```
*/
setTitle(title: (RawMessage | string)[] | RawMessage | string, options?: TitleDisplayOptions): void;
/**
- Explanation:
* Updates the subtitle if the subtitle was previously
* displayed via the setTitle method.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
updateSubtitle(subtitle: (RawMessage | string)[] | RawMessage | string): void;
}
/**
* Returns additional data about a /scriptevent command
* invocation.
*/
### Class: ScriptEventCommandMessageAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: ScriptEventCommandMessageAfterEvent` in the Minecraft Bedrock Edition Script API.
The `ScriptEventCommandMessageAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Identifier of this ScriptEvent command message.
*
*/
readonly id: string;
/**
- Explanation:
* If this command was initiated via an NPC, returns the entity
* that initiated the NPC dialogue.
*
*/
readonly initiator?: Entity;
/**
- Explanation:
* Optional additional data passed in with the script event
* command.
*
*/
readonly message: string;
/**
- Explanation:
* Source block if this command was triggered via a block
* (e.g., a commandblock.)
*
*/
readonly sourceBlock?: Block;
/**
- Explanation:
* Source entity if this command was triggered by an entity
* (e.g., a NPC).
*
*/
readonly sourceEntity?: Entity;
/**
- Explanation:
* Returns the type of source that fired this command.
*
*/
readonly sourceType: ScriptEventSource;
}
/**
* Allows for registering an event handler that responds to
* inbound /scriptevent commands.
*/
### Class: ScriptEventCommandMessageAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ScriptEventCommandMessageAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ScriptEventCommandMessageAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Registers a new ScriptEvent handler.
*
* This function can't be called in read-only mode.
*
*/
subscribe(
callback: (arg: ScriptEventCommandMessageAfterEvent) => void,
options?: ScriptEventMessageFilterOptions,
): (arg: ScriptEventCommandMessageAfterEvent) => void;
/**
- Explanation:
* Unsubscribes a particular handler for a ScriptEvent event.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
*/
unsubscribe(callback: (arg: ScriptEventCommandMessageAfterEvent) => void): void;
}
/**
* @beta
* Describes a particular seating position on this rideable
* entity.
*/
### Class: Seat
This section details the purpose, properties, methods, and code examples for `Class: Seat` in the Minecraft Bedrock Edition Script API.
The `Seat` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Angle in degrees that a rider is allowed to rotate while
* riding this entity.
*
*/
readonly lockRiderRotation: number;
/**
- Explanation:
* A maximum number of riders that this seat can support.
*
*/
readonly maxRiderCount: number;
/**
- Explanation:
* A minimum number of riders that can be placed in this seat
* position, if this seat is to be filled.
*
*/
readonly minRiderCount: number;
/**
- Explanation:
* Physical location of this seat, relative to the entity's
* location.
*
*/
readonly position: Vector3;
/**
- Explanation:
* Angle in degrees to rotate riders by.
*
*/
readonly seatRotation: number;
}
/**
* @beta
* Manages callbacks that are message passing to a server. This
* event is not currently fully implemented, and should not be
* used.
*/
### Class: ServerMessageAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: ServerMessageAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `ServerMessageAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when an internal message
* is passed.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: MessageReceiveAfterEvent) => void): (arg: MessageReceiveAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when an internal
* message is passed.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: MessageReceiveAfterEvent) => void): void;
}
/**
* Represents a loaded structure template (.mcstructure file).
* Structures can be placed in a world using the /structure
* command or the {@link StructureManager} APIs.
*/
### Class: Structure
This section details the purpose, properties, methods, and code examples for `Class: Structure` in the Minecraft Bedrock Edition Script API.
The `Structure` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The name of the structure. The identifier must include a
* namespace. For structures created via the /structure command
* or structure blocks, this namespace defaults to
* "mystructure".
*
*/
readonly id: string;
/**
- Explanation:
* The dimensions of the structure. For example, a single block
* structure will have a size of {x:1, y:1, z:1}
*
* @throws This property can throw when used.
*
* {@link InvalidStructureError}
*/
readonly size: Vector3;
/**
- Explanation:
* Returns a BlockPermutation representing the block contained
* within the Structure at the given location.
*
* @param location
* The block location relative to the Structure's origin.
* @returns
* Returns a BlockPermutation. Returns undefined if a block
* does not exist at the given location.
* @throws
* Throws if the location is outside the structure's bounds.
* Throws if the Structure has been deleted.
*
* {@link minecraftcommon.InvalidArgumentError}
*
* {@link InvalidStructureError}
*/
getBlockPermutation(location: Vector3): BlockPermutation | undefined;
/**
- Explanation:
* Returns whether the block at the given location is
* waterlogged.
*
* @param location
* The block location relative to the Structure's origin.
* @returns
* Returns whether the block at the given location is
* waterlogged. Returns false if a block does not exist at the
* given location.
* @throws
* Throws if the location is outside the structure's bounds.
* Throws if the Structure has been deleted.
*
* {@link minecraftcommon.InvalidArgumentError}
*
* {@link InvalidStructureError}
*/
getIsWaterlogged(location: Vector3): boolean;
/**
- Explanation:
* Returns whether the Structure is valid. The Structure may
* become invalid if it is deleted.
*
* @returns
* Returns whether the Structure is valid.
*/
isValid(): boolean;
/**
* @beta
- Explanation:
* Creates a copy of a Structure and saves it with a new name.
*
* This function can't be called in read-only mode.
*
* @param identifier
* The name of the newly created Structure.
* @param saveMode
* Determines how the Structure should be saved. Defaults to
* saving to the world.
* @returns
* Returns the newly created structure.
* @throws
* Throws if the identifier is invalid. A valid identifier must
* include a namespace and must be unique.
* Throws if the Structure has been deleted.
*
* {@link minecraftcommon.EngineError}
*
* {@link minecraftcommon.InvalidArgumentError}
*
* {@link InvalidStructureError}
*/
saveAs(identifier: string, saveMode?: StructureSaveMode): Structure;
/**
* @beta
- Explanation:
* Saves a modified Structure to the world file.
*
* This function can't be called in read-only mode.
*
* @throws
* Throws if the Structure has been deleted.
*
* {@link InvalidStructureError}
*/
saveToWorld(): void;
/**
* @beta
- Explanation:
* Sets a BlockPermutation within a Structure.
*
* This function can't be called in read-only mode.
*
* @param location
* The block location relative to the Structure's origin.
* @param blockPermutation
* The BlockPermutation to set.
* @throws
* Throws if the type of block is StructureVoid.
* Throws if the block is undefined and waterlogged is set to
* true.
* Throws if the block is air and waterlogged is set to true.
* Throws if the location is outside the structure's bounds.
* Throws if the Structure has been deleted.
*
* {@link minecraftcommon.InvalidArgumentError}
*
* {@link InvalidStructureError}
*/
setBlockPermutation(location: Vector3, blockPermutation?: BlockPermutation): void;
}
/**
* Manager for Structure related APIs. Includes APIs for
* creating, getting, placing and deleting Structures.
*/
### Class: StructureManager
This section details the purpose, properties, methods, and code examples for `Class: StructureManager` in the Minecraft Bedrock Edition Script API.
The `StructureManager` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Creates an empty Structure in memory. Use {@link
* Structure.setBlockPermutation} to populate the structure
* with blocks and save changes with {@link
* @minecraft/server.Structure.save}.
*
* This function can't be called in read-only mode.
*
* @param identifier
* The name of the structure. A valid identifier must include a
* namespace and must be unique.
* @param size
* The size of the structure. For example, to create a single
* block structure the size should be {x:1, y:1, z:1}.
* @param saveMode
* How the Structure should be saved upon creation. Defaults to
* StructureSaveMode.Memory.
* @returns
* Returns the newly created Structure.
* @throws
* Throws if the identifier is invalid. A valid identifier must
* include a namespace and must be unique.
*
* {@link minecraftcommon.EngineError}
*
* {@link minecraftcommon.InvalidArgumentError}
*/
createEmpty(identifier: string, size: Vector3, saveMode?: StructureSaveMode): Structure;
/**
* @beta
- Explanation:
* Creates a new Structure from blocks in the world. This is
* functionally equivalent to the /structure save command.
*
* This function can't be called in read-only mode.
*
* @param identifier
* The name of the structure. A valid identifier must include a
* namespace and must be unique.
* @param dimension
* The dimension where the blocks should be read from.
* @param options
* Additional options for creating a structure from the world.
* @returns
* Returns the newly created Structure.
* @throws
* Throws if the identifier is invalid. A valid identifier must
* include a namespace and must be unique.
* Throws if the structure bounds exceed the maximum size.
* Throws if the structure bounds contains blocks outside the
* world bounds.
*
*
* {@link minecraftcommon.InvalidArgumentError}
*/
createFromWorld(
identifier: string,
dimension: Dimension,
from: Vector3,
to: Vector3,
options?: StructureCreateOptions,
): Structure;
/**
- Explanation:
* Deletes a structure from memory and from the world if it
* exists.
*
* This function can't be called in read-only mode.
*
* @param structure
* The structure identifier or Structure object that should be
* deleted. Note, a Structure object will become invalid after
* it is deleted.
* @returns
* Returns whether the structure was removed.
* @throws
* Throws if a structure cannot be removed. For example, a
* structure loaded from a Behavior Pack.
*
* {@link minecraftcommon.InvalidArgumentError}
*/
delete(structure: string | Structure): boolean;
/**
- Explanation:
* Gets a Structure that is saved to memory or the world.
*
* This function can't be called in read-only mode.
*
* @param identifier
* The name of the structure to get.
* @returns
* Returns a Structure if it exists, otherwise undefined.
*/
get(identifier: string): Structure | undefined;
/**
* @beta
- Explanation:
* This function can't be called in read-only mode.
*
*/
getWorldStructureIds(): string[];
/**
- Explanation:
* Places a structure in the world. Structures placed in
* unloaded chunks will be queued for loading.
*
* This function can't be called in read-only mode.
*
* @param structure
* The structure's identifier or a Structure object.
* @param dimension
* The dimension where the Structure should be placed.
* @param location
* The location within the dimension where the Structure should
* be placed.
* @param options
* Additional options for Structure placement.
* @throws
* Throws if the integrity value is outside of the range [0,1]
* Throws if the integrity seed is invalid.
* Throws if the placement location contains blocks that are
* outside the world bounds.
*
* {@link minecraftcommon.ArgumentOutOfBoundsError}
*
* {@link minecraftcommon.InvalidArgumentError}
*
* {@link InvalidStructureError}
*/
place(
structure: string | Structure,
dimension: Dimension,
location: Vector3,
options?: StructurePlaceOptions,
): void;
}
/**
* A class that provides system-level events and functions.
*/
### Class: System
This section details the purpose, properties, methods, and code examples for `Class: System` in the Minecraft Bedrock Edition Script API.
The `System` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Returns a collection of after-events for system-level
* operations.
*
*/
readonly afterEvents: SystemAfterEvents;
/**
* @beta
- Explanation:
* Returns a collection of before-events for system-level
* operations.
*
*/
readonly beforeEvents: SystemBeforeEvents;
/**
- Explanation:
* Represents the current world tick of the server.
*
*/
readonly currentTick: number;
/**
* @beta
- Explanation:
* Cancels the execution of a job queued via {@link
* System.runJob}.
*
* @param jobId
* The job ID returned from {@link System.runJob}.
*/
clearJob(jobId: number): void;
/**
- Explanation:
* Cancels the execution of a function run that was previously
* scheduled via {@link System.run}.
*
*/
clearRun(runId: number): void;
/**
- Explanation:
* Runs a specified function at a future time. This is
* frequently used to implement delayed behaviors and game
* loops.
*
* @param callback
* Function callback to run when the tickDelay time criteria is
* met.
* @returns
* An opaque identifier that can be used with the `clearRun`
* function to cancel the execution of this run.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function printEveryMinute() {
* try {
* // Minecraft runs at 20 ticks per second.
* if (system.currentTick % 1200 === 0) {
* world.sendMessage('Another minute passes...');
* }
* } catch (e) {
* console.warn('Error: ' + e);
* }
*
* system.run(printEveryMinute);
* }
*
* printEveryMinute();
* ```
*/
run(callback: () => void): number;
/**
- Explanation:
* Runs a set of code on an interval.
*
* @param callback
* Functional code that will run when this interval occurs.
* @param tickInterval
* An interval of every N ticks that the callback will be
* called upon.
* @returns
* An opaque handle that can be used with the clearRun method
* to stop the run of this function on an interval.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const intervalRunIdentifier = Math.floor(Math.random() * 10000);
*
* system.runInterval(() => {
* world.sendMessage('This is an interval run ' + intervalRunIdentifier + ' sending a message every 30 seconds.');
* }, 600);
* ```
*/
runInterval(callback: () => void, tickInterval?: number): number;
/**
* @beta
- Explanation:
* Queues a generator to run until completion. The generator
* will be given a time slice each tick, and will be run until
* it yields or completes.
*
* @param generator
* The instance of the generator to run.
* @returns
* An opaque handle that can be used with {@link
* System.clearJob} to stop the run of this generator.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // A simple generator that places blocks in a cube at a specific location
* // with a specific size, yielding after every block place.
* function* blockPlacingGenerator(blockPerm: BlockPermutation, startingLocation: DimensionLocation, size: number) {
* for (let x = startingLocation.x; x < startingLocation.x + size; x++) {
* for (let y = startingLocation.y; y < startingLocation.y + size; y++) {
* for (let z = startingLocation.z; z < startingLocation.z + size; z++) {
* const block = startingLocation.dimension.getBlock({ x: x, y: y, z: z });
* if (block) {
* block.setPermutation(blockPerm);
* }
* yield;
* }
* }
* }
* }
*
* // When a button is pushed, we will place a 15x15x15 cube of cobblestone 10 blocks above it
* world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
* const cubePos = buttonPushEvent.block.location;
* cubePos.y += 10;
*
* const blockPerm = BlockPermutation.resolve('minecraft:cobblestone');
*
* system.runJob(blockPlacingGenerator(blockPerm, { dimension: buttonPushEvent.dimension, ...cubePos }, 15));
* });
* ```
*/
runJob(generator: Generator<void, void, void>): number;
/**
- Explanation:
* Runs a set of code at a future time specified by tickDelay.
*
* @param callback
* Functional code that will run when this timeout occurs.
* @param tickDelay
* Amount of time, in ticks, before the interval will be
* called.
* @returns
* An opaque handle that can be used with the clearRun method
* to stop the run of this function on an interval.
*/
runTimeout(callback: () => void, tickDelay?: number): number;
/**
* @beta
* @throws This function can throw errors.
*
* {@link minecraftcommon.EngineError}
*/
waitTicks(ticks: number): Promise<void>;
}
/**
* Provides a set of events that fire within the broader
* scripting system within Minecraft.
*/
### Class: SystemAfterEvents
This section details the purpose, properties, methods, and code examples for `Class: SystemAfterEvents` in the Minecraft Bedrock Edition Script API.
The `SystemAfterEvents` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* An event that fires when a /scriptevent command is set. This
* provides a way for commands and other systems to trigger
* behavior within script.
*
*/
readonly scriptEventReceive: ScriptEventCommandMessageAfterEventSignal;
}
/**
* @beta
* A set of events that fire before an actual action occurs. In
* most cases, you can potentially cancel or modify the
* impending event. Note that in before events any APIs that
* modify gameplay state will not function and will throw an
* error.
*/
### Class: SystemBeforeEvents
This section details the purpose, properties, methods, and code examples for `Class: SystemBeforeEvents` in the Minecraft Bedrock Edition Script API.
The `SystemBeforeEvents` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Fires when the scripting watchdog shuts down the server. The
* can be due to using too much memory, or by causing
* significant slowdown or hang.
* To prevent shutdown, set the event's cancel property to
* true.
*
*/
readonly watchdogTerminate: WatchdogTerminateBeforeEventSignal;
}
/**
* Contains information related to changes to a target block
* hit.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: TargetBlockHitAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: TargetBlockHitAfterEvent` in the Minecraft Bedrock Edition Script API.
The `TargetBlockHitAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* The position where the source hit the block.
*
*/
readonly hitVector: Vector3;
/**
- Explanation:
* The redstone power before the block is hit.
*
*/
readonly previousRedstonePower: number;
/**
- Explanation:
* The redstone power at the time the block is hit.
*
*/
readonly redstonePower: number;
/**
- Explanation:
* Optional source that hit the target block.
*
*/
readonly source: Entity;
}
/**
* Manages callbacks that are connected to when a target block
* is hit.
*/
### Class: TargetBlockHitAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: TargetBlockHitAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `TargetBlockHitAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a target block is
* hit.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: TargetBlockHitAfterEvent) => void): (arg: TargetBlockHitAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a target block is
* hit.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: TargetBlockHitAfterEvent) => void): void;
}
/**
* @beta
* Represents a trigger for firing an event.
*/
### Class: Trigger
This section details the purpose, properties, methods, and code examples for `Class: Trigger` in the Minecraft Bedrock Edition Script API.
The `Trigger` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
/**
- Explanation:
* Event name of the trigger.
*
*/
eventName: string;
/**
- Explanation:
* Creates a new trigger.
*
*/
constructor(eventName: string);
}
/**
* Contains information related to changes to a trip wire trip.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const overworld = world.getDimension('overworld');
* const targetLocation: Vector3 = { x: 0, y: 0, z: 0 };
*
* // set up a tripwire
* const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z });
* const tripwire = overworld.getBlock(targetLocation);
*
* if (redstone === undefined || tripwire === undefined) {
* console.warn('Could not find block at location.');
* } else {
*
* redstone.setPermutation(BlockPermutation.resolve('redstone_block'));
* tripwire.setPermutation(BlockPermutation.resolve('tripwire'));
*
* world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => {
* const eventLoc = tripWireTripEvent.block.location;
*
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
* console.warn(
* 'Tripwire trip event at tick ' +
* system.currentTick +
* (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''),
* );
* }
* });
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: TripWireTripAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: TripWireTripAfterEvent` in the Minecraft Bedrock Edition Script API.
The `TripWireTripAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Whether or not the block has redstone power.
*
*/
readonly isPowered: boolean;
/**
- Explanation:
* The sources that triggered the trip wire to trip.
*
*/
readonly sources: Entity[];
}
/**
* Manages callbacks that are connected to when a trip wire is
* tripped.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const overworld = world.getDimension('overworld');
* const targetLocation: Vector3 = { x: 0, y: 0, z: 0 };
*
* // set up a tripwire
* const redstone = overworld.getBlock({ x: targetLocation.x, y: targetLocation.y - 1, z: targetLocation.z });
* const tripwire = overworld.getBlock(targetLocation);
*
* if (redstone === undefined || tripwire === undefined) {
* console.warn('Could not find block at location.');
* } else {
*
* redstone.setPermutation(BlockPermutation.resolve('redstone_block'));
* tripwire.setPermutation(BlockPermutation.resolve('tripwire'));
*
* world.afterEvents.tripWireTrip.subscribe((tripWireTripEvent: TripWireTripAfterEvent) => {
* const eventLoc = tripWireTripEvent.block.location;
*
* if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y && eventLoc.z === targetLocation.z) {
* console.warn(
* 'Tripwire trip event at tick ' +
* system.currentTick +
* (tripWireTripEvent.sources.length > 0 ? ' by entity ' + tripWireTripEvent.sources[0].id : ''),
* );
* }
* });
* }
* ```
*/
### Class: TripWireTripAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: TripWireTripAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `TripWireTripAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a trip wire is
* tripped.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: TripWireTripAfterEvent) => void): (arg: TripWireTripAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a trip wire is
* tripped.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: TripWireTripAfterEvent) => void): void;
}
/**
* @beta
* Contains information related to a script watchdog
* termination.
*/
### Class: WatchdogTerminateBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: WatchdogTerminateBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `WatchdogTerminateBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true, cancels the termination of the script
* runtime. Note that depending on server configuration
* settings, cancellation of the termination may not be
* allowed.
*
*/
cancel: boolean;
/**
- Explanation:
* Contains the reason why a script runtime is to be
* terminated.
*
*/
readonly terminateReason: WatchdogTerminateReason;
}
/**
* @beta
* Manages callbacks that are connected to a callback that will
* be called when a script runtime is being terminated due to a
* violation of the performance watchdog system.
*/
### Class: WatchdogTerminateBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: WatchdogTerminateBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `WatchdogTerminateBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when a script runtime is
* being terminated due to a violation of the performance
* watchdog system.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): (arg: WatchdogTerminateBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called when a script runtime
* is being terminated due to a violation of the performance
* watchdog system.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: WatchdogTerminateBeforeEvent) => void): void;
}
/**
* Contains information related to changes in weather in the
* environment.
*/
### Class: WeatherChangeAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: WeatherChangeAfterEvent` in the Minecraft Bedrock Edition Script API.
The `WeatherChangeAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Dimension in which the weather has changed.
*
*/
readonly dimension: string;
/**
- Explanation:
* The weather type after the weather was changed.
*
*/
readonly newWeather: WeatherType;
/**
- Explanation:
* The weather type before the weather was changed.
*
*/
readonly previousWeather: WeatherType;
}
/**
* Manages callbacks that are connected to weather changing.
*/
### Class: WeatherChangeAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: WeatherChangeAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `WeatherChangeAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when weather changes.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: WeatherChangeAfterEvent) => void): (arg: WeatherChangeAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called when weather changes.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: WeatherChangeAfterEvent) => void): void;
}
/**
* @beta
* Contains information related to changes in weather in the
* environment.
*/
### Class: WeatherChangeBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: WeatherChangeBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `WeatherChangeBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* If set to true the weather change will be cancelled.
*
*/
cancel: boolean;
/**
- Explanation:
* Sets the duration of the new weather (in ticks).
*
*/
duration: number;
/**
- Explanation:
* The type of weather that will be applied.
*
*/
newWeather: WeatherType;
/**
- Explanation:
* The type of weather that it was prior to the event being
* fired.
*
*/
readonly previousWeather: WeatherType;
}
/**
* @beta
* Manages callbacks that are connected to before weather
* changing.
*/
### Class: WeatherChangeBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: WeatherChangeBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `WeatherChangeBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called before weather changes.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: WeatherChangeBeforeEvent) => void): (arg: WeatherChangeBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called before weather changes.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: WeatherChangeBeforeEvent) => void): void;
}
/**
* A class that wraps the state of a world - a set of
* dimensions and the environment of Minecraft.
*/
### Class: World
This section details the purpose, properties, methods, and code examples for `Class: World` in the Minecraft Bedrock Edition Script API.
The `World` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Contains a set of events that are applicable to the entirety
* of the world. Event callbacks are called in a deferred
* manner. Event callbacks are executed in read-write mode.
*
*/
readonly afterEvents: WorldAfterEvents;
/**
- Explanation:
* Contains a set of events that are applicable to the entirety
* of the world. Event callbacks are called immediately. Event
* callbacks are executed in read-only mode.
*
*/
readonly beforeEvents: WorldBeforeEvents;
/**
* @beta
- Explanation:
* The game rules that apply to the world.
*
*/
readonly gameRules: GameRules;
/**
- Explanation:
* Returns the general global scoreboard that applies to the
* world.
*
*/
readonly scoreboard: Scoreboard;
/**
- Explanation:
* Returns the manager for {@link Structure} related APIs.
*
*/
readonly structureManager: StructureManager;
/**
* @beta
- Explanation:
* A method that is internal-only, used for broadcasting
* specific messages between client and server.
*
* This function can't be called in read-only mode.
*
* @param id
* The message identifier.
* @param value
* The message.
*/
broadcastClientMessage(id: string, value: string): void;
/**
- Explanation:
* Clears the set of dynamic properties declared for this
* behavior pack within the world.
*
*/
clearDynamicProperties(): void;
/**
- Explanation:
* Returns the absolute time since the start of the world.
*
*/
getAbsoluteTime(): number;
/**
- Explanation:
* Returns an array of all active players within the world.
*
* @throws This function can throw errors.
*/
getAllPlayers(): Player[];
/**
- Explanation:
* Returns the current day.
*
* @returns
* The current day, determined by the world time divided by the
* number of ticks per day. New worlds start at day 0.
*/
getDay(): number;
/**
- Explanation:
* Returns the default Overworld spawn location.
*
* @returns
* The default Overworld spawn location. By default, the Y
* coordinate is 32767, indicating a player's spawn height is
* not fixed and will be determined by surrounding blocks.
*/
getDefaultSpawnLocation(): Vector3;
/**
- Explanation:
* Returns a dimension object.
*
* @param dimensionId
* The name of the dimension. For example, "overworld",
* "nether" or "the_end".
* @returns
* The requested dimension
* @throws
* Throws if the given dimension name is invalid
*/
getDimension(dimensionId: string): Dimension;
/**
- Explanation:
* Returns a property value.
*
* @param identifier
* The property identifier.
* @returns
* Returns the value for the property, or undefined if the
* property has not been set.
* @throws
* Throws if the given dynamic property identifier is not
* defined.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function incrementProperty(propertyName: string): boolean {
* let number = mc.world.getDynamicProperty(propertyName);
*
* console.warn('Current value is: ' + number);
*
* if (number === undefined) {
* number = 0;
* }
*
* if (typeof number !== 'number') {
* console.warn('Number is of an unexpected type.');
* return false;
* }
*
* mc.world.setDynamicProperty(propertyName, number + 1);
* return true;
* }
*
* incrementProperty('samplelibrary:number');
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function updateWorldProperty(propertyName: string): boolean {
* let paintStr = mc.world.getDynamicProperty(propertyName);
* let paint: { color: string; intensity: number } | undefined = undefined;
*
* console.log('Current value is: ' + paintStr);
*
* if (paintStr === undefined) {
* paint = {
* color: 'purple',
* intensity: 0,
* };
* } else {
* if (typeof paintStr !== 'string') {
* console.warn('Paint is of an unexpected type.');
* return false;
* }
*
* try {
* paint = JSON.parse(paintStr);
* } catch (e) {
* console.warn('Error parsing serialized struct.');
* return false;
* }
* }
*
* if (!paint) {
* console.warn('Error parsing serialized struct.');
* return false;
* }
*
* paint.intensity++;
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
* mc.world.setDynamicProperty(propertyName, paintStr);
*
* return true;
* }
*
* updateWorldProperty('samplelibrary:longerjson');
* ```
*/
getDynamicProperty(identifier: string): boolean | number | string | Vector3 | undefined;
/**
- Explanation:
* Gets a set of dynamic property identifiers that have been
* set in this world.
*
* @returns
* A string array of active dynamic property identifiers.
*/
getDynamicPropertyIds(): string[];
/**
- Explanation:
* Gets the total byte count of dynamic properties. This could
* potentially be used for your own analytics to ensure you're
* not storing gigantic sets of dynamic properties.
*
*/
getDynamicPropertyTotalByteCount(): number;
/**
- Explanation:
* Returns an entity based on the provided id.
*
* @param id
* The id of the entity.
* @returns
* The requested entity object.
* @throws
* Throws if the given entity id is invalid.
*/
getEntity(id: string): Entity | undefined;
/**
- Explanation:
* Returns the MoonPhase for the current time.
*
*/
getMoonPhase(): MoonPhase;
/**
- Explanation:
* Returns a set of players based on a set of conditions
* defined via the EntityQueryOptions set of filter criteria.
*
* @param options
* Additional options that can be used to filter the set of
* players returned.
* @returns
* A player array.
* @throws
* Throws if the provided EntityQueryOptions are invalid.
*/
getPlayers(options?: EntityQueryOptions): Player[];
/**
- Explanation:
* Returns the time of day.
*
* @returns
* The time of day, in ticks, between 0 and 24000.
*/
getTimeOfDay(): number;
/**
- Explanation:
* Plays a particular music track for all players.
*
* This function can't be called in read-only mode.
*
* @throws This function can throw errors.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const players = world.getPlayers();
* const targetLocation: Vector3 = {
* x: 0,
* y: 0,
* z: 0,
* };
*
* const musicOptions: MusicOptions = {
* fade: 0.5,
* loop: true,
* volume: 1.0,
* };
* world.playMusic('music.menu', musicOptions);
*
* const worldSoundOptions: WorldSoundOptions = {
* pitch: 0.5,
* volume: 4.0,
* };
* world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions);
*
* const playerSoundOptions: PlayerSoundOptions = {
* pitch: 1.0,
* volume: 1.0,
* };
*
* players[0].playSound('bucket.fill_water', playerSoundOptions);
* ```
*/
playMusic(trackId: string, musicOptions?: MusicOptions): void;
/**
- Explanation:
* Plays a sound for all players.
*
* This function can't be called in read-only mode.
*
* @throws
* An error will be thrown if volume is less than 0.0.
* An error will be thrown if fade is less than 0.0.
* An error will be thrown if pitch is less than 0.01.
* An error will be thrown if volume is less than 0.0.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const players = world.getPlayers();
* const targetLocation: Vector3 = {
* x: 0,
* y: 0,
* z: 0,
* };
*
* const musicOptions: MusicOptions = {
* fade: 0.5,
* loop: true,
* volume: 1.0,
* };
* world.playMusic('music.menu', musicOptions);
*
* const worldSoundOptions: WorldSoundOptions = {
* pitch: 0.5,
* volume: 4.0,
* };
* world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions);
*
* const playerSoundOptions: PlayerSoundOptions = {
* pitch: 1.0,
* volume: 1.0,
* };
*
* players[0].playSound('bucket.fill_water', playerSoundOptions);
* ```
*/
playSound(soundId: string, location: Vector3, soundOptions?: WorldSoundOptions): void;
/**
- Explanation:
* Queues an additional music track for players. If a track is
* not playing, a music track will play.
*
* This function can't be called in read-only mode.
*
* @param trackId
* Identifier of the music track to play.
* @param musicOptions
* Additional options for the music track.
* @throws
* An error will be thrown if volume is less than 0.0.
* An error will be thrown if fade is less than 0.0.
*
*/
queueMusic(trackId: string, musicOptions?: MusicOptions): void;
/**
- Explanation:
* Sends a message to all players.
*
* @param message
* The message to be displayed.
* @throws
* This method can throw if the provided {@link RawMessage} is
* in an invalid format. For example, if an empty `name` string
* is provided to `score`.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Displays "Apple or Coal"
* const rawMessage = {
* translate: 'accessibility.list.or.two',
* with: { rawtext: [{ translate: 'item.apple.name' }, { translate: 'item.coal.name' }] },
* };
* world.sendMessage(rawMessage);
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Displays the player's score for objective "obj". Each player will see their own score.
* const rawMessage = { score: { name: '*', objective: 'obj' } };
* world.sendMessage(rawMessage);
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Displays "Hello, world!"
* world.sendMessage('Hello, world!');
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Displays "First or Second"
* const rawMessage = { translate: 'accessibility.list.or.two', with: ['First', 'Second'] };
* world.sendMessage(rawMessage);
* ```
*/
sendMessage(message: (RawMessage | string)[] | RawMessage | string): void;
/**
- Explanation:
* Sets the world time.
*
* This function can't be called in read-only mode.
*
* @param absoluteTime
* The world time, in ticks.
*/
setAbsoluteTime(absoluteTime: number): void;
/**
- Explanation:
* Sets a default spawn location for all players.
*
* This function can't be called in read-only mode.
*
* @param spawnLocation
* Location of the spawn point. Note that this is assumed to be
* within the overworld dimension.
* @throws
* Throws if the provided spawn location is out of bounds.
*
* {@link Error}
*
* {@link LocationOutOfWorldBoundariesError}
*/
setDefaultSpawnLocation(spawnLocation: Vector3): void;
/**
- Explanation:
* Sets a specified property to a value.
*
* @param identifier
* The property identifier.
* @param value
* Data value of the property to set.
* @throws
* Throws if the given dynamic property identifier is not
* defined.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function incrementProperty(propertyName: string): boolean {
* let number = mc.world.getDynamicProperty(propertyName);
*
* console.warn('Current value is: ' + number);
*
* if (number === undefined) {
* number = 0;
* }
*
* if (typeof number !== 'number') {
* console.warn('Number is of an unexpected type.');
* return false;
* }
*
* mc.world.setDynamicProperty(propertyName, number + 1);
* return true;
* }
*
* incrementProperty('samplelibrary:number');
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function updateWorldProperty(propertyName: string): boolean {
* let paintStr = mc.world.getDynamicProperty(propertyName);
* let paint: { color: string; intensity: number } | undefined = undefined;
*
* console.log('Current value is: ' + paintStr);
*
* if (paintStr === undefined) {
* paint = {
* color: 'purple',
* intensity: 0,
* };
* } else {
* if (typeof paintStr !== 'string') {
* console.warn('Paint is of an unexpected type.');
* return false;
* }
*
* try {
* paint = JSON.parse(paintStr);
* } catch (e) {
* console.warn('Error parsing serialized struct.');
* return false;
* }
* }
*
* if (!paint) {
* console.warn('Error parsing serialized struct.');
* return false;
* }
*
* paint.intensity++;
* paintStr = JSON.stringify(paint); // be very careful to ensure your serialized JSON str cannot exceed limits
* mc.world.setDynamicProperty(propertyName, paintStr);
*
* return true;
* }
*
* updateWorldProperty('samplelibrary:longerjson');
* ```
*/
setDynamicProperty(identifier: string, value?: boolean | number | string | Vector3): void;
/**
- Explanation:
* Sets the time of day.
*
* This function can't be called in read-only mode.
*
* @param timeOfDay
* The time of day, in ticks, between 0 and 24000.
* @throws
* Throws if the provided time of day is not within the valid
* range.
*/
setTimeOfDay(timeOfDay: number | TimeOfDay): void;
/**
- Explanation:
* Stops any music tracks from playing.
*
* This function can't be called in read-only mode.
*
*/
stopMusic(): void;
}
/**
* Contains a set of events that are available across the scope
* of the World.
*/
### Class: WorldAfterEvents
This section details the purpose, properties, methods, and code examples for `Class: WorldAfterEvents` in the Minecraft Bedrock Edition Script API.
The `WorldAfterEvents` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @beta
- Explanation:
* This event fires for each BlockLocation destroyed by an
* explosion. It is fired after the blocks have already been
* destroyed.
*
*/
readonly blockExplode: BlockExplodeAfterEventSignal;
/**
- Explanation:
* This event fires when a button is pushed.
*
*/
readonly buttonPush: ButtonPushAfterEventSignal;
/**
* @beta
- Explanation:
* This event is triggered after a chat message has been
* broadcast or sent to players.
*
*/
readonly chatSend: ChatSendAfterEventSignal;
/**
- Explanation:
* This event is fired when an entity event has been triggered
* that will update the component definition state of an
* entity.
*
*/
readonly dataDrivenEntityTrigger: DataDrivenEntityTriggerAfterEventSignal;
/**
- Explanation:
* This event fires when an effect, like poisoning, is added to
* an entity.
*
*/
readonly effectAdd: EffectAddAfterEventSignal;
/**
- Explanation:
* This event fires when an entity dies.
*
*/
readonly entityDie: EntityDieAfterEventSignal;
/**
- Explanation:
* This event fires when entity health changes in any degree.
*
*/
readonly entityHealthChanged: EntityHealthChangedAfterEventSignal;
/**
- Explanation:
* This event fires when an entity hits (that is, melee
* attacks) a block.
*
*/
readonly entityHitBlock: EntityHitBlockAfterEventSignal;
/**
- Explanation:
* This event fires when an entity hits (that is, melee
* attacks) another entity.
*
*/
readonly entityHitEntity: EntityHitEntityAfterEventSignal;
/**
- Explanation:
* This event fires when an entity is hurt (takes damage).
*
*/
readonly entityHurt: EntityHurtAfterEventSignal;
/**
- Explanation:
* Fires when an entity is loaded.
*
*/
readonly entityLoad: EntityLoadAfterEventSignal;
/**
- Explanation:
* Fires when an entity is removed (for example, potentially
* unloaded, or removed after being killed).
*
*/
readonly entityRemove: EntityRemoveAfterEventSignal;
/**
- Explanation:
* This event fires when an entity is spawned.
*
*/
readonly entitySpawn: EntitySpawnAfterEventSignal;
/**
- Explanation:
* This event is fired after an explosion occurs.
*
*/
readonly explosion: ExplosionAfterEventSignal;
/**
* @beta
- Explanation:
* This event fires when a world.gameRules property has
* changed.
*
*/
readonly gameRuleChange: GameRuleChangeAfterEventSignal;
/**
- Explanation:
* This event fires when a chargeable item completes charging.
*
*/
readonly itemCompleteUse: ItemCompleteUseAfterEventSignal;
/**
- Explanation:
* This event fires when a chargeable item is released from
* charging.
*
*/
readonly itemReleaseUse: ItemReleaseUseAfterEventSignal;
/**
- Explanation:
* This event fires when a chargeable item starts charging.
*
*/
readonly itemStartUse: ItemStartUseAfterEventSignal;
/**
- Explanation:
* This event fires when a player successfully uses an item or
* places a block by pressing the Use Item / Place Block
* button. If multiple blocks are placed, this event will only
* occur once at the beginning of the block placement. Note:
* This event cannot be used with Hoe or Axe items.
*
*/
readonly itemStartUseOn: ItemStartUseOnAfterEventSignal;
/**
- Explanation:
* This event fires when a chargeable item stops charging.
*
*/
readonly itemStopUse: ItemStopUseAfterEventSignal;
/**
- Explanation:
* This event fires when a player releases the Use Item / Place
* Block button after successfully using an item. Note: This
* event cannot be used with Hoe or Axe items.
*
*/
readonly itemStopUseOn: ItemStopUseOnAfterEventSignal;
/**
- Explanation:
* This event fires when an item is successfully used by a
* player.
*
*/
readonly itemUse: ItemUseAfterEventSignal;
/**
- Explanation:
* This event fires when an item is used on a block by a
* player.
*
*/
readonly itemUseOn: ItemUseOnAfterEventSignal;
/**
- Explanation:
* A lever has been pulled.
*
*/
readonly leverAction: LeverActionAfterEventSignal;
/**
* @beta
- Explanation:
* This event is an internal implementation detail, and is
* otherwise not currently functional.
*
*/
readonly messageReceive: ServerMessageAfterEventSignal;
/**
- Explanation:
* This event fires when a piston expands or retracts.
*
*/
readonly pistonActivate: PistonActivateAfterEventSignal;
/**
- Explanation:
* This event fires for a block that is broken by a player.
*
*/
readonly playerBreakBlock: PlayerBreakBlockAfterEventSignal;
/**
- Explanation:
* Fires when a player moved to a different dimension.
*
*/
readonly playerDimensionChange: PlayerDimensionChangeAfterEventSignal;
/**
* @beta
*/
readonly playerGameModeChange: PlayerGameModeChangeAfterEventSignal;
/**
* @beta
- Explanation:
* This event fires when a players input permissions change.
*
*/
readonly playerInputPermissionCategoryChange: PlayerInputPermissionCategoryChangeAfterEventSignal;
/**
* @beta
- Explanation:
* An event for when a player interacts with a block.
*
*/
readonly playerInteractWithBlock: PlayerInteractWithBlockAfterEventSignal;
/**
* @beta
- Explanation:
* This event fires when a player interacts with an entity.
*
*/
readonly playerInteractWithEntity: PlayerInteractWithEntityAfterEventSignal;
/**
- Explanation:
* This event fires when a player joins a world. See also
* playerSpawn for another related event you can trap for when
* a player is spawned the first time within a world.
*
*/
readonly playerJoin: PlayerJoinAfterEventSignal;
/**
- Explanation:
* This event fires when a player leaves a world.
*
*/
readonly playerLeave: PlayerLeaveAfterEventSignal;
/**
- Explanation:
* This event fires for a block that is placed by a player.
*
*/
readonly playerPlaceBlock: PlayerPlaceBlockAfterEventSignal;
/**
- Explanation:
* This event fires when a player spawns or respawns. Note that
* an additional flag within this event will tell you whether
* the player is spawning right after join vs. a respawn.
*
*/
readonly playerSpawn: PlayerSpawnAfterEventSignal;
/**
- Explanation:
* A pressure plate has popped back up (i.e., there are no
* entities on the pressure plate.)
*
*/
readonly pressurePlatePop: PressurePlatePopAfterEventSignal;
/**
- Explanation:
* A pressure plate has pushed (at least one entity has moved
* onto a pressure plate.)
*
*/
readonly pressurePlatePush: PressurePlatePushAfterEventSignal;
/**
- Explanation:
* This event fires when a projectile hits a block.
*
*/
readonly projectileHitBlock: ProjectileHitBlockAfterEventSignal;
/**
- Explanation:
* This event fires when a projectile hits an entity.
*
*/
readonly projectileHitEntity: ProjectileHitEntityAfterEventSignal;
/**
- Explanation:
* A target block was hit.
*
*/
readonly targetBlockHit: TargetBlockHitAfterEventSignal;
/**
- Explanation:
* A trip wire was tripped.
*
*/
readonly tripWireTrip: TripWireTripAfterEventSignal;
/**
- Explanation:
* This event will be triggered when the weather changes within
* Minecraft.
*
*/
readonly weatherChange: WeatherChangeAfterEventSignal;
/**
- Explanation:
* This event fires when the script environment is initialized
* on a World.
*
*/
readonly worldInitialize: WorldInitializeAfterEventSignal;
}
/**
* A set of events that fire before an actual action occurs. In
* most cases, you can potentially cancel or modify the
* impending event. Note that in before events any APIs that
* modify gameplay state will not function and will throw an
* error. (e.g., dimension.spawnEntity)
*/
### Class: WorldBeforeEvents
This section details the purpose, properties, methods, and code examples for `Class: WorldBeforeEvents` in the Minecraft Bedrock Edition Script API.
The `WorldBeforeEvents` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
* @beta
- Explanation:
* This event is triggered after a chat message has been
* broadcast or sent to players.
*
*/
readonly chatSend: ChatSendBeforeEventSignal;
/**
- Explanation:
* This event is triggered after an event has been added to an
* entity.
*
*/
readonly effectAdd: EffectAddBeforeEventSignal;
/**
- Explanation:
* Fires before an entity is removed from the world (for
* example, unloaded or removed after being killed.)
*
*/
readonly entityRemove: EntityRemoveBeforeEventSignal;
/**
- Explanation:
* This event is fired after an explosion occurs.
*
*/
readonly explosion: ExplosionBeforeEventSignal;
/**
- Explanation:
* This event fires when an item is successfully used by a
* player.
*
*/
readonly itemUse: ItemUseBeforeEventSignal;
/**
- Explanation:
* This event fires when an item is used on a block by a
* player.
*
*/
readonly itemUseOn: ItemUseOnBeforeEventSignal;
/**
- Explanation:
* This event fires before a block is broken by a player.
*
*/
readonly playerBreakBlock: PlayerBreakBlockBeforeEventSignal;
/**
* @beta
*/
readonly playerGameModeChange: PlayerGameModeChangeBeforeEventSignal;
/**
* @beta
- Explanation:
* Fires before a player interacts with a block.
*
*/
readonly playerInteractWithBlock: PlayerInteractWithBlockBeforeEventSignal;
/**
* @beta
- Explanation:
* Fires before a player interacts with an entity.
*
*/
readonly playerInteractWithEntity: PlayerInteractWithEntityBeforeEventSignal;
/**
- Explanation:
* Fires when a player leaves the game.
*
*/
readonly playerLeave: PlayerLeaveBeforeEventSignal;
/**
* @beta
- Explanation:
* This event fires before a block is placed by a player.
*
*/
readonly playerPlaceBlock: PlayerPlaceBlockBeforeEventSignal;
/**
* @beta
*/
readonly weatherChange: WeatherChangeBeforeEventSignal;
/**
* @beta
- Explanation:
* This event fires immediately when the script environment is
* initialized on a World. Not all script functionality may be
* available. For guaranteed access to world state, use the
* world initialize after event.
*
*/
readonly worldInitialize: WorldInitializeBeforeEventSignal;
}
/**
* Contains information and methods that can be used at the
* initialization of the scripting environment for a World.
*/
### Class: WorldInitializeAfterEvent
This section details the purpose, properties, methods, and code examples for `Class: WorldInitializeAfterEvent` in the Minecraft Bedrock Edition Script API.
The `WorldInitializeAfterEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Manages callbacks that are run on the first tick of the
* World. Do note that this event may run multiple times within
* a session in the case that the /reload command is used.
*/
### Class: WorldInitializeAfterEventSignal
This section details the purpose, properties, methods, and code examples for `Class: WorldInitializeAfterEventSignal` in the Minecraft Bedrock Edition Script API.
The `WorldInitializeAfterEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when the scripting
* environment is initialized for a World.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: WorldInitializeAfterEvent) => void): (arg: WorldInitializeAfterEvent) => void;
/**
- Explanation:
* Removes a callback from being called the scripting
* environment is initialized for a World.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: WorldInitializeAfterEvent) => void): void;
}
/**
* @beta
* Contains information and methods that can be used at the
* initialization of the scripting environment for a World.
* Also, use the supplied blockRegistry object to register
* block custom components within the scope of the World
* Initialize execution.
*/
### Class: WorldInitializeBeforeEvent
This section details the purpose, properties, methods, and code examples for `Class: WorldInitializeBeforeEvent` in the Minecraft Bedrock Edition Script API.
The `WorldInitializeBeforeEvent` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
readonly blockTypeRegistry: BlockComponentRegistry;
/**
- Explanation:
* Provides the functionality for registering custom components
* for items.
*
*/
readonly itemComponentRegistry: ItemComponentRegistry;
}
/**
* @beta
* Manages callbacks that are run at the initialization of the
* scripting environment for a World. Do note that this event
* may run multiple times within a session in the case that the
* /reload command is used.
*/
### Class: WorldInitializeBeforeEventSignal
This section details the purpose, properties, methods, and code examples for `Class: WorldInitializeBeforeEventSignal` in the Minecraft Bedrock Edition Script API.
The `WorldInitializeBeforeEventSignal` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
/**
- Explanation:
* Adds a callback that will be called when the scripting
* environment is initialized for a World.
*
* This function can't be called in read-only mode.
*
*/
subscribe(callback: (arg: WorldInitializeBeforeEvent) => void): (arg: WorldInitializeBeforeEvent) => void;
/**
- Explanation:
* Removes a callback from being called the scripting
* environment is initialized for a World.
*
* This function can't be called in read-only mode.
*
*/
unsubscribe(callback: (arg: WorldInitializeBeforeEvent) => void): void;
}
/**
* @beta
* Contains additional options for searches for the
* dimension.findNearestBiome API.
*/
export interface BiomeSearchOptions {
/**
- Explanation:
* Bounding volume size to look within.
*
*/
boundingSize?: Vector3;
}
/**
* @beta
* Contains a set of events that will be raised for a block.
* This object must be bound using the BlockRegistry.
*/
export interface BlockCustomComponent {
/**
- Explanation:
* This function will be called before a player places the
* block.
*
*/
beforeOnPlayerPlace?: (arg: BlockComponentPlayerPlaceBeforeEvent) => void;
/**
- Explanation:
* This function will be called when an entity falls onto the
* block that this custom component is bound to.
*
*/
onEntityFallOn?: (arg: BlockComponentEntityFallOnEvent) => void;
/**
- Explanation:
* This function will be called when the block that this custom
* component is bound to is placed.
*
*/
onPlace?: (arg: BlockComponentOnPlaceEvent) => void;
/**
- Explanation:
* This function will be called when a player destroys a
* specific block.
*
*/
onPlayerDestroy?: (arg: BlockComponentPlayerDestroyEvent) => void;
/**
- Explanation:
* This function will be called when a player sucessfully
* interacts with the block that this custom component is bound
* to.
*
*/
onPlayerInteract?: (arg: BlockComponentPlayerInteractEvent) => void;
/**
- Explanation:
* This function will be called when a block randomly ticks.
*
*/
onRandomTick?: (arg: BlockComponentRandomTickEvent) => void;
/**
- Explanation:
* This function will be called when an entity steps off the
* block that this custom component is bound to.
*
*/
onStepOff?: (arg: BlockComponentStepOffEvent) => void;
/**
- Explanation:
* This function will be called when an entity steps onto the
* block that this custom component is bound to.
*
*/
onStepOn?: (arg: BlockComponentStepOnEvent) => void;
/**
- Explanation:
* This function will be called when a block ticks.
*
*/
onTick?: (arg: BlockComponentTickEvent) => void;
}
/**
* Contains optional parameters for registering a block event.
*/
export interface BlockEventOptions {
/**
- Explanation:
* If this value is set, this event will only fire if the
* impacted block's type matches this parameter.
*
*/
blockTypes?: string[];
/**
- Explanation:
* If this value is set, this event will only fire if the
* impacted block's permutation matches this parameter.
*
*/
permutations?: BlockPermutation[];
}
/**
* @beta
* Contains additional options for a block fill operation.
*/
export interface BlockFillOptions {
blockFilter?: BlockFilter;
ignoreChunkBoundErrors?: boolean;
}
export interface BlockFilter {
excludePermutations?: BlockPermutation[];
excludeTags?: string[];
excludeTypes?: string[];
includePermutations?: BlockPermutation[];
includeTags?: string[];
includeTypes?: string[];
}
/**
* Contains more information for events where a block is hit.
*/
export interface BlockHitInformation {
/**
- Explanation:
* Block that was hit.
*
*/
block: Block;
/**
- Explanation:
* Face of the block that was hit.
*
*/
face: Direction;
/**
- Explanation:
* Location relative to the bottom north-west corner of the
* block.
*
*/
faceLocation: Vector3;
}
/**
* Contains information for block raycast hit results.
*/
export interface BlockRaycastHit {
/**
- Explanation:
* Block that was hit.
*
*/
block: Block;
/**
- Explanation:
* Face of the block that was hit.
*
*/
face: Direction;
/**
- Explanation:
* Hit location relative to the bottom north-west corner of the
* block.
*
*/
faceLocation: Vector3;
}
/**
* Contains additional options for configuring a block raycast
* query.
*/
// @ts-ignore Class inheritance allowed for native defined classes
export interface BlockRaycastOptions extends BlockFilter {
/**
- Explanation:
* If true, liquid blocks will be considered as blocks that
* 'stop' the raycast.
*
*/
includeLiquidBlocks?: boolean;
/**
- Explanation:
* If true, passable blocks like vines and flowers will be
* considered as blocks that 'stop' the raycast.
*
*/
includePassableBlocks?: boolean;
/**
- Explanation:
* Maximum distance, in blocks, to process the raycast.
*
*/
maxDistance?: number;
}
/**
* @beta
* A BoundingBox is an interface to an object which represents
* an AABB aligned rectangle.
* The BoundingBox assumes that it was created in a valid state
* (min <= max) but cannot guarantee it (unless it was created
* using the associated {@link
* @minecraft-server.BoundingBoxUtils} utility functions.
* The min/max coordinates represent the diametrically opposite
* corners of the rectangle.
* The BoundingBox is not a representation of blocks - it has
* no association with any type, it is just a mathematical
* construct - so a rectangle with
* ( 0,0,0 ) -> ( 0,0,0 )
* has a size of ( 0,0,0 ) (unlike the very similar {@link
* BlockVolume} object)
*/
export interface BoundingBox {
/**
- Explanation:
* A {@link @minecraft-server.Vector3} that represents the
* largest corner of the rectangle
*
*/
max: Vector3;
/**
- Explanation:
* A {@link @minecraft-server.Vector3} that represents the
* smallest corner of the rectangle
*
*/
min: Vector3;
}
export interface CameraDefaultOptions {
/**
- Explanation:
* Sets a set of easing options for the camera.
*
*/
easeOptions: CameraEaseOptions;
}
/**
* Contains options associated with a camera ease operation.
*/
export interface CameraEaseOptions {
/**
- Explanation:
* Time for the ease operation.
*
*/
easeTime?: number;
/**
- Explanation:
* Type of ease operation to use.
*
*/
easeType?: EasingType;
}
/**
* Used to initiate a full-screen color fade.
*/
export interface CameraFadeOptions {
/**
- Explanation:
* Fade color to use.
*
*/
fadeColor?: RGB;
/**
- Explanation:
* Time in seconds for the fade-in, hold, and fade-out seconds.
*
*/
fadeTime?: CameraFadeTimeOptions;
}
/**
* Contains timings for a fade transition.
*/
export interface CameraFadeTimeOptions {
/**
- Explanation:
* Time, in seconds, for a fade-in.
*
*/
fadeInTime: number;
/**
- Explanation:
* Time, in seconds, for a fade-out.
*
*/
fadeOutTime: number;
/**
- Explanation:
* Time, in seconds, to hold the full screen color.
*
*/
holdTime: number;
}
export interface CameraSetFacingOptions {
easeOptions?: CameraEaseOptions;
facingEntity: Entity;
location?: Vector3;
}
export interface CameraSetLocationOptions {
easeOptions?: CameraEaseOptions;
location: Vector3;
}
export interface CameraSetPosOptions {
easeOptions?: CameraEaseOptions;
facingLocation: Vector3;
location?: Vector3;
}
export interface CameraSetRotOptions {
easeOptions?: CameraEaseOptions;
location?: Vector3;
rotation: Vector2;
}
/**
* @beta
* This interface defines an entry into the {@link
* @minecraft-server/CompoundBlockVolume} which represents a
* volume of positive or negative space.
*
*/
export interface CompoundBlockVolumeItem {
/**
- Explanation:
* The 'action' defines how the block volume is represented in
* the compound block volume stack.
* 'Add' creates a block volume which is positively selected
* 'Subtract' creates a block volume which represents a hole or
* negative space in the overall compound block volume.
*
*/
action?: CompoundBlockVolumeAction;
/**
- Explanation:
* The relativity enumeration determines whether the
* BlockVolume specified is positioned relative to the parent
* compound block volume origin, or in absolute world space.
*
*/
locationRelativity?: CompoundBlockVolumePositionRelativity;
/**
- Explanation:
* The volume of space
*
*/
volume: BlockVolume;
}
/**
* Contains a set of updates to the component definition state
* of an entity.
*/
export interface DefinitionModifier {
/**
- Explanation:
* Retrieves the list of component groups that will be added
* via this definition modification.
*
*/
addedComponentGroups: string[];
/**
- Explanation:
* The list of component groups that will be removed via this
* definition modification.
*
*/
removedComponentGroups: string[];
/**
* @beta
- Explanation:
* The list of entity definition events that will be fired via
* this update.
*
*/
triggers: Trigger[];
}
/**
* An exact coordinate within the world, including its
* dimension and location.
*/
export interface DimensionLocation {
/**
- Explanation:
* Dimension that this coordinate is associated with.
*
*/
dimension: Dimension;
/**
- Explanation:
* X component of this dimension-location.
*
*/
x: number;
/**
- Explanation:
* Y component of this dimension-location.
*
*/
y: number;
/**
- Explanation:
* Z component of this dimension-location.
*
*/
z: number;
}
/**
* @beta
* This interface represents a specific leveled enchantment
* that is applied to an item.
*/
export interface Enchantment {
/**
- Explanation:
* The level of this enchantment instance.
*
*/
level: number;
/**
- Explanation:
* The enchantment type of this instance.
*
*/
type: EnchantmentType;
}
/**
* Additional options for when damage has been applied via a
* projectile.
*/
export interface EntityApplyDamageByProjectileOptions {
/**
- Explanation:
* Optional entity that fired the projectile.
*
*/
damagingEntity?: Entity;
/**
- Explanation:
* Projectile that caused damage.
*
*/
damagingProjectile: Entity;
}
/**
* Additional descriptions and metadata for a damage event.
*/
export interface EntityApplyDamageOptions {
/**
- Explanation:
* Underlying cause of the damage.
*
*/
cause: EntityDamageCause;
/**
- Explanation:
* Optional entity that caused the damage.
*
*/
damagingEntity?: Entity;
}
/**
* Provides information about how damage has been applied to an
* entity.
*/
export interface EntityDamageSource {
/**
- Explanation:
* Cause enumeration of damage.
*
*/
cause: EntityDamageCause;
/**
- Explanation:
* Optional entity that caused the damage.
*
*/
damagingEntity?: Entity;
/**
- Explanation:
* Optional projectile that may have caused damage.
*
*/
damagingProjectile?: Entity;
}
/**
* Specifies additional filters that are used in registering a
* data driven trigger event for entities.
*/
export interface EntityDataDrivenTriggerEventOptions {
/**
- Explanation:
* If this value is set, this event will only fire for entities
* that match the entities within this collection.
*
*/
entities?: Entity[];
/**
- Explanation:
* If this value is set, this event will only fire if the
* impacted entities' type matches this parameter.
*
*/
entityTypes?: string[];
/**
- Explanation:
* If this value is set, this event will only fire if the
* impacted triggered event matches one of the events listed in
* this parameter.
*
*/
eventTypes?: string[];
}
/**
* Contains additional options for entity effects.
*/
export interface EntityEffectOptions {
/**
- Explanation:
* The strength of the effect.
*
*/
amplifier?: number;
/**
- Explanation:
* If true, will show particles when effect is on the entity.
*
*/
showParticles?: boolean;
}
/**
* Contains optional parameters for registering an entity
* event.
*/
export interface EntityEventOptions {
/**
- Explanation:
* If this value is set, this event will only fire for entities
* that match the entities within this collection.
*
*/
entities?: Entity[];
/**
- Explanation:
* If this value is set, this event will only fire if the
* impacted entities' type matches this parameter.
*
*/
entityTypes?: string[];
}
/**
* Contains options for filtering entities.
*/
export interface EntityFilter {
/**
- Explanation:
* Excludes entities that match one or more of the specified
* families.
*
*/
excludeFamilies?: string[];
/**
- Explanation:
* Excludes entities if have a specific gamemode that matches
* the specified gamemode.
*
*/
excludeGameModes?: GameMode[];
/**
- Explanation:
* Excludes entities that have a name that match one of the
* specified values.
*
*/
excludeNames?: string[];
/**
- Explanation:
* Excludes entities with a tag that matches one of the
* specified values.
*
*/
excludeTags?: string[];
/**
- Explanation:
* Excludes entities if they are one of the specified types.
*
*/
excludeTypes?: string[];
/**
- Explanation:
* If specified, includes entities that match all of the
* specified families.
*
*/
families?: string[];
/**
- Explanation:
* If specified, includes entities with a gamemode that matches
* the specified gamemode.
*
*/
gameMode?: GameMode;
/**
- Explanation:
* If specified, will only include entities that have at most
* this horizontal rotation.
*
*/
maxHorizontalRotation?: number;
/**
- Explanation:
* If defined, only players that have at most this level are
* returned.
*
*/
maxLevel?: number;
/**
- Explanation:
* If specified, only entities that have at most this vertical
* rotation are returned.
*
*/
maxVerticalRotation?: number;
/**
- Explanation:
* If specified, will only include entities that have at a
* minimum this horizontal rotation.
*
*/
minHorizontalRotation?: number;
/**
- Explanation:
* If defined, only players that have at least this level are
* returned.
*
*/
minLevel?: number;
/**
- Explanation:
* If specified, will only include entities that have at least
* this vertical rotation.
*
*/
minVerticalRotation?: number;
/**
- Explanation:
* Includes entities with the specified name.
*
*/
name?: string;
/**
* @beta
*/
propertyOptions?: EntityQueryPropertyOptions[];
/**
- Explanation:
* Gets/sets a collection of EntityQueryScoreOptions objects
* with filters for specific scoreboard objectives.
*
*/
scoreOptions?: EntityQueryScoreOptions[];
/**
- Explanation:
* Includes entities that match all of the specified tags.
*
*/
tags?: string[];
/**
- Explanation:
* If defined, entities that match this type are included.
*
*/
type?: string;
}
/**
* Contains additional information about an entity that was
* hit.
*/
export interface EntityHitInformation {
/**
- Explanation:
* Entity that was hit.
*
*/
entity?: Entity;
}
/**
* Contains options for selecting entities within an area.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[type=fox] positioned as @s if block ^ ^-1 ^ stone run summon salmon
*
* // Equivalent scripting code would be:
* function spawnFish(dimension: Dimension) {
* dimension
* .getEntities({
* type: 'fox',
* })
* .filter(entity => {
* const block = dimension.getBlock({
* x: entity.location.x,
* y: entity.location.y - 1,
* z: entity.location.z,
* });
*
* return block !== undefined && block.matches('minecraft:stone');
* })
* .forEach(entity => {
* dimension.spawnEntity('salmon', entity.location);
* });
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run playsound raid.horn @a
*
* // Equivalent scripting code would be:
* function playSounds(dimension: Dimension) {
* const targetPlayers = dimension.getPlayers();
* const originEntities = dimension.getEntities({
* type: 'armor_stand',
* name: 'myArmorStand',
* tags: ['dummyTag1'],
* excludeTags: ['dummyTag2'],
* });
*
* originEntities.forEach(entity => {
* targetPlayers.forEach(player => {
* player.playSound('raid.horn');
* });
* });
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[has_property={propId=propValue}]
*
* // Equivalent scripting code would be:
* function findEntitiesHavingPropertyEqualsTo(propId: string, propValue: boolean | number | string) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, value: { equals: propValue } }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // No equivalent commands as `propValue..` is inclusive in commands
*
* function findEntitiesHavingPropertyGreaterThan(propId: string, propValue: number) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, value: { greaterThan: propValue } }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[has_property={propId=propValue..}]
*
* // Equivalent scripting code would be:
* function findEntitiesHavingPropertyGreaterThanOrEqualsTo(propId: string, propValue: number) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, value: { greaterThanOrEquals: propValue } }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[has_property={property=propId}]
*
* // Equivalent scripting code would be:
* function findEntitiesHavingAProperty(propId: string) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // No equivalent commands as `..propValue` is inclusive in commands
*
* function findEntitiesHavingPropertyLessThan(propId: string, propValue: number) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, value: { lessThan: propValue } }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[has_property={propId=..propValue}]
*
* // Equivalent scripting code would be:
* function findEntitiesHavingPropertyLessThanOrEqualsTo(propId: string, propValue: number) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, value: { lessThanOrEquals: propValue } }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[has_property={propId=!propValue}]
*
* // Equivalent scripting code would be:
* function findEntitiesHavingPropertyNotEqualsTo(propId: string, propValue: boolean | number | string) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, value: { notEquals: propValue } }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[has_property={property=!propId}]
*
* // Equivalent scripting code would be:
* function findEntitiesNotHavingAProperty(propId: string) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, exclude: true }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[has_property={propId=lowerBoundValue..upperBoundValue}]
*
* // Equivalent scripting code would be:
* function findEntitiesHavingPropertyWithinRange(propId: string, lowerBoundValue: number, upperBoundValue: number) {
* const queryOption: EntityQueryOptions = {
* propertyOptions: [{ propertyId: propId, value: { lowerBound: lowerBoundValue, upperBound: upperBoundValue } }]
* };
*
* const overworld = world.getDimension('overworld');
* const entities = overworld.getEntities(queryOption);
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[type=armor_stand,name=myArmorStand,tag=dummyTag1,tag=!dummyTag2] run tellraw @a { "rawtext": [{"translate": "hello.world" }] }
*
* // Equivalent scripting code would be:
* function sendMessagesToPlayers(dimension: Dimension) {
* const targetPlayers = dimension.getPlayers();
* const originEntities = dimension.getEntities({
* type: 'armor_stand',
* name: 'myArmorStand',
* tags: ['dummyTag1'],
* excludeTags: ['dummyTag2'],
* });
*
* originEntities.forEach(entity => {
* targetPlayers.forEach(player => {
* player.sendMessage({ rawtext: [{ translate: 'hello.world' }] });
* });
* });
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having these commands:
*
* // scoreboard objectives add scoreObjective1 dummy
* // scoreboard players set @e[type=armor_stand,name=myArmorStand] scoreObjective1 -1
*
* // Equivalent scripting code would be:
* function setScores(dimension: Dimension) {
* const objective = world.scoreboard.addObjective('scoreObjective1', 'dummy');
* dimension
* .getEntities({
* type: 'armor_stand',
* name: 'myArmorStand',
* })
* .forEach(entity => {
* if (entity.scoreboardIdentity !== undefined) {
* objective.setScore(entity.scoreboardIdentity, -1);
* }
* });
* }
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* // Having this command:
*
* // execute as @e[type=armor_stand] run execute as @a[x=0,y=-60,z=0,c=4,r=15] run summon pig ~1 ~ ~
*
* // Equivalent scripting code would be:
* function spawnPigs(dimension: Dimension) {
* const armorStandArray = dimension.getEntities({
* type: 'armor_stand',
* });
* const playerArray = dimension.getPlayers({
* location: { x: 0, y: -60, z: 0 },
* closest: 4,
* maxDistance: 15,
* });
* armorStandArray.forEach(entity => {
* playerArray.forEach(player => {
* dimension.spawnEntity('pig', {
* x: player.location.x + 1,
* y: player.location.y,
* z: player.location.z,
* });
* });
* });
* }
* ```
*/
// @ts-ignore Class inheritance allowed for native defined classes
export interface EntityQueryOptions extends EntityFilter {
/**
- Explanation:
* Limits the number of entities to return, opting for the
* closest N entities as specified by this property. The
* location value must also be specified on the query options
* object.
*
*/
closest?: number;
/**
- Explanation:
* Limits the number of entities to return, opting for the
* farthest N entities as specified by this property. The
* location value must also be specified on the query options
* object.
*
*/
farthest?: number;
/**
- Explanation:
* Adds a seed location to the query that is used in
* conjunction with closest, farthest, limit, volume, and
* distance properties.
*
*/
location?: Vector3;
/**
- Explanation:
* If specified, includes entities that are less than this
* distance away from the location specified in the location
* property.
*
*/
maxDistance?: number;
/**
- Explanation:
* If specified, includes entities that are least this distance
* away from the location specified in the location property.
*
*/
minDistance?: number;
/**
* @beta
- Explanation:
* In conjunction with location, specified a cuboid volume of
* entities to include.
*
*/
volume?: Vector3;
}
/**
* @beta
*/
export interface EntityQueryPropertyOptions {
exclude?: boolean;
propertyId: string;
value?:
| boolean
| string
| EqualsComparison
| GreaterThanComparison
| GreaterThanOrEqualsComparison
| LessThanComparison
| LessThanOrEqualsComparison
| NotEqualsComparison
| RangeComparison;
}
/**
* Contains additional options for filtering players based on
* their score for an objective.
*/
export interface EntityQueryScoreOptions {
/**
- Explanation:
* If set to true, entities and players within this score range
* are excluded from query results.
*
*/
exclude?: boolean;
/**
- Explanation:
* If defined, only players that have a score equal to or under
* maxScore are included.
*
*/
maxScore?: number;
/**
- Explanation:
* If defined, only players that have a score equal to or over
* minScore are included.
*
*/
minScore?: number;
/**
- Explanation:
* Identifier of the scoreboard objective to filter on.
*
*/
objective?: string;
}
/**
* Contains information for entity raycast hit results.
*/
export interface EntityRaycastHit {
/**
- Explanation:
* Distance from ray origin to entity bounds.
*
*/
distance: number;
/**
- Explanation:
* Entity that was hit.
*
*/
entity: Entity;
}
/**
* Contains additional options for an entity raycast operation.
*/
// @ts-ignore Class inheritance allowed for native defined classes
export interface EntityRaycastOptions extends EntityFilter {
/**
* @beta
- Explanation:
* If true, blocks will not be considered as blocks that 'stop'
* the raycast.
*
*/
ignoreBlockCollision?: boolean;
/**
* @beta
- Explanation:
* If true, liquid blocks will be considered as blocks that
* 'stop' the raycast.
*
*/
includeLiquidBlocks?: boolean;
/**
* @beta
- Explanation:
* If true, passable blocks like vines and flowers will be
* considered as blocks that 'stop' the raycast.
*
*/
includePassableBlocks?: boolean;
/**
- Explanation:
* Maximum distance, in blocks, to process the raycast.
*
*/
maxDistance?: number;
}
/**
* @beta
* Equal to operator.
*/
export interface EqualsComparison {
/**
- Explanation:
* Threshold value compared against.
*
*/
equals: boolean | number | string;
}
/**
* Additional configuration options for the {@link
* Dimension.createExplosion} method.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
* // Creates an explosion of radius 15 that does not break blocks
*
* function createExplosions(location: DimensionLocation) {
* // Creates an explosion of radius 15 that does not break blocks
* location.dimension.createExplosion(location, 15, { breaksBlocks: false });
*
* // Creates an explosion of radius 15 that does not cause fire
* location.dimension.createExplosion(location, 15, { causesFire: true });
*
* // Creates an explosion of radius 10 that can go underwater
* location.dimension.createExplosion(location, 10, { allowUnderwater: true });
* }
* ```
*/
export interface ExplosionOptions {
/**
- Explanation:
* Whether parts of the explosion also impact underwater.
*
*/
allowUnderwater?: boolean;
/**
- Explanation:
* Whether the explosion will break blocks within the blast
* radius.
*
*/
breaksBlocks?: boolean;
/**
- Explanation:
* If true, the explosion is accompanied by fires within or
* near the blast radius.
*
*/
causesFire?: boolean;
/**
- Explanation:
* Optional source of the explosion.
*
*/
source?: Entity;
}
/**
* @beta
* Greater than operator.
*/
export interface GreaterThanComparison {
/**
- Explanation:
* Threshold value compared against.
*
*/
greaterThan: number;
}
/**
* @beta
* Greater than or equal to operator.
*/
export interface GreaterThanOrEqualsComparison {
/**
- Explanation:
* Threshold value compared against.
*
*/
greaterThanOrEquals: number;
}
/**
* @beta
* Contains a set of events that will be raised for an item.
* This object must be bound using the ItemComponentRegistry.
*/
export interface ItemCustomComponent {
onBeforeDurabilityDamage?: (arg: ItemComponentBeforeDurabilityDamageEvent) => void;
onCompleteUse?: (arg: ItemComponentCompleteUseEvent) => void;
onConsume?: (arg: ItemComponentConsumeEvent) => void;
onHitEntity?: (arg: ItemComponentHitEntityEvent) => void;
/**
- Explanation:
* This function will be called when an item containing this
* component is used to mine a block.
*
*/
onMineBlock?: (arg: ItemComponentMineBlockEvent) => void;
/**
- Explanation:
* This function will be called when an item containing this
* component is used by a player.
*
*/
onUse?: (arg: ItemComponentUseEvent) => void;
onUseOn?: (arg: ItemComponentUseOnEvent) => void;
}
/**
* @beta
* Less than operator.
*/
export interface LessThanComparison {
/**
- Explanation:
* Threshold value compared against.
*
*/
lessThan: number;
}
/**
* @beta
* Less than or equal to operator.
*/
export interface LessThanOrEqualsComparison {
/**
- Explanation:
* Threshold value compared against.
*
*/
lessThanOrEquals: number;
}
/**
* Additional configuration options for {@link
* World.playMusic}/{@link World.queueMusic} methods.
*/
export interface MusicOptions {
/**
- Explanation:
* Specifies a fade overlap for music at the end of play.
*
*/
fade?: number;
/**
- Explanation:
* If set to true, this music track will play repeatedly.
*
*/
loop?: boolean;
/**
- Explanation:
* Relative volume level of the music.
*
*/
volume?: number;
}
/**
* @beta
* Not equal to operator.
*/
export interface NotEqualsComparison {
/**
- Explanation:
* Threshold value compared against.
*
*/
notEquals: boolean | number | string;
}
/**
* Contains additional options for how an animation is played.
*/
export interface PlayAnimationOptions {
/**
- Explanation:
* Amount of time to fade out after an animation stops.
*
*/
blendOutTime?: number;
/**
- Explanation:
* Specifies a controller to use that has been defined on the
* entity.
*
*/
controller?: string;
/**
- Explanation:
* Specifies the state to transition to.
*
*/
nextState?: string;
/**
- Explanation:
* A list of players the animation will be visible to.
*
*/
players?: string[];
/**
- Explanation:
* Specifies a Molang expression for when this animation should
* complete.
*
*/
stopExpression?: string;
}
/**
* Additional options for how a sound plays for a player.
*/
export interface PlayerSoundOptions {
/**
- Explanation:
* Location of the sound; if not specified, the sound is played
* near a player.
*
*/
location?: Vector3;
/**
- Explanation:
* Optional pitch of the sound.
*
*/
pitch?: number;
/**
- Explanation:
* Optional volume of the sound.
*
*/
volume?: number;
}
export interface ProjectileShootOptions {
uncertainty?: number;
}
/**
* @beta
* Operator represents a lower/upper bound structure for
* expressing a potential range of numbers.
*/
export interface RangeComparison {
/**
- Explanation:
* Lower bound within a range.
*
*/
lowerBound: number;
/**
- Explanation:
* Upper bound within a range.
*
*/
upperBound: number;
}
/**
* Defines a JSON structure that is used for more flexible.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function placeTranslatedSign(location: DimensionLocation, text: string) {
* const signBlock = location.dimension.getBlock(location);
*
* if (!signBlock) {
* console.warn('Could not find a block at specified location.');
* return;
* }
* const signPerm = BlockPermutation.resolve('minecraft:standing_sign', { ground_sign_direction: 8 });
* signBlock.setPermutation(signPerm);
*
* const signComponent = signBlock.getComponent(BlockComponentTypes.Sign);
* if (signComponent) {
* signComponent.setText({ translate: 'item.skull.player.name', with: [text] });
* } else {
* console.error('Could not find a sign component on the block.');
* }
* }
*
* placeTranslatedSign(
* {
* dimension: world.getDimension('overworld'),
* x: 0,
* y: 0,
* z: 0,
* },
* 'Steve',
* );
* ```
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* function showMessage(player: Player) {
* const messageForm = new MessageFormData()
* .title({ translate: 'permissions.removeplayer' })
* .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] })
* .button1('Player 1')
* .button2('Player 2');
*
* messageForm
* .show(player)
* .then((formData: MessageFormResponse) => {
* // player canceled the form, or another dialog was up and open.
* if (formData.canceled || formData.selection === undefined) {
* return;
* }
*
* console.warn(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
* })
* .catch((error: Error) => {
* console.warn('Failed to show form: ' + error);
* });
* };
*
* showMessage(world.getAllPlayers()[0]);
* ```
*/
export interface RawMessage {
/**
- Explanation:
* Provides a raw-text equivalent of the current message.
*
*/
rawtext?: RawMessage[];
/**
- Explanation:
* Provides a token that will get replaced with the value of a
* score.
*
*/
score?: RawMessageScore;
/**
- Explanation:
* Provides a string literal value to use.
*
*/
text?: string;
/**
- Explanation:
* Provides a translation token where, if the client has an
* available resource in the players' language which matches
* the token, will get translated on the client.
*
*/
translate?: string;
/**
- Explanation:
* Arguments for the translation token. Can be either an array
* of strings or RawMessage containing an array of raw text
* objects.
*
*/
with?: string[] | RawMessage;
}
/**
* Provides a description of a score token to use within a raw
* message.
*/
export interface RawMessageScore {
/**
- Explanation:
* Name of the score value to match.
*
*/
name?: string;
/**
- Explanation:
* Name of the score value to match.
*
*/
objective?: string;
}
/**
* A `RawMessage` with only the `rawtext` property. When a
* `RawMessage` is serialized the contents are put into a
* rawtext property, so this is useful when reading saved
* RawMessages. See `BlockSignComponent.setText` and
* `BlockSignComponent.getRawText` for examples.
*/
export interface RawText {
/**
- Explanation:
* A serialization of the current value of an associated sign.
*
*/
rawtext?: RawMessage[];
}
/**
* Represents a fully customizable color within Minecraft.
*/
export interface RGB {
/**
- Explanation:
* Determines a color's blue component. Valid values are
* between 0 and 1.0.
*
*/
blue: number;
/**
- Explanation:
* Determines a color's green component. Valid values are
* between 0 and 1.0.
*
*/
green: number;
/**
- Explanation:
* Determines a color's red component. Valid values are between
* 0 and 1.0.
*
*/
red: number;
}
/**
* Represents a fully customizable color within Minecraft.
*/
// @ts-ignore Class inheritance allowed for native defined classes
export interface RGBA extends RGB {
/**
- Explanation:
* Determines a color's alpha (opacity) component. Valid values
* are between 0 (transparent) and 1.0 (opaque).
*
*/
alpha: number;
}
/**
* Contains additional options for how a scoreboard should be
* displayed within its display slot.
*/
export interface ScoreboardObjectiveDisplayOptions {
/**
- Explanation:
* Objective to be displayed.
*
*/
objective: ScoreboardObjective;
/**
- Explanation:
* The sort order to display the objective items within.
*
*/
sortOrder?: ObjectiveSortOrder;
}
/**
* Contains additional options for registering a script event
* event callback.
*/
export interface ScriptEventMessageFilterOptions {
/**
- Explanation:
* Optional list of namespaces to filter inbound script event
* messages.
*
*/
namespaces: string[];
}
/**
* @beta
*/
export interface SpawnEntityOptions {
initialPersistence?: boolean;
}
/**
* Provides additional options for {@link
* StructureManager.createFromWorld}
*/
export interface StructureCreateOptions {
/**
- Explanation:
* Whether blocks should be included in the structure. Defaults
* to true.
*
*/
includeBlocks?: boolean;
/**
- Explanation:
* Whether entities should be included in the structure.
* Defaults to true.
*
*/
includeEntities?: boolean;
/**
- Explanation:
* How the Structure should be saved. Defaults to
* StructureSaveMode.World.
*
*/
saveMode?: StructureSaveMode;
}
/**
* Provides additional options for {@link
* StructureManager.place}
*/
export interface StructurePlaceOptions {
/**
- Explanation:
* How the Structure should be animated when placed.
*
*/
animationMode?: StructureAnimationMode;
/**
- Explanation:
* How many seconds the animation should take.
*
*/
animationSeconds?: number;
/**
- Explanation:
* Whether blocks should be included in the structure. Defaults
* to true.
*
*/
includeBlocks?: boolean;
/**
- Explanation:
* Whether entities should be included in the structure.
* Defaults to true.
*
*/
includeEntities?: boolean;
/**
- Explanation:
* What percentage of blocks should be placed. A value of 1
* will place 100% of the blocks while a value of 0 will place
* none. The blocks are chosen randomly based on the {@link
* StructurePlaceOptions.integritySeed}.
*
*/
integrity?: number;
/**
- Explanation:
* Seed that determines which blocks are randomly chosen to be
* placed. Defaults to a random seed.
*
*/
integritySeed?: string;
/**
- Explanation:
* Which axes the Structure should be mirrored on when placed.
* Defaults to StructureMirrorAxis.None.
*
*/
mirror?: StructureMirrorAxis;
/**
- Explanation:
* How the Structure should be rotated when placed. Defaults to
* AxisAlignedRotation.None.
*
*/
rotation?: StructureRotation;
/**
- Explanation:
* Whether the structure should be waterlogged when placed.
* Defaults to false. If true, blocks will become waterlogged
* when placed in water.
*
*/
waterlogged?: boolean;
}
/**
* Contains additional options for teleporting an entity.
### Example Code:
The following example demonstrates the functionality of this feature:
* ```typescript
*
* const overworld = world.getDimension('overworld');
* const targetLocation = { x: 0, y: 0, z: 0 };
*
* const pig = overworld.spawnEntity('minecraft:pig', targetLocation);
*
* let inc = 1;
* const runId = system.runInterval(() => {
* pig.teleport(
* { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 },
* {
* facingLocation: targetLocation,
* },
* );
*
* if (inc > 100) {
* system.clearRun(runId);
* }
* inc++;
* }, 4);
* ```
*/
export interface TeleportOptions {
/**
- Explanation:
* Whether to check whether blocks will block the entity after
* teleport.
*
*/
checkForBlocks?: boolean;
/**
- Explanation:
* Dimension to potentially move the entity to. If not
* specified, the entity is teleported within the dimension
* that they reside.
*
*/
dimension?: Dimension;
/**
- Explanation:
* Location that the entity should be facing after teleport.
*
*/
facingLocation?: Vector3;
/**
- Explanation:
* Whether to retain the entities velocity after teleport.
*
*/
keepVelocity?: boolean;
/**
- Explanation:
* Rotation of the entity after teleport.
*
*/
rotation?: Vector2;
}
/**
* Contains additional options for displaying a title and
* optional subtitle.
*/
export interface TitleDisplayOptions {
/**
- Explanation:
* Fade-in duration for the title and subtitle, in ticks. There
* are 20 ticks per second. Use {@link TicksPerSecond} constant
* to convert between ticks and seconds.
*
*/
fadeInDuration: number;
/**
- Explanation:
* Fade-out time for the title and subtitle, in ticks. There
* are 20 ticks per second. Use {@link TicksPerSecond} constant
* to convert between ticks and seconds.
*
*/
fadeOutDuration: number;
/**
- Explanation:
* Amount of time for the title and subtitle to stay in place,
* in ticks. There are 20 ticks per second. Use {@link
* TicksPerSecond} constant to convert between ticks and
* seconds.
*
*/
stayDuration: number;
/**
- Explanation:
* Optional subtitle text.
*
*/
subtitle?: (RawMessage | string)[] | RawMessage | string;
}
/**
* Represents a two-directional vector.
*/
export interface Vector2 {
/**
- Explanation:
* X component of the two-dimensional vector.
*
*/
x: number;
/**
- Explanation:
* Y component of the two-dimensional vector.
*
*/
y: number;
}
/**
* Contains a description of a vector.
*/
export interface Vector3 {
/**
- Explanation:
* X component of this vector.
*
*/
x: number;
/**
- Explanation:
* Y component of this vector.
*
*/
y: number;
/**
- Explanation:
* Z component of this vector.
*
*/
z: number;
}
/**
* Contains additional options for a world-level playSound
* occurrence.
*/
export interface WorldSoundOptions {
/**
- Explanation:
* Pitch of the sound played at the world level.
*
*/
pitch?: number;
/**
- Explanation:
* Relative volume and space by which this sound is heard.
*
*/
volume?: number;
}
// @ts-ignore Class inheritance allowed for native defined classes
### Class: CommandError
This section details the purpose, properties, methods, and code examples for `Class: CommandError` in the Minecraft Bedrock Edition Script API.
The `CommandError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EnchantmentLevelOutOfBoundsError
This section details the purpose, properties, methods, and code examples for `Class: EnchantmentLevelOutOfBoundsError` in the Minecraft Bedrock Edition Script API.
The `EnchantmentLevelOutOfBoundsError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EnchantmentTypeNotCompatibleError
This section details the purpose, properties, methods, and code examples for `Class: EnchantmentTypeNotCompatibleError` in the Minecraft Bedrock Edition Script API.
The `EnchantmentTypeNotCompatibleError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: EnchantmentTypeUnknownIdError
This section details the purpose, properties, methods, and code examples for `Class: EnchantmentTypeUnknownIdError` in the Minecraft Bedrock Edition Script API.
The `EnchantmentTypeUnknownIdError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
// @ts-ignore Class inheritance allowed for native defined classes
### Class: InvalidContainerSlotError
This section details the purpose, properties, methods, and code examples for `Class: InvalidContainerSlotError` in the Minecraft Bedrock Edition Script API.
The `InvalidContainerSlotError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Thrown when a Structure is invalid. A structure becomes
* invalid when it is deleted.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: InvalidStructureError
This section details the purpose, properties, methods, and code examples for `Class: InvalidStructureError` in the Minecraft Bedrock Edition Script API.
The `InvalidStructureError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
* Thrown when trying to register an item custom component with
* a name that has already been registered.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemCustomComponentAlreadyRegisteredError
This section details the purpose, properties, methods, and code examples for `Class: ItemCustomComponentAlreadyRegisteredError` in the Minecraft Bedrock Edition Script API.
The `ItemCustomComponentAlreadyRegisteredError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
* Thrown when trying to register an item custom component with
* an invalid namespace.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemCustomComponentNameError
This section details the purpose, properties, methods, and code examples for `Class: ItemCustomComponentNameError` in the Minecraft Bedrock Edition Script API.
The `ItemCustomComponentNameError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
* Thrown after using the /reload command when trying to
* register a previously unregistered item custom component.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemCustomComponentReloadNewComponentError
This section details the purpose, properties, methods, and code examples for `Class: ItemCustomComponentReloadNewComponentError` in the Minecraft Bedrock Edition Script API.
The `ItemCustomComponentReloadNewComponentError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
* Thrown after using the /reload command when trying to
* register a previously registered item custom component that
* handles a new event.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemCustomComponentReloadNewEventError
This section details the purpose, properties, methods, and code examples for `Class: ItemCustomComponentReloadNewEventError` in the Minecraft Bedrock Edition Script API.
The `ItemCustomComponentReloadNewEventError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
* Thrown after using the /reload command when trying to
* register a previously registered item custom component with
* a newer API version.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: ItemCustomComponentReloadVersionError
This section details the purpose, properties, methods, and code examples for `Class: ItemCustomComponentReloadVersionError` in the Minecraft Bedrock Edition Script API.
The `ItemCustomComponentReloadVersionError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Thrown when the chunk for provided location or bounding area
* is not loaded.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: LocationInUnloadedChunkError
This section details the purpose, properties, methods, and code examples for `Class: LocationInUnloadedChunkError` in the Minecraft Bedrock Edition Script API.
The `LocationInUnloadedChunkError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* Thrown when a provided location or bounding area is outside
* the minimum or maximum dimension height.
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: LocationOutOfWorldBoundariesError
This section details the purpose, properties, methods, and code examples for `Class: LocationOutOfWorldBoundariesError` in the Minecraft Bedrock Edition Script API.
The `LocationOutOfWorldBoundariesError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
// @ts-ignore Class inheritance allowed for native defined classes
### Class: UnloadedChunksError
This section details the purpose, properties, methods, and code examples for `Class: UnloadedChunksError` in the Minecraft Bedrock Edition Script API.
The `UnloadedChunksError` class represents an object or behavior in Minecraft. It contains properties and methods that allow interaction with the Minecraft world programmatically.
private constructor();
}
/**
* @beta
*/
export const HudElementsCount = 13;
/**
* @beta
*/
export const HudVisibilityCount = 2;
/**
- Explanation:
* Holds the number of MoonPhases
*
*/
export const MoonPhaseCount = 8;
/**
* @beta
*/
export const TicksPerDay = 24000;
/**
- Explanation:
* How many times the server ticks per second of real time.
*
*/
export const TicksPerSecond = 20;
/**
- Explanation:
* A class that provides system-level events and functions.
*
*/
export const system: System;
/**
- Explanation:
* A class that wraps the state of a world - a set of
* dimensions and the environment of Minecraft.
*
*/
export const world: World;
### Summary
This document provides an extensive exploration of the Minecraft Bedrock Edition Script APIs.
Each section offers clear descriptions, practical code examples, and insights into their application.
The following topics were covered:
- **Core Enumerations**: Definitions of fixed constants, such as `BlockComponentTypes`, `Difficulty`, and `Direction`, that describe key properties of game entities and mechanics.
- **Classes**: Comprehensive details about classes like `Block`, `Entity`, and `Dimension`, showcasing their properties, methods, and usage examples.
- **Code Examples**: Included throughout the document to demonstrate real-world applications of API methods.
- **Advanced Features**: Deep dives into more complex topics like permutations, events, and interactions.
Developers can leverage this guide to create advanced scripts and enrich gameplay experiences, with each section tailored to simplify implementation and enhance understanding.
For further inquiries or exploration, consult the official [Minecraft documentation](https://docs.microsoft.com/minecraft/creator/).
Script examples
1: **__What Does It Do?__:** This script triggers the message `YOUR AT X:1 Y:10 Z:1` if your at `X:1,Y:10,Z:1`
**__Code__**
import { world, system } from "@minecraft/server";
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
let RAW_Z = player.location.z
let RAW_Y = player.location.y
let RAW_X = player.location.x
const Z = Math.floor(RAW_Z)
const Y = Math.floor(RAW_Y)
const X = Math.floor(RAW_X)
if (X === 12 && Y === -60 && Z === 39) {
player.sendMessage('YOUR AT X:1 Y:10 Z:1')
}
}
})
2:
This Script is an example for entityHitEntity.
import { world } from "@minecraft/server";
world.afterEvents.entityHitEntity.subscribe((data) => {
const player = data.damagingEntity
const entity = data.hitEntity
//you can change the type id to any entity you want
if (entity?.typeId === "minecraft:cow") {
//you can put you action here, you can make it open form to!
player.applyKnockback(30, 30, 30, 30);
}
})
3:
this will tell you whether you command was successful or not
import { system, world } from '@minecraft/server'
world.afterEvents.itemUse.subscribe((data) => {
const player = data.source
const item = data.itemStack
if (item.typeId === "minecraft:stick") {
player.runCommandAsync("tp @s[tag=test] 0 100 0").then((data) => {
if(data.successCount > 0){
console.warn("command works")
}
if(data.successCount == 0){
console.warn("command failed")
}
})
}
}
4:
This script creates an infinite block using the custom block components.
import { world } from '@minecraft/server'
world.beforeEvents.worldInitialize.subscribe((data) => {
data.blockTypeRegistry.registerCustomComponent('your custom component', {
onPlayerDestroy: data => {
data.block.setType(" your block Id")
}
})
})
5:
import { world } from "@minecraft/server" // the word within the brackets imports the method used from the module which is "@minecraft/server"
world.afterEvents.itemUse.subscribe((data => {
const player = data.source// this gets the entity that uses the item
const item = data.itemStack // this gets the item and all its possible methods e.g amount,stackable etc
const view = player.getViewDirection()// gets the players view direction
if (item.typeId === "minecraft:feather") { // item.typeId gets the identifier of the item used and then you open a pair of new brackets "{}" which when the if statement is true executes the code contained within those brackets
player.applyKnockback(view.x, view.z, 2, 0.5) // "view.x" and "view.z" represent the Knockback direction the view variable is given by this "const view = player.getViewDirection()" this just gets the direction the player is looking and we are getting the x-axis and the z-axis directions
//Then after getting the direction using view we tell the game to apply a horizontalStrength of 2 and verticalStrength of 0.5 to the Knockback
}
}));
6:
This script shows how to teleport an entity that was hit with a projectile.
world.afterEvents.projectileHitEntity.subscribe((data) => {
const HitEntity = data.getEntityHit().entity
const Projectile = data.projectile
if (HitEntity && Projectile.typeId === "minecraft:snowball") {
HitEntity.runCommandAsync("spreadplayers ~ ~ 3 6 @s")
}
})
7:
This script creates a freezing arrow that freezes the player upon hitting them.
import { system, world } from '@minecraft/server'
world.afterEvents.projectileHitEntity.subscribe((data) => {
const Projectile = data.projectile
const HitEntity = data.getEntityHit().entity
const Score = world.scoreboard.getObjective("cooldown")
const FreezeTime = 10 * 20;
if (HitEntity.typeId === "minecraft:player" && Projectile.typeId === "minecraft:arrow") {
Score.setScore(HitEntity, FreezeTime);
if (!HitEntity.hasTag("frozen")) {
HitEntity.runCommandAsync("inputpermission set @s movement disabled ")
HitEntity.runCommandAsync("inputpermission set @s camera disabled ")
HitEntity.addTag("frozen")
system.run(function loop() {
const ScoreValue = Score.getScore(HitEntity);
const Seconds = Math.floor(ScoreValue / 20);
if (ScoreValue > 0) {
Score.addScore(HitEntity, -1);
HitEntity.runCommandAsync(`title @s actionbar You Have Been Frozen. ${Seconds} Seconds Remaining.`);
} else {
HitEntity.runCommandAsync("title @s actionbar You Have Been Unfrozen ")
HitEntity.runCommandAsync("inputpermission set @s movement enabled ")
HitEntity.runCommandAsync("inputpermission set @s camera enabled ")
HitEntity.removeTag("frozen")
}
// while the player has the tag "frozen" it'll keep looping
if (HitEntity.hasTag("frozen")) system.run(loop);
});
}
}
})
8:
This script shows how to change item lore.
import { system, world } from "@minecraft/server";
class loreItem {
constructor(itemId, lore) {
this.itemId = itemId;
this.lore = lore;
}
}
const ItemArray = [
new loreItem("minecraft:netherite_sword", ["§bExcited Blade"]),
new loreItem("minecraft:diamond_sword", ["§bExcited Blade"]),
];
system.runInterval(() => {
for (const player of world.getPlayers()) {
const playerContainer = player.getComponent("inventory").container
for (let i = 0; i < playerContainer.size; i++) {
const item = playerContainer.getItem(i);
const findLore = ItemArray.find(x => x.itemId == item?.typeId);
const lore = item?.getLore();
if (!findLore || !item || lore?.length != 0) continue
item.setLore(findLore.lore);
playerContainer.setItem(i, item);
}
}
})
9:
This script is a general example of various before and after events.
import { world, system, SystemAfterEvents } from "@minecraft/server"
world.afterEvents.itemUse.subscribe(data => {
const player = data.source
const item = data.itemStack
const dimension = player.dimension.id
if (item.typeId === "minecraft:stick") {
player.teleport({ x: Math.random(player.location.x * 10, player.location.x * 20), y: Math.random(player.location.y * 10, player.location.y * 20), z: Math.random(player.location.x * 10, player.location.x * 20) })
}
if (item.typeId === "minecraft:lava_bucket") {
world.getDimension(dimension).spawnEntity("minecraft:chicken", player.location)
}
}
)
world.beforeEvents.playerBreakBlock.subscribe(event => {
const player = event.player
const block = event.block
const blockunderid = block.below(1).typeId
const blockunder = block.below(1)
if (!blockunder?.hasTag("diamond_pick_diggable") && !blockunder?.hasTag("iron_pick_diggable") && !blockunder?.hasTag("metal") && blockunder?.typeId != "minecraft:diamond_block" && !player.isSneaking) {
player.runCommandAsync(`setblock ${block.location.x} ${block.location.y} ${block.location.z} ${blockunderid}`)
}
}
)
world.afterEvents.playerPlaceBlock.subscribe(event => {
const player = event.player
const block = event.block
const blockid = event.block.typeId
let chance = Math.random()
let blockchance = Math.random()
if (!block.hasTag("diamond_pick_diggable") && !block.hasTag("iron_pick_diggable") && !block.hasTag("metal") && block.typeId != "minecraft:diamond_block" && !player.isSneaking && chance <= 0.4) {
player.runCommandAsync(`setblock ${block.above(1).location.x} ${block.above(1).location.y} ${block.above(1).location.z} ${blockid}`)
}
if (!player.isSneaking && chance >= 0.6 && blockchance >= 0.6) {
player.applyKnockback(chance + 0.5, chance + 0.5, chance + 0.5, chance + 0.5)
}
if (!player.isSneaking && chance >= 0.6 && blockchance <= 0.4) {
player.applyKnockback((chance + 0.2) * -1, (chance + 0.2) * -1, (chance + 0.2) * -1, (chance + 0.2) * -1)
}
})
world.afterEvents.entityDie.subscribe(event => {
const entity = event.deadEntity
const source = event.damageSource.damagingEntity
if (source?.typeId === "minecraft:player" && entity.typeId != "minecraft:item" && entity.typeId != "minecraft:splash_potion") {
const block = entity?.dimension?.getBlock({ x: entity.location.x, y: entity.location.y - 10, z: entity.location.z })
if (!block?.isAir && !block?.hasTag("diamond_pick_diggable") && !block?.hasTag("iron_pick_diggable") && !block?.hasTag("metal") && block?.typeId != "minecraft:diamond_block") {
entity.runCommandAsync(`setblock ${entity.location.x} ${entity.location.y} ${entity.location.z} ${block.typeId}`)
}
}
}
)
world.afterEvents.buttonPush.subscribe(event => {
let player = event.source
let button = event.block
let dimension = event.block.dimension.id
const entityquery = { excludeTypes: player, closest: true, location: button.location }
if (player.typeId === "minecraft:player" && player.typeId != "minecraft:item") {
for (let entity of world.getDimension(dimension).getEntities(entityquery)) {
if (entity.typeId != "minecraft:player") {
button.dimension.spawnEntity(entity.typeId, button.location)
break
}
}
}
}
)
world.afterEvents.projectileHitBlock.subscribe(event => {
const blockhitlocation = event.location
const entity = event.source
const block = entity?.dimension?.getBlock({ x: blockhitlocation.x, y: blockhitlocation.y - 20, z: blockhitlocation.z })
if (!block?.isAir && !block?.hasTag("diamond_pick_diggable") && !block?.hasTag("iron_pick_diggable") && !block?.hasTag("metal") && block?.typeId != "minecraft:diamond_block") {
entity?.runCommandAsync(`setblock ${block?.location.x} ${block?.location.y + 22} ${block?.location.z} ${block?.typeId}`)
}
})
world.afterEvents.pistonActivate.subscribe(event => {
const block = event.block
const piston = event.piston
piston.block.dimension.createExplosion(piston.block.location, 1, { source: piston, causesFire: true, breaksBlocks: false })
})
world.afterEvents.playerDimensionChange.subscribe(event => {
const prevlocation = event.fromLocation
const nextlocation = event.toLocation
const player = event.player
const prevblock = player.dimension.getBlock({ x: prevlocation.x, y: prevlocation.y - 10, z: prevlocation.z })
const nextblock = player.dimension.getBlock({ x: nextlocation.x, y: nextlocation.y - 10, z: nextlocation.z })
if (!prevblock?.isAir) {
player.runCommandAsync(`setblock ${prevlocation.x} ${prevlocation.y + 10} ${prevlocation.z} ${prevblock?.typeId}`)
}
if (!nextblock?.isAir) {
player.runCommandAsync(`setblock ${nextlocation.x} ${nextlocation.y + 10} ${nextlocation.z} ${nextblock?.typeId}`)
}
})
world.afterEvents.weatherChange.subscribe(event => {
for (const player of world.getAllPlayers()) {
player.runCommandAsync(`summon minecraft:creeper ~~10~ 0 0 minecraft:become_charged`)
break
}
})
world.beforeEvents.entityRemove.subscribe(event => {
const entity = event.removedEntity
let chance = Math.random()
for (let player of world.getAllPlayers()) {
if (entity.typeId != "minecraft:player" && entity.typeId != "minecraft:item" && chance >= 0.9 && entity.typeId != "minecraft:zombie_villager_v2") {
player.runCommandAsync(`summon ${entity.typeId} ${player.location.x + 10} ${player.location.y + 10} ${player.location.z + 10}`)
break
}
}
}
)
world.afterEvents.effectAdd.subscribe(event => {
const entity = event.entity
if (entity.typeId != "minecraft:player") {
entity.applyImpulse({ x: Math.random(), y: Math.random(), z: Math.random() })
}
})
world.afterEvents.projectileHitEntity.subscribe(event => {
const entity = event.source
if (entity?.typeId != "minecraft:player") {
entity.setOnFire(1, false)
}
if (entity?.typeId === "minecraft:player") {
entity.applyKnockback(Math.random(), Math.random(), Math.random(), Math.random())
}
})
world.afterEvents.entitySpawn.subscribe(event => {
let chance = Math.random()
const entity = event.entity
if (entity.typeId != "minecraft:item" && entity.typeId != "minecraft:player" && chance >= 0.6) {
entity.applyImpulse({ x: Math.random() + 0.5, y: Math.random() + 0.5, z: Math.random() + 0.5 })
}
})
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
for (let entity of world.getDimension(player.dimension.id).getEntities({ location: player.location, excludeTypes: player, maxDistance: 25 })) {
let chance = Math.random()
if (entity.typeId != "minecraft:player" && chance >= 0.2 && entity.typeId != "minecraft:item") {
if (chance >= 0.5) {
entity.applyImpulse({ x: Math.random() + 0.5, y: Math.random() + 0.1, z: Math.random() + 0.5 })
} else {
entity.applyImpulse({ x: (Math.random() + 0.5) * -1, y: Math.random() + 0.1, z: (Math.random() + 0.5) * -1 })
}
}
if (entity.typeId != "minecraft:player" && chance >= 0 && entity.typeId === "minecraft:item") {
if (chance >= 0.5) {
entity.applyImpulse({ x: Math.random() + 0.5, y: Math.random() + 0.5, z: Math.random() + 0.5 })
} else {
entity.applyImpulse({ x: (Math.random() + 0.5) * -1, y: Math.random() + 0.5, z: (Math.random() + 0.5) * -1 })
break
}
}
}
}
}, 100);
system.runInterval(() => {
world.getAllPlayers().filter(
(data) => {
const chance = Math.random()
if (data?.typeId === 'minecraft:player' && data?.isSwimming && chance >= 0.3) {
data.applyKnockback(0, 0, 0, 5)
data.playSound('bubble.upinside', data.location)
}
}
)
}, 200)
system.runInterval(() => {
world.getAllPlayers().filter(
(data) => {
const chance = Math.random()
const { x, y, z } = data.location
if (chance > 0.5) {
if (chance <= 1 / 4) {
data.dimension.spawnEntity('minecraft:lightning_bolt', { x: x + 20, y: y, z: z + 20 })
}
if (chance <= 2 / 4) {
data.dimension.spawnEntity('minecraft:lightning_bolt', { x: x - 20, y: y, z: z - 20 })
}
if (chance <= 3 / 4) {
data.dimension.spawnEntity('minecraft:lightning_bolt', { x: x + 20, y: y, z: z - 20 })
}
else {
data.dimension.spawnEntity('minecraft:lightning_bolt', { x: x - 20, y: y, z: z + 20 })
}
}
}
)
}, 200)
system.runInterval(() => {
world.getDimension('overworld').getEntities({ type: 'minecraft:lightning_bolt' }).filter(
(event) => {
const { x, y, z } = event.location
const chance = Math.random()
if (event.dimension.getBlock({ x: x, y: y - 1, z: z }) && chance > 0.75) {
event.dimension.createExplosion({ x: x, y: y - 1, z: z }, 10, { allowUnderwater: true, breaksBlocks: true, causesFire: true })
}
}
)
}, 20)
world.afterEvents.entityDie.subscribe(event => {
const entity = event.deadEntity
const chance = Math.random()
const { x, y, z } = entity?.location
if (entity?.typeId === 'minecraft:zombie' && chance > 0.05) {
entity.dimension.spawnEntity('omni_science:zombie_meteor', { x: x, y: 256, z: z })
}
})
const { x, y, z } = entity?.location
if (entity?.typeId === 'minecraft:zombie' && chance > 0.05) {
entity.dimension.spawnEntity('omni_science:zombie_meteor', { x: x, y: 256, z: z })
}
})
10.
This script is a detailed example of how to use an item to prompt a action form that allows the player to choose various actions.
import { world, system } from "@minecraft/server"
import { ActionFormData } from "@minecraft/server-ui"
world.afterEvents.playerBreakBlock.subscribe(event => {
const playerbreak = event.player
const playerbreakloc = event.player.location
if (playerbreak.isSneaking) {
playerbreak.runCommandAsync("execute as @p[tag=invincible] at @s run fill ^-1^^ ^1^2^7 air destroy")
}
if (playerbreak.hasTag("mine_blast")) {
playerbreak.dimension.createExplosion({ x: playerbreakloc.x, y: playerbreakloc.y, z: playerbreakloc.z }, 10, { breaksBlocks: true })
playerbreak.runCommandAsync("tag @s remove mine_blast")
}
}
)
world.afterEvents.entityHitEntity.subscribe(event => {
const jughitd = event.damagingEntity
const hurte = event.hitEntity
if (jughitd.hasTag("invincible")) {
hurte.applyKnockback(20, 20, 20, 20)
hurte.applyDamage(200)
}
}
)
world.beforeEvents.itemUse.subscribe((data => {
let player = data.source
let title = "§aKing's§f §4Scepter§f"
const playerloc = data.source.location
if (data.itemStack.typeId == "omni-science:king_of_games_scepter") {
system.run(() => main(player))
function main() {
const form = new ActionFormData()
.title(title)
.body(`Hello ${player.nameTag} how will you use the scepter today?`)
.button("§3Freeze§f §6Someone§f")
.button("§cUnfreeze§f")
.button("§3Stop Time§f")
.button("§6Resume Time§f")
.button('§6Invincibility§f')
.button(`§3Make Mortal§f`)
.button(`§4Nuke§f`)
.button(`§3Strike Lightning§f`)
.button(`§0Void Hole§f`)
.button(`§4Mine Blast§f`)
.button(`§3Fly§f`)
.button(`§4Remove Fly§f`)
.button(`§4Jail§f`)
.button(`§6Bail§f`)
.button("Exit")
form.show(player).then(r => {
if (r.selection == 0) Freeze(player)
if (r.selection == 1) unfreeze(player)
if (r.selection == 2) time_stop(player)
if (r.selection == 3) time_start(player)
if (r.selection == 4) invincible(player)
if (r.selection == 5) mortal(player)
if (r.selection == 6) nuke(player)
if (r.selection == 7) strike_lighting(player)
if (r.selection == 8) void_hole(player)
if (r.selection == 9) mine_blast(player)
if (r.selection == 10) fly(player)
if (r.selection == 11) remove_fly(player)
if (r.selection == 12) jail(player)
if (r.selection == 13) bail(player)
}
)
}
}
function unfreeze() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Unfreeze")
actionForm.body(`${player.nameTag} who do you want to set free?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync("tag @s remove time_loop")
player.runCommandAsync(`tag ${players[data.selection].name} remove frozen`)
player.runCommandAsync(`gamemode s ${players[data.selection].name}`)
player.runCommandAsync(`inputpermission set ${players[data.selection].name} movement enabled`)
player.runCommandAsync(`inputpermission set ${players[data.selection].name} camera enabled`)
}
)
}
function Freeze() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Freeze")
actionForm.body(`${player.nameTag} He finna get froze`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync("tag @s add time_loop")
player.runCommandAsync(`tag ${players[data.selection].name} add frozen`)
player.runCommandAsync(`inputpermission set ${players[data.selection].name} movement disabled`)
player.runCommandAsync(`inputpermission set ${players[data.selection].name} camera disabled`)
player.runCommandAsync(`gamerule sendcommandfeedback false`)
if (player.hasTag("time_loop")) {
system.runInterval(freeze, 0.1)
function freeze() {
player.runCommandAsync(`execute as @a[name="${players[data.selection].name}",tag=frozen] at @s run tp @s ~~~`)
player.runCommandAsync(`gamemode a @a[name="${players[data.selection].name}",tag=frozen]`)
}
}
}
)
}
function time_stop() {
player.runCommandAsync("tag @s add outside_time")
player.runCommandAsync("tag @a remove time_start")
player.runCommandAsync(`gamerule sendcommandfeedback false`)
system.runInterval(stop_all, 0.01)
function stop_all() {
player.runCommandAsync("execute unless entity @s[tag=stop] run tag @e[tag=!outside_time,tag=!time_start] add stop")
player.runCommandAsync(`execute unless entity @s[tag=stop] as @e[tag=!outside_time,tag=stop,r=20,type=!player,tag=!time_start] at @s run tp @s ~~~ facing 0 0 0`)
player.runCommandAsync(`execute unless entity @s[tag=stop] as @a[tag=!outside_time,tag=stop,tag=!time_start] at @s run tp @s ~~~`)
player.runCommandAsync("execute if entity @s[tag=stop,tag=!time_start] run tag @s remove stop")
player.runCommandAsync(`inputpermission set @a[tag=!outside_time,tag=stop,tag=!time_start] movement disabled`)
player.runCommandAsync(`inputpermission set @a[tag=!outside_time,tag=stop,tag=!time_start] camera disabled`)
}
}
function time_start() {
player.runCommandAsync("tag @e remove stop")
player.runCommandAsync("tag @e add time_start")
player.runCommandAsync("tag @s remove outside_time")
player.runCommandAsync("inputpermission set @a movement enabled")
player.runCommandAsync("inputpermission set @a camera enabled")
}
function invincible() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Invincible")
actionForm.body(`${player.nameTag} who do you want to make a giga steve?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`tag ${players[data.selection].name} add invincible`)
system.runInterval(invincibleeffect, 0.1)
function invincibleeffect() {
player.runCommandAsync(`effect @e[tag=invincible] resistance 99999 255 true`)
player.runCommandAsync(`effect @e[tag=invincible] strength 99999 7 true`)
player.runCommandAsync(`effect @e[tag=invincible] speed 99999 2 true`)
player.runCommandAsync(`effect @e[tag=invincible] haste 99999 9 true`)
player.runCommandAsync(`effect @e[tag=invincible] night_vision 99999 255 true`)
player.runCommandAsync(`effect @e[tag=invincible] jump_boost 99999 14 true`)
player.runCommandAsync(`effect @e[tag=invincible] saturation 99999 255 true`)
player.runCommandAsync(`effect @e[tag=invincible] regeneration 99999 255 true`)
player.runCommandAsync(`execute as @e[tag=invincible] at @s run tp @e[type=item,r=10,c=1] @s`)
}
}
)
}
function mortal() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Mortal")
actionForm.body(`${player.nameTag} who do you want to make a scrub?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`tag ${players[data.selection].name} remove invincible`)
player.runCommandAsync(`effect ${players[data.selection].name} clear`)
}
)
}
function nuke() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Nuke")
actionForm.body(`${player.nameTag} who's pc will you crash?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`execute as ${players[data.selection].name} at @s run function nuclear_bomb`)
}
)
}
function strike_lighting() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Strike Lightning")
actionForm.body(`${player.nameTag} who will you smite?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`execute as ${players[data.selection].name} at @s run summon lightning_bolt`)
}
)
}
function void_hole() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Void Hole")
actionForm.body(`${player.nameTag} who will you send to hell?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`execute as ${players[data.selection].name} at @s run fill ~-2~-64~-2 ~2~~2 air`)
}
)
}
function mine_blast() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Mine Blast")
actionForm.body(`${player.nameTag} who will you make blow up when they mine a block?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`tag ${players[data.selection].name} add mine_blast`)
}
)
}
function fly() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Fly")
actionForm.body(`${player.nameTag} who will you make fly?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`ability ${players[data.selection].name} mayfly true`)
}
)
}
function remove_fly() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Remove Fly")
actionForm.body(`${player.nameTag} who will you force to walk to school?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`ability ${players[data.selection].name} mayfly false`)
}
)
}
function jail() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Jail")
actionForm.body(`${player.nameTag} Who will you imprison?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`tag ${players[data.selection].name} add jail`)
player.runCommandAsync(`gamerule sendcommandfeedback false`)
system.runInterval(imprisonment, 0.1)
function imprisonment() {
player.runCommandAsync(`execute as @a[tag=jail] at @s run fill ~1 ~2 ~1 ~-1 ~-1 ~-1 glass keep`)
player.runCommandAsync(`inputpermission set @a[tag=jail] movement disabled`)
player.runCommandAsync(`gamemode a @a[tag=jail]`)
}
}
)
}
function bail() {
const players = world.getAllPlayers()
const actionForm = new ActionFormData()
actionForm.title("Bail")
actionForm.body(`${player.nameTag} who will you set free?`)
for (let playerI of players) {
actionForm.button(playerI.name)
}
actionForm.button(`Exit`)
actionForm.show(player).then((data) => {
player.runCommandAsync(`tag ${players[data.selection].name} remove jail`)
player.runCommandAsync(`execute as ${players[data.selection].name} at @s run fill ~-15~-15~-15 ~15~15~15 air replace glass`)
player.runCommandAsync(`gamemode s ${players[data.selection].name}`)
player.runCommandAsync(`inputpermission set ${players[data.selection].name} movement enabled`)
}
)
}
}
)
)
11:
//This is an example of how to grab blocks in the world and run a tick interval on them so that an event can happen to them.
import { world, system, StructureAnimationMode } from "@minecraft/server";
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
const block_at_player_position = player.dimension.getBlock(player.location)
if (block_at_player_position?.typeId === "os:rope" && player.isJumping) {
player.applyKnockback(0, 0, 0, 0.6)
}
if (block_at_player_position?.typeId === "os:rope" && !player.isJumping && !player.getEffect("slow_falling") && player.isFalling) {
player.addEffect("slow_falling", 10, { showParticles: false, amplifier: 1 })
}
}
}, 1);
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
player.dimension.getEntities({ maxDistance: 50, families: ["summon"], location: player.location, excludeTags: ["os:attack1"], excludeTypes: ["os:soul_dart"] }).forEach(dartp => {
dartp.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: dartp.location.x + Math.random(), y: dartp.location.y + 1 + Math.random() * 1.5, z: dartp.location.z + Math.random() })
dartp.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: dartp.location.x - Math.random(), y: dartp.location.y + 1 - Math.random() * 1.5, z: dartp.location.z - Math.random() })
})
}
}, 10);
//This is an example of how to grab a block in the world after a player places it and then after 45 seconds it will load a structure at the blocks location.
world.afterEvents.playerPlaceBlock.subscribe(event => {
const block = event.block
const player = event.player
const dimension = player.dimension.id
if (block.typeId === "os:magic_sapling") {
let chance = Math.random()
const animation = StructureAnimationMode.Layers
system.runTimeout(() => {
if (chance <= 0.25) {
world.structureManager.place("mystructure:mana_tree1", world.getDimension(dimension), { x: block.location.x, y: block.location.y, z: block.location.z }, { animationMode: animation, animationSeconds: 5 })
}
if (chance >= 0.50 && chance <= 0.74) {
world.structureManager.place("mystructure:mana_tree2", world.getDimension(dimension), { x: block.location.x, y: block.location.y, z: block.location.z }, { animationMode: animation, animationSeconds: 5 })
}
if (chance >= 0.75) {
world.structureManager.place("mystructure:mana_tree3", world.getDimension(dimension), { x: block.location.x, y: block.location.y, z: block.location.z }, { animationMode: animation, animationSeconds: 5 })
}
}, 600)
}
})
12:
//This script allows allows players to have certain effect if certain effects have been met such as if a player has a certain tag, if they're jumping, sprinting, etc.
import { world, system, TicksPerSecond } from "@minecraft/server";
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3") || player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
const item = player?.getComponent("minecraft:equippable").getEquipment("Mainhand")
if (item?.typeId.includes("sword")) {
player.addEffect("weakness", 6000, { amplifier: 255, showParticles: false })
player.addTag("os:weak")
} else {
if (player.getEffect("weakness") && player.hasTag("os:weak")) {
player.removeEffect("weakness")
player.removeTag("os:weak")
}
}
}
//removal of speed for nonsprinting assasins
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
if (!player.isSprinting || player.isSwimming || player.isFlying || player.isGliding && player.getEffect("speed")) {
player.removeEffect("speed")
}
}
//effects for assasin level 1
if (player.hasTag("os:assasin")) {
if (!player.getEffect("resistance") || player.getEffect("resistance").duration <= 1) {
player.addEffect("resistance", 6000, { amplifier: 0, showParticles: false })
}
if (player.isSprinting && !player.isFlying && !player.isSwimming && !player.isGliding) {
if (player.getEffect("speed")?.duration <= 1 || !player.getEffect("speed")) {
player.addEffect("speed", 6000, { amplifier: 0, showParticles: false })
}
}
if (player.isSneaking) {
if (!player.getEffect("invisibility") || player.getEffect("invisibility")?.duration <= 1) {
player.addEffect("invisibility", 60, { amplifier: 0, showParticles: true })
}
}
}
//effects for assasin level 2
if (player.hasTag("os:assasin1")) {
if (!player.getEffect("resistance") || player.getEffect("resistance")?.duration <= 1) {
player.addEffect("resistance", 6000, { amplifier: 1, showParticles: false })
}
if (player.isSprinting && !player.isFlying && !player.isSwimming && !player.isGliding) {
if (!player.getEffect("speed") || player.getEffect("speed")?.duration <= 1) {
player.addEffect("speed", 6000, { amplifier: 2, showParticles: false })
}
}
if (player.isSneaking) {
if (!player.getEffect("invisibility") || player.getEffect("invisibilty")?.duration <= 1) {
player.addEffect("invisibility", 100, { amplifier: 1, showParticles: true })
}
}
}
//effects for assasin level 3
if (player.hasTag("os:assasin2")) {
if (!player.getEffect("resistance") || player.getEffect("resistance")?.duration <= 1) {
player.addEffect("resistance", 6000, { amplifier: 2, showParticles: false })
}
if (player.isSprinting && !player.isFlying && !player.isSwimming && !player.isGliding) {
if (!player.getEffect("speed") || player.getEffect("speed")?.duration <= 1) {
player.addEffect("speed", 6000, { amplifier: 3, showParticles: false })
}
}
if (!player.getEffect("invisibility") || player.getEffect("invisibility")?.duration <= 1) {
player.addEffect("invisibility", 6000, { amplifier: 2, showParticles: false })
}
}
//effects for assasin level 4
if (player.hasTag("os:assasin3")) {
if (!player.getEffect("resistance") || player.getEffect("resistance")?.duration <= 1) {
player.addEffect("resistance", 6000, { amplifier: 3, showParticles: false })
}
if (player.isSprinting && !player.isFlying && !player.isSwimming && !player.isGliding) {
if (!player.getEffect("speed") || player.getEffect("speed")?.duration <= 1)
player.addEffect("speed", 6000, { amplifier: 4, showParticles: false })
}
if (!player.getEffect("invisibility") || player.getEffect("invisibility")?.duration <= 1) {
player.addEffect("invisibility", 6000, { amplifier: 3, showParticles: false })
}
}
//effects for mage level 1
if (player.hasTag("os:mage")) {
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { showParticles: false, amplifier: 0 })
}
}
//effects for mage level 2
if (player.hasTag("os:mage1")) {
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { showParticles: false, amplifier: 1 })
}
}
//effects for mage level 3
if (player.hasTag("os:mage2")) {
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { showParticles: false, amplifier: 2 })
}
}
//effects for mage level 4
if (player.hasTag("os:mage3")) {
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { showParticles: false, amplifier: 3 })
}
}
// removal of slow fall for all mages
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
if (player.isSneaking && player.isFalling && !player.isFlying && !player.isGliding && !player.isSwimming && !player.isInWater) {
if (!player.getEffect("slow_falling") || player.getEffect("slow_falling")?.duration <= 1) {
player.addEffect("slow_falling", 10, { amplifier: 0, showParticles: false })
}
}
if (player.getEffect("slow_falling")) {
if (player.isOnGround || player.isGliding || player.isSwimming || player.isInWater || player.isFlying) {
player.removeEffect("slow_falling")
}
}
}
//effects for warrior level 1
if (player.hasTag("os:warrior")) {
if (!player.getEffect("jump_boost") || player.getEffect("jump_boost")?.duration <= 1) {
player.addEffect("jump_boost", 6000, { amplifier: 1, showParticles: false })
}
if (!player.getEffect("health_boost") || player.getEffect("health_boost")?.duration <= 1) {
player.addEffect("health_boost", 6000, { amplifier: 1, showParticles: false })
}
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { amplifier: 0, showParticles: false })
}
}
//effects for warrior level 2
if (player.hasTag("os:warrior1")) {
if (!player.getEffect("jump_boost") || player.getEffect("jump_boost")?.duration <= 1) {
player.addEffect("jump_boost", 6000, { amplifier: 3, showParticles: false })
}
if (!player.getEffect("health_boost") || player.getEffect("health_boost")?.duration <= 1) {
player.addEffect("health_boost", 6000, { amplifier: 4, showParticles: false })
}
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { amplifier: 0, showParticles: false })
}
}
//effects for warrior level 3
if (player.hasTag("os:warrior2")) {
if (!player.getEffect("jump_boost") || player.getEffect("jump_boost")?.duration <= 1) {
player.addEffect("jump_boost", 6000, { amplifier: 7, showParticles: false })
}
if (!player.getEffect("health_boost") || player.getEffect("health_boost")?.duration <= 1) {
player.addEffect("health_boost", 6000, { amplifier: 6, showParticles: false })
}
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { amplifier: 0, showParticles: false })
}
}
//effects for warrior level 4
if (player.hasTag("os:warrior3")) {
if (!player.getEffect("jump_boost") || player.getEffect("jump_boost")?.duration <= 1) {
player.addEffect("jump_boost", 6000, { amplifier: 9, showParticles: false })
}
if (!player.getEffect("health_boost") || player.getEffect("health_boost")?.duration <= 1) {
player.addEffect("health_boost", 6000, { amplifier: 9, showParticles: false })
}
if (!player.getEffect("regeneration") || player.getEffect("regeneration")?.duration <= 1) {
player.addEffect("regeneration", 6000, { amplifier: 0, showParticles: false })
}
}
//adding of falling tag for all warriors
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
if (player.isFalling && !player.hasTag("os:falling")) {
player.addTag(`os:falling`)
}
}
//removal of falling tag for all warriors
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
if (player.isOnGround && !player.isSneaking && player.hasTag("os:falling")) {
player.removeTag("os:falling")
}
if (player.hasTag("os:falling") && player.isSwimming) {
player.removeTag("os:falling")
}
}
//warrior level 1 slam
if (player.hasTag("os:warrior") && player.hasTag("os:falling") && player.isSneaking && player.isOnGround) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
player.removeTag("os:falling")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 4, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 8 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random(), Math.random(), Math.random(), Math.random())
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
}
)
}
//warrior level 2 slam
if (player.hasTag("os:warrior1") && player.hasTag("os:falling") && player.isSneaking && player.isOnGround) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
player.removeTag("os:falling")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 6, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 16 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random() * 1.5, Math.random() * 1.5, Math.random() * 1.5, Math.random() * 1.5)
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
}
)
}
//warrior level 3 slam
if (player.hasTag("os:warrior2") && player.hasTag("os:falling") && player.isSneaking && player.isOnGround) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
player.removeTag("os:falling")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 8, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 24 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random() * 2, Math.random() * 2, Math.random() * 2, Math.random() * 2)
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
}
)
}
//warrior level 4 slam
if (player.hasTag("os:warrior3") && player.hasTag("os:falling") && player.isSneaking && player.isOnGround) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
player.removeTag("os:falling")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 32 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random() * 2.5, Math.random() * 2.5, Math.random() * 2.5, Math.random() * 2.5)
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
}
)
}
}
}, 1);
world.afterEvents.entityHurt.subscribe(event => {
const player = event.damageSource?.damagingEntity
const entity = event.hurtEntity
const item = event.damageSource?.damagingEntity?.getComponent("equippable")?.getEquipmentSlot("Mainhand")?.getItem()
if (player?.typeId === "minecraft:player" && !entity?.hasTag("os:peace")) {
if (player?.hasTag(`os:assasin`) && item?.typeId.includes("dagger")) {
if (player.hasTag(`os:all_target`)) {
entity?.addEffect("fatal_poison", 60, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 20 entity_attack entity ${player.nameTag}`)
}
} else {
if (player.hasTag(`os:hostile_target`) && (entity.getComponent("type_family").hasTypeFamily("monster") || entity.typeId === "minecraft:ender_dragon" || entity.typeId === "minecraft:wither" || entity.typeId === "minecraft:warden")) {
entity?.addEffect("fatal_poison", 60, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 20 entity_attack entity ${player.nameTag}`)
}
}
}
}
if (player?.hasTag(`os:assasin1`) && item?.typeId.includes("dagger")) {
if (player.hasTag(`os:all_target`)) {
entity?.addEffect("fatal_poison", 100, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 60 entity_attack entity ${player.nameTag}`)
}
} else {
if (player.hasTag(`os:hostile_target`) && (entity.getComponent("type_family").hasTypeFamily("monster") || entity.typeId === "minecraft:ender_dragon" || entity.typeId === "minecraft:wither" || entity.typeId === "minecraft:warden")) {
entity?.addEffect("fatal_poison", 100, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 60 entity_attack entity ${player.nameTag}`)
}
}
}
}
if (player?.hasTag(`os:assasin2`) && item?.typeId.includes("dagger")) {
if (player.hasTag(`os:all_target`)) {
entity?.addEffect("fatal_poison", 160, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 180 entity_attack entity ${player.nameTag}`)
}
} else {
if (player.hasTag(`os:hostile_target`) && (entity.getComponent("type_family").hasTypeFamily("monster") || entity.typeId === "minecraft:ender_dragon" || entity.typeId === "minecraft:wither" || entity.typeId === "minecraft:warden")) {
entity?.addEffect("fatal_poison", 160, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 180 entity_attack entity ${player.nameTag}`)
}
}
}
}
if (player?.hasTag(`os:assasin3`) && item?.typeId.includes("dagger")) {
if (player.hasTag(`os:all_target`)) {
entity?.addEffect("fatal_poison", 200, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 250 entity_attack entity ${player.nameTag}`)
}
} else {
if (player.hasTag(`os:hostile_target`) && (entity.getComponent("type_family").hasTypeFamily("monster") || entity.typeId === "minecraft:ender_dragon" || entity.typeId === "minecraft:wither" || entity.typeId === "minecraft:warden")) {
entity?.addEffect("fatal_poison", 200, { showParticles: true, amplifier: 0 })
if (player.isSneaking) {
entity.runCommandAsync(`damage @s 250 entity_attack entity ${player.nameTag}`)
}
}
}
}
if (player?.hasTag(`os:warrior`) && item?.typeId.includes("greatsword")) {
player.playAnimation("animation.os_hom.warrior_attack")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 3, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 18 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random() * 2, Math.random() * 2, Math.random() * 2, Math.random() * 2)
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
entities.dimension.playSound("mob.evocation_fangs.attack", entities.location, { volume: 1, pitch: 1 })
}
)
}
if (player?.hasTag(`os:warrior1`) && item?.typeId.includes("greatsword")) {
player.playAnimation("animation.os_hom.warrior_attack")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 50 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random() * 4, Math.random() * 4, Math.random() * 4, Math.random() * 4)
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
entities.dimension.playSound("mob.evocation_fangs.attack", entities.location, { volume: 1, pitch: 1 })
}
)
}
if (player?.hasTag(`os:warrior2`) && item?.typeId.includes("greatsword")) {
player.playAnimation("animation.os_hom.warrior_attack")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 7, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 150 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random() * 6, Math.random() * 6, Math.random() * 6, Math.random() * 6)
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
entities.dimension.playSound("mob.evocation_fangs.attack", entities.location, { volume: 1, pitch: 1 })
}
)
}
if (player?.hasTag(`os:warrior3`) && item?.typeId.includes("greatsword")) {
player.playAnimation("animation.os_hom.warrior_attack")
world.getDimension(player.dimension.id).getEntities({ maxDistance: 9, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities?.runCommandAsync(`damage @s 190 entity_attack entity ${player.nameTag}`)
entities?.applyKnockback(Math.random() * 8, Math.random() * 8, Math.random() * 8, Math.random() * 8)
entities.dimension.spawnParticle("minecraft:critical_hit_emitter", { x: entities.location.x, y: entities.location.y + 2, z: entities.location.z })
entities.dimension.playSound("mob.evocation_fangs.attack", entities.location, { volume: 1, pitch: 1 })
}
)
}
}
}
)
13:
//This script allows players to use a custom item to both gain a certain tag and create certain particles and sounds when they use an item as well.
import { world } from "@minecraft/server";
world.afterEvents.itemUse.subscribe(event => {
const itemid = event.itemStack.typeId
const player = event.source
//player tries to become assasin with worng emblem
if (itemid === "os:assasin_emblem_acolyte" || itemid === "os:assasin_emblem_shadow" || itemid === "os:assasin_emblem_shinobie") {
if (!player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you must use a deprived assasin emblem to become an assasin`)
}
}
//Becoming Assasin Level One
if (itemid === "os:assassin_emblem_deprived" && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:assasin")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just became an assasin!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:assassin_emblem_deprived 0 1`)
} else {
if (itemid === "os:assassin_emblem_deprived") {
if (player.hasTag("os:assasin")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use an acolyte assasin emblem to level up further.`)
}
if (player.hasTag("os:assasin1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a shadow assasin emblem to level up further.`)
}
if (player.hasTag("os:assasin2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a shinobi assasin emblem to level up further.`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a mage. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a warrior. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you are already a max level assasin use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//Becoming assasin level 2
if (itemid === "os:assassin_emblem_acolyte" && player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:assasin1")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to assasin level 2!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:assassin_emblem_acolyte 0 1`)
player.removeTag("os:assasin")
player.removeEffect("speed")
player.removeEffect("resistance")
player.removeEffect("invisibility")
} else {
if (itemid === "os:assassin_emblem_acolyte") {
if (player.hasTag("os:assasin1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a shadow assasin emblem to level up further.`)
}
if (player.hasTag("os:assasin2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a shinobi assasin emblem to level up further.`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a mage. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a warrior. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you are already a max level assasin use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//becoming assasin level 3
if (itemid === "os:assassin_emblem_shadow" && player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:assasin2")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to assasin level 3!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:assassin_emblem_shadow 0 1`)
player.removeTag("os:assasin1")
player.removeEffect("speed")
player.removeEffect("resistance")
player.removeEffect("invisibility")
} else {
if (itemid === "os:assassin_emblem_shadow") {
if (player.hasTag("os:assasin")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use an acolyte assasin emblem to level up further.`)
}
if (player.hasTag("os:assasin2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a shinobi assasin emblem to level up further.`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a mage. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a warrior. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you are already a max level assasin use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//becoming assasin level 4
if (itemid === "os:assassin_emblem_shinobi" && player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:assasin3")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to assasin level 4! You are now a max level assasin!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:assassin_emblem_shinobi 0 1`)
player.removeTag("os:assasin2")
player.removeEffect("speed")
player.removeEffect("resistance")
player.removeEffect("invisibility")
} else {
if (itemid === "os:assassin_emblem_shinobi") {
if (player.hasTag("os:assasin")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a acolyte assasin emblem to level up further.`)
}
if (player.hasTag("os:assasin1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a shadow assasin emblem to level up further.`)
}
if (player.hasTag("os:assasin2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a shinobi assasin emblem to level up further.`)
}
if (player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you are already a max level assasin use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a mage. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an assasin because you're already a warrior. If you'd like to become an assasin reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//player tries to become mage with worng emblem
if (itemid === "os:mage_emblem_adept" || itemid === "os:mage_emblem_master" || itemid === "os:mage_emblem_guru") {
if (!player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you must use a novice mage emblem to become a mage`)
}
}
//Becoming a mage level 1
if (itemid === "os:mage_emblem_novice" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:mage")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just became an mage!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:mage_emblem_novice 0 1`)
} else {
if (itemid === "os:mage_emblem_novice") {
if (player.hasTag("os:mage")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use an adept mage emblem to level up further.`)
}
if (player.hasTag("os:mage1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a master mage emblem to level up further.`)
}
if (player.hasTag("os:mage2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a guru mage emblem to level up further.`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a mage. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a warrior. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you are already a max level mage use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//Becoming mage level 2
if (itemid === "os:mage_emblem_adept" && player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:mage1")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to mage level 2!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:mage_emblem_adept 0 1`)
player.removeTag("os:mage")
player.removeEffect("regeneration")
} else {
if (itemid === "os:mage_emblem_adept") {
if (player.hasTag("os:mage1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a master mage emblem to level up further.`)
}
if (player.hasTag("os:mage2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a guru mage emblem to level up further.`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a mage. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a warrior. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you are already a max level mage use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//becoming mage level 3
if (itemid === "os:mage_emblem_master" && player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:mage2")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to mage level 3!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:mage_emblem_master 0 1`)
player.removeTag("os:mage1")
player.removeEffect("regeneration")
} else {
if (itemid === "os:mage_emblem_master") {
if (player.hasTag("os:mage")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use an adept mage emblem to level up further.`)
}
if (player.hasTag("os:mage2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a guru mage emblem to level up further.`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a mage. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a warrior. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you are already a max level mage use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//becoming mage level 4
if (itemid === "os:mage_emblem_guru" && player.hasTag("os:mage2") && !player.hasTag("os:mage3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.addTag("os:mage3")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to mage level 4! You are now a max level mage!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:mage_emblem_guru 0 1`)
player.removeTag("os:mage2")
player.removeEffect("regeneration")
} else {
if (itemid === "os:mage_emblem_guru") {
if (player.hasTag("os:mage")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a adept mage emblem to level up further.`)
}
if (player.hasTag("os:mage1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a master mage emblem to level up further.`)
}
if (player.hasTag("os:mage2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a guru mage emblem to level up further.`)
}
if (player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you are already a max level mage use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a mage. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you cannot become an mage because you're already a warrior. If you'd like to become an mage reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//player tries to become warrior with worng emblem
if (itemid === "os:warrior_emblem_intermediate" || itemid === "os:warrior_emblem_advanced" || itemid === "os:warrior_emblem_seasoned") {
if (!player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you must use a begginer warrior emblem to become a warrior`)
}
}
//Becoming a warrior level 1
if (itemid === "os:warrior_emblem_beginner" && !player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.addTag("os:warrior")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just became an warrior!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:warrior_emblem_beginner 0 1`)
} else {
if (itemid === "os:warrior_emblem_beginner") {
if (player.hasTag("os:warrior")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use an intermidiate warrior emblem to level up further.`)
}
if (player.hasTag("os:warrior1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a advanced warrior emblem to level up further.`)
}
if (player.hasTag("os:warrior2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a seasoned warrior emblem to level up further.`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you are already a max level warrior use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//Becoming warrior level 2
if (itemid === "os:warrior_emblem_intermediate" && player.hasTag("os:warrior") && !player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.addTag("os:warrior1")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to warrior level 2!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:warrior_emblem_intermediate 0 1`)
player.removeTag("os:warrior")
player.removeEffect("jump_boost")
player.removeEffect("health_boost")
player.removeEffect("strength")
} else {
if (itemid === "os:warrior_emblem_intermediate") {
if (player.hasTag("os:warrior1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a advanced warrior emblem to level up further.`)
}
if (player.hasTag("os:warrior2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a seasoned warrior emblem to level up further.`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you are already a max level warrior use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//becoming warrior level 3
if (itemid === "os:warrior_emblem_advanced" && player.hasTag("os:warrior1") && !player.hasTag("os:warrior2") && !player.hasTag("os:warrior3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.addTag("os:warrior2")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to warrior level 3!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:warrior_emblem_advanced 0 1`)
player.removeTag("os:warrior1")
player.removeEffect("jump_boost")
player.removeEffect("health_boost")
player.removeEffect("strength")
} else {
if (itemid === "os:warrior_emblem_advanced") {
if (player.hasTag("os:warrior")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use an intermidiate warrior emblem to level up further.`)
}
if (player.hasTag("os:warrior2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a seasoned warrior emblem to level up further.`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you are already a max level warrior use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//becoming warrior level 4
if (itemid === "os:warrior_emblem_seasoned" && player.hasTag("os:warrior2") && !player.hasTag("os:warrior3") && !player.hasTag("os:assasin") && !player.hasTag("os:assasin1") && !player.hasTag("os:assasin2") && !player.hasTag("os:assasin3") && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.addTag("os:warrior3")
player.dimension.playSound("random.levelup", player.location, { volume: 1, pitch: 1 })
player.dimension.spawnParticle("minecraft:totem_particle", { x: player.location.x, y: player.location.y + 2, z: player.location.z })
world.sendMessage(`${player.nameTag} just leveled up to warrior level 4! You are now a max level warrior!`)
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:warrior_emblem_seasoned 0 1`)
player.removeTag("os:warrior2")
player.removeEffect("jump_boost")
player.removeEffect("health_boost")
player.removeEffect("strength")
} else {
if (itemid === "os:warrior_emblem_seasoned") {
if (player.hasTag("os:warrior")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a intermidiate warrior emblem to level up further.`)
}
if (player.hasTag("os:warrior1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a advanced warrior emblem to level up further.`)
}
if (player.hasTag("os:warrior2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
world.sendMessage(`${player.nameTag} you need to use a seasoned warrior emblem to level up further.`)
}
if (player.hasTag("os:warrior3")) {
world.sendMessage(`${player.nameTag} you are already a max level warrior use a blank emblem to reset your class`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
if (player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
world.sendMessage(`${player.nameTag} you cannot become an warrior because you're already a warrior. If you'd like to become an warrior reset your class by using a blank emblem and try again.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//Removal of classes with a blank emblem
if (itemid === "os:emblem") {
if (player.hasTag("os:assasin") || player.hasTag("os:assasin1") || player.hasTag("os:assasin2") || player.hasTag("os:assasin3") || player.hasTag("os:warrior") || player.hasTag("os:warrior1") || player.hasTag("os:warrior2") || player.hasTag("os:warrior3") || player.hasTag("os:mage") || player.hasTag("os:mage1") || player.hasTag("os:mage2") || player.hasTag("os:mage3")) {
player.removeTag("os:assasin")
player.removeTag("os:assasin1")
player.removeTag("os:assasin2")
player.removeTag("os:assasin3")
player.removeTag("os:mage")
player.removeTag("os:mage1")
player.removeTag("os:mage2")
player.removeTag("os:mage3")
player.removeTag("os:warrior")
player.removeTag("os:warrior1")
player.removeTag("os:warrior2")
player.removeTag("os:warrior3")
player.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run clear @s os:emblem 0 1`)
world.sendMessage(`${player.nameTag} your class has been reset use a new level 1 emblem to choose a new class.`)
player.dimension.playSound("random.orb", player.location, { volume: 1, pitch: 1 })
player.removeEffect("speed")
player.removeEffect("regeneration")
player.removeEffect("strength")
player.removeEffect("invisibility")
player.removeEffect("regeneration")
player.removeEffect("health_boost")
player.removeEffect("jump_boost")
player.removeEffect("resistance")
}
else {
if (itemid === "os:emblem") {
world.sendMessage(`${player.nameTag} this item resets your class so you can choose a new one. You currently do not have a class.`)
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
})
14:
//This script makes it so that when an entity spawns in the world another entity is spawned at the entities location that triggered the event.
import { world, system } from "@minecraft/server";
world.afterEvents.entitySpawn.subscribe(event => {
const entity = event.entity
const cause = event.cause
if (entity?.typeId === "minecraft:sheep" && !entity.hasComponent("minecraft:is_baby")) {
entity?.dimension?.spawnEntity("os:ram", entity.location)
}
if (entity?.typeId === "minecraft:cow" && !entity.hasComponent("minecraft:is_baby")) {
entity?.dimension?.spawnEntity("os:bull", entity.location)
}
if (entity?.typeId === "minecraft:pig" && !entity.hasComponent("minecraft:is_baby")) {
entity?.dimension?.spawnEntity("os:boar", entity.location)
}
if (entity?.typeId === "minecraft:chicken" && !entity.hasComponent("minecraft:is_baby")) {
entity?.dimension?.spawnEntity("os:rooster", entity.location)
}
if (entity?.typeId.includes("villager") && entity?.typeId.includes("minecraft:")) {
let chance = Math.random()
if (chance >= 0.6) {
entity?.dimension?.spawnEntity("vk:village_guard", entity.location)
}
}
})
15:
//This script makes items lose durability whenever a player breaks a block whilst holding a custom item or when using a custom item. It uses Math.random() when the item has an unbreaking enchantment on the item to allow a lesser chance of the item losing durability. The replaceitem command decrements the durability everytime this script runs and then the script re enchants the item if it had any enchantments before it was replaced.
import { world, system } from "@minecraft/server";
const tries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
world.afterEvents.playerBreakBlock.subscribe(event => {
try {
const item = event?.itemStackAfterBreak
const player = event?.player
const enchants = item?.getComponent("minecraft:enchantable")?.getEnchantments()
const current_dam = item?.getComponent("minecraft:durability")?.damage
if (!item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (item?.typeId.includes("os:") && damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (item?.typeId.includes("os:") && damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
if (item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")?.level == 1) {
try {
let chance = Math.random()
if (chance >= 0.45) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
}
catch { }
}
if (item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")?.level == 2) {
try {
let chance = Math.random()
if (chance >= 0.65) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
}
catch { }
}
if (item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")?.level == 3) {
try {
let chance = Math.random()
if (chance >= 0.85) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
}
catch { }
}
}
catch { }
})
world.afterEvents.itemUse.subscribe(event => {
try {
const item = event.itemStack
const player = event.source
const enchants = item?.getComponent("minecraft:enchantable")?.getEnchantments()
const current_dam = item?.getComponent("minecraft:durability")?.damage
const offitem = player.getComponent("minecraft:equippable").getEquipment("Offhand")
const off_curr_damage = offitem?.getComponent("minecraft:durability")?.damage
const offenchant = offitem?.getComponent("minecraft:enchantable")?.getEnchantments()
const cooldown = item?.getComponent("minecraft:cooldown")?.getCooldownTicksRemaining(player)
const max_cooldown = item?.getComponent("minecraft:cooldown")?.cooldownTicks
if (cooldown >= max_cooldown || cooldown == 0 || !item.getComponent("minecraft:cooldown")) {
try {
if (item?.hasComponent("minecraft:durability") && player.getGameMode() != "creative" && item.hasTag("os:useable")) {
try {
if (!item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (item?.typeId.includes("os:") && damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (item?.typeId.includes("os:") && damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
if (item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")?.level == 1) {
try {
let chance = Math.random()
if (chance >= 0.45) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
}
catch { }
}
if (item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")?.level == 2) {
try {
let chance = Math.random()
if (chance >= 0.65) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
}
catch { }
}
if (item?.getComponent("minecraft:enchantable")?.getEnchantment("unbreaking")?.level == 3) {
try {
let chance = Math.random()
if (chance >= 0.85) {
try {
let damage = item?.getComponent("minecraft:durability")?.damage + 1
let max_dam = item?.getComponent("minecraft:durability")?.maxDurability
if (damage < max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 ${item.typeId} 1 ${damage}`).then(data => {
if (data.successCount == 1) {
try {
enchants.forEach(event => {
try {
const enchantment = event
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage}}] ${enchantment.type.id} ${event.level}`)
tries.forEach(event => {
try {
system.runTimeout(() => {
try {
player.runCommandAsync(`enchant @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${damage + event}}] ${enchantment.type.id} ${enchantment.level}`)
}
catch { }
}, event + 50)
}
catch { }
})
}
catch { }
})
}
catch { }
}
})
}
catch { }
}
if (damage >= max_dam) {
try {
player.runCommandAsync(`replaceitem entity @s[hasitem={item=${item.typeId},location=slot.weapon.mainhand,slot=0,data=${current_dam}}] slot.weapon.mainhand 0 air`)
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
}
catch { }
}
}
catch { }
}
}
catch { }
}
}
catch { }
}
}
catch { }
}
}
catch { }
})
16:
//This script allows the player to cast spells by using a custom item and makes it so that the player has to have a specific item in their offhand slot when using the custom item and gives the item in their offhand a chance of breaking.
import { world, system, TicksPerSecond } from "@minecraft/server";
world.afterEvents.itemUse.subscribe(event => {
const item = event?.itemStack
const player = event?.source
const chance = Math.random()
const offitem = player.getComponent("minecraft:equippable").getEquipment("Offhand")
if (item?.typeId === "os:magic_stone" && player?.hasTag("os:mage")) {
const block = player?.getBlockFromViewDirection({ maxDistance: 18, includeLiquidBlocks: false, includePassableBlocks: true })?.block
if (block?.above(1)?.isAir && block?.above(2)?.isAir) {
player.teleport({ x: block.location.x + 0.5, y: block.location.y + 1, z: block.location.z + 0.5 }, { checkForBlocks: true })
system.runTimeout(() => {
player?.dimension.playSound("mob.shulker.teleport", player.location, { volume: 1, pitch: 1 })
const plapart = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x + Math.random() * 3, y: player?.location.y + 1, z: player.location.z + Math.random() * 3 })
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x - Math.random() * 3, y: player?.location.y + 1, z: player.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
}, 6)
if (chance >= 0.25) {
block.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${item.typeId} 0 1`)
}
} else {
if (item?.typeId === "os:magic_stone" && player?.hasTag("os:mage")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
if (item?.typeId === "os:power_stone" && player?.hasTag("os:mage1")) {
const block = player?.getBlockFromViewDirection({ maxDistance: 36, includeLiquidBlocks: false, includePassableBlocks: true })?.block
if (block?.above(1)?.isAir && block?.above(2)?.isAir) {
player.teleport({ x: block.location.x + 0.5, y: block.location.y + 1, z: block.location.z + 0.5 }, { checkForBlocks: true })
system.runTimeout(() => {
player?.dimension.playSound("mob.shulker.teleport", player.location, { volume: 1, pitch: 1 })
const plapart = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x + Math.random() * 3, y: player?.location.y + 1, z: player.location.z + Math.random() * 3 })
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x - Math.random() * 3, y: player?.location.y + 1, z: player.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
}, 6)
if (chance >= 0.50) {
block.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${item.typeId} 0 1`)
}
} else {
if (item?.typeId === "os:power_stone" && player?.hasTag("os:mage1")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
if (item?.typeId === "os:alchemical_stone" && player?.hasTag("os:mage2")) {
const block = player?.getBlockFromViewDirection({ maxDistance: 54, includeLiquidBlocks: false, includePassableBlocks: true })?.block
if (block?.above(1)?.isAir && block?.above(2)?.isAir) {
player.teleport({ x: block.location.x + 0.5, y: block.location.y + 1, z: block.location.z + 0.5 }, { checkForBlocks: true })
system.runTimeout(() => {
player?.dimension.playSound("mob.shulker.teleport", player.location, { volume: 1, pitch: 1 })
const plapart = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x + Math.random() * 3, y: player?.location.y + 1, z: player.location.z + Math.random() * 3 })
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x - Math.random() * 3, y: player?.location.y + 1, z: player.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
}, 6)
if (chance >= 0.75) {
block.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${item.typeId} 0 1`)
}
} else {
if (item?.typeId === "os:alchemical_stone" && player?.hasTag("os:mage2")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
if (item?.typeId === "os:philosopher_stone" && player?.hasTag("os:mage3")) {
const block = player?.getBlockFromViewDirection({ maxDistance: 72, includeLiquidBlocks: false, includePassableBlocks: true })?.block
if (block?.above(1)?.isAir && block?.above(2)?.isAir) {
player.teleport({ x: block.location.x + 0.5, y: block.location.y + 1, z: block.location.z + 0.5 }, { checkForBlocks: true })
system.runTimeout(() => {
player?.dimension.playSound("mob.shulker.teleport", player.location, { volume: 1, pitch: 1 })
const plapart = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x + Math.random() * 3, y: player?.location.y + 1, z: player.location.z + Math.random() * 3 })
player.dimension.spawnParticle("minecraft:dragon_breath_fire", { x: player.location.x - Math.random() * 3, y: player?.location.y + 1, z: player.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
}, 6)
if (chance >= 0.99) {
block.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${item.typeId} 0 1`)
}
} else {
if (item?.typeId === "os:philosopher_stone" && player?.hasTag("os:mage3")) {
player.runCommandAsync(`playsound note.bass @s ~~~ 1 1 1`)
}
}
}
//Gravity Book
if (player.isSneaking && item.typeId === "os:gravity_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
player.addEffect("levitation", 20, { amplifier: 8, showParticles: false })
}
if (item.typeId === "os:gravity_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage") && !player.isSneaking) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.addEffect("levitation", 20, { amplifier: 8, showParticles: false })
}
)
}
if (player.isSneaking && item.typeId === "os:gravity_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
player.addEffect("levitation", 20, { amplifier: 8, showParticles: false })
}
if (item.typeId === "os:gravity_book" && offitem?.typeId === "os:philosopher_stone" && !player.isSneaking && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.addEffect("levitation", 20, { amplifier: 8, showParticles: false })
}
)
}
if (player.isSneaking && item.typeId === "os:gravity_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.50) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
player.addEffect("levitation", 20, { amplifier: 24, showParticles: false })
}
if (item.typeId === "os:gravity_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1") && !player.isSneaking) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.50) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.addEffect("levitation", 20, { amplifier: 24, showParticles: false })
}
)
}
if (player.isSneaking && item.typeId === "os:gravity_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
player.addEffect("levitation", 20, { amplifier: 30, showParticles: false })
}
if (item.typeId === "os:gravity_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2") && !player.isSneaking) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.addEffect("levitation", 20, { amplifier: 30, showParticles: false })
}
)
}
if (player.isSneaking && item.typeId === "os:gravity_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
player.addEffect("levitation", 20, { amplifier: 45, showParticles: false })
}
if (item.typeId === "os:gravity_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3") && !player.isSneaking) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 25, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.addEffect("levitation", 20, { amplifier: 45, showParticles: false })
}
)
}
//lighting book
if (item.typeId === "os:lightning_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 20, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.dimension.playSound("beacon.activate", entities.location, { volume: 1, pitch: 1.9 })
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 30)
}, 1)
system.runTimeout(() => {
entities.dimension.spawnEntity("minecraft:lightning_bolt", entities.location)
entities.runCommandAsync(`damage @s 5 entity_attack entity ${player.nameTag}`)
}, 30)
}
)
}
if (item.typeId === "os:lightning_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 20, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.dimension.playSound("beacon.activate", entities.location, { volume: 1, pitch: 1.9 })
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 30)
}, 1)
system.runTimeout(() => {
entities.dimension.spawnEntity("minecraft:lightning_bolt", entities.location)
entities.runCommandAsync(`damage @s 5 entity_attack entity ${player.nameTag}`)
}, 30)
}
)
}
if (item.typeId === "os:lightning_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.50) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 20, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.dimension.playSound("beacon.activate", entities.location, { volume: 1, pitch: 1.9 })
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 30)
}, 1)
system.runTimeout(() => {
entities.dimension.spawnEntity("minecraft:lightning_bolt", entities.location)
entities.runCommandAsync(`damage @s 10 entity_attack entity ${player.nameTag}`)
}, 30)
}
)
}
if (item.typeId === "os:lightning_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 20, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.dimension.playSound("beacon.activate", entities.location, { volume: 1, pitch: 1.9 })
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 30)
}, 1)
system.runTimeout(() => {
entities.dimension.spawnEntity("minecraft:lightning_bolt", entities.location)
entities.runCommandAsync(`damage @s 53 entity_attack entity ${player.nameTag}`)
}, 30)
}
)
}
if (item.typeId === "os:lightning_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 20, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.dimension.playSound("beacon.activate", entities.location, { volume: 1, pitch: 1.9 })
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:electric_spark_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 30)
}, 1)
system.runTimeout(() => {
entities.dimension.spawnEntity("minecraft:lightning_bolt", entities.location)
entities.runCommandAsync(`damage @s 50 entity_attack entity ${player.nameTag}`)
}, 30)
}
)
}
//soul blast book
if (item.typeId === "os:soul_blast_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 23 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 2, Math.random() * 2, Math.random() * 2, Math.random() * 2)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random(), z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y + 0.5 - Math.random(), z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 5)
}, 1)
}
)
}
if (item.typeId === "os:soul_blast_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 23 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 2, Math.random() * 2, Math.random() * 2, Math.random() * 2)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random(), z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y + 0.5 - Math.random(), z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 5)
}, 1)
}
)
}
if (item.typeId === "os:soul_blast_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 7, pitch: 1.9 })
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 60 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 4, Math.random() * 4, Math.random() * 4, Math.random() * 4)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random(), z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y + 0.5 - Math.random(), z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 10)
}, 1)
}
)
}
if (item.typeId === "os:soul_blast_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 9, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 170 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 6, Math.random() * 6, Math.random() * 6, Math.random() * 6)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random(), z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y + 0.5 - Math.random(), z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 15)
}, 1)
}
)
}
if (item.typeId === "os:soul_blast_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 11, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 210 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 8, Math.random() * 8, Math.random() * 8, Math.random() * 8)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random(), z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:soul_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y + 0.5 - Math.random(), z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 20)
}, 1)
}
)
}
//clear weather book
if (item.typeId === "os:clear_weather_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.setWeather("Clear", 900)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:clear_weather_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.setWeather("clear", 1300)
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:clear_weather_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.setWeather("clear", 3000)
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:clear_weather_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.setWeather("clear", 9000)
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:clear_weather_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.setWeather("clear", 1300)
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
//healing book
if (item.typeId === "os:healing_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 5, type: "minecraft:player" }).forEach(event => {
const entity2 = event
entity2.addEffect("instant_health", 1, { amplifier: 1, showParticles: false })
const plapart = system.runInterval(() => {
entity2.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random(), y: player.location.y + 0.5 + Math.random(), z: player.location.z + Math.random() })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
})
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:healing_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 7, type: "minecraft:player" }).forEach(event => {
const entity2 = event
entity2.addEffect("instant_health", 1, { amplifier: 3, showParticles: false })
const plapart = system.runInterval(() => {
entity2.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random(), y: player.location.y + 0.5 + Math.random(), z: player.location.z + Math.random() })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
})
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:healing_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 9, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 8, type: "minecraft:player" }).forEach(event => {
const entity2 = event
entity2.addEffect("instant_health", 1, { amplifier: 5, showParticles: false })
const plapart = system.runInterval(() => {
entity2.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random(), y: player.location.y + 0.5 + Math.random(), z: player.location.z + Math.random() })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
})
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:healing_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 11, type: "minecraft:player" }).forEach(event => {
const entity2 = event
entity2.addEffect("instant_health", 1, { amplifier: 7, showParticles: false })
const plapart = system.runInterval(() => {
entity2.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random(), y: player.location.y + 0.5 + Math.random(), z: player.location.z + Math.random() })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
})
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:healing_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 5, type: "minecraft:player" }).forEach(event => {
const entity2 = event
entity2.addEffect("instant_health", 1, { amplifier: 1, showParticles: false })
const plapart = system.runInterval(() => {
entity2.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random(), y: player.location.y + 0.5 + Math.random(), z: player.location.z + Math.random() })
system.runTimeout(() => {
system.clearRun(plapart)
}, 10)
}, 1)
})
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
//Ice book
if (item.typeId === "os:ice_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
if (!entities.getEffect("slowness")) {
entities.addEffect("slowness", 100, { amplifier: 1, showParticles: false })
}
const entdamtick = system.runInterval(() => {
let parchance = Math.random()
entities.runCommandAsync(`damage @s 1 freezing`)
if (parchance <= 0.49) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x + Math.random() * 1.2, y: entities.location.y + Math.random(), z: entities.location.z + Math.random() * 1.2 })
}
if (parchance >= 0.50) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x - Math.random() * 1.2, y: entities.location.y - Math.random(), z: entities.location.z - Math.random() * 1.2 })
}
if (entities.getComponent("minecraft:health").currentValue <= 0) {
system.clearRun(entdamtick)
} else {
system.runTimeout(() => {
system.clearRun(entdamtick)
}, 100)
}
}, 15)
})
}
if (item.typeId === "os:ice_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
if (!entities.getEffect("slowness")) {
entities.addEffect("slowness", 100, { amplifier: 1, showParticles: false })
}
const entdamtick = system.runInterval(() => {
let parchance = Math.random()
entities.runCommandAsync(`damage @s 1 freezing`)
if (parchance <= 0.49) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x + Math.random() * 1.2, y: entities.location.y + Math.random(), z: entities.location.z + Math.random() * 1.2 })
}
if (parchance >= 0.50) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x - Math.random() * 1.2, y: entities.location.y - Math.random(), z: entities.location.z - Math.random() * 1.2 })
}
if (entities.getComponent("minecraft:health").currentValue <= 0) {
system.clearRun(entdamtick)
} else {
system.runTimeout(() => {
system.clearRun(entdamtick)
}, 100)
}
}, 15)
})
}
if (item.typeId === "os:ice_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
if (!entities.getEffect("slowness")) {
entities.addEffect("slowness", 200, { amplifier: 3, showParticles: false })
}
const entdamtick = system.runInterval(() => {
let parchance = Math.random()
entities.runCommandAsync(`damage @s 1 freezing`)
if (parchance <= 0.49) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x + Math.random() * 1.2, y: entities.location.y + Math.random(), z: entities.location.z + Math.random() * 1.2 })
}
if (parchance >= 0.50) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x - Math.random() * 1.2, y: entities.location.y - Math.random(), z: entities.location.z - Math.random() * 1.2 })
}
if (entities.getComponent("minecraft:health").currentValue <= 0) {
system.clearRun(entdamtick)
} else {
system.runTimeout(() => {
system.clearRun(entdamtick)
}, 200)
}
}, 10)
})
}
if (item.typeId === "os:ice_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
if (!entities.getEffect("slowness")) {
entities.addEffect("slowness", 300, { amplifier: 5, showParticles: false })
}
const entdamtick = system.runInterval(() => {
let parchance = Math.random()
entities.runCommandAsync(`damage @s 1 freezing`)
if (parchance <= 0.49) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x + Math.random() * 1.2, y: entities.location.y + Math.random(), z: entities.location.z + Math.random() * 1.2 })
}
if (parchance >= 0.50) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x - Math.random() * 1.2, y: entities.location.y - Math.random(), z: entities.location.z - Math.random() * 1.2 })
}
if (entities.getComponent("minecraft:health").currentValue <= 0) {
system.clearRun(entdamtick)
} else {
system.runTimeout(() => {
system.clearRun(entdamtick)
}, 300)
}
}, 5)
})
}
if (item.typeId === "os:ice_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 20, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
if (!entities.getEffect("slowness")) {
entities.addEffect("slowness", 400, { amplifier: 7, showParticles: false })
}
const entdamtick = system.runInterval(() => {
let parchance = Math.random()
entities.runCommandAsync(`damage @s 1 freezing`)
if (parchance <= 0.49) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x + Math.random() * 1.2, y: entities.location.y + Math.random(), z: entities.location.z + Math.random() * 1.2 })
}
if (parchance >= 0.50) {
entities.dimension.spawnParticle("minecraft:snowflake_particle", { x: entities.location.x - Math.random() * 1.2, y: entities.location.y - Math.random(), z: entities.location.z - Math.random() * 1.2 })
}
if (entities.getComponent("minecraft:health").currentValue <= 0) {
system.clearRun(entdamtick)
} else {
system.runTimeout(() => {
system.clearRun(entdamtick)
}, 400)
}
}, 1)
})
}
//leech Book
if (item.typeId === "os:leech_books" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 10 entity_attack entity ${player.nameTag}`)
player.addEffect("instant_health", 1, { amplifier: 1, showParticles: false })
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random() * 1.5, y: player.location.y + 1 + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x - Math.random() * 1.5, y: player.location.y + 1 - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 20)
}, 5)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - 0.5 + Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 20)
}, 1)
}
)
}
if (item.typeId === "os:leech_books" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 10 entity_attack entity ${player.nameTag}`)
player.addEffect("instant_health", 1, { amplifier: 1, showParticles: false })
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random() * 1.5, y: player.location.y + 1 + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x - Math.random() * 1.5, y: player.location.y + 1 - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 20)
}, 5)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - 0.5 + Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 20)
}, 1)
}
)
}
if (item.typeId === "os:leech_books" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 6, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 20 entity_attack entity ${player.nameTag}`)
player.addEffect("instant_health", 1, { amplifier: 2, showParticles: false })
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random() * 1.5, y: player.location.y + 1 + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x - Math.random() * 1.5, y: player.location.y + 1 - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 20)
}, 5)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - 0.5 + Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 20)
}, 1)
}
)
}
if (item.typeId === "os:leech_books" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 8, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 30 entity_attack entity ${player.nameTag}`)
player.addEffect("instant_health", 1, { amplifier: 3, showParticles: false })
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random() * 1.5, y: player.location.y + 1 + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x - Math.random() * 1.5, y: player.location.y + 1 - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 20)
}, 5)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - 0.5 + Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 20)
}, 1)
}
)
}
if (item.typeId === "os:leech_books" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 40 entity_attack entity ${player.nameTag}`)
player.addEffect("instant_health", 1, { amplifier: 4, showParticles: false })
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x + Math.random() * 1.5, y: player.location.y + 1 + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:heart_particle", { x: player.location.x - Math.random() * 1.5, y: player.location.y + 1 - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 20)
}, 5)
const entpar = system.runInterval(() => {
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x + Math.random() * 1.5, y: entities.location.y + 0.5 + Math.random() * 1.5, z: entities.location.z + Math.random() * 1.5 })
entities.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: entities.location.x - Math.random() * 1.5, y: entities.location.y - 0.5 + Math.random() * 1.5, z: entities.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(entpar)
}, 20)
}, 1)
}
)
}
//combustion_book
if (item.typeId === "os:combustion_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 5, pitch: 1 })
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 13 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 4, Math.random() * 4, Math.random() * 4, Math.random() * 4)
}
)
}
if (item.typeId === "os:combustion_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 5, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 5, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 13 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 4, Math.random() * 4, Math.random() * 4, Math.random() * 4)
}
)
}
if (item.typeId === "os:combustion_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 7, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 10, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 40 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 6, Math.random() * 6, Math.random() * 6, Math.random() * 6)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
}
)
}
if (item.typeId === "os:combustion_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 5, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 9, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 120 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 8, Math.random() * 8, Math.random() * 8, Math.random() * 8)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
}
)
}
if (item.typeId === "os:combustion_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("cauldron.explode", player.location, { volume: 5, pitch: 1 })
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
world.getDimension(player.dimension.id).getEntities({ maxDistance: 11, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
entities.runCommandAsync(`damage @s 170 entity_attack entity ${player.nameTag}`)
entities.applyKnockback(Math.random() * 12, Math.random() * 12, Math.random() * 12, Math.random() * 12)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
player.dimension.spawnParticle("minecraft:huge_explosion_emitter", player.location)
}
)
}
//Stone Book
if (item.typeId === "os:stone_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
const blockpos = [1, 2, 3, 4, 5]
blockpos.forEach(event => {
system.runTimeout(() => {
const blockf = player.getBlockFromViewDirection({ maxDistance: event, includeLiquidBlocks: false, includePassableBlocks: false })?.block
if (blockf?.typeId.includes("stone") || blockf?.hasTag("stone") || blockf?.typeId.includes("slate") || blockf?.typeId.includes("ore")) {
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.runCommandAsync(`execute positioned ${blockf.location.x} ${blockf.location.y} ${blockf.location.z} run fill ~-1~-1~-1 ~1~1~1 air destroy`)
}
}, event * 0.8)
})
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
const blockpos = [1, 2, 3, 4, 5]
blockpos.forEach(event => {
system.runTimeout(() => {
const blockf = player.getBlockFromViewDirection({ maxDistance: event, includeLiquidBlocks: false, includePassableBlocks: false })?.block
if (blockf?.typeId.includes("stone") || blockf?.hasTag("stone") || blockf?.typeId.includes("slate") || blockf?.typeId.includes("ore")) {
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.runCommandAsync(`execute positioned ${blockf.location.x} ${blockf.location.y} ${blockf.location.z} run fill ~-1~-1~-1 ~1~1~1 air destroy`)
}
}, event * 0.8)
})
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
const blockpos = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
blockpos.forEach(event => {
system.runTimeout(() => {
const blockf = player.getBlockFromViewDirection({ maxDistance: event, includeLiquidBlocks: false, includePassableBlocks: false })?.block
if (blockf?.typeId.includes("stone") || blockf?.hasTag("stone") || blockf?.typeId.includes("slate") || blockf?.typeId.includes("ore")) {
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.runCommandAsync(`execute positioned ${blockf.location.x} ${blockf.location.y} ${blockf.location.z} run fill ~-2~-2~-2 ~2~2~2 air destroy`)
}
}, event * 0.8)
})
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
const blockpos = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
blockpos.forEach(event => {
system.runTimeout(() => {
const blockf = player.getBlockFromViewDirection({ maxDistance: event, includeLiquidBlocks: false, includePassableBlocks: false })?.block
if (blockf?.typeId.includes("stone") || blockf?.hasTag("stone") || blockf?.typeId.includes("slate") || blockf?.typeId.includes("ore")) {
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.runCommandAsync(`execute positioned ${blockf.location.x} ${blockf.location.y} ${blockf.location.z} run fill ~-2~-2~-2 ~2~2~2 air destroy`)
}
}, event * 0.8)
})
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
const blockpos = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
blockpos.forEach(event => {
system.runTimeout(() => {
const blockf = player.getBlockFromViewDirection({ maxDistance: event, includeLiquidBlocks: false, includePassableBlocks: true })?.block
if (!blockf?.isAir) {
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension?.spawnParticle("minecraft:explosion_particle", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.spawnParticle("minecraft:villager_happy", { x: blockf.location.x + Math.random(), y: blockf.location.y + Math.random(), z: blockf.location.z + Math.random() })
blockf?.dimension.runCommandAsync(`execute positioned ${blockf.location.x} ${blockf.location.y} ${blockf.location.z} run fill ~-2~-2~-2 ~2~2~2 air destroy`)
}
}, event * 0.8)
})
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
//stone skin book
if (item.typeId === "os:stone_skin_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 5, type: "minecraft:player" }).forEach(event => {
const entity2 = event
if (!entity2?.getEffect("resistance") || entity2?.getEffect("resistance")?.amplifier != 0) {
entity2.addEffect("resistance", 100, { amplifier: 0, showParticles: false })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
system.runTimeout(() => {
player.dimension.playSound("block.grindstone.use", entity2.location, { volume: 1, pitch: 0.2 })
}, 15)
}
})
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_skin_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 7, type: "minecraft:player" }).forEach(event => {
const entity2 = event
if (!entity2?.getEffect("resistance") || entity2?.getEffect("resistance")?.amplifier != 0) {
entity2.addEffect("resistance", 100, { amplifier: 0, showParticles: false })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
system.runTimeout(() => {
player.dimension.playSound("block.grindstone.use", entity2.location, { volume: 1, pitch: 0.2 })
}, 15)
}
})
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_skin_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 9, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 8, type: "minecraft:player" }).forEach(event => {
const entity2 = event
if (!entity2?.getEffect("resistance") || entity2?.getEffect("resistance")?.amplifier != 1) {
entity2.addEffect("resistance", 200, { amplifier: 1, showParticles: false })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
system.runTimeout(() => {
player.dimension.playSound("block.grindstone.use", entity2.location, { volume: 1, pitch: 0.2 })
}, 15)
}
})
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_skin_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 11, type: "minecraft:player" }).forEach(event => {
const entity2 = event
if (!entity2?.getEffect("resistance") || entity2?.getEffect("resistance")?.amplifier != 2) {
entity2.addEffect("resistance", 300, { amplifier: 2, showParticles: false })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
system.runTimeout(() => {
player.dimension.playSound("block.grindstone.use", entity2.location, { volume: 1, pitch: 0.2 })
}, 15)
}
})
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:stone_skin_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.dimension.getEntities({ location: player.location, maxDistance: 5, type: "minecraft:player" }).forEach(event => {
const entity2 = event
if (!entity2?.getEffect("resistance") || entity2?.getEffect("resistance")?.amplifier != 3) {
entity2.addEffect("resistance", 400, { amplifier: 3, showParticles: false })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
entity2.dimension.spawnParticle("minecraft:falling_dust_gravel_particle", { x: player.location.x + Math.random(), y: player.location.y + 2, z: player.location.z + Math.random() })
system.runTimeout(() => {
player.dimension.playSound("block.grindstone.use", entity2.location, { volume: 1, pitch: 0.2 })
}, 15)
}
})
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
//barrier wall book
if (item.typeId === "os:mud_wall_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`fill ^-1^-2^4 ^1^2^4 barrier replace air`).then(event => {
if (event.successCount == 1) {
const block = player.getBlockFromViewDirection({ maxDistance: 7 })?.block
if (block?.typeId === "minecraft:barrier") {
if (block && block?.typeId === "minecraft:barrier") {
const blockint = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x + Math.random() * 2, y: block.location.y + Math.random() * 2, z: block.location.z + Math.random() * 2 })
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x - Math.random() * 2, y: block.location.y - Math.random() * 4, z: block.location.z - Math.random() * 2 })
if (block?.isAir) {
system.clearRun(blockint)
}
}, 10)
}
system.runTimeout(() => {
block?.dimension.playSound("beacon.deactivate", block?.location, { volume: 1, pitch: 2 })
block?.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run fill ~-4~-5~-4 ~4~5~4 air replace barrier`)
const blockpar = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x + Math.random() * 3, y: block.location.y + Math.random() * 3, z: block.location.z + Math.random() * 3 })
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x - Math.random() * 3, y: block.location.y - Math.random() * 3, z: block.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(blockpar)
}, 20)
}, 1)
}, 250)
}
}
})
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:mud_wall_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`fill ^-1^-2^4 ^1^2^4 barrier replace air`).then(event => {
if (event.successCount == 1) {
const block = player.getBlockFromViewDirection({ maxDistance: 7 })?.block
if (block?.typeId === "minecraft:barrier") {
if (block && block?.typeId === "minecraft:barrier") {
const blockint = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x + Math.random() * 2, y: block.location.y + Math.random() * 2, z: block.location.z + Math.random() * 2 })
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x - Math.random() * 2, y: block.location.y - Math.random() * 4, z: block.location.z - Math.random() * 2 })
if (block?.isAir) {
system.clearRun(blockint)
}
}, 10)
}
system.runTimeout(() => {
block?.dimension.playSound("beacon.deactivate", block?.location, { volume: 1, pitch: 2 })
block?.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run fill ~-4~-5~-4 ~4~5~4 air replace barrier`)
const blockpar = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x + Math.random() * 3, y: block.location.y + Math.random() * 3, z: block.location.z + Math.random() * 3 })
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x - Math.random() * 3, y: block.location.y - Math.random() * 3, z: block.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(blockpar)
}, 20)
}, 1)
}, 250)
}
}
})
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item?.typeId === "os:mud_wall_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`fill ^-2^-2^4 ^2^2^4 barrier replace air`).then(event => {
if (event.successCount == 1) {
const block = player.getBlockFromViewDirection({ maxDistance: 7 })?.block
if (block?.typeId === "minecraft:barrier") {
if (block && block?.typeId === "minecraft:barrier") {
const blockint = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x + Math.random() * 2, y: block.location.y + Math.random() * 2, z: block.location.z + Math.random() * 2 })
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x - Math.random() * 2, y: block.location.y - Math.random() * 4, z: block.location.z - Math.random() * 2 })
if (block?.isAir) {
system.clearRun(blockint)
}
}, 10)
}
system.runTimeout(() => {
block?.dimension.playSound("beacon.deactivate", block?.location, { volume: 1, pitch: 2 })
block?.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run fill ~-6~-5~-6 ~6~5~6 air replace barrier`)
const blockpar = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x + Math.random() * 3, y: block.location.y + Math.random() * 3, z: block.location.z + Math.random() * 3 })
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x - Math.random() * 3, y: block.location.y - Math.random() * 3, z: block.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(blockpar)
}, 20)
}, 1)
}, 250)
}
}
})
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:mud_wall_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 9, pitch: 1.9 })
player.runCommandAsync(`fill ^-2^-3^4 ^2^3^4 barrier replace air`).then(event => {
if (event.successCount == 1) {
const block = player.getBlockFromViewDirection({ maxDistance: 7 })?.block
if (block?.typeId === "minecraft:barrier") {
if (block && block?.typeId === "minecraft:barrier") {
const blockint = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x + Math.random() * 2, y: block.location.y + Math.random() * 2, z: block.location.z + Math.random() * 2 })
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x - Math.random() * 2, y: block.location.y - Math.random() * 4, z: block.location.z - Math.random() * 2 })
if (block?.isAir) {
system.clearRun(blockint)
}
}, 10)
}
system.runTimeout(() => {
block?.dimension.playSound("beacon.deactivate", block?.location, { volume: 1, pitch: 2 })
block?.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run fill ~-6~-7~-6 ~6~7~6 air replace barrier`)
const blockpar = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x + Math.random() * 3, y: block.location.y + Math.random() * 3, z: block.location.z + Math.random() * 3 })
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x - Math.random() * 3, y: block.location.y - Math.random() * 3, z: block.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(blockpar)
}, 20)
}, 1)
}, 250)
}
}
})
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:mud_wall_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`fill ^-3^-4^4 ^3^4^4 barrier replace air`).then(event => {
if (event.successCount == 1) {
const block = player.getBlockFromViewDirection({ maxDistance: 7 })?.block
if (block?.typeId === "minecraft:barrier") {
if (block && block?.typeId === "minecraft:barrier") {
const blockint = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x + Math.random() * 2, y: block.location.y + Math.random() * 2, z: block.location.z + Math.random() * 2 })
block.dimension.spawnParticle("minecraft:rising_border_dust_particle", { x: block.location.x - Math.random() * 2, y: block.location.y - Math.random() * 4, z: block.location.z - Math.random() * 2 })
if (block?.isAir) {
system.clearRun(blockint)
}
}, 10)
}
system.runTimeout(() => {
block?.dimension.playSound("beacon.deactivate", block?.location, { volume: 1, pitch: 2 })
block?.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run fill ~-6~-9~-6 ~6~9~6 air replace barrier`)
const blockpar = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x + Math.random() * 3, y: block.location.y + Math.random() * 3, z: block.location.z + Math.random() * 3 })
block.dimension.spawnParticle("minecraft:elephant_tooth_paste_vapor_particle", { x: block.location.x - Math.random() * 3, y: block.location.y - Math.random() * 3, z: block.location.z - Math.random() * 3 })
system.runTimeout(() => {
system.clearRun(blockpar)
}, 20)
}, 1)
}, 250)
}
}
})
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
// Rivivify Book
if (item.typeId === "os:rivivify_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync("effect @s resistance 5 255 true")
player.runCommandAsync("effect @s instant_health 1 255 true")
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x + Math.random() * 1.5, y: player.location.y + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x - Math.random() * 1.5, y: player.location.y - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 20)
}, 100)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:rivivify_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync("effect @s resistance 5 255 true")
player.runCommandAsync("effect @s instant_health 1 255 true")
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x + Math.random() * 1.5, y: player.location.y + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x - Math.random() * 1.5, y: player.location.y - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 100)
}, 10)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item?.typeId === "os:rivivify_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 10, pitch: 1.9 })
player.runCommandAsync("effect @s resistance 10 255 true")
player.runCommandAsync("effect @s instant_health 1 255 true")
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x + Math.random() * 1.5, y: player.location.y + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x - Math.random() * 1.5, y: player.location.y - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 200)
}, 10)
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:rivivify_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 9, pitch: 1.9 })
player.runCommandAsync("effect @s resistance 15 255 true")
player.runCommandAsync("effect @s instant_health 1 255 true")
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x + Math.random() * 1.5, y: player.location.y + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x - Math.random() * 1.5, y: player.location.y - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 300)
}, 10)
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:rivivify_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync("effect @s resistance 20 255 true")
player.runCommandAsync("effect @s instant_health 1 255 true")
const plapar = system.runInterval(() => {
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x + Math.random() * 1.5, y: player.location.y + Math.random() * 1.5, z: player.location.z + Math.random() * 1.5 })
player.dimension.spawnParticle("minecraft:villager_happy", { x: player.location.x - Math.random() * 1.5, y: player.location.y - Math.random() * 1.5, z: player.location.z - Math.random() * 1.5 })
system.runTimeout(() => {
system.clearRun(plapar)
}, 400)
}, 10)
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "minecraft:stick") {
const block = player.getBlockFromViewDirection({ maxDistance: 7 }).block
world.sendMessage(`the tags are ${block.getTags()} the identifier is ${block.typeId}`)
}
// Soul Dart Book
if (item.typeId === "os:soul_dart" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, type: "os:soul_dart", location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 300)
}
)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:soul_dart" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, type: "os:soul_dart", location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 300)
}
)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item?.typeId === "os:soul_dart" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 10, pitch: 1.9 })
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage1`)
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage1`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, type: "os:soul_dart", location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 300)
}
)
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:soul_dart" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 9, pitch: 1.9 })
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage2`)
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage2`)
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage2`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, type: "os:soul_dart", location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 300)
}
)
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:soul_dart" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:soul_dart ~~~ 0 0 mage3`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, type: "os:soul_dart", location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 300)
}
)
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "minecraft:stick") {
const block = player.getBlockFromViewDirection({ maxDistance: 7 }).block
world.sendMessage(`the tags are ${block.getTags()} the identifier is ${block.typeId}`)
}
//Necromancy Book
if (item.typeId === "os:necromancy_book" && offitem?.typeId === "os:philosopher_stone" && !player.hasTag("os:mage") && !player.hasTag("os:mage1") && !player.hasTag("os:mage2") && !player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, families: ["summon"], location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 600)
}
)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:necromancy_book" && offitem?.typeId === "os:magic_stone" && player.hasTag("os:mage")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, families: ["summon"], location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 600)
}
)
if (chance >= 0.25) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item?.typeId === "os:necromancy_book" && offitem?.typeId === "os:power_stone" && player.hasTag("os:mage1")) {
player.dimension.playSound("beacon.power", player.location, { volume: 10, pitch: 1.9 })
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage1`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage1`)
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage1`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage1`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, families: ["summon"], location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 600)
}
)
if (chance >= 0.5) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:necromancy_book" && offitem?.typeId === "os:alchemical_stone" && player.hasTag("os:mage2")) {
player.dimension.playSound("beacon.power", player.location, { volume: 9, pitch: 1.9 })
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage2`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage2`)
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage2`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage2`)
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage2`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage2`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, families: ["summon"], location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 600)
}
)
if (chance >= 0.75) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
if (item.typeId === "os:necromancy_book" && offitem?.typeId === "os:philosopher_stone" && player.hasTag("os:mage3")) {
player.dimension.playSound("beacon.power", player.location, { volume: 5, pitch: 1.9 })
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:zombie_summon ~~~ 0 0 mage3`)
player.runCommandAsync(`summon os:skeleton_summon ~~~ 0 0 mage3`)
world.getDimension(player.dimension.id).getEntities({ maxDistance: 15, location: player.location, excludeTags: [`os:peace`], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(event => {
const entities = event
const dartcheck = system.runInterval(() => {
player.dimension.getEntities({ maxDistance: 20, families: ["summon"], location: player.location, excludeTags: ["os:attack1"] }).forEach(dart => {
dart.dimension.getEntities({ maxDistance: 15, location: dart.location, excludeTags: [`os:peace`, "os:attack1"], excludeNames: [`${player.nameTag}`], excludeTypes: ["minecraft:item", "minecraft:xp_orb", "minecraft:lightning_bolt"], excludeFamilies: ["inanimate"] }).forEach(darte => {
darte.addTag("os:attack1")
})
})
}, 1)
system.runTimeout(() => {
entities?.removeTag("os:attack1")
system.clearRun(dartcheck)
}, 600)
}
)
if (chance >= 0.99) {
player.dimension.playSound("random.break", player.location, { volume: 1, pitch: 1 })
player.runCommandAsync(`clear @s ${offitem.typeId} 0 1`)
}
}
})
17:
//This script creates a treecapitator function for players. Whenever an item spawns and as long as their is a player within 100 blocks of the item that is currently sneaking and holding any item that has the tag minecraft:is_axe then this script will create a timer that waits a random amount of ticks until it breaks a block beside where the item spawned originally if the block has a specific tag.
import { system, world } from "@minecraft/server";
world.afterEvents.entitySpawn.subscribe(event => {
const entity = event.entity
if (entity?.typeId === "minecraft:lightning_bolt") {
const block = entity?.dimension.getBlock({ x: entity.location.x, y: entity.location.y - 1, z: entity.location.z })
let chance = Math.random()
if (block?.typeId === "minecraft:sand") {
entity?.runCommandAsync(`fill ~-5~-5~-5 ~5~5~5 minecraft:glass replace minecraft:sand`)
}
if (chance <= 0.6 && block?.typeId === "minecraft:stone") {
entity?.runCommandAsync(`fill ~-1~-1~-1 ~1~1~1 os:electrum_ore replace stone`)
} else {
if (block?.typeId === "minecraft:stone") {
entity?.runCommandAsync(`fill ~-1~-1~-1 ~1~1~1 os:tonitruum_ore replace stone`)
}
}
}
if (entity?.typeId === "minecraft:item") {
const players = entity?.dimension?.getEntities({ location: entity.location, maxDistance: 100, type: "minecraft:player", closest: true })?.forEach(event => {
const player = event
const item = player?.getComponent("minecraft:equippable").getEquipment("Mainhand")
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking) {
const block = entity?.dimension?.getBlock(entity.location)
const blockabove = block?.above(1)
const blockbelow = block?.below(1)
const blockeast = block?.east(1)
const blockwest = block?.west(1)
const blocknorth = block?.north(1)
const blockne = block?.north(1).east(1)
const blocknw = block?.north(1).west(1)
const blocksw = block?.south(1).west(1)
const blockan = block.above(1).north(1)
const blockas = block.above(1).south(1)
const blockane = blockabove.north(1).east(1)
const blockanw = blockabove.north(1).west(1)
const blockase = blockabove.south(1).east(1)
const blockasw = blockabove.south(1).west(1)
const blockbn = blockbelow.north(1)
const blockbs = blockbelow.south(1)
const blockbne = blockbelow.north(1).east(1)
const blockbnw = blockbelow.north(1).west(1)
const blockbse = blockbelow.south(1).east(1)
const blockbsw = blockbelow.south(1).west(1)
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (block?.typeId.includes("log") || block?.typeId.includes("magic_wood") || block?.typeId.includes("magic_leaves")) {
block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockabove?.typeId.includes("log") || blockabove?.typeId.includes("magic_wood") || blockabove?.typeId.includes("magic_leaves")) {
blockabove.dimension.runCommandAsync(`execute positioned ${blockabove.location.x} ${blockabove.location.y} ${blockabove.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockbelow?.typeId.includes("log") || blockbelow?.typeId.includes("magic_wood") || blockbelow?.typeId.includes("magic_leaves")) {
blockabove.dimension.runCommandAsync(`execute positioned ${blockbelow.location.x} ${blockbelow.location.y} ${blockbelow.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockeast?.typeId.includes("log") || blockeast?.typeId.includes("magic_wood") || blockeast?.typeId.includes("magic_leaves")) {
blockeast.dimension.runCommandAsync(`execute positioned ${blockeast.location.x} ${blockeast.location.y} ${blockeast.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockwest?.typeId.includes("log") || blockwest?.typeId.includes("magic_wood") || blockwest?.typeId.includes("magic_leaves")) {
blockwest.dimension.runCommandAsync(`execute positioned ${blockwest.location.x} ${blockwest.location.y} ${blockwest.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blocknorth?.typeId.includes("log") || blocknorth?.typeId.includes("magic_wood") || blocknorth?.typeId.includes("magic_leaves")) {
blocknorth.dimension.runCommandAsync(`execute positioned ${blocknorth.location.x} ${blocknorth.location.y} ${blocknorth.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockne?.typeId.includes("log") || blockan?.typeId.includes("magic_wood") || blockan?.typeId.includes("magic_leaves")) {
blockne.dimension.runCommandAsync(`execute positioned ${blockne.location.x} ${blockne.location.y} ${blockne.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blocknw?.typeId.includes("log") || blocknw?.typeId.includes("magic_wood") || blocknw?.typeId.includes("magic_leaves")) {
blocknw.dimension.runCommandAsync(`execute positioned ${blocknw.location.x} ${blocknw.location.y} ${blocknw.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blocksw?.typeId.includes("log") || blocksw?.typeId.includes("magic_wood") || blocksw?.typeId.includes("magic_leaves")) {
blocksw.dimension.runCommandAsync(`execute positioned ${blocksw.location.x} ${blocksw.location.y} ${blocksw.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockan?.typeId.includes("log") || blockan?.typeId.includes("magic_wood") || blockan?.typeId.includes("magic_leaves")) {
blockan.dimension.runCommandAsync(`execute positioned ${blockan.location.x} ${blockan.location.y} ${blockan.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockas?.typeId.includes("log") || blockas?.typeId.includes("magic_wood") || blockas?.typeId.includes("magic_leaves")) {
blockas.dimension.runCommandAsync(`execute positioned ${blockas.location.x} ${blockas.location.y} ${blockas.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockane?.typeId.includes("log") || blockane?.typeId.includes("magic_wood") || blockane?.typeId.includes("magic_leaves")) {
blockane.dimension.runCommandAsync(`execute positioned ${blockane.location.x} ${blockane.location.y} ${blockane.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockanw?.typeId.includes("log") || blockanw?.typeId.includes("magic_wood") || blockanw?.typeId.includes("magic_leaves")) {
blockanw.dimension.runCommandAsync(`execute positioned ${blockanw.location.x} ${blockanw.location.y} ${blockanw.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockase?.typeId.includes("log") || blockase?.typeId.includes("magic_wood") || blockase?.typeId.includes("magic_leaves")) {
blockase.dimension.runCommandAsync(`execute positioned ${blockase.location.x} ${blockase.location.y} ${blockase.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockasw?.typeId.includes("log") || blockasw?.typeId.includes("magic_wood") || blockasw?.typeId.includes("magic_leaves")) {
blockasw.dimension.runCommandAsync(`execute positioned ${blockasw.location.x} ${blockasw.location.y} ${blockasw.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockbn?.typeId.includes("log") || blockbn?.typeId.includes("magic_wood") || blockbn?.typeId.includes("magic_leaves")) {
blockbn.dimension.runCommandAsync(`execute positioned ${blockbn.location.x} ${blockbn.location.y} ${blockbn.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockbs?.typeId.includes("log") || blockbs?.typeId.includes("magic_wood") || blockbs?.typeId.includes("magic_leaves")) {
blockbs.dimension.runCommandAsync(`execute positioned ${blockbs.location.x} ${blockbs.location.y} ${blockbs.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockbne?.typeId.includes("log") || blockbne?.typeId.includes("magic_wood") || blockbne?.typeId.includes("magic_leaves")) {
blockbne.dimension.runCommandAsync(`execute positioned ${blockbne.location.x} ${blockbne.location.y} ${blockbne.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockbnw?.typeId.includes("log") || blockbnw?.typeId.includes("magic_wood") || blockbnw?.typeId.includes("magic_leaves")) {
blockbnw.dimension.runCommandAsync(`execute positioned ${blockbnw.location.x} ${blockbnw.location.y} ${blockbnw.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockbse?.typeId.includes("log") || blockbse?.typeId.includes("magic_wood") || blockbse?.typeId.includes("magic_leaves")) {
blockbse.dimension.runCommandAsync(`execute positioned ${blockbse.location.x} ${blockbse.location.y} ${blockbse.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
system.runTimeout(() => {
if (item?.hasTag("minecraft:is_axe") && player?.isSneaking && block) {
if (blockbsw?.typeId.includes("log") || blockbsw?.typeId.includes("magic_wood") || blockbsw?.typeId.includes("magic_leaves")) {
blockbsw.dimension.runCommandAsync(`execute positioned ${blockbsw.location.x} ${blockbsw.location.y} ${blockbsw.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}, Math.random() / Math.random() / Math.random() / Math.random() / Math.random())
}
}
)
}
if (entity?.typeId === "minecraft:item") {
const players = entity?.dimension.getEntities({ location: entity.location, maxDistance: 100, type: "minecraft:player", closest: true }).forEach(event => {
const player = event
const item = player?.getComponent("minecraft:equippable").getEquipment("Mainhand")
if (item?.hasTag("minecraft:is_pickaxe") && player?.isSneaking) {
const block = entity?.dimension?.getBlock(entity.location)
const blockabove = block?.above(1)
const blockbelow = block?.below(1)
const blockeast = block?.east(1)
const blockwest = block?.west(1)
const blocknorth = block?.north(1)
const blockne = block?.north(1).east(1)
const blocknw = block?.north(1).west(1)
const blocksw = block?.south(1).west(1)
const blockan = block.above(1).north(1)
const blockas = block.above(1).south(1)
const blockane = blockabove.north(1).east(1)
const blockanw = blockabove.north(1).west(1)
const blockase = blockabove.south(1).east(1)
const blockasw = blockabove.south(1).west(1)
const blockbn = blockbelow.north(1)
const blockbs = blockbelow.south(1)
const blockbne = blockbelow.north(1).east(1)
const blockbnw = blockbelow.north(1).west(1)
const blockbse = blockbelow.south(1).east(1)
const blockbsw = blockbelow.south(1).west(1)
if (block?.typeId.includes("ore")) {
block.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockabove?.typeId.includes("ore")) {
blockabove.dimension.runCommandAsync(`execute positioned ${blockabove.location.x} ${blockabove.location.y} ${blockabove.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockbelow?.typeId.includes("ore")) {
blockabove.dimension.runCommandAsync(`execute positioned ${blockbelow.location.x} ${blockbelow.location.y} ${blockbelow.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockeast?.typeId.includes("ore")) {
blockeast.dimension.runCommandAsync(`execute positioned ${blockeast.location.x} ${blockeast.location.y} ${blockeast.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockwest?.typeId.includes("ore")) {
blockwest.dimension.runCommandAsync(`execute positioned ${blockwest.location.x} ${blockwest.location.y} ${blockwest.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blocknorth?.typeId.includes("ore")) {
blocknorth.dimension.runCommandAsync(`execute positioned ${blocknorth.location.x} ${blocknorth.location.y} ${blocknorth.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockne?.typeId.includes("ore")) {
blockne.dimension.runCommandAsync(`execute positioned ${blockne.location.x} ${blockne.location.y} ${blockne.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blocknw?.typeId.includes("ore")) {
blocknw.dimension.runCommandAsync(`execute positioned ${blocknw.location.x} ${blocknw.location.y} ${blocknw.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blocksw?.typeId.includes("ore")) {
blocksw.dimension.runCommandAsync(`execute positioned ${blocksw.location.x} ${blocksw.location.y} ${blocksw.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockan?.typeId.includes("ore")) {
blockan.dimension.runCommandAsync(`execute positioned ${blockan.location.x} ${blockan.location.y} ${blockan.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockas?.typeId.includes("ore")) {
blockas.dimension.runCommandAsync(`execute positioned ${blockas.location.x} ${blockas.location.y} ${blockas.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockane?.typeId.includes("ore")) {
blockane.dimension.runCommandAsync(`execute positioned ${blockane.location.x} ${blockane.location.y} ${blockane.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockanw?.typeId.includes("ore")) {
blockanw.dimension.runCommandAsync(`execute positioned ${blockanw.location.x} ${blockanw.location.y} ${blockanw.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockase?.typeId.includes("ore")) {
blockase.dimension.runCommandAsync(`execute positioned ${blockase.location.x} ${blockase.location.y} ${blockase.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockasw?.typeId.includes("ore")) {
blockasw.dimension.runCommandAsync(`execute positioned ${blockasw.location.x} ${blockasw.location.y} ${blockasw.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockbn?.typeId.includes("ore")) {
blockbn.dimension.runCommandAsync(`execute positioned ${blockbn.location.x} ${blockbn.location.y} ${blockbn.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockbs?.typeId.includes("ore")) {
blockbs.dimension.runCommandAsync(`execute positioned ${blockbs.location.x} ${blockbs.location.y} ${blockbs.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockbne?.typeId.includes("ore")) {
blockbne.dimension.runCommandAsync(`execute positioned ${blockbne.location.x} ${blockbne.location.y} ${blockbne.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockbnw?.typeId.includes("ore")) {
blockbnw.dimension.runCommandAsync(`execute positioned ${blockbnw.location.x} ${blockbnw.location.y} ${blockbnw.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockbse?.typeId.includes("ore")) {
blockbse.dimension.runCommandAsync(`execute positioned ${blockbse.location.x} ${blockbse.location.y} ${blockbse.location.z} run setblock ~~~ minecraft:air destroy`)
}
if (blockbsw?.typeId.includes("ore")) {
blockbsw.dimension.runCommandAsync(`execute positioned ${blockbsw.location.x} ${blockbsw.location.y} ${blockbsw.location.z} run setblock ~~~ minecraft:air destroy`)
}
}
}
)
}
}
)
world.afterEvents.itemUse.subscribe(event => {
const item = event?.itemStack
const player = event?.source
const block = player?.getBlockFromViewDirection({ maxDistance: 7 })?.block
if (item?.typeId === "minecraft:stick") {
world.sendMessage(`${block.getTags()}`)
}
})
18:
//This script allows the player to use certain custom items to accomplish varous things.
import { ItemStack, world, system } from "@minecraft/server"
world.afterEvents.itemUse.subscribe(event => {
const item = event.itemStack
const player = event.source
const inventory = player.getComponent("minecraft:inventory").container
const offitem = player.getComponent("minecraft:equippable").getEquipment("Offhand")
if (item.typeId === "os:soul_catcher") {
if (offitem?.typeId === "os:magic_stone" || offitem?.typeId === "os:power_stone" || offitem?.typeId === "os:alchemical_stone" || offitem?.typeId === "os:philosopher_stone") {
const entities = player.getEntitiesFromViewDirection({ maxDistance: 7, excludeFamilies: ["inanimate", "boss"], excludeTypes: ["minecraft:player", "minecraft:item", "minecraft:lightning_bolt", "minecraft:npc", "os:gargoyle", "minecraft:xp_orb", "minecraft:ender_dragon", "minecraft:wither", "minecraft:warden", "os:herobrine"] })?.forEach(event => {
const entity = event.entity
if (!entity?.hasComponent("minecraft:projectile") && !entity?.hasComponent("minecraft:boss")) {
const item = new ItemStack(`${entity.typeId.replace("minecraft:", "")}_spawn_egg`)
inventory.addItem(item)
entity.teleport({ x: player.location.x, y: player.location.y + 500, z: player.location.z })
system.runTimeout(() => {
entity.runCommandAsync("kill @s")
}, 10)
}
})
} else {
world.sendMessage(`${player.nameTag} you need a magical stone to use this item. It will harvest the soul of any mob you use it on and give you their spawn egg.`)
}
}
if (item.typeId === "os:soul") {
const block = player.getBlockFromViewDirection({ maxDistance: 7 })?.block
if (block?.typeId === "os:gargoyle" && block?.below(1)?.typeId === "os:gargoyle_pedestal") {
const blockrot = block.permutation.getState("minecraft:cardinal_direction")
block?.dimension.runCommandAsync(`execute positioned ${block.location.x} ${block.location.y} ${block.location.z} run summon os:gargoyle ~~~ 0 0`).then(data => {
if (data.successCount == 1) {
block.setType("minecraft:air")
player.runCommandAsync(`clear @s[m=!creative] ${item.typeId} 0 1`)
const garg = block.dimension.getEntities({ location: block.location, maxDistance: 1.5, closest: true, type: "os:gargoyle" }).forEach(gargoyle => {
system.runTimeout(() => {
gargoyle.runCommandAsync(`setblock ${block.location.x} ${block.location.y} ${block.location.z} os:gargoyle["minecraft:cardinal_direction"="${blockrot}"]`).then(ok => {
if (ok.successCount == 1) {
gargoyle.runCommandAsync("event entity @s despawn")
}
})
}, 900)
})
}
})
}
}
})
19:
//This script makes it so that when a player breaks a block8 xp is summoned at the blocks location.
import { world } from "@minecraft/server";
world.beforeEvents.playerBreakBlock.subscribe(event => {
const player = event.player
const block = event.block
if (block?.typeId.includes("os:") && block?.typeId.includes("ore") && player.getGameMode() != "creative") {
let chance = Math.random()
if (chance >= 0 && chance <= 0.49) {
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
}
if (chance >= 0.50 && chance <= 0.74) {
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
}
if (chance >= 0.75 && chance <= 0.99) {
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
}
if (chance == 1) {
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
player.runCommandAsync(`summon xp_orb ${block.location.x} ${block.location.y} ${block.location.z}`)
}
}
})
20:
//How to let players and entities swim in custom blocks. And how to make items float in custom blocks.
import { world, system } from "@minecraft/server"
system.runInterval(() => {
for (let player of world.getAllPlayers()) {
// grabbing the block at the player location.
const block = player.dimension.getBlock(player.location)
//checking if the block's typeId is os:blood and if the player is jumping.
if (!block.isAir && block?.typeId === "os:blood" && player?.isJumping) {
// pushing the player upwards as if they were swimming
player.applyKnockback(0, 0, 0, 0.3)
}
// checking if the block's typeId is os:barbed_wire and if the player is not in spectator or creative.
if (block.typeId === "os:barbed_wire" && !player.getGameMode().includes("creative") && !player.getGameMode().includes("spectator")) {
// giving the player slowness.
player.addEffect("slowness", 21, { amplifier: 2, showParticles: false })
// damaging the player. player.runCommandAsync("damage @s 1 fly_into_wall")
}
if (player.isFalling && !block.isAir && block?.typeId === "os:blood" && !player.isJumping) {
player.applyKnockback(0, 0, 0, 0.01)
}
//grabbing all entities in the world except entities with specific families and not players.
for (let entity of world.getDimension(player.dimension.id).getEntities({ excludeTypes: ["minecraft:player"], excludeFamilies: ["os:blood_swimmer"] })) {
try {
// grabbing the block at the entities location.
const block2 = entity?.dimension.getBlock(entity.location)
// checking if the block's typeId is os:blood
if (!block2?.isAir && block2?.typeId === "os:blood") {
// pushing the entity upwards as if they were swimming.
entity?.applyImpulse({ x: 0, y: 0.1, z: 0 })
if (!entity?.getEffect("slow_falling") && !entity?.isFalling) {
//giving the entity slow falling to slow their fall in the custom block. entity?.addEffect("slow_falling", 15, { showParticles: false, amplifier: 0 })
}
}
if (block2.typeId === "os:barbed_wire" && !entity.typeId.includes("minecraft:item") && !entity.typeId.includes("minecraft:xp_orb") && !entity.getComponent("type_family").hasTypeFamily("inanimate")) {
entity?.addEffect("slowness", 21, { amplifier: 2, showParticles: false })
entity.runCommandAsync(`damage @s 1 fly_into_wall`)
}
}
catch { }
}
}
}, 1)
21:
// This script is an example of how to use custom components in scripting.
import { world, system, StructureAnimationMode, BlockType, BlockPermutation, BlockTypes } from "@minecraft/server"
world.beforeEvents.worldInitialize.subscribe(event => {
// setting an array of strings to use later.
const blockid = ["minecraft:grass_block", "minecraft:bee_nest", "log", "wood", "minecraft:cherry_leaves", "minecraft:acacia_leaves", "minecraft:dark_oak_leaves", "minecraft:birch_leaves", "minecraft:jungle_leaves", "minecraft:oak_leaves", "minecraft:spruce_leaves", "minecraft:mangrove_leaves", "minecraft:mangrove_roots", "minecraft:moss_block", "minecraft:vine", "minecraft:water", "minecraft:flowing_water", "minecraft:seagrass", "minecraft:sea_pickle", "minecraft:kelp", "minecraft:coral", "minecraft:slime", "minecraft:dirt", "minecraft:sand", "minecraft:suspicious_sand", "minecraft:podzol", "minecraft:grass_path", "minecraft:farmland", "minecraft:red_sand", "minecraft:red_sandstone", "minecraft:sandstone", "minecraft:sandstone", "minecraft:stone", "minecraft:terracota", "minecraft:cobblestone", "minecraft:diorite", "minecraft:andesite", "minecraft:granite", "minecraft:deepslate", "minecraft:hardened_clay", "minecraft:mud", "gravel", "minecraft:tuff", "minecraft:redstone_ore", "minecraft:honey_block", "minecraft:deepslate_redstone_ore", "minecraft:iron_ore", "minecraft:deepslate_iron_ore", "minecraft:clay", "minecraft:dripstone_block", "minecraft:mangrove_roots", "minecraft:moss_block", "minecraft:muddy_mangrove_roots", "minecraft:packed_mud", "minecraft:hay_block", "minecraft:honeycomb_block", "minecraft:dirt_with_roots", "minecraft:mossy_cobblestone", "minecraft:cobbled_deepslate"]
// A custom component for blocks called os:spread_rot event.blockComponentRegistry.registerCustomComponent("os:spread_rot", {
// This runs when an entity steps on the block.
onStepOn({ entity }) {
// If the entity dosent have the tag os:infected and the entity is not a player and if the dynamic property os:cure = false then it will add the tag blood_mob to the entity and begin an infection process.
if (!entity.hasTag("os:infected") && !entity.typeId.includes("minecraft:player") && entity.getDynamicProperty("os:cured") == false) {
entity.addTag("blood_mob")
entity.addTag("os:infected")
entity.addEffect("hunger", 1200, { showParticles: true, amplifier: 10 })
system.runTimeout(() => {
try {
const part_timer = system.runInterval(() => {
try {
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
}
catch { }
}, 1)
system.runTimeout(() => {
system.clearRun(part_timer)
}, 5)
entity.runCommandAsync(`summon ${entity.typeId.replace("minecraft:", "os:infected_")}`).then(data => {
if (data.successCount == 1) {
entity.runCommandAsync(`tag @s remove blood_mob`).then(data1 => {
if (data1.successCount == 1) {
entity.runCommandAsync(`kill @s`)
}
})
}
})
}
catch { }
}, 1200)
}
},
// This runs when the block is placed.
onPlace({ block }) {
try {
// block lactions relative to the block placed in the north, east, west, and south positions.
const blocklocs = [block.north(1), block.south(1), block.west(1), block.east(1), block.above(1), block.below(1)]
blocklocs.forEach(block1 => {
// These if statements check the blocks tags and typeid and based on what those are the blocks will be turned into a corresponding block.
if (blockid.toString().includes(block1?.typeId)) {
if ((block1?.above(1)?.hasTag("fertilize_area") || block1?.above(1)?.hasTag("plant") || block1?.above(1)?.typeId === "minecraft:short_grass" || block1?.above(1)?.typeId.includes("fern") || block1?.above(1)?.typeId.includes("mushroom") || block1?.above(1)?.hasTag("minecraft:crop") || block1?.above(1)?.typeId === "minecraft:bamboo") && (!block1?.above(1)?.typeId.includes("minecraft:grass") && !block1?.above(1)?.typeId.includes("minecraft:moss_block") && !block1?.above(1)?.hasTag("meat"))) {
block1.dimension.runCommandAsync(`fill ${Math.round(block1.above(1).location.x - 5)} ${Math.round(block1.above(1).location.y - 5)} ${Math.round(block1.above(1).location.z - 5)} ${Math.round(block1.above(1).location.x + 5)} ${Math.round(block1.above(1).location.y + 15)} ${Math.round(block1.above(1).location.z + 5)} minecraft:air replace ${block1?.above(1)?.typeId}`)
} else if ((block1?.below(1)?.hasTag("fertilize_area") || block1?.below(1)?.hasTag("plant") || block1?.below(1)?.typeId === "minecraft:short_grass" || block1?.below(1)?.typeId.includes("fern") || block1?.below(1)?.typeId.includes("mushroom") || block1?.below(1)?.hasTag("minecraft:crop") || block1?.below(1)?.typeId === "minecraft:bamboo") && (!block1?.below(1)?.typeId.includes("minecraft:grass") && !block1?.below(1)?.typeId.includes("minecraft:moss_block") && !block1?.below(1)?.hasTag("meat"))) {
block1.dimension.runCommandAsync(`fill ${Math.round(block1.below(1).location.x - 5)} ${Math.round(block1.below(1).location.y - 5)} ${Math.round(block1.below(1).location.z - 5)} ${Math.round(block1.below(1).location.x + 5)} ${Math.round(block1.below(1).location.y + 15)} ${Math.round(block1.below(1).location.z + 5)} minecraft:air replace ${block1?.below(1)?.typeId}`)
}
}
})
let super_chance = Math.floor(Math.random() * 5000 + 1)
if (block?.typeId === "os:skintissue") {
let chance3 = Math.floor(Math.random() * 10000 + 1)
if (chance3 >= 9995) {
let chance4 = Math.floor(Math.random() * 8 + 1)
const animation = StructureAnimationMode.Blocks
let blocktime = Math.floor(Math.random() * 20 + 1)
if (chance4 == 1) {
world.structureManager.place("mystructure:bone1", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
} else if (chance4 == 2) {
world.structureManager.place("mystructure:bone2", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
} else if (chance4 == 3) {
world.structureManager.place("mystructure:bone3", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
} else if (chance4 == 4) {
world.structureManager.place("mystructure:bone4", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
} else if (chance4 == 5) {
world.structureManager.place("mystructure:bone5", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
} else if (chance4 == 6) {
world.structureManager.place("mystructure:bone6", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
} else if (chance4 == 7) {
world.structureManager.place("mystructure:bone7", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
} else if (chance4 == 8) {
world.structureManager.place("mystructure:dragonskelly", block.above(1).dimension, block.above(1).location, { animationMode: animation, animationSeconds: blocktime })
}
}
}
if (block?.typeId === "os:skintissue" && block.above(1).isAir && block.above(2).isAir && super_chance >= 4999) {
try {
block.dimension.spawnEntity("os:guardian_statue", block.above(1).location)
}
catch { }
}
let chance = Math.floor(Math.random() * 100 + 1)
if (block?.typeId === "os:skintissue" && block.above(1).isAir) {
if (chance >= 95) {
try {
let chance1 = Math.floor(Math.random() * 5 + 1)
if (chance1 == 1) {
block.above(1).setType("os:blood_flower")
} else if (chance1 == 2) {
block.above(1).setType("os:rot_houstonia")
} else if (chance1 == 3) {
block.above(1).setType("os:rot_orchid")
} else if (chance1 == 4) {
block.above(1).setType("os:rot_paeonia")
} else if (chance1 == 5) {
block.above(1).setType("os:rotgrass")
}
}
catch { }
}
let chance1 = Math.floor(Math.random() * 1000 + 1)
if (chance1 >= 999) {
block.above(1).setType("os:hive")
}
}
if (block?.typeId === "os:trachea" || (block?.hasTag("meat") && block?.typeId.includes("leaves")) || block?.typeId === "os:blood_vines") {
try {
blocklocs.forEach(block1 => {
if (blockid.toString().includes(block1?.typeId)) {
let time = Math.floor(Math.random() * 300 + 1)
const place_corrupt_timer = system.runTimeout(() => {
try {
if (block1?.typeId === "minecraft:bee_nest") {
block1?.setType("os:hive")
} else if (block1?.typeId.includes("log") || block1?.typeId.includes("wood")) {
block1?.setType("os:trachea")
} else if (block1?.typeId === "minecraft:cherry_leaves") {
block1?.setType("os:cherry_leaves_rotted")
} else if (block1?.typeId === "minecraft:acacia_leaves") {
block1?.setType("os:leaves_acacia_rotted")
} else if (block1?.typeId === "minecraft:dark_oak_leaves") {
block1?.setType("os:leaves_big_oak_rotted")
} else if (block1?.typeId === "minecraft:birch_leaves") {
block1?.setType("os:leaves_birch_rotted")
} else if (block1?.typeId === "minecraft:jungle_leaves") {
block1?.setType("os:leaves_jungle_rotted")
} else if (block1?.typeId === "minecraft:oak_leaves") {
block1?.setType("os:leaves_oak_rotted")
} else if (block1?.typeId === "minecraft:spruce_leaves") {
block1?.setType("os:leaves_spruce_rotted")
} else if (block1?.typeId === "minecraft:mangrove_leaves") {
block1?.setType("os:mangrove_leaves_rotted")
} else if (block1?.typeId === "minecraft:mangrove_roots") {
block1?.setType("os:mangrove_roots_rotted")
} else if (block1?.typeId === "minecraft:moss_block") {
block1?.setType("os:moss_block_rotted")
} else if (block1?.typeId === "minecraft:vine") {
if (block1.permutation.getState("vine_direction_bits") == 4) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "south" }))
} else if (block1.permutation.getState("vine_direction_bits") == 1) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "north" }))
} else if (block1.permutation.getState("vine_direction_bits") == 2) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "east" }))
} else if (block1.permutation.getState("vine_direction_bits") == 8) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "west" }))
}
} else {
system.clearRun(place_corrupt_timer)
}
}
catch { }
}, time)
}
})
}
catch { }
}
}
catch { }
},
onRandomTick({ block }) {
try {
const blocklocs = [block.north(1), block.south(1), block.west(1), block.east(1), block.above(1), block.below(1)]
blocklocs.forEach(block1 => {
if (blockid.toString().includes(block1?.typeId) && block.hasTag("meat") && !block?.typeId.includes("leaves") && !block1?.hasTag("meat") && !block1?.isAir) {
try {
let timer = Math.floor(Math.random() * 4800)
const corrupt_timer = system.runTimeout(() => {
try {
if (block1?.typeId === "minecraft:water" || block1?.typeId === "minecraft:flowing_water" || block1?.typeId === "minecraft:seagrass" || block1?.typeId === "minecraft:sea_pickle" || block1?.typeId === "minecraft:kelp" || block1?.typeId.includes("coral") || block1?.typeId === "minecraft:slime") {
block1.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 6 }))
} else if (block1?.typeId === "minecraft:grass_block" || block1?.typeId === "minecraft:podzol" || block1?.typeId === "minecraft:grass_path") {
block1?.setType("os:skintissue")
} else if (block1?.hasTag("dirt") || block1?.typeId === "minecraft:farmland") {
block1?.setType("os:fleshmound")
} else if (block1?.typeId === "minecraft:sand" || block1?.typeId === "minecraft:suspicous_sand") {
block1?.setType("os:bone_sand")
} else if (block1?.typeId === "minecraft:red_sand") {
block1?.setType("os:red_sand_rotted")
} else if (block1?.typeId === "minecraft:red_sandstone") {
block1?.setType("os:red_sandstone_rotted")
} else if (block1?.typeId === "minecraft:sandstone") {
block1?.setType("os:sandstone_rotted")
} else if (block1?.typeId === "minecraft:stone" || block1?.typeId.includes("terracota") || block1?.typeId === "minecraft:cobblestone" || block1?.typeId === "minecraft:diorite" || block1?.typeId === "minecraft:andesite" || block1?.typeId === "minecraft:granite") {
block1?.setType("os:bloodstone")
} else if (block1?.typeId === "minecraft:deepslate") {
block1?.setType("os:crimstone")
} else if (block1?.typeId === "minecraft:hardened_clay") {
block1?.setType("os:hardened_clay_rotted")
} else if (block1?.typeId === "minecraft:mud") {
block1?.setType("os:mud_rotted")
} else if (block1?.typeId.includes("gravel")) {
block1?.setType("os:squishyflesh")
} else if (block1?.typeId === "minecraft:tuff") {
block1?.setType("os:tuff_rotted")
} else if (block1?.typeId === "minecraft:cherry_leaves") {
block1?.setType("os:cherry_leaves_rotted")
} else if (block1?.typeId === "minecraft:acacia_leaves") {
block1?.setType("os:leaves_acacia_rotted")
} else if (block1?.typeId === "minecraft:dark_oak_leaves") {
block1?.setType("os:leaves_big_oak_rotted")
} else if (block1?.typeId === "minecraft:birch_leaves") {
block1?.setType("os:leaves_birch_rotted")
} else if (block1?.typeId === "minecraft:jungle_leaves") {
block1?.setType("os:leaves_jungle_rotted")
} else if (block1?.typeId === "minecraft:oak_leaves") {
block1?.setType("os:leaves_oak_rotted")
} else if (block1?.typeId === "minecraft:spruce_leaves") {
block1?.setType("os:leaves_spruce_rotted")
} else if (block1?.typeId === "minecraft:mangrove_leaves") {
block1?.setType("os:mangrove_leaves_rotted")
} else if (block1?.typeId.includes("log") || block1?.typeId.includes("wood")) {
block1?.setType("os:trachea")
} else if (block1?.typeId === "minecraft:redstone_ore" || block1?.typeId === "minecraft:honey_block") {
block1?.setType("os:fat_tissue")
} else if (block1?.typeId === "minecraft:deepslate_redstone_ore") {
block1?.setType("os:thickfattissue")
} else if (block1?.typeId === "minecraft:iron_ore") {
block1?.setType("os:bloodironore")
} else if (block1?.typeId === "minecraft:deepslate_iron_ore") {
block1?.setType("os:deeprot_bloodiron_ore")
} else if (block1?.typeId === "minecraft:clay") {
block1?.setType("os:clay_rotted")
} else if (block1?.typeId === "minecraft:dripstone_block") {
block1?.setType("os:dripstone_block_rotted")
} else if (block1?.typeId === "minecraft:mangrove_roots") {
block1?.setType("os:mangrove_roots_rotted")
} else if (block1?.typeId === "minecraft:moss_block") {
block1?.setType("os:moss_block_rotted")
} else if (block1?.typeId === "minecraft:muddy_mangrove_roots") {
block1?.setType("os:muddy_mangrove_roots_rotted")
} else if (block1?.typeId === "minecraft:packed_mud") {
block1?.setType("os:packed_mud_rotted")
} else if (block1?.typeId === "minecraft:hay_block") {
block1?.setType("os:hay_block_rotted")
} else if (block1?.typeId === "minecraft:honeycomb_block") {
block1?.setType("os:honeycomb_rotted")
} else if (block1?.typeId === "minecraft:dirt_with_roots") {
block1?.setType("os:dirt_with_roots_rotted")
} else if (block1?.typeId === "minecraft:mossy_cobblestone") {
block1?.setType("os:cobblestone_mossy_rotted")
} else if (block1?.typeId === "minecraft:cobbled_deepslate") {
block1?.setType("os:cobbled_deepslate_rotted")
} else if (block1?.typeId === "minecraft:vine") {
if (block1.permutation.getState("vine_direction_bits") == 4) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "south" }))
} else if (block1.permutation.getState("vine_direction_bits") == 1) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "north" }))
} else if (block1.permutation.getState("vine_direction_bits") == 2) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "east" }))
} else if (block1.permutation.getState("vine_direction_bits") == 8) {
block1.setPermutation(BlockPermutation.resolve("os:blood_vines", { "minecraft:block_face": "west" }))
}
} else {
system.clearRun(corrupt_timer)
}
}
catch { }
}, timer)
}
catch { }
}
})
}
catch { }
},
onPlayerDestroy({ block }) {
}
})
event.blockComponentRegistry.registerCustomComponent("os:spawn_particle", {
onPlace({ block }) {
try {
if (block.above(1).isAir) {
block.dimension.spawnParticle("minecraft:redstone_ore_dust_particle", { x: block.location.x + 0.5, y: block.location.y + 1.1, z: block.location.z + 0.5 })
}
}
catch { }
}
})
event.blockComponentRegistry.registerCustomComponent("os:cave_vines", {
})
event.blockComponentRegistry.registerCustomComponent("os:aerosolizer", {
onRandomTick({ block }) {
const parttimer = system.runInterval(() => {
block.dimension.spawnParticle("minecraft:crop_growth_emitter", { x: block.location.x + Math.floor(Math.random() * 10 + 1), y: block.location.y + Math.floor(Math.random() * 10 + 1), z: block.location.z + Math.floor(Math.random() * 10 + 1) })
block.dimension.spawnParticle("minecraft:crop_growth_emitter", { x: block.location.x - Math.floor(Math.random() * 10 - 1), y: block.location.y - Math.floor(Math.random() * 10 - 1), z: block.location.z - Math.floor(Math.random() * 10 - 1) })
block.dimension.spawnParticle("minecraft:crop_growth_emitter", { x: block.location.x + Math.floor(Math.random() * 10 + 1), y: block.location.y + Math.floor(Math.random() * 10 + 1), z: block.location.z + Math.floor(Math.random() * 10 + 1) })
block.dimension.spawnParticle("minecraft:crop_growth_emitter", { x: block.location.x - Math.floor(Math.random() * 10 - 1), y: block.location.y - Math.floor(Math.random() * 10 - 1), z: block.location.z - Math.floor(Math.random() * 10 - 1) })
}, 2)
system.runTimeout(() => {
system.clearRun(parttimer)
}, 20)
block.dimension.playSound("beacon.ambient", block.location)
}
})
event.blockComponentRegistry.registerCustomComponent("os:dripstone", {
})
event.blockComponentRegistry.registerCustomComponent("os:hive", {
onRandomTick({ block }) {
try {
const chance = Math.floor(Math.random() * 100 + 1)
if (chance >= 85) {
if (block.above(1).isAir) {
block.dimension.spawnEntity("os:parasite", block.above(1).location)
}
}
}
catch { }
}
})
event.blockComponentRegistry.registerCustomComponent("os:blood", {
onPlace({ block }) {
try {
const blocks = [block.east(1), block.west(1), block.north(1), block.south(1)]
let spread_timer1 = Math.floor(Math.random() * 30 + 1)
blocks.forEach(block1 => {
try {
if (!block1.below(1).typeId.includes("os:blood") && !block.below(1).typeId.includes("os:blood") && !block.below(1).isAir && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood")) {
const spread_timer = system.runTimeout(() => {
try {
if ((block.permutation.getState("os:fluid_level") == 6 && block1.isAir && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood")) || (block.permutation.getState("os:fluid_level") == 5 && block1.isAir && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood")) || (block.permutation.getState("os:fluid_level") == 6 && block1.permutation.getState("os:fluid_level") < 6 && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood") && block1.typeId === "os:blood") || (block.permutation.getState("os:fluid_level") == 5 && block1.permutation.getState("os:fluid_level") < 5 && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood") && block1.typeId === "os:blood")) {
block1.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 4 }))
} else if ((block.permutation.getState("os:fluid_level") == 4 && block1.isAir && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood")) || (block.permutation.getState("os:fluid_level") == 4 && block1.permutation.getState("os:fluid_level") < 4 && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood") && block1.typeId === "os:blood")) {
block1.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 3 }))
} else if ((block.permutation.getState("os:fluid_level") == 3 && block1.isAir && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood")) || (block.permutation.getState("os:fluid_level") == 3 && block1.permutation.getState("os:fluid_level") < 3 && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood") && block1.typeId === "os:blood")) {
block1.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 2 }))
} else if ((block.permutation.getState("os:fluid_level") == 2 && block1.isAir && !block.below(1).isAir && !block.below(1).typeId.includes("os:blood"))) {
block1.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 1 }))
}
}
catch { }
}, spread_timer1)
} else if (block.below(1).isAir || (block.below(1).typeId.includes("os:blood") && block.below(1).permutation.getState("os:fluid_level") < 5)) {
const down_timer = system.runTimeout(() => {
block.below(1).setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 5 }))
}, spread_timer1)
}
}
catch { }
})
if ((block.permutation.getState("os:fluid_level") == 5 && !block.above(1).typeId.includes("os:blood")) || (block.permutation.getState("os:fluid_level") == 4 && !block.above(1).typeId.includes("os:blood")) || ((block.north(1).permutation.getState("os:fluid_level") < 5 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 5 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 5 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 5 || !block.west(1).typeId.includes("os:blood"))) || (block.permutation.getState("os:fluid_level") == 3 && !block.above(1).typeId.includes("os:blood")) || ((block.north(1).permutation.getState("os:fluid_level") < 4 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 4 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 4 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 4 || !block.west(1).typeId.includes("os:blood"))) || (block.permutation.getState("os:fluid_level") == 2 && !block.above(1).typeId.includes("os:blood")) || ((block.north(1).permutation.getState("os:fluid_level") < 3 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 3 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 3 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 3 || !block.west(1).typeId.includes("os:blood"))) || (block.permutation.getState("os:fluid_level") == 1 && !block.above(1).typeId.includes("os:blood")) || ((block.north(1).permutation.getState("os:fluid_level") < 2 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 2 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 2 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 2 || !block.west(1).typeId.includes("os:blood")))) {
let remove_time = Math.floor(Math.random() * 30 + 1)
const remove_blood_timer = system.runInterval(() => {
try {
if (block.permutation.getState("os:fluid_level") == 5 && !block.above(1).typeId.includes("os:blood")) {
block.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 4 }))
} else if (block.permutation.getState("os:fluid_level") == 4 && !block.above(1).typeId.includes("os:blood")) {
if ((block.north(1).permutation.getState("os:fluid_level") < 5 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 5 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 5 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 5 || !block.west(1).typeId.includes("os:blood"))) {
block.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 3 }))
}
} else if (block.permutation.getState("os:fluid_level") == 3 && !block.above(1).typeId.includes("os:blood")) {
if ((block.north(1).permutation.getState("os:fluid_level") < 4 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 4 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 4 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 4 || !block.west(1).typeId.includes("os:blood"))) {
block.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 2 }))
}
} else if (block.permutation.getState("os:fluid_level") == 2 && !block.above(1).typeId.includes("os:blood")) {
if ((block.north(1).permutation.getState("os:fluid_level") < 3 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 3 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 3 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 3 || !block.west(1).typeId.includes("os:blood"))) {
block.setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 1 }))
}
} else if (block.permutation.getState("os:fluid_level") == 1 && !block.above(1).typeId.includes("os:blood")) {
if ((block.north(1).permutation.getState("os:fluid_level") < 2 || !block.north(1).typeId.includes("os:blood")) && (block.south(1).permutation.getState("os:fluid_level") < 2 || !block.south(1).typeId.includes("os:blood")) && (block.east(1).permutation.getState("os:fluid_level") < 2 || !block.east(1).typeId.includes("os:blood")) && (block.west(1).permutation.getState("os:fluid_level") < 2 || !block.west(1).typeId.includes("os:blood"))) {
block.setType("minecraft:air")
}
}
}
catch { }
}, remove_time)
}
}
catch { }
}
})
event.itemComponentRegistry.registerCustomComponent("os:bucket_of_axolotl", {
onUseOn({ block, source }) {
if (block.above(1).isAir && !block.typeId.includes("os:blood")) {
block.above(1).setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 6 }))
source.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run replaceitem entity @s slot.weapon.mainhand 0 minecraft:bucket`)
block.dimension.spawnEntity("os:infected_axolotl", block.above(1).center())
source.dimension.playSound("bucket.empty_fish", source.location, { volume: 1, pitch: 1 })
}
if (block.typeId === "os:blood" && block.hasTag("os:fluid_level6")) {
block.dimension.spawnEntity("os:infected_axolotl", block.center())
source.dimension.playSound("bucket.empty_fish", source.location, { volume: 1, pitch: 1 })
source.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run replaceitem entity @s slot.weapon.mainhand 0 minecraft:bucket`)
}
}
})
event.itemComponentRegistry.registerCustomComponent("os:bucket_of_blood", {
onUseOn({ block, source }) {
if (block.above(1).typeId.includes("minecraft:water") || block.above(1).typeId.includes("minecraft:flowing_water")) {
block.above(1).setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 6 }))
source.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run replaceitem entity @s slot.weapon.mainhand 0 minecraft:bucket`)
source.dimension.playSound("bucket.empty_fish", source.location, { volume: 1, pitch: 1 })
} else if (block.above(1).isAir) {
source.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run replaceitem entity @s slot.weapon.mainhand 0 minecraft:bucket`)
source.dimension.playSound("bucket.empty_fish", source.location, { volume: 1, pitch: 1 })
block.above(1).setPermutation(BlockPermutation.resolve("os:blood", { "os:fluid_level": 6 }))
}
}
})
})
world.beforeEvents.itemUseOn.subscribe(data => {
const item = data.itemStack
const player = data.source
const block = data.block
const blockabove = block.above(1)
if (item.typeId === "minecraft:bucket" && blockabove.typeId === "os:blood" && blockabove.hasTag("os:fluid_level6")) {
player.runCommandAsync(`execute if block ${blockabove.location.x} ${blockabove.location.y} ${blockabove.location.z} os:blood run fill ${blockabove.location.x} ${blockabove.location.y} ${blockabove.location.z} ${blockabove.location.x} ${blockabove.location.y} ${blockabove.location.z} minecraft:air replace os:blood`).then(data => {
if (data.successCount == 1) {
player.runCommandAsync(`playsound bucket.empty_fish @a[r=10] ~~~ 1 1 1`)
player.runCommandAsync(`replaceitem entity @s slot.weapon.mainhand 0 os:bucket_of_blood`)
}
})
}
})
22:
// This script allows various functions for item usage.
import { ItemStack, world, system, SystemAfterEvents, TicksPerSecond } from "@minecraft/server"
//when player eats tumor
world.beforeEvents.worldInitialize.subscribe(event => {
event.itemComponentRegistry.registerCustomComponent('os:tumor', {
onConsume({ source }) {
source.runCommand('effect @p poison 10 1 false')
}
})
})
//when player drinks cure
world.beforeEvents.worldInitialize.subscribe(event => {
event.itemComponentRegistry.registerCustomComponent('os:cure_vial', {
onConsume({ source }) {
source.runCommand('tag @p remove infected')
source.runCommand('effect @p weakness 0 0 true')
source.runCommand('effect @p mining_fatigue 0 0 true')
}
})
event.itemComponentRegistry.registerCustomComponent("os:cure", {
onUse({ source }) {
const entities = source.getEntitiesFromViewDirection({ maxDistance: 7, excludeFamilies: ["monster", "blood_mob", "player", "inanimate"], excludeTags: ["blood_mob", "os:infected"], excludeTypes: ["minecraft:item", "minecraft:xp_orb"] }).forEach(entity1 => {
let entity = entity1.entity
if (!entity.hasComponent("projectile")) {
entity.setDynamicProperty("os:cured", true)
entity.dimension.playSound("block.enchanting_table.use", entity.location, { volume: 1, pitch: 1 })
entity.runCommandAsync("effect @s clear")
entity.addTag("antidote")
source.runCommandAsync(`execute unless entity @s[m=creative] unless entity @s[m=spectator] run replaceitem entity @s slot.weapon.mainhand 0 os:syringe`)
const parttime = system.runInterval(() => {
entity.dimension.spawnParticle("minecraft:crop_growth_emitter", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random(), z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:crop_growth_emitter", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random(), z: entity.location.z - Math.random() })
}, 2)
system.runTimeout(() => {
system.clearRun(parttime)
}, 10)
}
})
}
})
})
//when hitting while holding blood_rot_sword or malice_blade
world.afterEvents.entityHurt.subscribe(event => {
try {
const entity = event.hurtEntity
const hurting = event.damageSource.damagingEntity
const held_item = hurting.getComponent("equippable")?.getEquipmentSlot("Mainhand")?.getItem()
if (((hurting?.typeId === "minecraft:player") && (held_item.typeId === "os:blood_rot_sword")) || ((hurting?.typeId === "minecraft:player") && (held_item.typeId === "os:malice_blade"))) {
entity.runCommandAsync("effect @p regeneration 5 1 false")
}
}
catch { }
})
23:
// This script allows entities to run a script event whenever they use the /scriptevent command with the corresponding ID and message.
import { world, system } from "@minecraft/server"
system.afterEvents.scriptEventReceive.subscribe(event => {
const message = event.message
const id = event.id
if (id === "os:spread" && message === "rot") {
try {
const entity = event.sourceEntity
const block = entity.dimension.getBlock(entity.location).below(1)
const blocklocs = [block.north(1), block.south(1), block.west(1), block.east(1), block.above(1), block.below(1), block]
blocklocs.forEach(block1 => {
if (!block1?.hasTag("meat") && !block1?.isAir) {
if (block1?.typeId === "minecraft:grass_block" || block1?.typeId === "minecraft:podzol" || block1?.typeId === "minecraft:grass_path") {
block1?.setType("os:skintissue")
}
if (block1?.typeId === "minecraft:water" || block1?.typeId === "minecraft:flowing_water" || block1?.typeId === "minecraft:seagrass" || block1?.typeId === "minecraft:sea_pickle" || block1?.typeId === "minecraft:kelp" || block1?.typeId.includes("coral") || block1?.typeId === "minecraft:slime") {
block1?.setType("os:blood")
}
if (block1?.hasTag("dirt") || block1?.typeId === "minecraft:farmland") {
block1?.setType("os:fleshmound")
}
if (block1?.typeId.includes("gravel")) {
block1?.setType("os:squishyflesh")
}
if (block1?.typeId.includes("log") || block1?.typeId.includes("wood")) {
block1?.setType("os:trachea")
}
if (block1?.typeId === "minecraft:sand" || block1?.typeId === "minecraft:suspicous_sand") {
block1?.setType("os:bone_sand")
}
if (block1?.typeId === "minecraft:red_sand") {
block1?.setType("os:red_sand_rotted")
}
if (block1?.typeId === "minecraft:stone" || block1?.typeId.includes("terracota") || block1?.typeId === "minecraft:cobblestone" || block1?.typeId === "minecraft:diorite" || block1?.typeId === "minecraft:andesite" || block1?.typeId === "minecraft:granite") {
block1?.setType("os:bloodstone")
}
if (block1?.typeId === "minecraft:redstone_ore" || block1?.typeId === "minecraft:honey_block") {
block1?.setType("os:fat_tissue")
}
if (block1?.typeId === "minecraft:deepslate_redstone_ore") {
block1?.setType("os:thickfattissue")
}
if (block1?.typeId === "minecraft:cherry_leaves") {
block1?.setType("os:cherry_leaves_rotted")
}
if (block1?.typeId === "minecraft:mossy_cobblestone") {
block1?.setType("os:cobblestone_mossy_rotted")
}
if (block1?.typeId === "minecraft:mossy_cobblestone") {
block1?.setType("os:cobblestone_mossy_rotted")
}
if (block1?.typeId === "minecraft:deepslate") {
block1?.setType("os:crimstone")
}
if (block1?.typeId === "minecraft:iron_ore") {
block1?.setType("os:bloodironore")
}
if (block1?.typeId === "minecraft:deepslate_iron_ore") {
block1?.setType("os:deeprot_bloodiron_ore")
}
if (block1?.typeId === "minecraft:clay") {
block1?.setType("os:clay_rotted")
}
if (block1?.typeId === "minecraft:cobbled_deepslate") {
block1?.setType("os:cobbled_deepslate_rotted")
}
if (block1?.typeId === "minecraft:dirt_with_roots") {
block1?.setType("os:dirt_with_roots_rotted")
}
if (block1?.typeId === "minecraft:dripstone_block") {
block1?.setType("os:dripstone_block_rotted")
}
if (block1?.typeId === "minecraft:hardened_clay") {
block1?.setType("os:hardened_clay_rotted")
}
if (block1?.typeId === "minecraft:hay_block") {
block1?.setType("os:hay_block_rotted")
}
if (block1?.typeId === "minecraft:bee_nest") {
block1?.setType("os:hive")
}
if (block1?.typeId === "minecraft:honeycomb_block") {
block1?.setType("os:honeycomb_rotted")
}
if (block1?.typeId === "minecraft:acacia_leaves") {
block1?.setType("os:leaves_acacia_rotted")
}
if (block1?.typeId === "minecraft:dark_oak_leaves") {
block1?.setType("os:leaves_big_oak_rotted")
}
if (block1?.typeId === "minecraft:birch_leaves") {
block1?.setType("os:leaves_birch_rotted")
}
if (block1?.typeId === "minecraft:jungle_leaves") {
block1?.setType("os:leaves_jungle_rotted")
}
if (block1?.typeId === "minecraft:oak_leaves") {
block1?.setType("os:leaves_oak_rotted")
}
if (block1?.typeId === "minecraft:spruce_leaves") {
block1?.setType("os:leaves_spruce_rotted")
}
if (block1?.typeId === "minecraft:mangrove_leaves") {
block1?.setType("os:mangrove_leaves_rotted")
}
if (block1?.typeId === "minecraft:mangrove_roots") {
block1?.setType("os:mangrove_roots_rotted")
}
if (block1?.typeId === "minecraft:moss_block") {
block1?.setType("os:moss_block_rotted")
}
if (block1?.typeId === "minecraft:mud") {
block1?.setType("os:mud_rotted")
}
if (block1?.typeId === "minecraft:muddy_mangrove_roots") {
block1?.setType("os:muddy_mangrove_roots_rotted")
}
if (block1?.typeId === "minecraft:packed_mud") {
block1?.setType("os:packed_mud_rotted")
}
if (block1?.typeId === "minecraft:red_sand") {
block1?.setType("os:red_sand_rotted")
}
if (block1?.typeId === "minecraft:red_sandstone") {
block1?.setType("os:red_sandstone_rotted")
}
if (block1?.typeId === "minecraft:sandstone") {
block1?.setType("os:sandstone_rotted")
}
if (block1?.typeId === "minecraft:tuff") {
block1?.setType("os:tuff_rotted")
}
}
})
}
catch { }
}
})
world.afterEvents.entityHurt.subscribe(event => {
try {
const entity = event.hurtEntity
const damager = event.damageSource?.damagingEntity
if (!entity.hasTag("os:infected") && damager?.getComponent("type_family")?.hasTypeFamily("blood_mob") && !entity.typeId.includes("minecraft:player") && entity.getDynamicProperty("os:cured") == false) {
entity.addTag("blood_mob")
entity.addTag("os:infected")
entity.addEffect("hunger", 1200, { showParticles: true, amplifier: 10 })
system.runTimeout(() => {
try {
const part_timer = system.runInterval(() => {
try {
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
}
catch { }
}, 1)
system.runTimeout(() => {
system.clearRun(part_timer)
}, 5)
entity.runCommandAsync(`summon ${entity.typeId.replace("minecraft:", "os:infected_")}`).then(data => {
if (data.successCount == 1) {
entity.runCommandAsync(`tag @s remove blood_mob`).then(data1 => {
if (data1.successCount == 1) {
entity.runCommandAsync(`kill @s`)
}
})
}
})
}
catch { }
}, 1200)
}
}
catch { }
})
world.afterEvents.entityDie.subscribe(event => {
try {
const entity = event.deadEntity
if (entity?.hasTag("blood_mob")) {
try {
entity.runCommandAsync(`summon ${entity.typeId.replace("minecraft:", "os:infected_")}`)
}
catch { }
}
}
catch { }
})
world.afterEvents.entitySpawn.subscribe(event => {
try {
const entity = event.entity
const family = entity.getComponent("type_family").getTypeFamilies()
if (!family.includes("blood_mob")) {
entity.setDynamicProperty("os:cured", false)
}
}
catch { }
})
system.afterEvents.scriptEventReceive.subscribe(event => {
try {
const id = event.id
const message = event.message
const entity = event.sourceEntity
if (id.includes("os:moon") && message.includes("infect") && entity.getDynamicProperty("os:cured") == false) {
if (!entity.hasTag("os:infected") && !entity.typeId.includes("minecraft:player") && entity.getDynamicProperty("os:cured") == false) {
entity.addTag("blood_mob")
entity.addTag("os:infected")
entity.addEffect("hunger", 1200, { showParticles: true, amplifier: 10 })
system.runTimeout(() => {
try {
const part_timer = system.runInterval(() => {
try {
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x + Math.random(), y: entity.location.y + Math.random() + 0.5, z: entity.location.z + Math.random() })
entity.dimension.spawnParticle("minecraft:basic_smoke_particle", { x: entity.location.x - Math.random(), y: entity.location.y - Math.random() + 0.5, z: entity.location.z - Math.random() })
}
catch { }
}, 1)
system.runTimeout(() => {
system.clearRun(part_timer)
}, 5)
entity.runCommandAsync(`summon ${entity.typeId.replace("minecraft:", "os:infected_")}`).then(data => {
if (data.successCount == 1) {
entity.runCommandAsync(`tag @s remove blood_mob`).then(data1 => {
if (data1.successCount == 1) {
entity.runCommandAsync(`kill @s`)
}
})
}
})
}
catch { }
}, 1200)
}
}
}
catch { }
})
24:
// This script makes hoes able to turn grass into farmland and makes axes able to turn logs into stripped logs when used.
```js
import {world} from "@minecraft/server"
world.afterEvents.itemUse.subscribe(event=>{
try {
const item = event.itemStack
const player = event.source
const block = player.getBlockFromViewDirection({maxDistance:7}).block
const stripped_log = block.typeId.replace("minecraft:", "minecraft:stripped_")
if (item.typeId.includes("etpg:") && item.typeId.includes("axe") && block.typeId.includes("log")){
try {
block.setType(`${stripped_log}`)
}
catch {}
}
if (item.typeId.includes("etpg:") && item.typeId.includes("hoe") && block.typeId.includes("grass_block")){
try {
block.setType(`minecraft:farmland`)
}
catch {}
}
}
catch {}
})
```