#Molang General

1 messages · Page 2 of 1

fluid atlas
#

it is always zero

#

I guess, same with z

swift rivet
#

q.position is server side so it changes every tick but animation runs every frame. Ofc it will be 0 99% of the time as the position stays the same except for one frame every 1/20th of a second when it changes

#

Also don't forget that you can do complex expressions in molang. I'd do it like this q.position != v.prev_pos ? {v.delta_pos=q.position-v.prev_pos; v.prev_pos=q.position;};

ember wyvern
#

yo guys how can i get a variable from a temp variable

#

t.player -> v.test

#

like this

abstract nacelle
#

you can do t.player -> v.attack_time > 0 for example, but the variable need to be public

lofty falcon
#

How can get the remainder

#

of a divsion

#

Nvm found

#
math.mod( value, dem)
lofty falcon
#

How big can numbers be in molang? is there a limt?

swift rivet
#

Molang values are 32 bit floats

#

So approximately 3.4028235 × 10³⁸ is the largest number you can store, and 16777216 is the largest integer that you can store without loosing precision

lofty falcon
#

Thanks should be big enough

lofty falcon
#

I would assume yes but I don't mess with molang very much

swift rivet
#

Yes, it applies to everything

lofty falcon
#

cool that ain't good for me tho

polar steeple
#

why query.scoreboard() only work when i setdisplay the score

edgy perch
#

MC is blind, it needs visual aid

polar steeple
polar steeple
#

nah that's me looking at others code

edgy perch
#

and then the only mistake on your code was as simple as

#

istg it kills my mood every time

lofty falcon
#

balls

polar steeple
#

true
i was working with a single animation all day and when it finally done i removed the score from the display and hit the record button and the freaking molang stooped working
no error in the log so i was lost

swift rivet
swift rivet
polar steeple
#

can script change them?

swift rivet
#

yes

polar steeple
#

nice will take a look at it
thanks

swift rivet
#

setProperty, getProperty, clearProperty

sage bronze
#

can anyone tell me what exactly i need to do to fix this?

swift rivet
#

I think only regular variables can be structs, but temps can't. So replace things like t.supertile.size with t.supertile_size

polar steeple
#

i want to decrease an entity heath by one but can't figure it out
i am doing it like this

"minecraft:health":{"value": "q.health - 1"}

is something wrong or is there a better way?

sage bronze
abstract nacelle
polar steeple
abstract nacelle
#

otherwise use scripting

polar steeple
#

script it is than

solid sierra
solid sierra
half verge
#

lol

sage bronze
solid sierra
#

Dude, I apologized for my mistake and you're still pushing this

#

Bit unnecessary

edgy perch
#

@slim fern sorry for the ping

#

I did it, I used scripts to give me block and item IDs...

#

but it's as I feared. we might need to wait for a flattening update

#

I learned scripting just to do this

tiny furnace
#

Hey, be careful with the emojis. Avoid emoji spam

edgy perch
#

Avoided 👍

sage bronze
#

dw about it

rough hound
polar steeple
#

i was trying to decree the health multiple time

coral forge
#

You'd probably have to have a component group for each possible health value, and switch based off of an entity property

tawdry stone
#

Hello, everyone
Please help: I don't understand where the source of the second and third errors can be

steel rapids
#

guys

#

how I can debug molang?

swift rivet
#

Only with indirect measures. Make it affect the color of entity or on BP side have an AC that can either print one thing or another, based on a molang condition. If you want to do something more advanced, you can make an AC that transfers molang value to a score or on RP side make a display with entity or particles

steel rapids
#

what is AC?

swift rivet
#

Animation controller

steel rapids
#

ok kkkkk

#

thanks man

steel rapids
#

I want see value this entity_cardinal_direction

swift rivet
#

You can't just "see it" directly. Use it in animation to scale a bone or in color overlay

steel rapids
#

😭

#

thanks so much vex

distant coyote
#

yo is there a query that can detect the tag of a player?

sharp light
ember wyvern
#

is there a way to detect breeding

summer walrus
#

