API Reference
Complete API reference for Anvil, exposing all available classes, functions, and modules.
API Modules
Actors API
anvil.api.actors
Logic API
anvil.api.logic
Blocks API
anvil.api.blocks
Items API
anvil.api.items
World API
anvil.api.world
Biomes API
anvil.api.biomes
UI API
anvil.api.ui
PBR API
anvil.api.pbr
Vanilla API
anvil.api.vanilla
Core Library
Configuration
anvil.lib.config
Config
A class used to read and write to the config.ini file.
__init__()
Initializes a Config object.
add_option(section, option, value)
Sets a value in the anvilconfig.json file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The section to set the value in. |
required |
option
|
str
|
The option to set the value in. |
required |
value
|
Any
|
The value to set. |
required |
add_section(section)
Adds a section to the anvilconfig.json file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The section to add. |
required |
get_option(section, option)
Gets a value from the anvilconfig.json file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The section to get the value from. |
required |
option
|
str
|
The option to get the value from. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The value of the option. |
has_option(section, option)
Checks if an option exists in the anvilconfig.json file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The section to check the option in. |
required |
option
|
str
|
The option to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the option exists, False otherwise. |
has_section(section)
Checks if a section exists in the anvilconfig.json file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The section to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the section exists, False otherwise. |
save()
Saves the anvilconfig.json file.
ConfigOption
Bases: StrEnum
Configuration options available in the anvil config file.
Defines all the configuration keys that can be set in various sections of the configuration file.
ConfigPackageTarget
Bases: StrEnum
Package target types for anvil projects.
Defines the types of packages that can be created.
ConfigSection
Bases: StrEnum
Configuration sections for the anvil config file.
Defines the main sections that can be present in the configuration file.
Schemas
anvil.lib.schemas
AddonDescriptor
An object representing an addon descriptor with validation for names and namespaces.
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
__init__(name, is_vanilla=False, is_vanilla_allowed=False)
Constructs all the necessary attributes for the AddonObject object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the addon object. |
required |
is_vanilla
|
bool
|
If the object is from vanilla Minecraft. Defaults to False. |
False
|
is_vanilla_allowed
|
bool
|
If overriding vanilla objects is allowed. Defaults to False. |
False
|
AddonObject
Bases: AddonDescriptor
An object representing an addon with functionality to modify its content, queue it for processing, and export it.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the addon object. |
is_vanilla |
bool
|
Indicates if the object is from vanilla Minecraft. |
object_type |
str
|
The type of the addon object. |
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
__init__(name, is_vanilla=False)
Constructs all the necessary attributes for the AddonObject object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the addon object. |
required |
content(content)
Sets the content of the addon object and returns the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
do_not_shorten()
Setter property that disables shortening of dict
when exporting.
queue(directory=None)
Queues the addon object for processing and logs the event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory
|
str
|
The directory of the addon object. |
None
|
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
JsonSchemes
A class used to read and write to the json_schemes.json file.
MinecraftBlockDescriptor
Bases: AddonDescriptor
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
states
property
Returns a string representation of the block states.
tags
property
Returns the tags associated with the block.
MinecraftDescription
Bases: AddonDescriptor
Handles Minecraft descriptions.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the Minecraft object. |
is_vanilla |
bool
|
If the object is from vanilla Minecraft. Defaults to False. |
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
Types
anvil.lib.types
Enums
anvil.lib.enums
Anchor
Bases: StrEnum
Enumeration representing the two anchor points that can be used in Minecraft: the feet and the eyes.
BlockFaces
Bases: StrEnum
Enumeration representing the different faces of a block in Minecraft.
BlockMaterial
Bases: StrEnum
Enumeration representing the different types of rendering methods a block can use in Minecraft.
BlockMovementType
Bases: StrEnum
Enumeration for the different types of block movement in Minecraft.
PushPull: The default value for this field. The block will be pushed and pulled by a piston. Push: The block will only be pulled by a piston and will ignore a sticky piston. Popped: The block is destroyed when moved by a piston. Immovable: The block is unaffected by a piston.
BlockStickyType
Bases: StrEnum
Enumeration for the different types of block stickiness in Minecraft.
Sticky: The block will stick to a sticky piston. NonSticky: The block will not stick to a sticky piston.
CameraShakeType
Bases: StrEnum
Enumeration representing the types of camera shakes that can occur in Minecraft.
CloneMode
Bases: StrEnum
Enumeration representing the different modes that can be used when cloning in Minecraft.
ComponentTarget
Bases: StrEnum
Enumeration for the different component targets in Minecraft.
DamageCause
Bases: StrEnum
Enumeration for the different causes of damage in the game.
Difficulty
Bases: StrEnum
Enumeration for the different levels of game difficulty.
Dimension
Bases: StrEnum
Enumeration for the different dimensions in the game.
Effects
Bases: StrEnum
Enumeration for the different types of effects in the game.
FilterEquipmentDomain
Bases: StrEnum
Enumeration representing the different equipment domains that can be used in filters in Minecraft.
FilterOperation
Bases: StrEnum
Enumeration representing the different operations that can be used in filters in Minecraft.
FilterSubject
Bases: StrEnum
Enumeration representing the different subjects that can be used in filters in Minecraft.
FogCameraLocation
Bases: StrEnum
Enumeration for the different locations of the fog camera in the game.
Gamemodes
Bases: StrEnum
Enumeration for the different types of game modes.
InputPermissions
Bases: StrEnum
Enumeration representing the different input permissions that can be set for a player in Minecraft.
ItemCategory
Bases: StrEnum
Enumeration representing the categories of blocks and items that can be used in Minecraft.
LeashSpringType
Bases: StrEnum
Enumeration for the different types of leash springs in Minecraft.
Bouncy: Simulates a highly elastic spring that never reaches an equilibrium if the leashed entity is suspended mid-air. Dampened: Simulates a dampened spring attached to the front of the leashed entity's collision. It reaches an equilibrium if the entity is suspended mid-air and aligns with the movement direction. QuadDampened: Simulates four dampened springs connected to the center of each side of the entities' collisions. It reaches an equilibrium if the entity is suspended mid-air and gradually aligns with the leash holder over time.
LootPoolType
Bases: StrEnum
Enumeration for the different types of loot pools.
MaskMode
Bases: StrEnum
Enumeration representing the different mask modes that can be applied in Minecraft.
MaterialDefinitions
Bases: StrEnum
Enumeration representing the different definitions that can be set for a material in Minecraft.
MaterialFunc
Bases: StrEnum
Enumeration representing the different functions that can be set for a material in Minecraft.
MaterialOperation
Bases: StrEnum
Enumeration representing the different operations that can be set for a material in Minecraft.
MaterialStates
Bases: StrEnum
Enumeration representing the different states a material can be in Minecraft.
MusicCategory
Bases: StrEnum
Enumeration for the different categories of music in the game.
Population
Bases: StrEnum
Enumeration for the different types of in-game populations.
RawTextConstructor
A class that constructs raw text with various possible styling and structures.
Attributes:
Name | Type | Description |
---|---|---|
_raw_text |
list
|
The raw text being constructed, stored as a list of dictionaries representing different parts. |
__init__()
Initializes a new RawTextConstructor instance.
__str__()
Converts the RawTextConstructor instance to a string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string representation of the raw text. |
score(objective, target)
Appends the score of the given target under the given objective to the raw text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
objective
|
str
|
The objective under which the target's score is tracked. |
required |
target
|
Selector | Target | str
|
The target whose score is to be appended. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
The instance of the current RawTextConstructor. |
selector(target)
style(*styles)
Applies the provided styles to the raw text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
styles
|
Style
|
The styles to be applied. |
()
|
Returns:
Name | Type | Description |
---|---|---|
self |
The instance of the current RawTextConstructor. |
text(text)
Appends the given text to the raw text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be appended. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
The instance of the current RawTextConstructor. |
translate(text)
Localizes the given text and appends it to the raw text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to be localized and appended. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
The instance of the current RawTextConstructor. |
RenderDistanceType
Bases: StrEnum
Enumeration for the different types of render distances in the game.
RideableDismountMode
Bases: StrEnum
Enumeration for the different modes of dismounting a rideable entity in Minecraft.
ScoreboardOperation
Bases: StrEnum
Enumeration for the different operations that can be performed on a scoreboard.
ScoreboardOperator
Bases: StrEnum
Enumeration for the different types of mathematical operators.
Selector
A class used to construct a target selector for Minecraft commands. The class offers various methods to set target parameters such as its type, name, count, coordinates, distance, volume, scores, rotation, permissions, and gamemode.
__init__(target=Target.S)
Initializes a Selector object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Target
|
The target type. Defaults to Target.S (self). |
S
|
__str__()
Returns the target selector as a string.
coordinates(*, x=None, y=None, z=None)
Sets the coordinates of the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
Coordinate
|
The x Coordinate. Defaults to None. |
None
|
y
|
Coordinate
|
The y Coordinate. Defaults to None. |
None
|
z
|
Coordinate
|
The z Coordinate. Defaults to None. |
None
|
count(count)
Sets the count of the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of targets to select. |
required |
distance(*, r=None, rm=None)
Sets the distance of the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r
|
Coordinate
|
The maximum distance. Defaults to None. |
None
|
rm
|
Coordinate
|
The minimum distance. Defaults to None. |
None
|
family(family)
Sets the family of the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
family
|
str
|
The family of the target. |
required |
gamemode(gamemode)
Selects targets that have the specified gamemode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gamemode
|
Gamemodes
|
The gamemode to check for. |
required |
has_item(*, item, data=-1, quantity=None, location=None, slot=None)
Selects targets that have the specified item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
str | Identifier
|
The item to check for. |
required |
data
|
int
|
The data value of the item. Defaults to -1. |
-1
|
quantity
|
int
|
The quantity of the item. Defaults to None. |
None
|
location
|
Slots
|
The location of the item. Defaults to None. |
None
|
slot
|
int
|
The slot of the item. Defaults to None. |
None
|
has_permission(*, camera=None, movement=None)
Selects targets that have the specified permissions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
camera
|
bool
|
Defaults to None. |
None
|
movement
|
bool
|
Defaults to None. |
None
|
has_property(**properties)
Selects targets that have the specified property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
property
|
str
|
The property to check for. |
required |
value
|
str
|
The value of the property. |
required |
name(name)
Sets the name of the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the target. |
required |
rotation(*, ry=None, rym=None, rx=None, rxm=None)
Sets the rotation of the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ry
|
float
|
The maximum yaw. Defaults to None. |
None
|
rym
|
float
|
The minimum yaw. Defaults to None. |
None
|
rx
|
float
|
The maximum pitch. Defaults to None. |
None
|
rxm
|
float
|
The minimum pitch. Defaults to None. |
None
|
scores(**scores)
Sets the scores of the target.
Example
selector.scores(score1=1, score2=2, score3=3)
tag(*tags)
Sets the tags of the target.
Example
selector.tag("tag1", "!tag2")
type(*types)
Sets the type of the target.
volume(*, dx=None, dy=None, dz=None)
Sets the volume of the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dx
|
float
|
The x volume. Defaults to None. |
None
|
dy
|
float
|
The y volume. Defaults to None. |
None
|
dz
|
float
|
The z volume. Defaults to None. |
None
|
Slots
Bases: StrEnum
Enumeration for the different types of inventory slots in the game.
SoundCategory
Bases: StrEnum
Enumeration for the different categories of sounds in the game.
Style
Bases: StrEnum
Enumeration for the different styles of text in the game.
Target
Bases: StrEnum
Enumeration for the types of targets that can be selected in Minecraft.
Weather
Bases: StrEnum
Enumeration representing the different types of weather that can be set in Minecraft.
Filters
anvil.lib.filters
Filter
all_of(*filters)
staticmethod
Returns true when all of the filters evaluate to true.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*filters
|
Filter
|
Variable number of filter conditions |
()
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter group requiring all conditions to be true |
Example
Filter.all_of( Filter.is_family("monster"), Filter.is_difficulty(Difficulty.Hard) )
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filterlist
all_slots_empty(value=FilterEquipmentDomain.Any, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the designated equipment location for the subject entity is completely empty.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
FilterEquipmentDomain
|
The equipment location to test. Defaults to FilterEquipmentDomain.Any. |
Any
|
subject
|
FilterSubject
|
Subject to test the value against. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use in testing. Defaults to FilterOperation.Equals. |
Equals
|
any_of(*filters)
staticmethod
Returns true when any of the filters evaluate to true.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*filters
|
Filter
|
Variable number of filter conditions |
()
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter group requiring at least one condition to be true |
Example
Filter.any_of( Filter.is_family("monster"), Filter.is_family("creature") )
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filterlist
any_slot_empty(value=FilterEquipmentDomain.Any, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the designated equipment location for the subject entity has any empty slot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
FilterEquipmentDomain
|
The equipment location to test. Defaults to FilterEquipmentDomain.Any. |
Any
|
subject
|
FilterSubject
|
Subject to test the value against. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use in testing. Defaults to FilterOperation.Equals. |
Equals
|
clock_time(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Compares the current time with a float value in the range (0.0, 1.0).
Time values: 0.0=Noon, 0.25=Sunset, 0.5=Midnight, 0.75=Sunrise
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
Time value between 0.0 and 1.0 |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing game time |
Example
Filter.clock_time(0.0) # Test for noon Filter.clock_time(0.5) # Test for midnight
Note
Use hourly_clock_time for integer-based time (0-24000 range)
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/clock_time
distance_to_nearest_player(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Compares the distance to the nearest Player with a float value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The distance value to compare against (minimum 0.0) |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing distance to nearest player |
Example
Test if entity is within 10 blocks of nearest player
Filter.distance_to_nearest_player(10.0, operator=FilterOperation.LessEqual)
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/distance_to_nearest_player
has_ability(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity has the named ability.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The ability type to test. Valid values: - "flySpeed", "flying", "instabuild", "invulnerable", - "lightning", "mayfly", "mute", "noclip", - "verticalFlySpeed", "walkSpeed", "worldbuilder" |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing player ability |
Example
Filter.has_ability("instabuild") # Test if player has creative mode Filter.has_ability("flying") # Test if player can fly
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_ability
has_biome_tag(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Checks if the entity is in a biome with the specified tag.
has_component(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity contains the named component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The component identifier to test for (e.g., "minecraft:health") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing for component presence |
Example
Test if entity has health component
Filter.has_component("minecraft:health")
Test if target has tameable component
Filter.has_component("minecraft:tameable", subject=FilterSubject.Target)
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_component
has_container_open(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject Player entity has opened a container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether container is open |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing if player has container open |
Example
Filter.has_container_open(True) # Test if player has container open
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_container_open
has_mob_effect(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether the Subject has the specified mob effect.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The mob effect identifier (e.g., "poison", "regeneration") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing mob effect presence |
Example
Filter.has_mob_effect("poison") # Test if entity is poisoned Filter.has_mob_effect("regeneration") # Test if entity is regenerating
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_mob_effect
has_nametag(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject has been given a custom name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity has a nametag |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing nametag presence |
Example
Filter.has_nametag(True) # Test if entity has been named
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_nametag
has_ranged_weapon(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is holding a ranged weapon like a bow or crossbow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity has ranged weapon |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing ranged weapon possession |
Example
Filter.has_ranged_weapon(True) # Test if entity has bow/crossbow
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_ranged_weapon
has_silk_touch(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject is holding an item with silk touch enchantment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether item has silk touch |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing silk touch presence |
Example
Filter.has_silk_touch(True) # Test if held item has silk touch
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_silk_touch
has_trade_supply(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether the target has any trade supply left.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity has trade supply |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing trade supply availability |
Example
Filter.has_trade_supply(True) # Test if villager has trades available
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/has_trade_supply
hourly_clock_time(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Compares the current 24 hour time with an int value in the range [0, 24000].
This is an updated version of clock_time that uses integers based on in-game time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
Time value between 0 and 24000 (0=dawn, 6000=noon, 12000=sunset, 18000=midnight) |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing game time in ticks |
Example
Filter.hourly_clock_time(6000) # Test for noon Filter.hourly_clock_time(18000) # Test for midnight
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/hourly_clock_time
in_block(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is inside a specified Block type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Block identifier (e.g., "minecraft:water", "minecraft:lava") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing if entity is inside block |
Example
Filter.in_block("minecraft:water") # Test if entity is in water block Filter.in_block("minecraft:lava") # Test if entity is in lava
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_block
in_caravan(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is in a caravan.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in caravan |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing caravan membership |
Example
Filter.in_caravan(True) # Test if llama is in caravan
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_caravan
in_clouds(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is in the clouds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in clouds |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing cloud height |
Example
Filter.in_clouds(True) # Test if entity is at cloud level
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_clouds
in_contact_with_water(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity in contact with any water: water, rain, splash water bottle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in contact with water |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing water contact |
Example
Filter.in_contact_with_water(True) # Test if entity touches any water source
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_contact_with_water
in_lava(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is in lava.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in lava |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing lava immersion |
Example
Filter.in_lava(True) # Test if entity is in lava
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_lava
in_nether(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is in Nether dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in Nether |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing Nether dimension |
Example
Filter.in_nether(True) # Test if entity is in Nether
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_nether
in_overworld(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is in Overworld dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in Overworld |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing Overworld dimension |
Example
Filter.in_overworld(True) # Test if entity is in Overworld
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_overworld
in_water_or_rain(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is in water or rain.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in water or rain |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing water or rain exposure |
Example
Filter.in_water_or_rain(True) # Test if entity is wet
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/in_water_or_rain
inactivity_timer(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the specified duration in seconds of inactivity for despawning has been reached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
Inactivity duration in seconds |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing inactivity timer |
Example
Filter.inactivity_timer(300, operator=FilterOperation.GreaterEqual) # 5+ minutes inactive
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/inactivity_timer
is_altitude(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests the current altitude against a provided value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
Y-coordinate altitude to test |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing altitude/Y position |
Example
Filter.is_altitude(64, operator=FilterOperation.Greater) # Above sea level
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_altitude
is_avoiding_mobs(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is fleeing from other mobs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is avoiding mobs |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing avoidance behavior |
Example
Filter.is_avoiding_mobs(True) # Test if entity is fleeing
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_avoiding_mobs
is_baby(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is a baby.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is baby |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing baby state |
Example
Filter.is_baby(True) # Test if entity is baby/child
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_baby
is_block(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the block has the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
BlockDescriptor | Identifier
|
Block descriptor or identifier to test |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing block type |
Example
Filter.is_block("minecraft:stone") # Test if block is stone
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_block
is_brightness(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests the current brightness against a provided value in the range (0.0f, 1.0f).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
Brightness value between 0.0 (darkest) and 1.0 (brightest) |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing brightness level |
Example
Filter.is_brightness(0.5, operator=FilterOperation.Less) # Test if dim
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_brightness
is_climbing(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is climbing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is climbing |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing climbing state |
Example
Filter.is_climbing(True) # Test if entity is on ladder/vines
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_climbing
is_color(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is the named color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Color name (e.g., "red", "blue", "white", etc.) |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing entity color |
Example
Filter.is_color("red") # Test if sheep is red Filter.is_color("white") # Test if wolf is white
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_color
is_family(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is a member of the named family.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The family name to test for (e.g., "monster", "player", "mob") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing family membership |
Example
Test if entity is a monster
Filter.is_family("monster")
Test if target is not a player
Filter.is_family("player", subject=FilterSubject.Target, operator=FilterOperation.Not)
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_family
is_game_rule(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether a named game rule is active.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Game rule name (e.g., "doMobSpawning", "keepInventory") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing game rule state |
Example
Filter.is_game_rule("doMobSpawning") # Test if mob spawning enabled
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_game_rule
is_humid(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether the Subject is in an area with humidity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether area is humid |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing humidity level |
Example
Filter.is_humid(True) # Test if in humid biome (jungle, swamp)
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_humid
is_immobile(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is immobile.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is immobile |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing immobility state |
Example
Filter.is_immobile(True) # Test if entity cannot move
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_immobile
is_in_village(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether the Subject is inside the bounds of a village.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is in village |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing village bounds |
Example
Filter.is_in_village(True) # Test if entity is within village
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_in_village
is_leashed(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is leashed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is leashed |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing leash state |
Example
Filter.is_leashed(True) # Test if mob is on leash
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_leashed
is_leashed_to(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity leashed to the calling entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether subject is leashed to caller |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing leash connection |
Example
Filter.is_leashed_to(True, subject=FilterSubject.Target) # Test if target is leashed to cls
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_leashed_to
is_missing_health(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject is not at full health.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is missing health |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing damaged state |
Example
Filter.is_missing_health(True) # Test if entity is damaged
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_missing_health
is_moving(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is moving.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
The movement state to test for |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing movement state |
Example
Filter.is_moving(True) # Test if entity is moving
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_moving
is_navigating(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject is currently pathfinding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is pathfinding |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing navigation state |
Example
Filter.is_navigating(True) # Test if mob is pathfinding to destination
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_navigating
is_persistent(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject's persistence matches the bool value passed in.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Persistence state to test |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing persistence |
Example
Filter.is_persistent(True) # Test if entity won't despawn
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_persistent
is_riding_self(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is riding the calling entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether subject is riding caller |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing rider relationship |
Example
Filter.is_riding_self(True, subject=FilterSubject.Target) # Test if target is riding cls
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_riding_self
is_sleeping(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether the Subject is sleeping.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is sleeping |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing sleep state |
Example
Filter.is_sleeping(True) # Test if villager is sleeping in bed
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_sleeping
is_sneak_held(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity has the sneak input held.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether sneak input is held |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing sneak input |
Example
Filter.is_sneak_held(True) # Test if player is holding sneak button
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_sneak_held
is_sneaking(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject entity is sneaking.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is sneaking |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing sneak state |
Example
Filter.is_sneaking(True) # Test if player is sneaking
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_sneaking
is_snow_covered(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether the Subject is in an area with snow cover.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether area has snow cover |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing snow coverage |
Example
Filter.is_snow_covered(True) # Test if in snowy biome
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_snow_covered
is_temperature_type(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests whether the current temperature is a given type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Temperature type ("cold", "mild", "ocean", "warm") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing temperature category |
Example
Filter.is_temperature_type("cold") # Test if in cold biome
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_temperature_type
is_temperature_value(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests the current temperature against a provided value in the range (0.0, 1.0).
Where 0.0 is the coldest temp and 1.0 is the hottest.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
Temperature value between 0.0 (coldest) and 1.0 (hottest) |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing temperature value |
Example
Filter.is_temperature_value(0.8, operator=FilterOperation.Greater) # Test if very hot
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_temperature_value
is_underground(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is underground.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is underground |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing underground state |
Example
Filter.is_underground(True) # Test if entity is below surface
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_underground
is_vehicle_family(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity's vehicle is a member of the named family.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Vehicle family name to test |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing vehicle family |
Example
Filter.is_vehicle_family("boat") # Test if riding boat
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_vehicle_family
is_waterlogged(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject block is submerged in water.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether block is waterlogged |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing waterlogged state |
Example
Filter.is_waterlogged(True, subject=FilterSubject.Block) # Test if block is waterlogged
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/is_waterlogged
light_level(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the mob is outside of the specified light level range (0, 16).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
Light level value between 0 and 16 |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing light level |
Example
Filter.light_level(7, operator=FilterOperation.Less) # Test if dark enough for mob spawning
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/light_level
moon_intensity(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Compares the current moon intensity with a float value in the range (0.0, 1.0).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
Moon intensity between 0.0 and 1.0 |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing moon brightness |
Example
Filter.moon_intensity(1.0) # Test for full moon
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/moon_intensity
moon_phase(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Compares the current moon phase with an integer value in the range (0, 7).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
Moon phase between 0 and 7 (0=full moon, 4=new moon) |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing moon phase |
Example
Filter.moon_phase(0) # Test for full moon Filter.moon_phase(4) # Test for new moon
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/moon_phase
none_of(*filters)
staticmethod
Returns true when none of the filters evaluate to true.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*filters
|
Filter
|
Variable number of filter conditions |
()
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter group requiring no conditions to be true |
Example
Filter.none_of( Filter.is_family("player"), Filter.has_tag("peaceful") )
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filterlist
on_fire(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject is on fire.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is on fire |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing fire state |
Example
Filter.on_fire(True) # Test if entity is burning
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/on_fire
on_hot_block(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject is on a hot block (like magma).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is on hot block |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing hot block contact |
Example
Filter.on_hot_block(True) # Test if standing on magma block
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/on_hot_block
on_ladder(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true when the subject entity is on a ladder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is on ladder |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing ladder state |
Example
Filter.on_ladder(True) # Test if entity is climbing ladder
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/on_ladder
surface_mob(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject is a surface mob.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is surface mob |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing surface mob classification |
Example
Filter.surface_mob(True) # Test if mob spawns on surface
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/surface_mob
taking_fire_damage(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests if the subject is taking fire damage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity is taking fire damage |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing fire damage |
Example
Filter.taking_fire_damage(True) # Test if entity is burning and taking damage
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/taking_fire_damage
trusts(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns true if the subject is trusted by entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether entity trusts subject |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing trust relationship |
Example
Filter.trusts(True, subject=FilterSubject.Player) # Test if entity trusts player
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/trusts
weather(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests the current weather in the dimension against a provided weather value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Weather type ("clear", "rain", "thunder") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing weather conditions |
Example
Filter.weather("rain") # Test if raining Filter.weather("thunder") # Test if thunderstorm
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/weather
weather_at_position(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Tests the current weather, at the actor's position, against a provided weather value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Weather type ("clear", "rain", "thunder") |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing local weather conditions |
Example
Filter.weather_at_position("rain") # Test if raining at exact position
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/weather_at_position
y_rotation(value, *, subject=FilterSubject.Self, operator=FilterOperation.Equals)
classmethod
Returns the Y rotation of this entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
Y rotation value in degrees |
required |
subject
|
FilterSubject
|
Subject to test. Defaults to FilterSubject.Self. |
Self
|
operator
|
FilterOperation
|
Operation to use. Defaults to FilterOperation.Equals. |
Equals
|
Returns:
Name | Type | Description |
---|---|---|
dict |
Filter testing Y rotation |
Example
Filter.y_rotation(0.0, operator=FilterOperation.Less) # Test if facing north-ish
Reference
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/filters/y_rotation
Library Functions
anvil.lib.lib
A collection of useful functions and classes used throughout the program.
CopyFiles(old_dir, new_dir, target_file, rename=None)
Copies a file from one directory to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
old_dir
|
str
|
The path to the source directory. |
required |
new_dir
|
str
|
The path to the destination directory. |
required |
target_file
|
str
|
The name of the file to be copied. |
required |
rename
|
str
|
The new name for the copied file. Defaults to None. |
None
|
CopyFolder(old_dir, new_dir)
Copies a folder and all its contents to a new location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
old_dir
|
str
|
The path to the source directory. |
required |
new_dir
|
str
|
The path to the destination directory. |
required |
CreateDirectory(path)
Creates a new directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the new directory. |
required |
File(name, content, directory, mode, skip_tag=False, **parameters)
Create or modify a file with the given content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the file. |
required |
content
|
str | dict
|
The content of the file. |
required |
directory
|
str
|
The directory path where the file should be created or modified. |
required |
mode
|
str
|
The file mode, either "w" (write) or "a" (append). |
required |
skip_tag
|
bool
|
Whether to skip adding the file metadata tag. Defaults to False. |
False
|
*Parameters
|
Additional StrEnum. |
required |
Note
The file content is converted to the appropriate format based on the file extension.
FileExists(path)
Checks if a file exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
_type_
|
The path to the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the file exists, False otherwise. |
MoveFolder(old_dir, new_dir)
Moves a folder and all its contents to a new location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
old_dir
|
str
|
The path to the source directory. |
required |
new_dir
|
str
|
The path to the destination directory. |
required |
RemoveDirectory(path)
Removes a directory and all its contents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the directory to be removed. |
required |
RemoveFile(path)
Removes a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the file to be removed. |
required |
clamp(value, _min, _max)
Clamps a value between a minimum and maximum limit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The value to be clamped. |
required |
_min
|
float
|
The lower limit. |
required |
_max
|
float
|
The upper limit. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The clamped value. |
frange(start, stop, num=1)
Generate a list of interpolated float values between start and stop.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start
|
int
|
The starting value. |
required |
stop
|
int
|
The ending value. |
required |
num
|
float
|
The number of values to generate. Defaults to 1. |
1
|
Returns:
Name | Type | Description |
---|---|---|
list |
A list of interpolated values between start and stop. |
normalize_180(angle)
Normalizes an angle between -180 and 180.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angle
|
float
|
The angle to be normalized. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The normalized angle. |
process_color(Color, add_alpha=False)
Processes color values from different formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
Color
|
Color
|
The color to process, can be tuple or hex string. |
required |
add_alpha
|
bool
|
Whether to add alpha channel if missing. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
str | list[float]
|
str | list[float]: Processed color in the appropriate format. |
Raises:
Type | Description |
---|---|
ValueError
|
If color format is invalid. |
TypeError
|
If color type is not supported. |
process_subcommand(command, error_handle='Error')
Executes a subprocess command with error handling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
str
|
The command to execute. |
required |
error_handle
|
str
|
Error message prefix. Defaults to "Error". |
'Error'
|
salt_from_str(s)
Generates a hash value from a string for use as a random seed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
str
|
The input string to hash. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
A hash value derived from the input string. |
validate_namespace_project_name(namespace, project_name, is_addon=False)
Validates namespace and project name according to Minecraft addon requirements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace
|
str
|
The namespace to validate. |
required |
project_name
|
str
|
The project name to validate. |
required |
is_addon
|
bool
|
Whether this is for an addon. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If validation fails for any requirement. |
zipit(zip_name, dir_list)
Create a ZIP archive containing multiple directories and files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
zip_name
|
The name of the ZIP archive. |
required | |
dir_list
|
dict
|
A dictionary where the keys are source directories and the values are target directories. |
required |
Note
The target directories represent the structure inside the ZIP archive.
Reports
anvil.lib.reports
ReportCollector
__init__()
A dictionary where keys are ReportType and values are list[defaultdict]
.
These inner defaultdict
will automatically create a key if it doesn't exist
and initialize it to a dictionary of empty sets.
The dictionary is later used to generate a report of what have been added to the pack.
Sounds
anvil.lib.sounds
MusicDefinition
Bases: AddonObject
Handles music definitions.
Attributes:
Name | Type | Description |
---|---|---|
_extensions |
dict
|
The file extensions for the music definition. |
_sounds |
list[SoundDescription]
|
A list of sound descriptions. Defaults to empty list. |
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
queue
property
Returns the queue for the music definition.
Returns:
Name | Type | Description |
---|---|---|
queue |
The queue for the music definition. |
__init__()
Initializes a MusicDefinition instance.
content(content)
Sets the content of the addon object and returns the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
do_not_shorten()
Setter property that disables shortening of dict
when exporting.
music_definition(music_reference, min_delay=60, max_delay=180)
Defines a music for the MusicDefinition instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
music_category
|
MusicCategory
|
The category of the music. |
required |
min_delay
|
int
|
The minimum delay for the music. Defaults to 60. |
60
|
max_delay
|
int
|
The maximum delay for the music. Defaults to 180. |
180
|
Returns:
Name | Type | Description |
---|---|---|
SoundDescription |
The created sound description instance. |
SoundDefinition
Bases: AddonObject
Handles sound definitions.
Attributes:
Name | Type | Description |
---|---|---|
_sounds |
list[SoundDescription]
|
A list of sound descriptions. Defaults to empty list. |
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
queue
property
Returns the queue for the sound definition.
Returns:
Name | Type | Description |
---|---|---|
queue |
The queue for the sound definition. |
__init__()
Initializes a SoundDefinition instance.
content(content)
Sets the content of the addon object and returns the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
do_not_shorten()
Setter property that disables shortening of dict
when exporting.
sound_reference(sound_reference, category, use_legacy_max_distance=False, max_distance=0, min_distance=9999)
Defines a sound for the SoundDefinition instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sound_reference
|
str
|
The sound_reference of the sound. |
required |
category
|
SoundCategory
|
The category of the sound. |
required |
use_legacy_max_distance
|
bool
|
Use legacy max distance if True. Defaults to False. |
False
|
max_distance
|
int
|
The maximum distance for the sound. Defaults to 0. |
0
|
min_distance
|
int
|
The minimum distance for the sound. Defaults to 9999. |
9999
|
Returns:
Name | Type | Description |
---|---|---|
SoundDescription |
The created sound description instance. |
SoundDescription
Represents a sound description for Minecraft addon sound definitions.
Manages the configuration and properties of individual sound effects, including volume, distance, and 3D positioning parameters.
identifier
property
Gets the sound definition identifier.
Returns:
Name | Type | Description |
---|---|---|
str |
The sound definition identifier. |
__init__(sound_reference, category, use_legacy_max_distance=False, max_distance=0, min_distance=9999)
Initializes a SoundDescription instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sound_reference
|
str
|
The definition of the sound. |
required |
category
|
SoundCategory
|
The category of the sound. |
required |
use_legacy_max_distance
|
bool
|
Use legacy max distance if True. Defaults to False. |
False
|
max_distance
|
int
|
The maximum distance for the sound. Defaults to 0. |
0
|
min_distance
|
int
|
The minimum distance for the sound. Defaults to 9999. |
9999
|
add_sound(sound_name, volume=1, weight=1, pitch=[1, 1], is_3d=None, stream=None, load_on_low_memory=False)
Adds a sound to the SoundDescription instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sound_name
|
str
|
The name of the sound. |
required |
volume
|
int
|
The volume of the sound. Defaults to 1. |
1
|
weight
|
int
|
The weight of the sound. Defaults to 1. |
1
|
pitch
|
list[int]
|
The pitch of the sound. Defaults to [1, 1]. |
[1, 1]
|
is_3d
|
bool
|
If the sound is 3D. Defaults to None. |
None
|
stream
|
bool
|
If the sound is streamed. Defaults to None. |
None
|
load_on_low_memory
|
bool
|
If the sound is loaded on low memory. Defaults to False. |
False
|
SoundEvent
Bases: AddonObject
Handles sound events for entities and individual sounds.
Manages the creation and configuration of sound events that can be triggered by entities or as standalone sounds in the game.
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
queue
property
Returns the queue for the sound event.
Returns:
Name | Type | Description |
---|---|---|
queue |
The queue for the sound event. |
__init__()
Initializes a SoundEvent instance.
add_entity_event(entity_identifier, sound_identifier, sound_event, volume=1.0, pitch=(0.8, 1.2), variant_query=None, variant_map=None)
Adds an entity event to the SoundEvent instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity_identifier
|
Identifier
|
The identifier of the entity. |
required |
sound_event
|
EntitySoundEvent
|
The sound event for the entity. |
required |
sound_identifier
|
str
|
The identifier of the sound. |
required |
volume
|
float
|
The volume of the event. Defaults to 1.0. |
1.0
|
pitch
|
tuple[float, float]
|
The pitch of the event. Defaults to (0.8, 1.2). |
(0.8, 1.2)
|
variant_query
|
Molang
|
The variant query for the event. Defaults to None. |
None
|
variant_map
|
str
|
The variant map for the event. Defaults to None. |
None
|
add_individual_event(sound_identifier, volume=1.0, pitch=(0.8, 1.2))
Adds an individual event to the SoundEvent instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sound_identifier
|
str
|
The identifier of the sound. |
required |
volume
|
float
|
The volume of the event. Defaults to 1.0. |
1.0
|
pitch
|
tuple[float, float]
|
The pitch of the event. Defaults to (0.8, 1.2). |
(0.8, 1.2)
|
content(content)
Sets the content of the addon object and returns the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
do_not_shorten()
Setter property that disables shortening of dict
when exporting.
Textures
anvil.lib.textures
ItemTexturesObject
Bases: AddonObject
Handles item textures for the addon.
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
queue
property
Queues the item textures.
Returns:
Name | Type | Description |
---|---|---|
object |
The parent's queue method result. |
__init__()
Initializes a ItemTexturesObject instance.
add_item(item_name, directory, *item_sprites)
Adds item textures to the content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item_name
|
str
|
The name of the item. |
required |
directory
|
str
|
The directory path for the textures. |
required |
item_sprites
|
str
|
The names of the item sprites. |
()
|
content(content)
Sets the content of the addon object and returns the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
do_not_shorten()
Setter property that disables shortening of dict
when exporting.
TerrainTexturesObject
Bases: AddonObject
Handles terrain textures for the addon.
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
queue
property
Queues the block textures.
Returns:
Name | Type | Description |
---|---|---|
object |
The parent's queue method result. |
__init__()
Initializes a TerrainTexturesObject instance.
add_block(block_name, directory, *block_textures)
Adds block textures to the content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block_name
|
str
|
The name of the block. |
required |
directory
|
str
|
The directory path for the textures. |
required |
block_textures
|
str
|
The names of the block textures. |
()
|
content(content)
Sets the content of the addon object and returns the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
do_not_shorten()
Setter property that disables shortening of dict
when exporting.
UITexturesObject
Bases: AddonObject
Handles UI textures for the addon.
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
Name | Type | Description |
---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The name of the addon object. |
queue
property
Queues the item textures.
Returns:
Name | Type | Description |
---|---|---|
object |
The parent's queue method result. |
__init__()
Initializes a UITexturesObject instance.
add_item(texture_name, directory, *textures)
Adds item textures to the content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture_name
|
str
|
The name of the texture. |
required |
directory
|
str
|
The directory path for the textures. |
required |
textures
|
str
|
The names of the textures. |
()
|
content(content)
Sets the content of the addon object and returns the object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
do_not_shorten()
Setter property that disables shortening of dict
when exporting.
Templater
anvil.lib.templater
Translator
anvil.lib.translator
AnvilTranslator
__init__()
Initialize the translator with an Excel file path.
add_localization_entry(key, value)
Add a new localization entry to the en_US sheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The localization key |
required |
value
|
str
|
The English value |
required |
auto_translate_all(languages=None)
Automatically translate all entries from source language to target languages.
get_localization_value(key)
Get the localization value for a specific key from the source language (en_US).