Molang Registry Functions: Difference between revisions
No edit summary |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 26: | Line 26: | ||
{| class="wikitable fixed-header sortable" | {| class="wikitable fixed-header sortable" | ||
!Name!!Description!!Usage | !Name!!Description!!Usage | ||
|- | |||
|<syntaxhighlight lang="kotlin">is_time_of_day(timeOfDay: String): Double</syntaxhighlight> | |||
|Returns <code>1.0</code> if the provided <code>String</code> corresponds to a registered time range, such as <code>day</code> or <code>night</code>. Otherwise, will return <code>0.0</code>. | |||
|<syntaxhighlight lang="kotlin">q.world.is_time_of_day('morning')</syntaxhighlight> | |||
|- | |- | ||
|<syntaxhighlight lang="kotlin">game_time(): Double</syntaxhighlight> | |<syntaxhighlight lang="kotlin">game_time(): Double</syntaxhighlight> | ||
| Line 42: | Line 46: | ||
|Takes a block position and returns <code>1.0</code> if it is raining there, otherwise returns <code>0.0</code>. | |Takes a block position and returns <code>1.0</code> if it is raining there, otherwise returns <code>0.0</code>. | ||
|<syntaxhighlight lang="kotlin">q.world.is_raining_at(0, 0, 0)</syntaxhighlight> | |<syntaxhighlight lang="kotlin">q.world.is_raining_at(0, 0, 0)</syntaxhighlight> | ||
|- | |||
|<syntaxhighlight lang="kotlin">is_snowing_at(x: Int, y: Int, z: Int): Double</syntaxhighlight> | |||
|Takes a block position and returns <code>1.0</code> if it is snowing there, otherwise returns <code>0.0</code>. | |||
|<syntaxhighlight lang="kotlin">q.world.is_snowing_at(0, 0, 0)</syntaxhighlight> | |||
|- | |- | ||
|<syntaxhighlight lang="kotlin">is_chunk_loaded_at(x: Int, y: Int, z: Int): Double</syntaxhighlight> | |<syntaxhighlight lang="kotlin">is_chunk_loaded_at(x: Int, y: Int, z: Int): Double</syntaxhighlight> | ||
| Line 55: | Line 63: | ||
|<syntaxhighlight lang="kotlin">q.world.is_raining()</syntaxhighlight> | |<syntaxhighlight lang="kotlin">q.world.is_raining()</syntaxhighlight> | ||
|- | |- | ||
|<syntaxhighlight lang="kotlin">set_block(x: Int, y: Int, z: Int, block: String): Double | |<syntaxhighlight lang="kotlin">set_block(x: Int, y: Int, z: Int, block: String): Double</syntaxhighlight> | ||
|Take a block position and set it to be a block. Returns <code>0.0</code> and | |Take a block position and set it to be a block. Returns <code>1.0</code> if the block was set successfully. Will return <code>0.0</code> and log the unknown string if it's an invalid block or already set to the specified <code>block</code>. | ||
|<syntaxhighlight lang="kotlin">q.world.set_block(0, 0, 0, 'minecraft:dirt')</syntaxhighlight> | |<syntaxhighlight lang="kotlin">q.world.set_block(0, 0, 0, 'minecraft:dirt')</syntaxhighlight> | ||
|- | |||
|<syntaxhighlight lang="kotlin">is_air(x: Double, y: Double, z: Double): Double</syntaxhighlight> | |||
|Takes a block position and returns <code>1.0</code> if the block state is air, otherwise returns <code>0.0</code>. | |||
|<syntaxhighlight lang="kotlin">q.world.is_air(0, 0, 0)</syntaxhighlight> | |||
|- | |- | ||
|<syntaxhighlight lang="kotlin">get_block(x: Int, y: Int, z: Int): ObjectValue<Block></syntaxhighlight> | |<syntaxhighlight lang="kotlin">get_block(x: Int, y: Int, z: Int): ObjectValue<Block></syntaxhighlight> | ||
| Line 63: | Line 75: | ||
|<syntaxhighlight lang="kotlin">q.world.get_block(0, 0, 0)</syntaxhighlight> | |<syntaxhighlight lang="kotlin">q.world.get_block(0, 0, 0)</syntaxhighlight> | ||
|- | |- | ||
|<syntaxhighlight lang="kotlin">spawn_explosion(x: Double, y: Double, z: Double, range: Double, interaction: String?) | |<syntaxhighlight lang="kotlin">spawn_explosion(x: Double, y: Double, z: Double, range: Double, interaction: String?): Double</syntaxhighlight> | ||
|Spawns an explosion at <code>x</code>, <code>y</code>, and <code>z</code> with range of <code>range</code>. <code>interaction</code> is a string of what kind of explosion it should be, such as <code>block</code>, <code>mob</code>, <code>tnt</code>, <code>trigger</code>, or <code>none</code>. Is <code>tnt</code> by default. | |Spawns an explosion at <code>x</code>, <code>y</code>, and <code>z</code> with range of <code>range</code>. <code>interaction</code> is a string of what kind of explosion it should be, such as <code>block</code>, <code>mob</code>, <code>tnt</code>, <code>trigger</code>, or <code>none</code>. Is <code>tnt</code> by default. Will return <code>1.0</code> if successful, otherwise returns <code>0.0</code>. | ||
|<syntaxhighlight lang="kotlin">q.world.spawn_explosion(0, 0, 0, 3)</syntaxhighlight> | |<syntaxhighlight lang="kotlin">q.world.spawn_explosion(0, 0, 0, 3)</syntaxhighlight> | ||
|- | |- | ||
| Line 71: | Line 83: | ||
|<syntaxhighlight lang="kotlin">q.world.spawn_lightning(0, 0, 0)</syntaxhighlight> | |<syntaxhighlight lang="kotlin">q.world.spawn_lightning(0, 0, 0)</syntaxhighlight> | ||
|- | |- | ||
|<syntaxhighlight lang="kotlin">spawn_bedrock_particles(particle: String, x: Double, y: Double, z: Double, player: MoValue?) Double | |<syntaxhighlight lang="kotlin">spawn_bedrock_particles(particle: String, x: Double, y: Double, z: Double, player: MoValue?): Double</syntaxhighlight> | ||
|Spawns bedrock particles at the location <code>x</code>, <code>y</code>, and <code>z</code>. When run on the server, if a <code>player</code> value is specified (either a player object or a UUID) then only the <code>player</code> specified will receive the packet, otherwise all nearby players will receive it. If run on a client then it will play the animation for only that player, ignoring the <code>player</code> value, returning <code>0.0</code> if the particle is not in the registry. | |Spawns bedrock particles at the location <code>x</code>, <code>y</code>, and <code>z</code>. When run on the server, if a <code>player</code> value is specified (either a player object or a UUID) then only the <code>player</code> specified will receive the packet, otherwise all nearby players will receive it. If run on a client then it will play the animation for only that player, ignoring the <code>player</code> value, returning <code>0.0</code> if the particle is not in the registry. Will return <code>1.0</code> if ran successfully, otherwise will return <code>0.0</code>. | ||
|<syntaxhighlight lang="kotlin">q.world.spawn_bedrock_particles(' | |<syntaxhighlight lang="kotlin">q.world.spawn_bedrock_particles('cobblemon:cherry_leaves_particle', 0, 0, 0)</syntaxhighlight> | ||
|- | |||
|<syntaxhighlight lang="kotlin">spawn_pokemon(x: Int, y: Int, z: Int, properties: String): MoValue</syntaxhighlight> | |||
|Takes a block position and spawns a Pokémon at the given position with the provided <code>properties</code> String. Returns an <code>ObjectValue<PokemonEntity></code> of the spawned Pokémon. Returns <code>0.0</code> if the spawn was not successful. | |||
|<syntaxhighlight lang="kotlin">q.world.spawn_pokemon(0, 0, 0, 'bidoof lvl=100')</syntaxhighlight> | |||
|- | |||
|<syntaxhighlight lang="kotlin">spawn_npc(x: Double, y: Double, z: Double, npcClass: String, level: Int): MoValue</syntaxhighlight> | |||
|Takes a block position and spawns an NPC at that position with the provided <code>npcClass</code> and NPC <code>level</code>. The NPC <code>level</code> is utilized for party pool customization. Returns an <code>ObjectValue<NPCEntity></code> of the spawned NPC. Returns <code>0.0</code> if the spawn was not successful. | |||
|<syntaxhighlight lang="kotlin">q.world.spawn_npc(0, 0, 0, 'sacchi', 1)</syntaxhighlight> | |||
|- | |||
|<syntaxhighlight lang="kotlin">play_sound_on_server(sound: String, soundSource: String, x: Double, y: Double, z: Double, player: MoValue?, volume: Double?, pitch: Double?): Double</syntaxhighlight> | |||
|Plays the given <code>sound</code> on the <code>soundSource</code> track at <code>x</code>, <code>y</code>, and <code>z</code>. If a <code>player</code> value is specified (either a player object or a UUID) then only the player will receive the packet, otherwise all nearby players will receive it. Giving <code>volume</code> or <code>pitch</code> will change their respective values, but will each default to <code>1.0</code> if no value is provided. Will return <code>1.0</code> if the sound was played successfully, otherwise will return <code>0.0</code>. | |||
|<syntaxhighlight lang="kotlin">q.world.play_sound_on_server('cobblemon:pokemon.bidoof.cry', 'master', 0, 0, 0)</syntaxhighlight> | |||
|- | |- | ||
|<syntaxhighlight lang="kotlin">get_entities_around(x: Double, y: Double, z: Double, range: Double): ArrayStruct<MoValue></syntaxhighlight> | |<syntaxhighlight lang="kotlin">get_entities_around(x: Double, y: Double, z: Double, range: Double): ArrayStruct<MoValue></syntaxhighlight> | ||
|Returns a list of entities within <code>range</code> of <code>x</code>, <code>y</code>, and <code>z</code>. This list contains the most specific MoValue for an entity, either Player, PokemonEntity, NPCEntity, or a regular Entity. | |Returns a list of entities within <code>range</code> of <code>x</code>, <code>y</code>, and <code>z</code>. This list contains the most specific MoValue for an entity, either Player, PokemonEntity, NPCEntity, or a regular Entity. | ||
|<syntaxhighlight lang="kotlin">q.world.get_entities_around(0, 0, 0, 10)</syntaxhighlight> | |<syntaxhighlight lang="kotlin">q.world.get_entities_around(0, 0, 0, 10)</syntaxhighlight> | ||
|- | |||
|<syntaxhighlight lang="kotlin">is_healer_in_use(position: ArrayStruct<MoValue>): Double</syntaxhighlight> | |||
|Takes a block position as an <code>ArrayStruct<MoValue></code> and checks the healing machine at the stated position. Returns <code>0.0</code> if a healer exists and it is not being utilized. Otherwise, returns <code>1.0</code> if no healer is found or if it is in use. | |||
|<syntaxhighlight lang="kotlin">q.world.is_healer_in_use(q.array(0, 0, 0))</syntaxhighlight> | |||
|} | |} | ||
Latest revision as of 04:22, 7 December 2025
Registry ObjectValue Functions
| Name | Description | Usage |
|---|---|---|
is_in(tag: ResouceLocation): Double
|
Returns 1.0 if tag is in the registry, otherwise returns 0.0.
|
v.registry.is_in('#cobblemon:guilded_chest')
|
is_of(identifier: ResourceLocation): Double
|
Returns 1.0 if identifier is in the registry, otherwise returns 0.0.
|
v.registry.is_of('minecraft:dirt')
|
Biome Functions
Can use the Registry ObjectValue. Type is ObjectValue<Biome>.*
| Name | Description | Usage |
|---|---|---|
| None :) |
World Functions
Can use the Registry ObjectValue. Type is ObjectValue<Level>.*
| Name | Description | Usage |
|---|---|---|
is_time_of_day(timeOfDay: String): Double
|
Returns 1.0 if the provided String corresponds to a registered time range, such as day or night. Otherwise, will return 0.0.
|
q.world.is_time_of_day('morning')
|
game_time(): Double
|
Returns the game time in ticks. | q.world.game_time()
|
time_of_day(): Double
|
Returns the dayTime in ticks.
|
q.world.time_of_day()
|
server(): QueryStruct
|
Returns a Server object if on a server, otherwise returns 0.0.
|
q.world.server()
|
is_raining_at(x: Int, y: Int, z: Int): Double
|
Takes a block position and returns 1.0 if it is raining there, otherwise returns 0.0.
|
q.world.is_raining_at(0, 0, 0)
|
is_snowing_at(x: Int, y: Int, z: Int): Double
|
Takes a block position and returns 1.0 if it is snowing there, otherwise returns 0.0.
|
q.world.is_snowing_at(0, 0, 0)
|
is_chunk_loaded_at(x: Int, y: Int, z: Int): Double
|
Takes a block position and returns 1.0 if the chunk containing the block is loaded, otherwise returns 0.0.
|
q.world.is_chunk_loaded_at(0, 0, 0)
|
is_thundering(): Double
|
Returns 1.0 if the the world is thundering, otherwise returns 0.0.
|
q.world.is_thundering()
|
is_raining(): Double
|
Returns 1.0 if the the world is raining, otherwise returns 0.0.
|
q.world.is_raining()
|
set_block(x: Int, y: Int, z: Int, block: String): Double
|
Take a block position and set it to be a block. Returns 1.0 if the block was set successfully. Will return 0.0 and log the unknown string if it's an invalid block or already set to the specified block.
|
q.world.set_block(0, 0, 0, 'minecraft:dirt')
|
is_air(x: Double, y: Double, z: Double): Double
|
Takes a block position and returns 1.0 if the block state is air, otherwise returns 0.0.
|
q.world.is_air(0, 0, 0)
|
get_block(x: Int, y: Int, z: Int): ObjectValue<Block>
|
Gets the block at the location x, y, and z.
|
q.world.get_block(0, 0, 0)
|
spawn_explosion(x: Double, y: Double, z: Double, range: Double, interaction: String?): Double
|
Spawns an explosion at x, y, and z with range of range. interaction is a string of what kind of explosion it should be, such as block, mob, tnt, trigger, or none. Is tnt by default. Will return 1.0 if successful, otherwise returns 0.0.
|
q.world.spawn_explosion(0, 0, 0, 3)
|
spawn_lightning(x: Double, y: Double, z: Double): Double
|
Spawns a lightning bolt at the location x, y, and z. Returns 1.0.
|
q.world.spawn_lightning(0, 0, 0)
|
spawn_bedrock_particles(particle: String, x: Double, y: Double, z: Double, player: MoValue?): Double
|
Spawns bedrock particles at the location x, y, and z. When run on the server, if a player value is specified (either a player object or a UUID) then only the player specified will receive the packet, otherwise all nearby players will receive it. If run on a client then it will play the animation for only that player, ignoring the player value, returning 0.0 if the particle is not in the registry. Will return 1.0 if ran successfully, otherwise will return 0.0.
|
q.world.spawn_bedrock_particles('cobblemon:cherry_leaves_particle', 0, 0, 0)
|
spawn_pokemon(x: Int, y: Int, z: Int, properties: String): MoValue
|
Takes a block position and spawns a Pokémon at the given position with the provided properties String. Returns an ObjectValue<PokemonEntity> of the spawned Pokémon. Returns 0.0 if the spawn was not successful.
|
q.world.spawn_pokemon(0, 0, 0, 'bidoof lvl=100')
|
spawn_npc(x: Double, y: Double, z: Double, npcClass: String, level: Int): MoValue
|
Takes a block position and spawns an NPC at that position with the provided npcClass and NPC level. The NPC level is utilized for party pool customization. Returns an ObjectValue<NPCEntity> of the spawned NPC. Returns 0.0 if the spawn was not successful.
|
q.world.spawn_npc(0, 0, 0, 'sacchi', 1)
|
play_sound_on_server(sound: String, soundSource: String, x: Double, y: Double, z: Double, player: MoValue?, volume: Double?, pitch: Double?): Double
|
Plays the given sound on the soundSource track at x, y, and z. If a player value is specified (either a player object or a UUID) then only the player will receive the packet, otherwise all nearby players will receive it. Giving volume or pitch will change their respective values, but will each default to 1.0 if no value is provided. Will return 1.0 if the sound was played successfully, otherwise will return 0.0.
|
q.world.play_sound_on_server('cobblemon:pokemon.bidoof.cry', 'master', 0, 0, 0)
|
get_entities_around(x: Double, y: Double, z: Double, range: Double): ArrayStruct<MoValue>
|
Returns a list of entities within range of x, y, and z. This list contains the most specific MoValue for an entity, either Player, PokemonEntity, NPCEntity, or a regular Entity.
|
q.world.get_entities_around(0, 0, 0, 10)
|
is_healer_in_use(position: ArrayStruct<MoValue>): Double
|
Takes a block position as an ArrayStruct<MoValue> and checks the healing machine at the stated position. Returns 0.0 if a healer exists and it is not being utilized. Otherwise, returns 1.0 if no healer is found or if it is in use.
|
q.world.is_healer_in_use(q.array(0, 0, 0))
|
Dimension Functions
Can use the Registry ObjectValue. Type is ObjectValue<Dimension>.*
| Name | Description | Usage |
|---|---|---|
| None :) |
Block Functions
Can use the Registry ObjectValue. Type is ObjectValue<Block>.*
| Name | Description | Usage |
|---|---|---|
| None :) |
Footnote: *Technically the type is ObjectValue<Holder<*>>, but for the purposes of this documentation Holder has been omitted.