Hi, does someone can tell me what are the differences between variable, temp and context ? (I saw the Microsoft Guide but I didn't understand)

half verge
#

variable.variable_name Read/write storage on an actor
temp.variable_name Read/write temporary storage
context.variable_name Read-only storage provided by the game in certain scenarios

coral forge
#

Temps are kind of like local variables in a function/method in programming languages

summer walrus
coral forge
rough hound
abstract nacelle
white brook
#

How to assign something into equipment and inside a group?

frozen star
abstract nacelle
#

this depends on what format version are you using, if you are using 1.20.30 or above, you need to set "menu_category" on "description" in the item, otherwise, use the component "minecraft:creative_category"

frozen star
#

That link as the listing of the groups, which I believe is what he needs regardless of version.

abstract nacelle
#

I know

white brook
#

@frozen star ❤️

frozen star
white brook
#

Oh I was just thanking u with a heart sorry for the ping

frozen star
#

no problem... just organizing my fishing loot

dense flame
#

Question: Can I use a range in this?
query.camera_rotation(0) ? 1 : 0
so could I say if between -45, 45 ? 1 :0?

swift rivet
#

q.in_range(q.camera_rotation(0), -45, 45)

dense flame
#

oh perfect.

eager harness
#

query.scoreboard('0')==pds

#

query.scoreboard('pds')==0

#

pds is my scoreboard name

#

Am I stupid I can't seem to get this to work.

foggy peak
#
"set_property": { 
   "working_tv:channel": "'(q.get_property('working_tv:channel') % 5) + 1'"
}
#

How should I format this so Minecraft read it correctly?

swift rivet
#

There is no get_property query and no % operator in molang. Use q.property and math.mod instead

foggy peak
#

ngl, script syntax has messed my muscle memory up

foggy peak
#

Whats the syntax of Math.mod?

#

nvm

#

I have a weird ' wrap around the query

#

It messes it up

tiny furnace
#

Im finding that, for some reason... && works like or, while || works like and. Any possible explications?

swift rivet
#

Do you negate the whole expression by any chance? If so it might be De Morgan's laws at fault
!(A && B) = !A || !B
!(A || B) = !A && !B

tiny furnace
#

I did not, nope

tiny furnace
#

How can I make this set the value of the block state into different ones based on the block being in test?
For example, this molang thing is asking if the block has a block with the found tag in -1, 0, 0 from it:
"kai:west": "q.block_neighbor_has_any_tag(-1, 0, 0, 'found') ? 1 : 0"

I want to make it to work exactly like that but also include something like
and if I have a block in -1, 1, 0 with the found tag, do to kai:west the ? 2: 3

#

I hope that makes any sense, my brain is too burnt right now

tiny furnace
#

I think my solution is "kai:west": "q.block_neighbor_has_any_tag(-1, 0, 0, 'found') ? (q.block_neighbor_has_any_tag(-1, 1, 0, 'found') ? 3 : 1) : 0", will give it a shot

#

yup, that is indeed it

foggy peak
#

Does molang has toFixed(2) ?

#

I tried math.round(number,2)

#

But it's not possible

#

This table on has rounding function to the integer and not float

swift rivet
#

General formula is round(x*10^n)/(10^n)
Where x is input number and n is number of decimal places

foggy peak
#

Btw

#

Im trying to develope a better animated UV

#

Do u mind if I dm u for something?

#

For context

#

If you load 2 textures as animated UV (both share the same number of frame + size ), one that stacks as a square grid and one stack vertically , the vertically will crash Minecraft

#

So Im making a webapp (use ffmpeg) to convert video to grid animated UV, then use molang to animate it correctly

#

For example:

swift rivet
#

Is it for entity texture or block flipbook?

foggy peak
#

And in-game:

foggy peak
#

I figure all the math out

#

I just need a bit help with trimming the black screen

#

For context, the way the grid is created is base on this formula:

math.ceil(math.sqrt(numberOfFrame))

#

So there will be blank frame AKA the black frame

#

I need to use molang to keep up where the UV position then do a reset

#

ScriptAPI would be much better to do this but sadly, I cant find a way to use Script to move UV

#

I guess Mathew method of grid stacking can give us the position when the blank screen starts, then if the molang tracking === blank screen, reset?

#

nah use Mathew improved method of grid stacking...

swift rivet
#

"offset": ["math.mod(math.mod(math.floor(FPS*q.life_time), FRAME_COUNT), FRAMES_HORIZONTALLY) / FRAMES_HORIZONTALLY", "math.floor(math.mod(math.floor(FPS*q.life_time), FRAME_COUNT)/FRAMES_HORIZONTALLY) / FRAMES_VERTICALLY"]

foggy peak
#

Your math doesnt move the UV frame by frame, just run the UV across the image

swift rivet
#

edited, try now

#

forgot to floor the frame count

foggy peak
#

Your math is still flaw

#

The verticle need to make a jump across a frame not by 1 pixel jump

#
"offset": [ 
"(math.mod(math.floor(query.life_time * 10), query.property('working_tv:channel_frame')) / query.property('working_tv:channel_frame'))",
"math.mod(math.floor(query.life_time/(query.property('working_tv:channel_frame') / 10))*(math.mod(1, query.property('working_tv:channel_frame')) / query.property('working_tv:channel_frame')),1)"
],
#

This is my method

#

It works

#

Just that it cant cut the blank frame

#

query.property('working_tv:channel_frame') is just the number of frame

#

FPS is 10

swift rivet
swift rivet
swift rivet
#

10 or 100

foggy peak
#

Sorry

#

Hmm

#

Wait

#

I can just seperated them

swift rivet
#

oops wait

foggy peak
#

Nah

#

Hmm

swift rivet
#

now it's good

#

wait no

foggy peak
#

💀

#

Bruh

swift rivet
#

Now it reallyt is

foggy peak
#

Just seperate 2 axis

swift rivet
#

frame count is how many non blank frames you have

foggy peak
#

Doesnt work

swift rivet
#

show ur offset molang

foggy peak
#
"offset": [ 
     "(math.mod(math.mod(math.floor(query.life_time * 10), 13), query.property('working_tv:channel_frame')) / query.property('working_tv:channel_frame'))",
    "math.mod(math.floor(query.life_time/(query.property('working_tv:channel_frame') / 10))*(math.mod(1, query.property('working_tv:channel_frame')) / query.property('working_tv:channel_frame')),1)"
],
#

Take a look at the texture

#

13 blank frames

swift rivet
#
"offset": [
    "math.mod(math.mod(math.floor(10*q.life_time), 13), q.property('working_tv:channel_frame')) / q.property('working_tv:channel_frame')",
    "math.floor(math.mod(math.floor(10*q.life_time), 13) / q.property('working_tv:channel_frame')) / q.property('working_tv:channel_frame')"
]```
foggy peak
swift rivet
#

it will

foggy peak
#

Cause ur math will loops from 1 -> 13

#

Then stop

#

Bruh Im so good at this

#

Yeah

#

It loop from frame 1 - > frame 13

#

It should loop from 1 -> 87

swift rivet
#

then change 13 to 87

#

FRAME_COUNT was supposed to be total number of non-blank frames, and you used 13 in your code so I assumed you had 13 frames total

foggy peak
#

Bruh

#

it works now

#

😩

#

@swift rivet Do u have github or something?

#

I want to give u credit for this

#

Now find a way to get the blank frame using ffmpeg

#

💀

tiny furnace
#

Hey @swift rivet, I would love your help with something. Is probably simple... but to be honest, my brain is very much burnt on this topic. So, I want a block state to have 4 different values, all depending on neighboring blocks. Basically I want the condition (from the diamond block in this image) to be true if any of these other blocks are there. So, either west is true or up, west and WT (west and top, in the same state of west) are true

#

Im making it like this:

"kai:west": "q.block_neighbor_has_any_tag(-1, 0, 0, 'connected_glass') ? (q.block_neighbor_has_any_tag(-1, 1, 0, 'connected_glass') ? (q.block_neighbor_has_any_tag(-1, -1, 0, 'connected_glass') ? 3 : 2) : 1) : 0"
#

I also have to test for bottom blocks to have another value, that is why the fourth value

#

The tedious task is testing for WT and WB in the same state. I am unable to add more, unfortunately

swift rivet
#

I don't really understand tbh

tiny furnace
#

Do you see what the molang condition is doing here?

#

From my understanding it should be doing:
0: If the block to the west does not have the 'connected_glass' tag.
1: If the block to the west has the 'connected_glass' tag, and the block one unit above does not have the 'connected_glass' tag.
2: If the block to the west has the 'connected_glass' tag, the block one unit above also has the 'connected_glass' tag, but the block one unit below does not have the 'connected_glass' tag.
3: If the block to the west has the 'connected_glass' tag, and both the block one unit above and one unit below have the 'connected_glass' tag

#

I am right here?

coral forge
#

Can't you use addition for molang queries? At least from my understanding, boolean queries return 1.0 or 0.0. Something like

"kai:west": "q.block_neighbor_has_any_tag(-1, 0, 0, 'connected_glass') + q.block_neighbor_has_any_tag(-1, 1, 0, 'connected_glass') + q.block_neighbor_has_any_tag(-1, -1, 0, 'connected_glass') "

Should work, unless its changed or you want there to need to be the block to the west for it to work at all.

tiny furnace
#

I don't think i'll be able to use a boolean query for this, as I very much need it to be divided in 4 different values in the same state

coral forge
#

I just mean that I think it should be possible to add up the queries rather than using a series of ternary operators

tiny furnace
#

And what are the benefits of that?

coral forge
#

Say you have a block with the tag on top. Adding them together will return as 1, whereas using the ternary operators will return as 0 because there isn't a block with the tag to the west

tiny furnace
#

I see

#

However, that condition will mess up much of my stuff... I would love other solution

tiny furnace
coral forge
#

Ah, sorry, I missed that it was supposed to be conditional on the west block. I think your query should work though, the coordinates just might need some tweaking to get the right blocks

tiny furnace
#

Coordinates are fine

#

That just means that my problem is in my second condition

#

Let me show you... sec

tiny furnace
#

query.block_state('kai:west') == 3
This is being true even though kai:west is 0, 1 or 2...

tiny furnace
#

You can sort of replace && with ternary operators right?

coral forge
#

I don't use them too much, but I think so

tiny furnace
#

It seems like it, yeah, thanks!

tiny furnace
#

Im making my condition true if the diamond block has all three gold blocks in that position from it. Everything works fine unless I place a block below it with the same tag... thoughts?

#
query.block_state('kai:north') == 0 && (query.block_state('kai:east_ub') == 0 || query.block_state('kai:up') == 0 || query.block_state('kai:east') == 0)
#

The condition is being true in all the diamond blocks:

#

The redstone blocks should not have the condition set to true, but they do.

#

Any thoughts?

#

Redstone blocks should only have the condition set to true if the emerald blocks were gold blocks.

abstract nacelle
#

is minecraft dev edition?

half verge
tiny furnace
abstract nacelle
#

epic

abstract nacelle
#

and its possible to do it with entities? like show what component group is active

tiny furnace
tiny furnace
abstract nacelle
#

epic! thank you

severe cave
#

Is there a way to detect that cattle are lured by food?

tiny furnace
#

Any thoughts on how I could get all these:

                    "kai:north": "q.block_neighbor_has_any_tag(0, 0, -1, 'connected_glass') ? 1 : 0",
                    "kai:south": "q.block_neighbor_has_any_tag(0, 0, 1, 'connected_glass') ? 1 : 0",
                    "kai:east": "q.block_neighbor_has_any_tag(1, 0, 0, 'connected_glass') ? 1 : 0",
                    "kai:west": "q.block_neighbor_has_any_tag(-1, 0, 0, 'connected_glass') ? 1 : 0"

Into a single block state? I want to be able to manage the data just like nothing changed from the code above, but using a single block state instead of 4.

tiny furnace
#

I think I got it:

"kai:direction": "q.block_neighbor_has_any_tag(0, 0, -1, 'connected_glass') ? 'north' : (q.block_neighbor_has_any_tag(0, 0, 1, 'connected_glass') ? 'south' : (q.block_neighbor_has_any_tag(1, 0, 0, 'connected_glass') ? 'east' : (q.block_neighbor_has_any_tag(-1, 0, 0, 'connected_glass') ? 'west' : 'none')))"```
devout socket
#

how to check the entities around

frozen star
#

There is an entity sensor, is this for something other than an entity file?

half verge
polar steeple
#

how to d this with molang
if(q.block_state('') < 15){
return q.block_state('')+1
}else{
return 0
}

polar steeple
swift rivet
#

math.mod(q.block_state()+1, 16) also works

#

Assuming you want to increment block state from 0 to 15 and then reset to 0 and repeat

edgy perch
#

holon

#

q.body_y_rotation

#

how do I log the rotation values

dapper star
#

Have you tried molang to scoreboard?

pure flume
#

Which molang is used to detect that the player's hand is empty?
solved

sharp light
abstract nacelle
sharp light
#

Not sure tbh, but with just molang you can't

torpid vault
#

Not sure what q.body_y_rotation returns but with Scripting you can get the entity’s rotation

#

Ah, I don’t think you’re able to get the body’s rotation, you can only get the head’s rotation in scripting

swift rivet
# edgy perch how do I log the rotation values

There is no easy way but there are some harder options. On BP side you can make an AC logic that will transfer any molang value into scoreboard by breaking it down into components and adding those components via scoreboard add. On the client, you can make a particle or entity based display that would be able to display any value as a floating text

severe cave
#

I made an animation of the skeleton's attack, how to detect the skeleton's bow and arrow attack

zinc raft
#

And what would the query be like for an enum type property that has several values?

#

Does anyone know how to read or detect any of the values ​​of this property with molang(query)?
tf:add_marcos": {
"type": "enum",
"values": [
"holograma",
"iron",
"copper",
"gold",
"diamond",
"emerald",
"netherite"
],
"default": "holograma",
"client_sync": true
},

