#Molang General
1 messages · Page 2 of 1
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;};
yo guys how can i get a variable from a temp variable
t.player -> v.test
like this
you can do t.player -> v.attack_time > 0 for example, but the variable need to be public
How big can numbers be in molang? is there a limt?
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
Thanks should be big enough
Thought I should ask dose that apply to numbers that are gotten from query
I would assume yes but I don't mess with molang very much
Yes, it applies to everything
cool that ain't good for me tho
why query.scoreboard() only work when i setdisplay the score
🤦 me trying to fix my script and looking through all the file after it stooped working
same energy
nah that's me looking at others code
and then the only mistake on your code was as simple as
istg it kills my mood every time
balls
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
because the scores are only sent to the client if they need to be displayed. It always works on the BP side tho. Either keep the score displayed or even better, use actor properties
uhm actor properties?
can script change them?
yes
nice will take a look at it
thanks
setProperty, getProperty, clearProperty
can anyone tell me what exactly i need to do to fix this?
I think only regular variables can be structs, but temps can't. So replace things like t.supertile.size with t.supertile_size
More about structs https://bedrock.dev/docs/stable/Molang#Structs
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?
oh ok
@solid sierra I WILL MURDER YOU.
minecraft: Heath dont support Molang, try using /damage instead
i don't want the damage sound and color
you can use hurt_color and maybe /stopsound?
otherwise use scripting
script it is than
Did not know that. Will note it down.
My bad
lol
LOL
no wonder Grimm was having trouble
@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
Hey, be careful with the emojis. Avoid emoji spam
Avoided 👍
i was picking on u lol
dw about it
Please just add another minecraft:health component in a component group with a health lower than the current one.
i was trying to decree the health multiple time
You'd probably have to have a component group for each possible health value, and switch based off of an entity property
Hello, everyone
Please help: I don't understand where the source of the second and third errors can be
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
what is AC?
Animation controller
And How see varaible values?
I want see value this entity_cardinal_direction
You can't just "see it" directly. Use it in animation to scale a bone or in color overlay
yo is there a query that can detect the tag of a player?
no, add a property and check for that.
is there a way to detect breeding
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)
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
Temps are kind of like local variables in a function/method in programming languages
Oh ok thank you, and context ? I don't understand this kind of variable
They're only used in attachables afaik. They're used to get information about the entity that the attachable is attached to. For example, c.is_first_person is used in attachables so they render differently in players in first person than they do in third person
context in Minecraft means that if the thing you're testing for is returning true in this context. For example, !c.is_first_person will return true if an attachable is being rendered in third person in this context. This means if another player is looking at you while you're in first person the query will return true
whats the difference with v.is_first_person?
How to assign something into equipment and inside a group?
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"
That link as the listing of the groups, which I believe is what he needs regardless of version.
I know
@frozen star ❤️
Yes?
Oh I was just thanking u with a heart sorry for the ping
no problem... just organizing my fishing loot
Question: Can I use a range in this?
query.camera_rotation(0) ? 1 : 0
so could I say if between -45, 45 ? 1 :0?
q.in_range(q.camera_rotation(0), -45, 45)
oh perfect.
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.
"set_property": {
"working_tv:channel": "'(q.get_property('working_tv:channel') % 5) + 1'"
}
How should I format this so Minecraft read it correctly?
There is no get_property query and no % operator in molang. Use q.property and math.mod instead
Oops
ngl, script syntax has messed my muscle memory up
Whats the syntax of Math.mod?
nvm
I have a weird ' wrap around the query
It messes it up
Im finding that, for some reason... && works like or, while || works like and. Any possible explications?
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
I did not, nope
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
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
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
math.round(100*t.x)/100
General formula is round(x*10^n)/(10^n)
Where x is input number and n is number of decimal places
Well, I figure this out later but thank you anyway
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:
Is it for entity texture or block flipbook?
Animated UV so entity
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...
"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"]
Didnt work pal
Your math doesnt move the UV frame by frame, just run the UV across the image
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
Total number of frames or frame count for one axis?
What would be the value here for example
1 axis
10 or 100
math.floor(query.life_time * 10) -> math.mod(math.floor(query.life_time * 10), FRAME_COUNT)
oops wait
Now it reallyt is
Just seperate 2 axis
frame count is how many non blank frames you have
show ur offset molang
"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
"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')"
]```
This move from left to right then top to bottom
I know its not going work
it will
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
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
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
💀
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
I don't really understand tbh
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?
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.
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
I just mean that I think it should be possible to add up the queries rather than using a series of ternary operators
And what are the benefits of that?
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
I see
However, that condition will mess up much of my stuff... I would love other solution
Should this be correct Blaze? Or I am wrong?
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
Coordinates are fine
That just means that my problem is in my second condition
Let me show you... sec
query.block_state('kai:west') == 3
This is being true even though kai:west is 0, 1 or 2...
You can sort of replace && with ternary operators right?
I don't use them too much, but I think so
It seems like it, yeah, thanks!
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.
how do you visualize that?
is minecraft dev edition?
Using scripts 
epic
is there an addon to download that? XD
and its possible to do it with entities? like show what component group is active
No idea 🤷♂️
I would say so, yes. You can get help for making a script like that for entities in #1067535382285135923
epic! thank you
bump
Is there a way to detect that cattle are lured by food?
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.
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')))"```
how to check the entities around
There is an entity sensor, is this for something other than an entity file?
"v.x = 0;
for_each(v.pig, query.get_nearby_entities(4, 'minecraft:pig'), {
v.x = v.x + v.pig->query.get_relative_block_state(0, 1, 0, 'flammable');
});"
how to d this with molang
if(q.block_state('') < 15){
return q.block_state('')+1
}else{
return 0
}
nvm
q.block_state('') < 15 ? q.block_state('') + 1 : 0
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
yeah
Log?
Have you tried molang to scoreboard?
Which molang is used to detect that the player's hand is empty?
solved
unless you have a dev client, you can't
even with scripts?
Not sure tbh, but with just molang you can't
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
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
I made an animation of the skeleton's attack, how to detect the skeleton's bow and arrow attack
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
},
I think it is
query.has_target
When Skeleton has a target but is out of range, Skeleton will track the target, so I don't think q.has _ target alone is enough.
is there a molang function for entity property?
q.property('namespace:property')
thanks
Is this in the rp or BP? If it's in the rp, client_sync needs to be set to true in the property
it is set to true
what format_version should i be in?
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
sure
i need to update my other files first
still the same
Oof. Not really sure what the issue is. Maybe something was misspelled?
fixed it
the entity file format was 1.8.0
tnx
any way to test hurt entity from resource side?
You need to store the current health of entity in a variable by doing v.health = q.health every tick, then check if v.health > q.health the next tick.
ye but if q.health itself doesnt work client side then how would it work
You sure it doesn't ? I'm not sure.
afaik it doesnt. probably so you dont make a resource pack to see other player's health on servers
ill try tho
It does.
Is there any query to detect crawling
query.is_crawling
Thanks
do variables remain between ac transitions? and if not can i make them do?
Yes
does query.is_first_person not work in behavior animation controllers
it doesnt work in behavior side
"v.frame = query.is_using_item ? ((v.frame ?? 0.0) == 0.0 ? 1.0 : 0.0);"
Why it not work :((
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
}
Can you please elaborate ?
You can simply stop playing the animation to return it to 0 at any point.
if that's what you meant.
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.
two changing values or two constant values ?
I'm assuming you have to type this same thing a lot of time. Am I right?
You can use variables.
query.property('cbr:color') == 3 && query.can_fly && ( query.property('cbr:burn') >=4 || query.property('cbr:burn') == 0 )```
wait, that's it?
Yes, that's parantheses.
well I feel dumb now lol.
but yes, these were changing variables that I was checking for.
thanks
I was imagining far more complicated symbols that I haven't gotten around to learning yet
keep removing the most useful functions in the addons :)
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
They will not, we already know them, they are not going to mention what exactly that "buggy behavior" is, because those queries really work well, if the problem is lag, a lot of things in the game cause lag. It just doesn't make sense
Even if it will going to be versioned, we cannot maintain a min engine version forever because new functions will come out
I literally have an entity that uses a lot of for each with those queries (and they are long functions), I have put more than 30 and I had no lag in the world, after 40 I could already feel the lag, but at no time will 40 be seen times of those mobs because when generating them you can set a density limit.
The only way is an alternative (I doubt it)
In fact, maybe I'm wrong but I felt more lag with for each of the scripts than with Molang
I still think it's worth asking, as understanding the why can help us as a community think of alternative solutions to removing it.
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
you're right
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
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
We will never know the reason I guess
If you read their message, the reason is described there.
It's very vague though
"buggy behavior" and "laggy"?
yeah, very vague
its like with blocks and items components, "cumulous of problems"
I mean if you do some brainstorming, you'll get it. Atleast, she is giving us a heads-up or who was even going to tell us even that "vague reason".
Well, I can't figure out why, I have put more than 30 entities that use for each and the world didn't bother me.
I just want to know the reason, eliminate several queries that could be considered as most used in the addons, it would have to AT LEAST have a justifiable reason to eliminate them
There must be indeed a justifiable reason to eliminate them. They didn't just woke up and chose violence 😄
I mean if you're using experimental stuff then you must be always ready for the worst.
That's why we are asking what the justification is...
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.
It's not about how it's is working for you. It's probably about how it's working for them. For example: Maybe, these queries were not easier to maintain and were prone to causing unintended issues during development.
It could be, but it's just a guess, that's why I'm asking what the reason is.
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.
You can ask them very nicely and they should respond to you.
They already did it where they sent the message
The same thing will happen as with the components of items and blocks.
*disappears
Veka wasn't really focusing on to that question. They had a lot of concerns (feedbacks) so I think it didn't got the spotlight. You might want to focus specially on your one and main question.
Anyways, whatever it is, it's not coming anytime soon!
If you leave the get rider and scoreboard queries they talked about.
I said it for "Blaze Drake" not for Veka
Oh! The ping's missing. To be honest, we already have a way to get everything about the rider and ride using multiple filters in a manner.
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.
Well, in some specific situations they can be avoided, but not always
What's your issue ?
In most cases, there is a workaround.
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
My brain can't process all of that right now. I wanted to know why you want to use these queries.
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
compares the values between two scoreboards, takes the player who has the same value as the entity and at the same time a specific item to execute a function in an animation controller
That's why you don't use experimental. It's just like gambling.
This is a particular situation, many addons use these queries, not all of them can be avoided
can be done using commands.
there are functions that need experimental
I did, but it's not very specific.
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
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.
I didn't find another alternative, I tried with commands but I already explained why it is not possible
Even after that I have to use the states in the animation controller
I solved this problem and by using commands when I was making my first fully functional multiplayer compatible custom fishing rod. I'll let you know about it when I'm free. It's a bit complicated.
The q.target stuff was also about it ☝️
I used this in commands
execute as @s if score @s bardiche = @p[tag=bardiche,c=1] bardiche as @p[tag=bardiche,c=1] at @s if score @s bardiche = @e[type=ch:bardiche_function,r=4,c=1] bardiche run```
okay, I'll wait for it
Sure, would have shown you now the but the code is on my pc and I'm not on my pc right now. Thanks for your patience!
👍
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
Mine doesn't and Molang also generates a considerable amount of lag.
You should just know how to use them properly 😄
I generated 30 entities (that use more than one for_each like the one I showed you) and it didn't give me lag either, after 40 it felt a bit
You have a good pc right?
The lag should occur in the world, right?
in ticks
depends on both of them. Your pc and the game.
My PC is not really good, it lags when I increase the chunk distance more than 20, but the lag should be in ticks because it overloads the server
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)
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')"
}
}
I replied to you about this in an other post.
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" } },
What's not working?
Minecraft:effect isn't a component. If you're trying to add a potion effect, use minecraft:mob_effect(https://learn.microsoft.com/en-us/minecraft/creator/reference/content/entityreference/examples/entitycomponents/minecraftcomponent_mob_effect?view=minecraft-bedrock-stable)
What you're trying to do ?
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.
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.
Ok thanks for your time
I gonna try
I'm trying to make my helmet grant night vision when it's dark.
You can use the has_equipment filter with the is_brightness filter in an environment sensor to add a component group containing the minecraft:spell_effects component.
query.is_item_equipped('minecraft:lava_bucket')
Is that correct?
actually, I might just use query.is_item_name_any
q.is_item_any('slot.weapon.mainhand',0,'minecraft:lava_bucket') is what you'd want to do
ye
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
Got to love mojank sometimes
mojang always are stupid
just wait to query.target, query.get_nearby_entities, query.get_riders, be deprecated
Is it possible to have another block change the state of another block using MoLang?
No
aww damn it
Well, molang itself cant do anyrhing
What can?
Block events can
ye
You can use random ticking or the ticking component to check a condition using molang
Could you give an example?
https://wiki.bedrock.dev/blocks/block-events.html#sequenced-responses If you have further questions, you can ask in #1067876948858118185
Seems to be more of a #1067869022273667152 question. I see no usage of Molang except for the default one for experience drop
Does anyone compare the two valuables || and && are the same?
||
means or and
&&
means and.
For example:-
q.is_item_name_any('slot.hotbar.mainhand','minecraft:carrot') || q.is_using_item
will return true if either the player is holding the carrot or using the carrot but
q.is_item_name_any('slot.hotbar.mainhand','minecraft:carrot') && q.is_using_item
will return true if player is both holding the carrot and using it too.
How about using it in custom block?
its the same
"condition": "q.block_state('state') == 1 || q.block_state('state) == 2"```
Oh so they activate at the same time?
Because I need them to activate at the same time
"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
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')
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?
or does it do like this part here
In programming, it always checks && before ||
Using () will ensure the behaviour you want
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'))"```
Yep
Thank you very much man. Appreciate it
anyone know if query.get_equipped_item_name is being deprecated?
It is deprecated https://bedrock.dev/docs/stable/Molang#query.get_equipped_item_name
That's up to you
you can still using it
but use query.is_item_name_any
its better
How can I detect when the player looks up?
Tried using this query.head_y_rotation(75)
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'"
Is it possible to add different state values?
Like lets say
"condition":
"(query.block_state(alpha) + query.block_state(beta)) == 10"```
[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' )
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
state
block_state
[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 ';'
Pretty sure query.get_equipped_item_name is being deprecated
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
As for this issue, maybe try replacing your !== with !=? Molang uses != to represent not equal to, so maybe the second = is making minecraft think you're trying to set a variable too.
does not work
Can you send your block code?
I meant the json file. Also, are you still getting a content log error? Finally, what are you trying to do?
I want the block to make a sound if the item is not on this list
"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' ",
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 !=.
!= doesn't work initially
Then there must be an issue somewhere else in your blocks file.
As != is what tests for inequality
ok
freds
French
in friends list
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
ок
I dropped the json block
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 ~~~"
]
}
}
]
},
{
"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 ~~~"
]
}
}
]
},
what is he doing ( ; )?
ends the expression.
ok
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'.
Can you send the query you're using?
Is there a way to check the current age of a mob, particularly the age of a baby mob?
I think you can use q.life_time.
query.equipped_item_any_tag('slot.weapon.mainhand',0,'color_white')
"minecraft:tags": {
"tags": [
"color_white"
]
}
Maybe this is a bug, because despite the error everything works normally.
Yeah, it looks fine to me. That's weird that an error's showing up though
Is that not for animations? Also, I was hoping to mimic the age timer of baby mobs (i.e. making a food item reduce the grow timer by 20% of the current time left).
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
how can I make a mob run in a random direction while still staying within a certain distance from the player it's targeting?
I don't think you can do that. You'll have to make your entity's frames look smooth compared to one another
No, it works everywhere. The doc is wrong.
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
Scripts
but its in .60 preview, I think
It seems that there is no other way but to rely on behavior, and achievement will be off
Have you figured this out yet?
No
anyone know how to fix this?
all other query functions work
It functions properly but i keep getting that error
I want to kill an entity, if the query.has_rider = 0
How would I implement this into the entity's code?😅
You could make a queued ticking that runs on loop and have an event connected to it, then that event has a condition that is query.has_rider == 0 and if that condition is true, you do a run_command to do kill @s
{
{
"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
Thank you
(q.is_in_ui || v.is_paperdoll) ? 0 : q.is_item_name_any('slot.weapon.mainhand', 0, 'namespace:item_name')
The solution the other provided seems to be for a block not a entity. For entity, please just use an animation controller with !q.has_rider.
Intro: https://wiki.bedrock.dev/animation-controllers/animation-controllers-intro.html
Running commands: https://wiki.bedrock.dev/animation-controllers/entity-commands.html
oh ye, that's my bad. My excuse is that it was 5am xD
It's okay, it happens buddy!
@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)"```
@sleek glen help me
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?
I'm sorry, I don't have any idea about that query.
Maybe it works with query.equipment_count == 0
Returns the number of equipped pieces of armor for an entity from 0 to 4, not counting items held in hands. (To query for hand slots, use query.is_item_equipped or query.is_item_name_any).
He already got a solution.
Fix
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.
How do you use this?
It's v.attack_time.
Can entity properties be modified using item events?
No, you must use entity events to modify entity properties. You can use item event to run a /event command to modify the entity properties.
Oh yeah thanks
{ "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
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.
I even just tried hotbar yet didn't work
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
Okay thanks I'll do that
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?
does anyone use arrays?
if anyone does, do you have some examples I could look at. the docs weren't enough
Yes
Which arrays ?
Idk I saw there was something with arrays but idk how to use them
Can I do something like query.block_state('dma:smelter_states') >= 1 && <=2
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
oh well
for the first 2 block states, I could just test if smelter_states is <=2
saves a bit more
how do I make int property set_property event add rather than setting a number up?
Set it to q.property('ex:property_name')+<val>
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?
They might add them back when the custom biome feature is fixed. Otherwise, there isn't a big use for it really
And they have been revamping the tag system also, so that may be a reason also
what do you mean no use? i have been relying on them for years, if you think you can replace them with environment sensors, then tell me how to use those in a resource pack?
now you should use scripting
you can use a property
huh, last i checked properties are a BP thing
i do, and as for now, scripting can not read biomes
"client_sync": true
it can but idk if its only for preview at the moment
i know that, what i meant is RP only, meaning without a behavior pack so you can use it in servers
ah, yeah, you cannot
the current preview can only tell you the location of the nearest specified biome, not the biome that you are in, the same way /locate does it.
there is a BiomeType
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
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
The "query.block_neighbor_has_any_tag" can I use the part of my custom door block in my addon?
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
Why don't you just conditionally play it? {"animation":"!q.is_first_person:} instead of just "animation" under animate
how to detect when the player is climbing a ladder?
there is no query.is_climbing
Have you tested whether query.is_wall_climbing works?
yes, doesnt work
@coral forge I want to activate the animation while the player is flying, how can I make a different flying animation?
🤷♂️
There might be a query in the docs(https://learn.microsoft.com/en-us/minecraft/creator/reference/content/molangreference/examples/molangconcepts/queryfunctions?view=minecraft-bedrock-stable), but I don't know off the top of my head
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
Do not ping random people for help or otherwise.
Random pings are never good
; No one is obligated to help you at random.
"query.can_fly && !variable.is_first_person"```
Player does not appear when running
"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
"v.convert = q.above_top_solid(v.posx, v.posz);",
why does it think q.above_top_solid doesnt exist?
oh, not just me https://bugs.mojang.com/browse/MCPE-178975
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
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
Please don’t cross-post.
wdym
You already asked that question in #1067876948858118185, don’t re-send it again here.
but people are here to ask no ?
Yes, but don’t ask the same question in multiple channels.
#usage message
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
for the time create a variable with q.life_time
then, as a condition use (query.life_time - YourVariable) >= 1.0
1.0 is more or equal to one second
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
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
how to use q.all_tags?
No it doesn't, but I wish it did. lol
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 😔
but v.is_first_person works on attachables too
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.
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 🤞
Looks like I just have to try and iron out the jank out of the reconstruction method then.
You could still use that btw, it'd allow you to have junk-free method up to a certain amount of players
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...
Ah, right, since you have one entity per player
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.
It's using this function to compute it: https://www.desmos.com/calculator/rkytsupkqy
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.
oo that's quite smart
Though because there is slight lag with the camera rotation query, moving the mouse quickly causes visual jank.
Huh, there is? Camera queries always executed at frame rate for me
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.
Ahh I see, I very rarely used camera rotation, but used position quite often
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
But since it's very unlikely for the player to be switching back and forth every frame, it can be safely assumed that the player is in the same mode that they were in for the last few frames. Changing perspective should specifically involve sudden large changes in camera position.
Changes specifically along the camera ray (or approximately along it, accounting for camera rotation and translational motion).
I could probably solve this by permitting deviation from the camera ray as defined by camera rotation by extrapolating the rotation movement, and using the player trajectory to estimate where they will be next frame.
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.
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.
entity properties
Can you show me an example on how to manipulate these properties, or are there any links to the documentation?
oh, sorry about that, i thought i inserted the link https://learn.microsoft.com/en-us/minecraft/creator/documents/introductiontoentityproperties?view=minecraft-bedrock-stable
be wary of the limitations
Yeah I do not think what i want is possible, like when spawning particles you can set molang variables, this does not seam to be possible for entity animation, no idea why tho.
have you set client_sync to true?
I need to change some of these player variables but they are unreachable.
Any other way to properly trigger a player attack animation?
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.
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 is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Is there a molang that checks players nearby?
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.
query.state ?
What do you mean?
Are there workarounds to test a item held by second player in the entity
That error is just because there's no entity associated with the version of the player in the ui screen. Your addon will work fine even with that error appearing, but I believe you can do something like q.is_in_ui? return false; return <query you're using> if you don't want it to appear. I could be wrong though, I haven't tested that directly myself
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'
Ah, oops, my bad, you need a ; at the end of the second line as well
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
molang no, just scripting
📵
use scripting now, is better
It was abandoned in development long ago, and so mojang is cleaning up the abandoned projects now. HCF is next
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
Is there a script for that? I tried searching and couldn't find anything.
//Get riders
const rider = entity?.getComponent("minecraft:rideable").getRiders();
//Get ride
const rideEntity = entity?.getComponent("riding").entityRidingOn```
by the way, I saw that they also added query.rider_head_x_rotation()=>float, I'm not sure it works as I think, I need the entity I'm riding to move its head in the same direction I'm looking, but the default animation of the entities Mountable locks movement at 30°. I used query:get riders before to achieve this but now I can't :/
Does anybody know what happen to query.biome_has_any_tag ?
Removed in 1.20.70
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?
nvm, found it out already, it turns out that no need to use molang
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.
q.scoreboard doesn't work anymore?
Only in BP
ye
It works in BP?
Yes
What queries can I use to detect Y movement in an animation?
Aka if my entity is flying up or down
q.vertical_speed
Or you can measure a Y position change and calculate speed from that
Oh lovely, thanks!
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.
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?
expire when a new particle is created.
In particle lifetime component "expiration_expression": "v.particle_age && q.effect_particle_count > 1"
Thank you very much ❤️
Detect WASD using molang, is there other way to do detect that cause the query.movement_direction doesn't work for me...
That query uses the NSEW coordinates of the world, if it could be applied to an entity it would be excellent
Sorry what's NSEW? Sorry for being dumb
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
Also can I use on BP anim controller or just client sided packs only
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.
There is, but it's a bit complicated
script?
No, just math in molang
because it is complicated?
I think I made it but it's not very Accurate cause once you turn your head really ² fast it sometimes doesn't work
XD
Yeah I use cardinal facing, wait imma send a small snipsset
"query.cardinal_facing == 2 && query.movement_direction(0) >= 0.1"
"query.cardinal_facing == 5 && query.movement_direction(2) <= -0.1"
"query.cardinal_facing == 3 && query.movement_direction(0) >= 0.1"
"query.cardinal_facing == 4 && query.movement_direction(2) >= 0.1"
This detect if I'm moving the A of left movement button hahahaha
Yeah hahahaha a bit buggy tho
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
To my knowledge, molang doesn't support +=
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
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.
How to test if entity has effect?
no, maybe with scripting, but not with molang
using entity filters or scripting
I want to make the entity texture blueish whenever it gets hit by a specific projectile
Is that possible in scripting?
||@abstract nacelle||
you can detect who deals the damage
Ok but can you make the entity texture blueish?
Just like pvz zombies when they get hit by a snow pea
with render controllers, idk
Oh ok thx
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
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
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?
Ahh, thanks!
Interesting, does 0..0 stands for the coords of the seat or the rider array
?
No, it would be the seat that is used as a reference, for example if I put this query on the head of a horse it will move in the same direction as the head of the rider in seat 0 but if I put 1..1, I suppose it will move in the direction of rider head seat 1
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
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
Using molang queries, can you find XYZ direction the entity is facing?
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
'park'
What is the name of the molang that detects when we are wearing armor?
q.is_item_name_any(equippableSlot, slotNumber, ItemName)
How to fix
Check icons on your BP items, or format version of it. It should be 1.16.100 and above
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)"
You can't multiple
Also where do you use that?
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?
"geometry": "query.is_name_any('player_selector') ? geometry.player_selector : geometry.map_frame
Are you sure that's how you supposed to write that molang?
query.is_name_any?
Yes²
Did you try to use query.get_name ?
Then try that for the mean time while checking the query.is_name_any
The VS code and documentation recomends query.is_name_any
[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?
The property doesn't exist
this exist
Well it's saying your property doesn't exist
Did you turn on "client_sync": true?
I fixed, it was in animation controller of resource
This entity was using a animation controller in resource, but i forget to remove
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?
q.scoreboard isn't removed yet?
It's not removed but it doesn't work on resource packs anymore, only in behavior packs.
It never worked in resource packs, it is necessary to use properties for that
Nope it works on RP packs before but the scoreboard should be visible using scoreboard objectives setdisplay
You can't tell it doesn't cause I use that always, it was removed after 1.20.60
ah yes, just showing the scoreboard, but that wasn't very useful
I didn't know they removed it completely.
Removed in the rp packs
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
I thought it was still working with the showdisplay, I didn't know
molang animations are neat
hi there
is the query.time_stamp reutrning the tick of the minecraft day? or it returns the total ticks since the server created?
just test it my guy i feel like it would be easy to tell the difference between the two
How to detect biome tag?
I forgor this was a thing 💀
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
I dont think so, only with scripting
no
But, I need the molang anyway, for the script it doesn't fall the way I want it to
what about query.is_in_ui what does that one do?
detect if you opened an interface
ANY interface
you cant specify what interface you opened
Ok, well for my purposes that may work
What does molang expression "this" return, I've found that couple times on vanilla sample (e.g. player animation.player.holding)
Can Molang check for a tag on a player?
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
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?
Maybe it's not in education edition. It's only come out of experimental pretty recently
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.
I'm trying to use query.has_biome_tag in an animation controller but it is trowing an error unrecognized token
Can anybody help?
check documentation to see if it is beta or stable. If Beta, make sure you have the molang Features experiment toggled on.
It's stable
is there a painting template? or even an animated painting template? the discord search thing sucks dick
is deprecated as I remember
idk, just do a block / entity with random texture when is placed
i for some reason find this line unbelievably funny
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)
Molang is basically just queries, math, and basic loops
What parts of a behavior pack can I use queries?
can i access queries through scripts
no
ikr
@swift rivet any idea why this don't work?
trying to delay the particle
How to use query.time_of_day?
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.
Is that possible to use regex in molang scripts? I need to check if item's id contains golden_
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
what method can be used to return power jump strength value?
I'm making a resource pack so this wouldn't suit my needs
But thanks for the tag suggestion
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?
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?
add minecraft: interact to your entity or use scripting
Thanks Gabriel! I solved this just by using "take_item" on interact.
what molang is similiar to is_sheared? Gi need something that could return 0 to 5 integers
hello, can we set values for molang variables inside block.json files?
q.property....
dummy components are deprecated
I think it doesnt support molang
they are being removed?
what are the alternatives then?
no, I mean, actually, they are not used as much, there are better alternatives
entity properties
they are very important in entities
they are like "infinite dummy components"
this one's interesting
Bruh its outdated
but how can you read it in geometry?
I want to have something similar to query.variant
query.property('your:property') == 'value'
that's the solution I found
yeah, you can create an int property and use it like a variant
"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
it acts similar to components huh
client_sync?
in manifest.json?
no, in the property
like this
🫡
@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
values have a min and a max
it should be
values: [0,6]
that means the enum_exmaple is wrong here?
no, enum its okay, how do you specify a min and a max with strings lol
"property:example": {
"range": [0, 100000],
"default": 0,
"type": "int",
"client_sync": true
}
yeah thanks for the replies I took a look at the microsoft docs the wiki.bedrock really is outdated
Synchronization works with any type of data, right?
Yes you can use it on any property
Is there a way to run external molang? Some time ago I read that it could be done with a .molang extension, I remember reading it in the official documentation.
I don't know
That does not exist
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
Simple. Use molang and math. I'm sleepy but if you put up with my slowness I'll help you.
Do you want to activate the animation when the player turns his head sharply in one direction or only Is it a question of speed in any direction?
Thanks to mathematics we can calculate by speed with respect to angles or relative distances but with spherical coordinates, a transformation is applied according to the spherical radius. It's more complex and unnecessary, so we use angle velocity.
Look for perpendicular velocity variables and evaluate one or both with trigonometry, use Newtonian kinematics to calculate the speed you want and with molang you check if it meets the condition, conditions the execution of the animation in the animation controller.
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
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"
I only care about turning left and right
That's a little too much information, just having trouble with the math xD
Evaluate speed and also direction. Simple.
Abandon your problems.
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
Is that Y axis in direction_z?
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]
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
Is that the case in snowstorm or in the game
in game
it work
thank you
is it possible to make particle that have
"minecraft:particle_motion_parametric"
have gravity?
"direction": [0, -1, 0]
don't do anything there
The first definition has problems, Mojang mentioned this in the official documentation. Use parentheses to enclose the first and it will be the argument of the second.
Exact
Yup here it is, always use latest format version folks