severe cave
polar steeple
#

is there a molang function for entity property?

coral forge
#

q.property('namespace:property')

polar steeple
#

thanks

polar steeple
coral forge
# polar steeple

Is this in the rp or BP? If it's in the rp, client_sync needs to be set to true in the property

polar steeple
coral forge
#

Huh, that's strange. I'm not entirely sure, maybe try 1.20.40

#

I've only barely started using properties instead of dummy components myself

polar steeple
#

sure
i need to update my other files first

polar steeple
#

still the same

coral forge
#

Oof. Not really sure what the issue is. Maybe something was misspelled?

polar steeple
#

tnx

mossy shell
#

any way to test hurt entity from resource side?

sleek glen
mossy shell
sleek glen
mossy shell
#

afaik it doesnt. probably so you dont make a resource pack to see other player's health on servers

#

ill try tho

mossy shell
gusty saddle
mossy shell
#

do variables remain between ac transitions? and if not can i make them do?

austere oak
#

does query.is_first_person not work in behavior animation controllers

mossy shell
low finch
#

"v.frame = query.is_using_item ? ((v.frame ?? 0.0) == 0.0 ? 1.0 : 0.0);"
Why it not work :((

unborn nimbus
#

How do I return the "timeline" to 0 if the animation is not met?

#
        "animation.ressur": {
            "timeline": {
                "5.0": [
                "/give @s apple"
                ]
            },
            "animation_length": 5.1,
            "loop": true
        }
sleek glen
#

You can simply stop playing the animation to return it to 0 at any point.

#

if that's what you meant.

honest flint
#

Is there a way to simplify this?

query.property('cbr:color') == 3 && query.can_fly && query.property('cbr:burn') >=4 || query.property('cbr:color') == 3 && query.can_fly && query.property('cbr:burn') == 0

#

Trying to be more efficient; the only property that changes is cbr:burn, but I have to retype everything just to check for that one value.

It's not a problem for me now, but I'm sure it'll be in the future when I need to check for more than two values.

sleek glen
#

I'm assuming you have to type this same thing a lot of time. Am I right?

#

You can use variables.

torpid vault
honest flint
#

wait, that's it?

sleek glen
#

Yes, that's parantheses.

honest flint
#

well I feel dumb now lol.
but yes, these were changing variables that I was checking for.

honest flint
#

I was imagining far more complicated symbols that I haven't gotten around to learning yet

abstract nacelle
coral forge
#

Yeah, it's a bit disappointing. Though hopefully Kayla is able to bring the feedback from the post back to mojang. I doubt it will change their mind at this point though

abstract nacelle
#

Even if it will going to be versioned, we cannot maintain a min engine version forever because new functions will come out

abstract nacelle
#

In fact, maybe I'm wrong but I felt more lag with for each of the scripts than with Molang

coral forge
#

My guess for why they're removing it is potential issues for handling null returns. If that is it, there could just be content log errors and just having the function return 0 if there's a null. I just want to see if Kayla has the info for what led to their decision

#

I definitely disagree with it, but getter understanding always helps

abstract nacelle
#

I would really appreciate an explanation as to why there is an urgent need to move everything out experimental, I know that it is better for it to be stable, but when it is not possible, why is it not better to leave it as is? because they are used functions, with the items and blocks they eliminated a lot of components because they couldn't remove them from experimental and I can't understand why. I cant understand why is better remove it instead of leave it as it is

coral forge
#

Yeah, it doesn't make any sense

#

Most of the time when somethings deprecated in an api, it's still accessible, just not improved anymore and has a warning that it is

abstract nacelle
#

We will never know the reason I guess

sleek glen
coral forge
#

It's very vague though

abstract nacelle
#

yeah, very vague

#

its like with blocks and items components, "cumulous of problems"

sleek glen
abstract nacelle
abstract nacelle
sleek glen
abstract nacelle
#

because in all this time it worked fine, literally 90% of my entities use it and they are not simple for_each and I had no problems

#

So that's why we're asking what that "buggy behavior" is.

sleek glen
abstract nacelle
#

Even if that were the problem, what is our alternative to achieve the same behavior?

#

If it's none, I really think that's not the solution. These queries fulfill a very important function in addons.

sleek glen
abstract nacelle
#

The same thing will happen as with the components of items and blocks.

#

*disappears

sleek glen
#

Anyways, whatever it is, it's not coming anytime soon!

#

If you leave the get rider and scoreboard queries they talked about.

abstract nacelle
sleek glen
abstract nacelle
sleek glen
# abstract nacelle I mostly use query.get_nearby_entities and query.target

Just a week ago, I was almost going to use q.target because I was not finding a way to place a connection between the player and an entity spawned by him. Since, the entity is a projectile it sets the entity (in this case me) as it's owner. So, I thought why not make the entity target it's owner only using is_owner filter than I can use q.target to place a connection between them but I ended up using a workaround made up of commands.

abstract nacelle
sleek glen
#

In most cases, there is a workaround.

abstract nacelle
# sleek glen What's your issue ?

I show you this example

v.player = 0; v.score = 0; v.score2 = 0; v.detect = 0; for_each(t.player, q.get_nearby_entities(5, 'minecraft:player'), {t.score = q.scoreboard('bardiche'); t.score2 = (t.player -> q.scoreboard('bardiche')); {v.player = t.player; v.score = t.score; v.score2 = t.score2; v.detect = (v.player -> query.is_item_name_any('slot.weapon.mainhand', 1, 'ch:bardiche') == 1 ? v.score2 == v.score) ? {return 1.0;};};});```
#

How I can avoid this? XD

sleek glen
#

My brain can't process all of that right now. I wanted to know why you want to use these queries.

abstract nacelle
#

Even if you could, with the fact that it is more expensive and having to change the entire addon for something that was not even justified is very annoying

abstract nacelle
sleek glen
#

That's why you don't use experimental. It's just like gambling.

abstract nacelle
#

This is a particular situation, many addons use these queries, not all of them can be avoided

abstract nacelle
abstract nacelle
#

For example, if you could from the subject's filters it could be, but you have to use the execute score, if you take the closest player and you don't have the score, you won't take another one, you will wait for the closest player to be the one. let him fulfill it

sleek glen
#

I'm not really going to debate about if those queries were useless or useful. I also know that they were useful. I'm just trying to know why you chose to use them instead of the workarounds. If there were none, then it would make a lot of sense to me.

abstract nacelle
#

Even after that I have to use the states in the animation controller

sleek glen
#

The q.target stuff was also about it ☝️

abstract nacelle
sleek glen
abstract nacelle
#

👍

#

In any case, let's not forget that commands that are constantly executed also cause lag.

#

lag is one of the reasons Kayla specified

#

next update, mojang delete functions
jk

sleek glen
#

You should just know how to use them properly 😄

abstract nacelle
sleek glen
#

You have a good pc right?

abstract nacelle
#

in ticks

sleek glen
abstract nacelle
#

and that didn't happen

#

in fact, it happens when you put a very large hitbox on an entity (hopefully mojang doesn't limit the size to hitboxes and can fix it)

uncut cloak
#

How come query.block_neighbor_has_any_tag in this doesn't work?

"minecraft:geometry": {
    "identifier": "geometry.amber_glass",
    "bone_visibility": {
        "north_top": "query.block_neighbor_has_any_tag(0,1,0, 'glass')"
    }
}
sleek glen
#

I replied to you about this in an other post.

quick totem
#

why not..?

#

{ "format_version": "1.10.0", "animation_controllers": { "controller.animation.attacking": { "initial_state": "default", "states": { "default": { "transitions": [ { "attack": "variable.attack_time > 0.1" } ] }, "attack": { "on_entry": [ "/gamemode 1 @s" ], "on_exit": [ "/gamemode 0 @s" ], "transitions": [ { "default": "variable.attack.time < 0.1" } ] } } } } }

#

{ "format_version": "1.11.0", "minecraft:entity": { "description": { "identifier": "minecraft:player", "is_spawnable": false, "is_summonable": false, "is_experimental": false, "scripts":{ "animate":[ "attack" ] }, "animations": { "attack": "controller.animation.attacking" } },

sleek glen
mossy hinge
#

Hiiii
I need help

#

How tô fix this ?

coral forge
sleek glen
#

Add an effect to the player itself?

#

minecraft:spell_effects is the right component for it but in-case you're trying to give an effect to nearby entities use what Blaze said.

mossy hinge
sleek glen
# mossy hinge Yep

So, please use the component I sent. You can find an example of it in player.json itself.

#

You can see it being used to add the bad omen effect.

mossy hinge
#

Ok thanks for your time
I gonna try

mossy hinge
sleek glen
uncut cloak
#

query.is_item_equipped('minecraft:lava_bucket')

#

Is that correct?

#

actually, I might just use query.is_item_name_any

coral forge
#

q.is_item_any('slot.weapon.mainhand',0,'minecraft:lava_bucket') is what you'd want to do

uncut cloak
#

ye

edgy perch
#

They're deprecating this?

#

The thing that can query values from mobs using commands and scripting API?

#

The thing that lets me query values from mobs without changing their behavior files?

#

pretty stupid

coral forge
abstract nacelle
#

just wait to query.target, query.get_nearby_entities, query.get_riders, be deprecated

uncut cloak
#

Is it possible to have another block change the state of another block using MoLang?

uncut cloak
#

aww damn it

inner jasper
#

Well, molang itself cant do anyrhing

uncut cloak
#

What can?

inner jasper
#

Block events can

uncut cloak
#

ye

inner jasper
#

You can use random ticking or the ticking component to check a condition using molang

uncut cloak
#

Could you give an example?

inner jasper
uncut cloak
#

oki

#

Thank you

inner jasper
#

Seems to be more of a #1067869022273667152 question. I see no usage of Molang except for the default one for experience drop

graceful grail
#

Does anyone compare the two valuables || and && are the same?

sleek glen
graceful grail
#

How about using it in custom block?

abstract nacelle
#
"condition": "q.block_state('state') == 1 || q.block_state('state) == 2"```
graceful grail
#

Oh so they activate at the same time?

graceful grail
#

Because I need them to activate at the same time

uncut cloak
#
"condition": "query.block_neighbor_has_any_tag(1,0,0, 'lava_height_15') && query.block_neighbor_has_any_tag(0,-1,0, 'basin') || query.block_neighbor_has_any_tag(-1,0,0, 'lava_height_15') && query.block_neighbor_has_any_tag(0,-1,0, 'basin')```
#

I don't know how to explain what I'm wanting to ask, so please bear with me for a moment

uncut cloak
#

or will it work like "condition": "query.block_neighbor_has_any_tag(1,0,0, 'lava_height_15') &&
query.block_neighbor_has_any_tag(0,-1,0, 'basin')
||
query.block_neighbor_has_any_tag(-1,0,0, 'lava_height_15')
&& query.block_neighbor_has_any_tag(0,-1,0, 'basin')

#

Like does it do an 'or' for the middle 2?

uncut cloak
inner jasper
#

Using () will ensure the behaviour you want

uncut cloak
#

ahh ok

#

Thank you

#

so like this?

"condition": "(query.block_neighbor_has_any_tag(1,0,0, 'lava_height_15') && query.block_neighbor_has_any_tag(0,-1,0, 'basin')) || (query.block_neighbor_has_any_tag(-1,0,0, 'lava_height_15') && query.block_neighbor_has_any_tag(0,-1,0, 'basin'))"```
uncut cloak
#

Thank you very much man. Appreciate it

tiny furnace
#

Mathematical

uncut cloak
#

anyone know if query.get_equipped_item_name is being deprecated?

uncut cloak
#

ahh damn

#

Also, should I start updating my add-ons to 1.20.60 instead of 1.20.50?

inner jasper
#

That's up to you

abstract nacelle
#

but use query.is_item_name_any

#

its better

uneven quail
#

How can I detect when the player looks up?

uneven quail
#

Tried using this query.head_y_rotation(75)

stray vale
#

I'm trying to do the wiki tutorial on the molang to scoreboard converter but the game gives me the error "unhandled request for unknown variable 'variable.digit'"

uncut cloak
#

Is it possible to add different state values?
Like lets say

"condition":
"(query.block_state(alpha) + query.block_state(beta)) == 10"```
devout socket
#

[Molang][error]-block_definitions | /storage/emulated/0/Android/data/com.mojang.minecraftpe/files/games/com.mojang/behavior_packs/[АБА] | blocks/doors/up_protective_door.json | /storage/emulated/0/Android/data/com.mojang.minecraftpe/files/games/com.mojang/behavior_packs/[АБА] | blocks/doors/up_protective_door.json | aba:up_protective_door | events | aba:event | condition | condition | Error parsing: query.block_neighbor_has_any_tag(1,0,0, 'stone' || 'wood' )

uncut cloak
#

both query.block_property & query.has_block_property are deprecated after 1.20.40 right?

#

Because I am seeing them in event conditions in 1.20.50

#

in Bridge. btw

devout socket
devout socket
#

[Molang][error]-block_definitions | /storage/emulated/0/Android/data/com.mojang.minecraftpe/files/games/com.mojang/behavior_packs/[АБА] | blocks/doors/up_protective_door_a.json | /storage/emulated/0/Android/data/com.mojang.minecraftpe/files/games/com.mojang/behavior_packs/[АБА] | blocks/doors/up_protective_door_a.json | aba:up_protective_door_a | events | aba:event | condition | condition | query.get_equipped_item_name !== 'key_card_a' || query.get_equipped_item_name !== 'key_card_b' || query.get_equipped_item_name !== 'key_card_c' || query.get_equipped_item_name !== 'key_card_d' || query.get_equipped_item_name !== 'key_card_aba' | Error: complex expressions (contains either '=' or ';') must end with a ';'

uncut cloak
coral forge
#

It already is deprecated

#

Deprecated normally means that it's not going to be updated anymore, so any bugs with it won't be fixed

coral forge
coral forge
#

Can you send your block code?

coral forge
#

I meant the json file. Also, are you still getting a content log error? Finally, what are you trying to do?

devout socket
#

                "condition": "query.get_equipped_item_name !== 'key_card_a' || query.get_equipped_item_name !== 'key_card_b' || query.get_equipped_item_name !== 'key_card_c' || query.get_equipped_item_name !== 'key_card_d' || query.get_equipped_item_name !== 'key_card_aba' ",


coral forge
#

I meant the whole file(I want to help, but there might be some other issue with the block that could be making it not work). And you didn't change the !== to !=.

coral forge
#

Then there must be an issue somewhere else in your blocks file.

#

As != is what tests for inequality

devout socket
#

freds

#

French

#

in friends list

coral forge
#

I prefer to chat in public so other people can see this conversation later if they have similar issues. Though I can do dms if you dont want your block code to be in public

#

Note that I won't answer future questions in dms though

devout socket
devout socket
#

true:


              {
                "condition": "query.get_equipped_item_name != 'key_card_a' && query.get_equipped_item_name != 'key_card_b' && query.get_equipped_item_name != 'key_card_c' && query.get_equipped_item_name != 'key_card_d' && query.get_equipped_item_name != 'key_card_aba' ",
                "sequence": [
                  {
                    "run_command": {
                      "command": [
                        "playsound aba.error @a ~~~"
                      ]
                    }
                  }
                ]
              },

sleek glen
# devout socket true: ```js { "condition": "query.get_equipped_i...

              {
                "condition": "q.get_equipped_item_name != 'key_card_a' && q.get_equipped_item_name != 'key_card_b' && q.get_equipped_item_name != 'key_card_c' && q.get_equipped_item_name != 'key_card_d' && q.get_equipped_item_name != 'key_card_aba';",
                "sequence": [
                  {
                    "run_command": {
                      "command": [
                        "playsound aba.error @a ~~~"
                      ]
                    }
                  }
                ]
              },

devout socket
sleek glen
devout socket
pure flume
#

Does anyone know what tag format I should use to avoid receiving this error? The tag used is color_white

[Molang][error]-Error: query.equipped_item_any_tag requires tags to be in the format 'my_tag_name'.
coral forge
#

Can you send the query you're using?

formal herald
#

Is there a way to check the current age of a mob, particularly the age of a baby mob?

sleek glen
pure flume
#
"minecraft:tags": {
  "tags": [
    "color_white"
  ]
}
#

Maybe this is a bug, because despite the error everything works normally.

coral forge
#

Yeah, it looks fine to me. That's weird that an error's showing up though

formal herald
split bolt
# foggy peak

can you help me with that. i want that the UV frames look smooth

#

i want to make a smooth UV animation in enitity like blocks. not that texture from a sudden jump to the next frame

stray vale
#

how can I make a mob run in a random direction while still staying within a certain distance from the player it's targeting?

coral forge
sleek glen
rain oracle
#

query.has_biome_tag, how do i use this query, and what is in this return from molang?,
i tried like q.biome_has_any_tag it doesn't work,
i want to find an alternative to q.biome_has_any_tag because it was removed in the latest beta

abstract nacelle
#

but its in .60 preview, I think

rain oracle
uncut cloak
pure flume
spark spade
#

anyone know how to fix this?

#

all other query functions work

#

It functions properly but i keep getting that error

uncut cloak
#

Without a specified entity??

#

Tf

mild night
#

I want to kill an entity, if the query.has_rider = 0
How would I implement this into the entity's code?😅

uncut cloak
#
{ 
 
    {
       "components":
        {
        "minecraft:queued_ticking": {
             "loop": true,
             "event": "test:event",
             "ticking": [20,20]
            }
      }
},
{
    "events":
        {
          "test:event":
         {
          "sequence": 
                   {
                   "condition": "query.has_rider == 0",
                   "run_command": {
                         "command": "kill @s" 
                   }
               }
            }
        }
    }
}
#

I believe it should be something like that

mild night
#

Thank you

sleek glen
sleek glen
slow sandBOT
uncut cloak
sleek glen
meager hamlet
#

@sleek glen I don't want the animation to work when the player wears all the armor pieces. I wrote one, which molang should we use, but it didn't work?

#
"!query.has_armor_slot(0) || !query.has_armor_slot(1) ||!query.has_armor_slot(2) || !query.has_armor_slot(3)"```
meager hamlet
#

@sleek glen help me

gaunt swallow
#

surface_particle_color, query.surface_particle_texture_coordinate, and query.surface_particle_texture_size are now versioned with 1.20.70 to allow the three queries to see leaf blocks as the surface texture below the block. Molang versions lower than 1.20.70 will continue to not see the leaf block below them

What is this?

sleek glen
pure flume
sleek glen
#

He already got a solution.

white folio
#

Hello! So what query or variable triggers from minecraft:behavior.melee_box_attack?

#

I saw this in the docs and my eyes lit up. I can make way more polished attacking mechanics.

I simply just need to know how does one link it.

left furnace
#

Can entity properties be modified using item events?

sleek glen
left furnace
#

Oh yeah thanks

uneven quail
#

{ "format_version": "1.10.0", "animation_controllers": { "controller.animation.m870_reload": { "initial_state": "default", "states": { "default": { "transitions": [ { "shoot": "query.get_equipped_item_name=='m870' && (q.scoreboard('m870') == 0) && query.is_item_name_any('slot.inventory', 'gun:ammo4')" } ] }, "shoot": { "on_entry": [ "/say reloading gun!", "/title @s actionbar Auto-Reloading", "/execute @a[hasitem={item=pg:a1,location=slot.weapon.mainhand}] ~ ~ ~ /replaceitem entity @p slot.weapon.mainhand 0 gun:m870" ], "animations": [ "m870_anim_reload" ], "transitions": [ { "default": "(q.all_animations_finished)" } ] } } } } }

#

Why this doesn't work

#

Didn't work after I added a.is_item_name_any

swift rivet
#

From documentation

The slot index is required for slot names that have multiple slots, for example 'slot.hotbar'
So if you want to check if item is in inventory, you'll have to loop through every slot and check if it has item or not.

uneven quail
swift rivet
#

It didn't work because you didn't specify slot index. That query can check only 1 slot at a time, not the whole hotbar or inventory at once

uneven quail
#

Okay thanks I'll do that

uncut cloak
#
query.block_state('dma:slots') == 0 && (query.block_state('dma:smelter_states') == 1|| query.block_state('dma:smelter_states') == 2) && (query.is_item_name_any('slot.weapon.mainhand', 0, 'minecraft:raw_iron_block') || query.is_item_name_any('slot.weapon.mainhand', 0, 'minecraft:raw_gold_block') || query.is_item_name_any('slot.weapon.mainhand', 0, 'minecraft:raw_copper_block'))```
Just want to make sure, but with the brackets around the various sections, that just checks if one of the conditions inside the brackets is true, right?
elfin stump
#

does anyone use arrays?

#

if anyone does, do you have some examples I could look at. the docs weren't enough

sleek glen
elfin stump
#

Idk I saw there was something with arrays but idk how to use them

uncut cloak
#

Can I do something like query.block_state('dma:smelter_states') >= 1 && <=2

coral forge
#

You'd need to do query.block_state('dma:smelter_states') >= 1 && query.block_state('dma:smelter_states') <=2. Molang doesn't know what you're comparing to 2 unless you put the query again

uncut cloak
#

oh well

#

for the first 2 block states, I could just test if smelter_states is <=2

#

saves a bit more

left furnace
#

how do I make int property set_property event add rather than setting a number up?

coral forge
#

Set it to q.property('ex:property_name')+<val>

ocean umbra
#

what's the point of deleting biome_has_any_tag and biome_has_all_tags instead of releasing them? what went wrong with? of entity related queries i get it but why biomes? why?

uncut cloak
#

And they have been revamping the tag system also, so that may be a reason also

ocean umbra
abstract nacelle
ocean umbra
ocean umbra
abstract nacelle
abstract nacelle
ocean umbra
#

i know that, what i meant is RP only, meaning without a behavior pack so you can use it in servers

ocean umbra
abstract nacelle
#

In any case you would still need a BP to make it work in the RP, we will have to wait some time until one day they make Local Scripts

#

that sucks

graceful grail
# devout socket

How do you do that door? I mean, you make two blocks right? How do you interact with another block?

#

I need to know because I made a custom door but they do not resonate interact

graceful grail
brisk heron
#

why doesnt this work? i know its not the best way but this is what suits for what im doing

"0.1667": ["!query.is_first_person * -104.178", "!query.is_first_person * -34.3204", "!query.is_first_person * -6.8844"],
#

im trying to make the animation play only when in 3rd person

coral forge
#

Why don't you just conditionally play it? {"animation":"!q.is_first_person:} instead of just "animation" under animate

abstract nacelle
#

how to detect when the player is climbing a ladder?

#

there is no query.is_climbing

pure flume
abstract nacelle
meager hamlet
#

@coral forge I want to activate the animation while the player is flying, how can I make a different flying animation?

coral forge
#

🤷‍♂️

#

for this reason, please don't ping random people to answer your question

#

Just let people answer it if they know

#

If no one is answering, they probably don't know, meaning you might need to do some research or debugging

slow sandBOT
#
Do not ping random people

Do not ping random people for help or otherwise.

Random pings are never good dont_ping_lich; No one is obligated to help you at random.

meager hamlet
#
"query.can_fly && !variable.is_first_person"```
Player does not appear when running
mellow iris
#
"doubleb:loaded": {
          "client_sync": true,
          "type": "int",
          "range": [
            0,
            2
          ],
          "default": 0
        },
#

I've been trying to understand this error for more than half an hour, it appeared in some recent updates, it worked before

fallen sorrel
#

"v.convert = q.above_top_solid(v.posx, v.posz);",

why does it think q.above_top_solid doesnt exist?

#

go figure as soon as i find a way to do molang to scoreboard, i immediately find a rare problem with it

#

screw it im bruteforcing the heightmap info via scripting

rotund plover
#

q.is_item_name_any('slot.weapon.mainhand', 'bridge:key')query.max_durability
is that correct?
if the player has key on hand it work and use 1 durability
if the player doesn't have the key on hand nothing work

torpid vault
#

Please don’t cross-post.

rotund plover
#

wdym

torpid vault
#

You already asked that question in #1067876948858118185, don’t re-send it again here.

rotund plover
#

but people are here to ask no ?

torpid vault
#

Yes, but don’t ask the same question in multiple channels.

rotund plover
#

uh..

#

k?

torpid vault
#

#usage message

rotund plover
#

bc i didn't knew

#

people tell me where to go

#

dude

white marlin
#

Hey ! I was wondering if there was a way to detect if an entity has been in the air for a certain amount of time ?

#

Like for more than 1s for exemple

#

I know that there's the query q.is_on_ground, but it does not give the time the entity has been in the air

abstract nacelle
#

1.0 is more or equal to one second

rustic marlin
#

Okay so I'm trying to figure something out and I need someone to clarify for me.

The goal is to get the precise location of the player into an entity's client-side Molang. It must be the precise position that the player is rendered at (not where they are according to the server). I already have the location of the camera, but it doesn't work so well when the player is in third person.

There is a query, q.is_first_person, which I see referenced a lot on this matter. However it seems to always be 0 for entities/attachments other than the player. So I don't think it is meant to just globally tell whether the client player is in first or third person but is highly contextual. I also see v.is_first_person and c.is_first_person referenced, but I think these must be typos since such variables don't seem to exist.

So, from an entity, is there a reliable way to determine whether the client player is in first or third person? Or even better, just directly get the rendered position of the player?

I cannot use experimental features or modify the player entity files for this.

#

What I'm doing right now is taking the camera position and vector, and doing some math with the server-side trajectory of the player to try and figure out where the player actually is. I know for sure that the player is going to be on the camera vector anywhere from 0 to 4 blocks along the ray, and I use the trajectory to pick out where. The issue is that it is often inconsistent if I am moving quickly or looking certain ways.

#

Ah, that explains v.is_first_person: #old-beginner-questions message

swift rivet
#

Does it actually work on other entities? I thought it only works on the player

#

Also btw the difference between v.is_first_person and c.is_first_person is that the latter is for attachables

odd jolt
#

how to use q.all_tags?

rustic marlin
swift rivet
#

You could give player an attachable that'd conditionally emit a particle if in 1st person, and then you can read particle/emitter count from the same particle type, so you'll have that information on any particle of the same type that you emit, but there is no official way to transfer that info from particle to entity. Otherwise I'd suggest using temp leaking, but it doesn't work if attachables are rendered anywhere in game, and based on your description I'm guessing you can't afford to disable them globally.

#

As a hacky workaround, you could store list of positions for multiple players in properties, then compare it to your client side reconstructed position to find which player is the current client

#

If there are too many players in multiplayer, fallback to just client side reconstruction

#

And all of that is necessary just because q.is_first_person doesn't work on other entities 😔

abstract nacelle
rustic marlin
#

Definitely can't afford hacky workarounds since this is for the Marketplace.

#

Alternatively, is there a way to play an animation on an entity for a specific player? Being able to figure out which player it needs to target in a clean way would be useful.

#

It'd be nice if they would just give us the Molang queries that get other entity variables already.

swift rivet
#

Ikr, but nope, those got removed. I was really looking forward to those, especially q.get_nearby_entities in combination with q.is_local_player, since it was the only way to cleanly read data from client player. Maybe we might get something like q.local_player at some point 🤞

rustic marlin
#

Looks like I just have to try and iron out the jank out of the reconstruction method then.

swift rivet
rustic marlin
#

The entities are linked to specific players, and render differently if their specific player is in first or third person. So the two hurdles to cross are determining whether the client is their player, and computing with good precision where the player is being rendered at.

#

I don't think storing more than one player will be needed since the entity already has the current and previous server positions in its properties. It's what allows it to compute the location.

#

Though it would certainly help if two players are in close proximity...

swift rivet
#

Ah, right, since you have one entity per player

rustic marlin
#

Well, several entities per player, but it's functionally the same.

#

All of them follow the player's position server-side to try and figure out where they are client-side.

#

Obviously players well outside the estimated region wouldn't be considered.

#

I think I can probably make it keep track of its estimation of first vs third person and update it as it goes, considering what it thought it was before. Most of the time it works just fine, but sometimes when the player is looking in a certain direction, it will flicker between the two.

#

One of the lines is the player's server-side trajectory, the other line is the camera ray. Where these two lines are the closest on the camera ray is where it reckons the player is being rendered at.

#

Though if these lines are close to being parallel (i.e. the player is moving in the direction that they're looking), it tends to be unstable.

swift rivet
#

oo that's quite smart

rustic marlin
#

Though because there is slight lag with the camera rotation query, moving the mouse quickly causes visual jank.

swift rivet
#

Huh, there is? Camera queries always executed at frame rate for me

rustic marlin
#

If you get the precise location of the camera, and then plot a bone directly in front of the player using camera rotation, it will lag behind very slightly when you turn.

#

The camera location is frame-precise though.

swift rivet
#

Ahh I see, I very rarely used camera rotation, but used position quite often

rustic marlin
#

Another thing I could look at would be tracking the movement of the camera when it rotates. If the player is in first person, the rotation will have no effect on position. But if the player is in third person, there will be a substantial effect, and the camera will orbit around their head position. Though combining this with the fact that the player is moving translationally may prove difficult.

#

Of course that doesn't work if the player lets go of their mouse. lol

rustic marlin
#

Changes specifically along the camera ray (or approximately along it, accounting for camera rotation and translational motion).

rustic marlin
#

One thing is for sure, the block of Molang that will do all this will be absolutely chonky. lol

#

Lot of moving parts going on all at once to factor in.

versed forum
#

Is there a way to pass data to an animation when played? I am trying to play the 'animation.player.attack.rotations' animation but it requires the 'variable.attack_time' to be set.

versed forum
versed forum
ocean umbra
versed forum
#

Any other way to properly trigger a player attack animation?

mossy shell
#

hello

#

is it possible to query the index of the selected hotbar slot?

dim rampart
#

Excuse me, do you know if it is possible to create a Billboarding effect on a particle, depending on where you see it, it changes texture? For example, like some old games, like Doom or Mario Kart 1, which depending on where the camera was, gave an effect like 3D.

swift rivet
#

With only particles you can scale UV based on distance to camera, but nothing else. But you can do a proper parallax scrolling effect using entities, by computing 3D camera position and animating UV based on it. There is also an option to use custom materials with stencil to render 3D objects inside of other objects, like here https://discord.com/channels/523663022053392405/1135204977342693548, but it's not easy to do.

Discord

Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

devout socket
#

Is there a molang that checks players nearby?

pure flume
#

I used query.property to change the render controller of the player in the client entity, it works fine but when the pause screen is opened this appears, does anyone know why?

[Molang][error]-minecraft:player.0.c18e65aa-7b21-4637-9b63-8ad63622ef01.Alex | Error: query.property does not have an actor.
pure flume
ember wyvern
#

Are there workarounds to test a item held by second player in the entity

coral forge
pure flume
#

Yes it works fine, but I tried something similar and the error persists. I tried what you said but now the error is that the expression must end with ; I couldn't get it to work

#
q.is_in_ui? return false; return q.property('test:property') == 'default'
coral forge
#

Ah, oops, my bad, you need a ; at the end of the second line as well

pure flume
#

I give up, I can't solve this, as it doesn't interfere with the addon's functioning I'll leave it like that. Placing ; at the end of the expression I received this error:

Error: unary Return 'return' operator not followed by expression
#

But thanks anyway

abstract nacelle
devout socket
#

📵

rotund copper
#

q.get_ride and q.get_rider were removed?????

#

why

abstract nacelle
coral forge
cedar willow
#

Hi I need some help with this

#

The particle is triggered by the player, and I have no anchor point to attach the particle to the player model so the emmiter is infront of the player

#

I want to move it from the middle to the right, but using Offset doesnt take account to player rotation so im thinking abt using molang to deal with it

#

I tried to turn on local rotation but no avails

inland forum
abstract nacelle
inland forum
hot trail
#

Does anybody know what happen to query.biome_has_any_tag ?

inner jasper
indigo rampart
#

is there any query to read whether entity is being lit to explode (e.g. creeper has prepared to explode)

#

i've inspected the creeper resource pack file and found q.swell_amount, is it available for any entity that has minecraft:explode component?

indigo rampart
#

nvm, found it out already, it turns out that no need to use molang

slim fern
#

Is there any way I can use movement_direction to play different animations when the entity walks backwards while facing forward? I'd like some examples too.

uneven quail
#

q.scoreboard doesn't work anymore?

inner jasper
slim fern
#

ye

uneven quail
inner jasper
#

Yes

tiny furnace
#

What queries can I use to detect Y movement in an animation?

#

Aka if my entity is flying up or down

swift rivet
#

q.vertical_speed
Or you can measure a Y position change and calculate speed from that

tiny furnace
#

Oh lovely, thanks!

sleek glen
#

How do you kill a particle if there are more of them in the world ? I simply want one of it to exist in the world. I found out query.effect_emitter_count & query.effect_particle_count queries but not sure on where to use them.

swift rivet
#

Do you want a particle to expire when a new particle is created, or do you want to keep old particle and not emit a new one?

sleek glen
swift rivet
#

In particle lifetime component "expiration_expression": "v.particle_age && q.effect_particle_count > 1"

sleek glen
#

Thank you very much ❤️

snow wing
#

Detect WASD using molang, is there other way to do detect that cause the query.movement_direction doesn't work for me...

inland forum
snow wing
inland forum
#

north, south...

snow wing
# inland forum north, south...

(Sorry for ping)

Can it detects negative value? If I forward it the query became 1 but I move backwards what will happen? -1? Hahahaha

snow wing
inland forum
#

Yes it works in BP, but as I said it only takes into account the coordinates of the world not the player's

#

Maybe there is a way to solve it with mathematics, but I don't know.

swift rivet
#

There is, but it's a bit complicated

inland forum
swift rivet
#

No, just math in molang

inland forum
#

because it is complicated?

snow wing
inland forum
#

XD

snow wing
snow wing
snow wing
inland forum
#

?

#

It doesn't look functional, does it really work?

snow wing
#

Yeah hahahaha a bit buggy tho

main sage
#

i'm trying to count the 1's in binary form of a number and then see if it's equal to 2 but i'm always getting an error

temp.bitsCount = 0;
temp.LampCode = query.block_state('ar:light_display');
loop(4,{
temp.bitsCount += math.mod(temp.LampCode, 2);
temp.LampCode = math.floor(temp.LampCode / 2);});
return (temp.bitsCount == 2) ? 1 : 0;

[Molang][error]-block_definitions | components | temp.bitsCount = 0;temp.LampCode = query.block_state('ar:light_display');loop(4,{temp.bitsCount += math.mod(temp.LampCode, 2);temp.LampCode = math.floor(temp.LampCode / 2);});return temp.bitsCount; | Error: binary Assignment '=' operator at end of expression

inner jasper
main sage
#

yep that seems to be the issue

#

thanks

brisk heron
#

would this work if im using the particle inside of an animation of a cosmetic? ( it doenst use attachables, it uses q.mark_variant with a render controller to load specific geometries )

(c.owning_entity -> q.mark_variant) v.particle_age+v.particle_random_3

#

i just want to know if the c.owning_entity -> q.mark_variant part would work

unreal arch
#

Is there a query for testing if a item is a block/renders as a block or not? For example, a crafting table renders as a block in hand.

rough jasper
#

How to test if entity has effect?

abstract nacelle
abstract nacelle
rough jasper
#

Is that possible in scripting?

#

||@abstract nacelle||

abstract nacelle
rough jasper
#

Just like pvz zombies when they get hit by a snow pea

abstract nacelle
rough jasper
safe fog
#

How does this work now?

#

Like how would i use a rider head y rotation in an animation?

final zealot
# safe fog Like how would i use a rider head y rotation in an animation?

Just query.ride_body_y_rotation to rotate a bone or do any expression, like any other query. It should be used by the entity that is riding, then it'll return the body rotation for y axis of the ride (a horse, for example)
q.rider_body_y_rotation you should use on the ride, and it'll return the body y rotation of the entity that is mounting it

inland forum
#

you can use:
query.rider_head_x_rotation(0..0)
where (0..0) are the seats that control the horse
you can also use:
query.rider_head_x_rotation(0..0)>0
to detect if the rider player is looking down

final zealot
#

Anyone good with Math here?

I need to rotate the player root bone around the Z axis in 360 degrees, but keep its model in the same place. As the axis of the player is not in the center of the model but in the player feet, I need to rotate the X and Y axis together to achieve this.
Rotating the bone 90 degrees four times in Blockbench, I discovered that the rotations behave like in this first image to rotate the root bone around itself.
Is there any Math expression that will do exactly this calculation by just having the variable of Z rotation? Or do I need to manually check values and update a different variable for x and z according the z rotation?

safe fog
#

?

inland forum
#

I have also tried setting only (0), it works, but an error appears in the event log

#

I have used it to control flying entities, instead of using the rxm selector, and it works very well

#

I also use it to manage the cannon of my robots and it also works

safe fog
#

Ahh

#

But can also be 0..1 if two seats to be looked at

inland forum
#

I think that would go crazy, I really don't know what would happen, maybe I'm wrong in how it works

#

There is not much information about it, I have also only tried it with rider 0, I have not tried it with rider 1, because I have no friends :,v

verbal tulip
#

Using molang queries, can you find XYZ direction the entity is facing?

snow wing
#

How do I check the value in the entity properties using the query.property if the property are string enum

"example:gearshift": { 
    "type": "enum", 
    "values": ["park", "reverse", "neutral", "drive"], 
    "default": "park", 
    "client_sync": true 
}
#

query.property('example:gearshift') == park, doesn't work

meager hamlet
#

What is the name of the molang that detects when we are wearing armor?

abstract nacelle
austere comet
snow wing
#

Check icons on your BP items, or format version of it. It should be 1.16.100 and above

kind bolt
#

hey

#

what's a good query to pair walking with shooting?

#

i need help badly with this

kind bolt
#

bc when my mob chases its enemy

#

it starts to vibrate

#

please help

slim token
#

Can anyone tell me what the error is?

"geometry": "query.is_name_any('player_selector') == 1.0 ? geometry.player_selector : (query.is_name_any('arizona_map') == 1.0 ? geometry.map_frame : geometry.default)"

snow wing
#

Also where do you use that?

slim token
#

I was using it on the armor stands. Depending on the name I put on it, it will have this geometry.

#

VS Code started to report an error when I used query.get_name, I changed it to query.is_name_any and it gives an error in the game when I use conditional multiples.

#

There is no other way to make this work without using deprecated query.get_name?

snow wing
slim token
#

I was try it, its not work

snow wing
slim token
#

query.is_name_any?

snow wing
slim token
#

Yes

snow wing
slim token
#

Yes, but its deprecated

#

Its work, but its deprecated

snow wing
#

Then try that for the mean time while checking the query.is_name_any

slim token
#

The VS code and documentation recomends query.is_name_any

half hatch
#
[Molang][error]-bedablio:shop_pc |  | Error: query.property: property does not exist, consider using query.has_property.

i have this problem, how can i fix this?

half hatch
inner jasper
#

Well it's saying your property doesn't exist

half hatch
#

done

#

why it dont show its from resource

snow wing
half hatch
#

This entity was using a animation controller in resource, but i forget to remove

summer marsh
#

hi there, do someone know how to use the query.cooldown_time_remaining? is it possible to test the remaining time of a specific cooldown type?

uneven quail
#

q.scoreboard isn't removed yet?

snow wing
abstract nacelle
snow wing
#

You can't tell it doesn't cause I use that always, it was removed after 1.20.60

abstract nacelle
abstract nacelle
snow wing
#

But it will works on the bp packs cause when you use that in RP it shows error saying it only works on BP pack

abstract nacelle
urban bough
summer marsh
#

hi there
is the query.time_stamp reutrning the tick of the minecraft day? or it returns the total ticks since the server created?

urban bough
#

just test it my guy i feel like it would be easy to tell the difference between the two

red glacier
#

How to detect biome tag?

random wolf
#

I forgor this was a thing 💀

sterile shore
#

Is there any query to detect that the player has used the item completely?

for example: if the player eats food or drinks a potion, he executes the command

amber delta
#

is there a query to know if some one is viewing an NPC dialogue?

#

query has rider?

abstract nacelle
sterile shore
amber delta
abstract nacelle
#

ANY interface

#

you cant specify what interface you opened

amber delta
#

Ok, well for my purposes that may work

indigo rampart
#

What does molang expression "this" return, I've found that couple times on vanilla sample (e.g. player animation.player.holding)

amber delta
#

Can Molang check for a tag on a player?

coral forge
#

Nope. You can check for scoreboards to be at a certain value in behavior packs though, using q.scoreboard('<scoreboard name>')==<value>, ex. q.scoreboard('cur_quest')==1

#

You can also use an environment sensor on the player to test if they have the tag using the has_tag filter, and set a property if the player has it

amber delta
#

I'm getting unrecognized token when I add the query.scoreboard to the animation controller. Is that a newer thing? I'm working in 1.20.13 becuase it is for education edition? Or did I mess something up?

coral forge
#

Maybe it's not in education edition. It's only come out of experimental pretty recently

amber delta
#

Ok, Education Edition is simply Bedrock a bit behind with some extra security and items like camera portfolio and writable exportable books and portfolio. Oh and they hide the experimental toggles and the content logging.

#

ok so if q.scoreboard was experimental what toggle does it need (I have made it so I can access those and the content logging)

#

Would that be Molang features?

#

Ok so with Molang features enabled it works.

lucid nacelle
#

I'm trying to use query.has_biome_tag in an animation controller but it is trowing an error unrecognized token

#

Can anybody help?

amber delta
lucid nacelle
#

It's stable

plain crest
#

is there a painting template? or even an animated painting template? the discord search thing sucks dick

abstract nacelle
abstract nacelle
plain crest
#

i for some reason find this line unbelievably funny

wintry crow
#

So I'm trying to understand what exactly molang is or does separately from editing json files. Up to now the extent of my knowledge is just running events through tests in behavior pack files, components, component groups, etc. what exactly makes molang different and where in the files can it be used? (I have used a query for an animation but have very little knowledge)

lilac flame
#

Molang is basically just queries, math, and basic loops

wintry crow
#

What parts of a behavior pack can I use queries?

half verge
#

animation controllers

#

entity server side

tawny mica
#

can i access queries through scripts

lucid nacelle
#

?

abstract nacelle
abstract nacelle
#

the replace is scripting

lucid nacelle
#

that function takes ages to execute

#

I'm better off using environment sensor

abstract nacelle
random wolf
#

Hmmm

polar steeple
#

@swift rivet any idea why this don't work?
trying to delay the particle

tough niche
#

How to use query.time_of_day?

urban bough
#

is it possible to use molang to play a sound event at certain values? For instance if i wanted to play the sound every time a sin wave reached the high and low extreme.

toxic raven
#

Is that possible to use regex in molang scripts? I need to check if item's id contains golden_

coral forge
#

Not that I'm aware of. You could potentially use a script instead and have that script modify an entity property. Then, query for that property

#

You could also try querying for the minecraft:golden_tier tag

#

This is on all gold equipment

mossy shell
#

what method can be used to return power jump strength value?

toxic raven
#

But thanks for the tag suggestion

waxen oriole
#

Guys, how can I check on a BP AC from an entity's perspective if a player's using an specific item on it so I can trigger an animation based on that?

waxen oriole
#

Or the other way around: how can I check if the player is interacting with an specific entity so I can remove an item when doing it?

abstract nacelle
waxen oriole
brisk sentinel
#

what molang is similiar to is_sheared? Gi need something that could return 0 to 5 integers

ocean umbra
#

hello, can we set values for molang variables inside block.json files?

abstract nacelle
#

dummy components are deprecated

abstract nacelle
brisk sentinel
#

what are the alternatives then?

abstract nacelle
abstract nacelle
#

they are very important in entities

#

they are like "infinite dummy components"

brisk sentinel
abstract nacelle
brisk sentinel
#

but how can you read it in geometry?

#

I want to have something similar to query.variant

abstract nacelle
brisk sentinel
#

that's the solution I found

abstract nacelle
brisk sentinel
#

oh dang this one is cool

#

thanks for introducting this to me

abstract nacelle
#
"your:property": {
    "type": "int",
    "values": [0,10],
   "default": 0,
   "client_sync": true
}```
#

make sure you have client_sync in true to use the property in your resource pack

brisk sentinel
#

it acts similar to components huh

brisk sentinel
#

in manifest.json?

abstract nacelle
#

no, in the property

brisk sentinel
#

ahhh I see

#

why is it needed?

#

ahhh I see

#

I saw the explanation

#

thanks a lot

abstract nacelle
#

🫡

brisk sentinel
#

@abstract nacelle

 "minecraft:entity": {
     "description": {
       "identifier": "si:geode_pet",
       "properties": {
         "property:ore_type": {
           "type": "int",
           "values": [
             0, //Coal 
             1, //Iron
             2,
             3,
             4,
             5,
             6
           ],
           "client_sync": true,
           "default": 0
         }
       },
       "is_spawnable": true,
       "is_summonable": true,
       "is_experimental": false
       },

Sorry for the ping, but I followed the wiki but something seems wrong it cannot read it

abstract nacelle
#

it should be
values: [0,6]

brisk sentinel
#

that means the enum_exmaple is wrong here?

abstract nacelle
pure flume
brisk sentinel
#

yeah thanks for the replies I took a look at the microsoft docs the wiki.bedrock really is outdated

storm haven
pure flume
storm haven
pure flume
#

I don't know

junior tartan
#

How to make the animation activate only when the rider turns strongly?
I think something with query.yaw_speed but Idk how to use it

storm haven
storm haven
storm haven
#

In animations you place:

{ "ejecutar": "" }

The indexed animation on the client-side entity and the conditional molang to validate within the key.

The angular velocity by kinematics can be seen as a normal velocity applied to an arc that varies according to your radial consideration. I won't get my grades for that xD imagine it's a linear trajectory.

v = r/t

storm haven
# junior tartan How to make the animation activate only when the rider turns strongly? I think s...

You can also add the syntax I showed you directly into the client-side entity file scripts. Inside cheer up. Although it was not constantly updated like the animation controller.

"scripts": {
  "animate": [
    { "Ejecutar": "" }
  ]
}

To do what the animation controller does you would have to add a time updater attribute to the animation, attributes... And in the updated one, a molang that internally verifies the clock update conditions, etc. But these things are for advanced technicians like me.

#

For more information visit the community resources and search for "Universal Templates"

junior tartan
#

That's a little too much information, just having trouble with the math xD

storm haven
polar steeple
#

why dose this return -0.5

"(v.direction == 'front') ? 0.5 : (v.direction == 'back') ? -0.5 : 0"

even if i did this

"minecraft:emitter_initialization": {
  "creation_expression": "v.direction = 'front';"
},
#

@swift rivet any idea?
sorry for the ping

swift rivet
#

Is that Y axis in direction_z?

polar steeple
#

yeah i am using direction_z

#

oh
No it is in the x

swift rivet
#

There's a bug, if direction is close to being horizontal, it will snap to horizontal, but in the opposite axis

#

So if your direction is something like [0, 0.99, 0.1] it will actually be [0, -1, 0]

polar steeple
#

wired
since using 0.5 directly work fine

#

0.5 turn to -0.5
i don't think that related

#

and it is not snapping
any value i put instead of -0.5 the expression take it

swift rivet
#

Is that the case in snowstorm or in the game

polar steeple
#

in game

swift rivet
#
"(v.direction == 'front') ? 0.5 : ((v.direction == 'back') ? -0.5 : 0)"
#

Try this

polar steeple
#

is it possible to make particle that have
"minecraft:particle_motion_parametric"
have gravity?
"direction": [0, -1, 0]
don't do anything there

storm haven
swift rivet
#

Yup here it is, always use latest format version folks