#Molang General
1 messages · Page 3 of 1
No. You have to calculate gravity yourself inside of parametric motion. Parametric motion is basically just "set particle position to xyz", so you need to calculate such xyz that it looks like gravity
Another option is to get rid of parametric motion and instead use acceleration, where you can calculate it such that it works exactly like your parametric motion formula
can this be achieved without the parametric motion?
i am using it to offset each face
What is context.other used for?
How do we do ranges in molang in the sense that I want to return something within a range of 20 and 60 for instance?
Wdym? Like a random value? Remap 0-1 float to a custom range? Test if a value is within the range?
Hard to explain since I want this for feature placement, since it returns a fixed value of 68, but instead of a fixed value, I want to to place anywhere between like 62 and 68. I can send the line if you'd like? (I feel like this fits more in #1067869318383157430 than #1067869232395735130 since I am dealing with molang but correct me)
Math.random?
You dont need molang for that though? Just use extent
I am using that pool/pond template pack Cici made a long time ago, but currently burning to make it work for my needs
It can't use extent
Is there a query for checking for a full inventory in an entity? I have an item generator entity that spawns a loot table about every 13 seconds and since it has a hopper component it takes them all in. I was hoping to stop it's controller animations once full, or at least test for it if possible. Got any ideas? 💡
with scripting yes, with molang I don't know if you can make detecting an item in the inventory increase the value of a variable, if so, then use loops together with q.is_item_name_any
Oh I see, didn't think of scripting thank you @abstract nacelle and that could work with looping, I will have to look into that 😁
"v.flying_nimbus = (q.is_riding ? (q.get_ride -> q.owner_identifier) == 'dbe:flying_nimbus') || (q.is_riding ? (q.get_ride -> q.owner_identifier) == 'dbe:black_flying_nimbus'); ",
How can i convert it to script?
OBs: it is a var that i use to play an animation when i'm riding a flying nimbus
"v.damage_percentage < 100 ? {v.damage_state = 0;};",
is this right?
cant work out what the syntax is from the docs
i just want to set the damage state if the percentage is less than 100
is there any molang (in Resource pack Animation Controller) that could read something abt attachable (item) that coud be modified using script?
Like query.remaining_durability but it doesn't work in RP
Or read abt the player holding the item? Like tag. Or some variable?
Nope
Best option is to probably just switch out the item
Or put some item into an empty slot and detect that
for real....
I mean if you can edit player.json there are options, but otherwise no
What else can Molang in RP read abt the item?
Feel free to look around the docs https://bedrock.dev/docs/stable/Molang
Can probably read item tags, and ID but not much else
Item tags are constant right?
You can check for items in different slots tho
Well, then I guess I could put some trigger item into Offhand
But then player cant use Offhand anymore
Yes
Can we make a suggestion for ScriptAPI to be able to trigger animation of Attachable 😦
Different items then
Hows abt item name?
nvm
is_name_any return the namespace not the anvil name thing
Is it?
Let me try
it didn't work
😦
Is it possible to query the player's movement speed based on keyframe animation, with the speed starting from 0 and increasing, and set all keyframes to increment from zero? When the speed is greater than or equal to 1, all keyframes should revert to their default values. This way, the amplitude of the animation's movements gradually increases with the movement speed. If possible, how can I achieve this?
how would i make a sine like this?
How do I save the value of q.anim_time in a variable once it clears a condition (for example, math.pow(q.anime_time, 3) > 30)? ( it will continue to update after the condition is meant but I want it to be updated once)
math.pow(q.anime_time, 3) > 30) ? v.anim_time = q.anim_time;
q.anim_time > 2 ? Math.abs(q.anim_time < 0 ? 0 : Math.sin(q.anim_time * 90)) * 1 / q.anim_time : Math.abs(q.anim_time < 0 ? 0 : Math.sin(q.anim_time * 90))
similar ig
thanks
np
"loop" : true,
"bones" : {
"root" : {
"position" : [ "this", "query.is_owner_identifier_any('minecraft:zombie') ? -6.0 : 0.0", "this"]
},
"l_leg" : {
"rotation" : [ "-90.0 - this", "-10.0 - this", "-this" ]
},
"r_leg" : {
"rotation" : [ "-90.0 - this", "10.0 - this", "-this" ]
}
}
Does anyone know how to fix this? I tried to use query.is_owner_identifier_any('minecraft:zombie') to change the root position of all zombie jockeys to -6.0 and the rest of the zombies to 0.0. But it does not work for some reason.
Is there a workaround to make v.attack_time work on an attachable?
no
I faintly heard that this query only works on server-side. Is this really true? If so, I don’t exactly get why. I would like further information about that.
What even is the point of having public and private molang variables...
there is literally only one place where it matters (c.owning_entity) and it makes animating attachbles basically impossible for no reason
all query functions are public, why not variables
That's a good question, I agree that it does seem unnecessarily restrictive
I have been hurt by attachables.
no one even checks the molang offten
What's the syntax for query.any_tag? When I use "q.any_tag('tag')" the log says that the token is unrecognized
yes, its for items and blocks
How to detect an entity moving backwards and distinguish it from the forward movement? Is there a query for it?
there is query.movement_direction
What's the appropriate equation to get my object to rotate with the circle path? Currently I have it spinning like the black arrow
You'd have to set the x and z of it to trig functions of some kind. If this is in a resource pack, something like: "position":["<radius>*math.cos(q.anim_time)",0,"<radius>*math.sin(q.anim_time)"], replacing <radius> with the radius of the circle
Hmmm 🤔 okay 👍
Is there any ways to detect item in off hand using "query" after 1.21.20 update? And what "query.equipped_item_is_attachable" is formated like?
So it only work with "slot.hotbar"?
And slot.weapon.mainhand
How to use query.equipped_item_is_attachable ?
Oh i found it :D
I suppose, if the item is an attachable return true
Is there a way to remove custom item from creative inventory?
Sorry for pinging:( forgot to turn it off
menu_category: none
Thank you very much
But it will make the item cannot be obtained with command
nope
Is there any way get the distance from a target in animations? I know query.distance_from_camera works for the player but not for the target entity.
you must to use scripting + entity property for this, q.target doesnt exist anymore
hello, how to detect if anim_time surpassed to two seconds? is anim_time a micro? or millisecond?
Pretty sure it's in seconds
oh
how do you make your entity turn smooth instead of just direct turning, is it possible?
i have heard of yaw_speed but doesn't know how do i make it turn smoothly
Turning left or right*
any way to get the time the particle was spawned/created (for acceleration)?
using q.yaw_speed and math.lerp
v.particle_age and v.emitter_age
save it where? what do you want to do?
i meaaaaaaaan
i need the value when the particle was spawned, not what moment of lifetime its currently
i'm trying to make a spiralish thingy, i already made it through scripts
For turning (up, down) or (left, right)?
only left right
srry I dont understand
Oh so like this:
math.lerp(q.yaw_speed, -25, q.frame_alpha)
Like that? Or how would I do it? 😅
try it xd
Okay, thanks!
Did this work?
nope, haven't tried it yet :v
how do i make an xyz var
huh
starting value not possible?
idk, but that's how i make one. Hope someone goes in here to assist you. I haven't really messed with molangs more enough.
You can also just make it:
v.my_vector_x, v.my_vector_y, v.my_vector_z but that's long or bad practice i guess
I wouldn't use structs unless you have a reason to, as each strict nesting level takes a bit of extra performance
But if you want to e.g. pass a vector variable from scripting, I usually do something like that in the emitter initialization v.vec ?? {v.vec.x=0; v.vec.y=0; v.vec.z=0;}; since variables passed from scripting are populated before emitter initializes, so using a null coalescing ?? for initialization is a must
is that possible from snowstorm
Not sure
You could do just v.vec.x=0; v.vec.y=0; v.vec.z=0;
And then add the ?? part after exporting
Tho it's only useful if you intend to pass values from scripting
i am
i can't seem to figure it out
you have any example?
Examples of what?
is there a query for when an entity with range attack shoot
the charge one don't work for me
What's the purpose of q.has_block_state?
Can it be used anywhere outside of block permutation conditions?
@ornate wren you happen to know the answer?
I dont think people even use it for block perms right? Never seen it. I cant think of an example of when you would ever use it
I was gonna say maybe in entities for those that have blocks as a target perhaps?
that would require the component to actually work though 
Wdym?
oh
i've never had issues with it
ig i'll stop using it then
Meters or minutes?
meters
its probably more than that but I've never had consistent results with it
No clue
any idea what is wrong
Well it says the property does not exist
"query.property" does not exist
the function it self
that is why it is suggesting query.has_property
No, thats not what its saying. Its saying YOUR property does not exist
Hence its suggesting to USE has_proeprty
nvm
but that error is kinda miss leading
client_sync: true was needed
How was it misleading?
this is what i understood from it
You just misinterpreted it then because
It clearly says:
q.property - property does nto exist
ah
i read it q.property does not exist
player.json does not have property 'dz:minimap'
version?
manifest?
?
manifest
format version
min_engine_version
entity client?
full
full screen
ops
you tried to put "format_version": "1.10.0" in entity client
The normal thing is to put version 1.10.0 or 1.8.0
This error only appears when I open the Minecraft pause menu, but it is just a warning, it does not interfere with the code, but it is very annoying so I want to find a way to remove this error.
although in this case 1.21.2 is not an acceptable version and it also exceeds the version of your manifest
Ah, I see, that usually happens when you add a geometry in the player entity, I don't know how to fix it, it probably has no solution even if everything works correctly.
ok
thanks
So, your addon works correctly? The only problem is the message, right?
yes
Just check if the player isn't in the UI before the expression so it doesn't interfere with the paperdoll
got renamed back from dear to molang
can variables defined in the in behavior pack be accessed from rp?
no
i was using
q.item_is_charged('main_hand')
thinking it get triggered when mainhand item is changed 🤦♂️
is there something like this?
when we were able to get item id it was as simple as storing the id on entry and keeping track of it
query.is_item_name_any?
ah, no
nvm
idk, use scripting XD
How do I detect if the enemy got hit?
(q.hurt_time doesn’t work)
You could store the q.health of the entity in a variable then check next tick if variable > q.health. If it returns true, it means your entity took damage.
You could do all of this in an animation controller.
hurt_time is for minecarts and boats
that is nice
can anyone make a new bug report on query.any_tag('wood')
Mojang forgot to add Warped, Crimson, Bamboo and Cherry blocks type as wood
what does "context.other->q.remaining_durability" mean? specifically the "context.other->"
The other item for repair… I think it's the 2nd one in the UI.
hi there, is it possible using molang to get if the entity is over a slab?
half block collision box in general
q.on_ground && (q.position(1) - math.floor(q.position(1)) == 0.5)
not sure if there is other ways
will try that, thx!
Is there a way to run a function every few seconds that spawns an entity at a random position around each player?
I'm not clear if there's ways to run these sorts of timed functions/scripts
does anyone know how to add this check
(t.iterator = 0; loop(27, {query.is_item_name_any('slot.inventory', t.iterator, 'minecraft:arrow') ? {return true;}; t.iterator = t.iterator + 1;}); t.iterator = 0; loop(9, {query.is_item_name_any('slot.hotbar', t.iterator, 'minecraft:arrow') ? {return true;}; t.iterator = t.iterator + 1;}); {query.is_item_name_any('slot.weapon.offhand', 0, 'minecraft:arrow') ? {return true;};}; return false);
as part of the expresion below
"v.charge_amount = q.main_hand_item_use_duration > 0.0f ? (math.clamp((q.main_hand_item_max_duration - q.main_hand_item_use_duration) / 5, 1, 3)) : 0;"
https://discord.com/channels/523663022053392405/1298130824314486794
I made a post, i just need help to detect this left and right on the x axis, with math. I alr figured out how to make molangs to transition base on movement on the x axis just need math to transform it to left and right movement
Anyone know the values that q.hurt_direction returns?
the minecart dose use it
https://github.com/search?q=repo%3AMojang%2Fbedrock-samples hurt_direction &type=code
Doesn't tell me what values are returned.
it is a number,, but i am not sure what it represent
That's not really helpful.
what does From Motion does?
Can you use c.owning_entity in attacheables to query if owenr is sneaking etc?
i don't think you need it, you should just be able to do query.is_sneaking
Yes
Guys, is there a query to check if the player is using an item on a specific block?
Question 2: is thera a query to check if the player has or hasn't a tag?
ok according to the documentation q.armour_color_slot will take the armor slot and will return the color value
But....
query.armor_color_slot(0, 0) // Head, red
query.armor_color_slot(0, 1) // Head, green
query.armor_color_slot(0, 2) // Head, blue
query.armor_color_slot(0, 3) // Head, alpha
How can I make a block that detects if there is a solid block right above with molang?
what values wwould it show for undyed leather armor?
what value does the query return
can we use query.is_item_name_any to change item icon?
Is it possible to test for the biome a mob is in?
"undyed_helmet": "q.armor_texture_slot(0) == 0 && q.armor_color_slot(0,0) == 0.62745099 && q.armor_color_slot(0,1) == 0.39607846 && q.armor_color_slot(0,2) == 0.25098039"
You can read more about the specific values for the query and how the molang is used in a BPAC on the readme of my pack on github.
were you able to find a solution in the end?
not possible
to access private variables without editing the entity
What value does query.distance_from_camera return when on a server?
Probably 0 or error but it should be simple enough to test anyways
How would I check if a block is Obsidian using molang, but without using the diamond_pick_diggable tag
maybe try out query.block_has_all_tags
The documentation says:
Takes a world-origin-relative position and one or more tag names, and returns either 0 or 1 based on if the block at that position has all of the tags provided.
is there some way to store a permanent variable with molang? i want, on a global level, for the game to save when the Ender Dragon is defeated
it occurs to me the exact same thing could be done with tags, but i'm not sure how to query if ANY player has a tag
as i remember, you can make a molang folder, and then define your global variables
molang/molang_file_name.molang
Thank you!
I am so confused. What even is Molang? It's not Script API, it's not commands. What is it?
The pins have helpful stuff 🙂
Ah, I forgot pinned messages are a thing. Thanks!
I see the pinned message. But where is it used? Where is the file for it, and what is it under? main.molang?
Why Does Molang Exist?
Molang is a simple expression-based language designed for fast, data-driven calculation of values at run-time, and with a direct connection to in-game values and systems. Its focus is to enable low-level systems like animation to support flexible data-driven behavior for both internal and external creators, while staying highly performant.
It's mainly used in client stuff such as render controllers, animations(and controllers) but can also be used in world gen.
I see, thanks!
A VitePress-powered documentation site
-- this section is incomplete, the variable, domain, and syntax pages are still useful
Alright; I posted a forum in another section but have found out more information in the last five minutes.
How do I loop through each player? Like, check scoreboard against each player?
Is there a function that returns an array of all players?
I need a value that persists across closing and reopening the game. Ideally a global one (which does not appear to exist)
could you set a scoreboard value for a fakePlayer and then query that using query.scoreboard?
that doesn't make sense, where do you plan to use the q.scoreboard?
yea I'm not thinking this morning. I was thinking of using it in a BPAC with player.json but yea where would it query from, doesn't make sense, lol
You can use script or "execute" command
this is a molang question though for a global persistent value, I'm assuming they are wanting to use it in some type of BPAC
what are you trying to use the value for?
you have to use it with a property and q.property
I want to save it and use it in a feature_rule. It’s highly unusual AFAIK
There’s a feature rule that counts iterations, I should be able to set that to 0 to gate generating the feature. What’s confusing me is setting up the global value
I like the fake player idea but don’t know how to execute it. I hate being “that guy” with all this, lmao
Were I working in JS I feel I know exactly what to do, but I’m unsure if I can even use the javascript api to generate structures using features
Omg, I finally figured out how to change variable values in animation transitions. You define the value for it, add "return" and then put the conditions to be met.
Actually, on_entry works better because you can then put math.random_integer in it.
{
"format_version": "1.10.0",
"animation_controllers": {
"controller.animation.scan": {
"states": {
"default": {
"transitions": [
{
"walking": "(1.0)"
}
],
"on_entry": [
"/execute @e[tag=prototype,type=wolf] ~~~ function scan"
"/execute @e[type=zombie_villager] ~~~ function scan"
"/execute @e[type=husk] ~~~ function scan"
]
},
"walking": {
"transitions": [
{
"default": "(1.0)"
}
],
"on_entry": [
"/execute @e[tag=prototype,type=wolf,tag=wolf] ~~~ function scan"
"/execute @e[type=zombie_villager,tag=zombie] ~~~ function scan"
"/execute @e[type=husk,tag=husk] ~~~ function scan"
]
}
}
}
}
}
is this correct?
does q.property work for attachables?
ik this is easy to test myself im just asking in case someone already knows
It doesn't
Anyway why does c.owning_entity in an attachable just throw "error: unhandled request for unknown variable c.owning_entity"?
I had the same issue, last I checked you cant query the owning entity nor property. However, things like q.is_sneaking will query if the owner is sneaking.
yea most queries just work directly like that
Anyway, weird
This means that there's absolutely no way to get entity properties in attachables right? Like not even through public variables?
Yeah.
Probably because you're calling it outside of attachable file. I think you can just save it to variable in pre_animation and then call that variable elsewhere
Oh great
Thanks will try that
in the attachable's pre animation do I have to do v.lol = c.owning_entity -> v.my_public_variable_constantly_set_to_the_property; or v.lol = c.owning_entity -> q.property('namespace:my_property');?
Either way should work, even just v.lol = c.owning_entity;
How do I detect if a player is riding a specific entity cause the query.is_riding is only a true or false and doesn't take any parameters
I believe that's only possible via scripting. I asked for the same thing a while ago and that was the only answer I got.
[Molang][error]-minecraft:player.0.c18e65aa-7b21-4637-9b63-8ad63622ef01.Noor | Error: query.property does not have an actor.
Why does my player shows this error?
will this work in molang?
"shoot_first_person_hold": "c.is_first_person && q.is_using_item"
will that run when I'm in first person and right-click
Alr my animation is a lil broken
I got it working for the first time
I have it as
query,is_sneaking
and when I first sneak, it works
but it stops working after that
no matter how many times I sneak again
is this a proper molang?
"shoot_first_person_hold": "query.is_item_name_any('slot.weapon.mainhand', 'jm:testgun2') && query.is_using_item"
because it's not working unfortunately
Are you making a behavior pack animation controller? You might need a way to transition between states.
I got it to play the animation using javascript
but the animation is bugged
I gotta fix it
Oh thank you so much, sorry i saw this very late
Do you know of a way we can see the output of all molang query, like similar to how we check code used print functions/methods
hmmm, you have the on_entry and on_exit in a BPAC, which can run commands. You can use tellraw or titleraw when there is a state change, or you can assign scoreboard values, like I did with the detect leather color.
What is the molang for offhand
Um
You can use:
query.is_item_name_any('slot.weapon.offhand', 0, 'namespace:item_name')
https://wiki.bedrock.dev/documentation/queries.html#query-is-item-name-any
anyone have an idea why v.attack_time doesn't work in attachables? Is there any alternative?
How to use query.is_item_name_any on a sub item category? I want to target an invisibility potion.
Can I ignore the slot name in query.is_item_name_any?
are you using the query in a behavior pack animation controller? you can use the on entry on exit to use commands with hasitem
I didn't see a way to add item data to the query
Thanks. I was using rp animation controller. But I got it working by just using potion item for now. If I had to try some more I was going to do something like 'minecraft:potion:7'. Because I only saw an ominous banner referred as 'minecraft:banner:15' which was in behavior file.
oh interesting the minecraft:banner:15, I'll try some stuff out
how do you get the turning speed of a mob?
Hardcoded variables are private by default, you can make th3m public if you can edit the player file, else youre going to need to use scripting to execute the animations. They append controllers to the actor at runtime so they have access to private variables.
How can I obtain the x y z coordinates of my entity's target?
how do i generate a semi random number from 0 to 2 for a block permutation with molang?
i want to use texture variations but it doesn't work with custom geometries.
math.random_integer(low, high) Random integer value between low and high inclusive
is it accepted in block permutations tho?
that's a hard no
i guess i will have to do it with scripts.
How do I fix this error [Molang][error]-minecraft:player.0.c18e65aa-7b21-4637-9b63-8ad63622ef01.Steve | Error: query.property does not have an actor.
I run a molang in a render controller part of the entity
This is it
q.property('smile:ride') == true && variable.short_arm_offset_right == 0.5
The default value of the property is false and i set that via scripts to true
Did you try c.owning_entity -> v.attack_time or otherwise syncing attack state via entity properties?
what's the query to knw when an entity is using an ranged attack? not when it shoots but when is trying to attack something
v.attack_time is private by default, they can make it public if they can edit the player files or they can use an animation applied at runtime with the variable uses in it via /playanimation
Yeah, that sounds right.
I seem to remember the public variable system breaking not too long ago.
I haven't checked recently. imo if it's not, they should remove it, there's no need to stop attachables from reading them
Dude, I wish Mojang had a team to manage commands, filters, and Molang like they do with scripting systems.
I'm so sad these systems are always lagging behind or just totally in the gutter.
Yeah and it really sucks because in most cases the client-side implementations have been really good but when theyre bad, theyre awful
Actually, yeah, come to think of it… outside deferred, the client's been left in the dust for years. They're really locked in on the all the server-side stuff right now.
Not all of the server stuff, still waiting on actual sound control 
Is my animation controller good?
{
"format_version": "1.10.0",
"animation_controllers": {
"controller.animation.spidone": {
"initial_state": "idle",
"states": {
"idle": {
"animations": ["animation.spidone.idle"],
"transitions": [
{
"summoning": "q.mark_variant == 1"
},
{
"walk": "q.mark_variant == 2"
}
]
},
"summoning": {
"animations": ["animation.spidone.summoning"],
"transitions": [
{
"idle": "q.mark_variant == 0"
},
{
"walk": "q.mark_variant == 2"
}
]
},
"walk": {
"animations": ["animation.spidone.walk"],
"transitions": [
{
"idle": "q.mark_variant == 0"
},
{
"summoning": "q.mark_variant == 1"
}
]
}
}
}
}
}
It doesn't work
I can try that
how can i make queries like this one. there's not a blue pencil like the Bridge V1?
use scripting
Is this valid?
v.ext.x.z = 1,2
no xd
if you want to make .x and .z axis from a vector3 in once, use this formula json v.extXZ = Math.sqrt(Math.pow(v.ext.x, 2) + Math.pow(v.ext.z, 2)
Does anyone have a good example of using { } brace scope delimiters for setting up a variable?
When did Mojang add .molang files?
Is the content just accessible anytime or do I have to do something else?
Is it usable in features?
Never, it's a feature in bridge
(Math.cos(query.anim_time * 90 + 180)+1)*3.75
if i want the frequency to be faster, should i multiply
query.anim_time * 90
by query.ground_speed?
or is there any other query
Sorry that's unrelated to the question. But what did you use to get a preview of Molang expression?
https://jannisx11.github.io/molang-grapher/
blockbech also have one (same creator)
Thank you.
np
i need it to depend on the movement speed
query.ground_speed is not working
How can I output values to the debug log or anything that lets me see values of expressions/variables in-game?
alr
thanks
How can I acess thw developer version?
I made a suggestion on the Minecraft Feedback server that we should get a molang query for getting the client-side camera rotation. Much appreciated if you upvote it: #1325377682103599215 message
You can’t.
you could render numbers above ur head
with render controllers
and then just push values there
context.<name>
when and why do we use query like this?
dose all query work with it?
Can someone explain how query.movement_direction works and what it outputs. Any documentation gives me vague answers and never includes the output. I want to use it to where the robe of my mob will rotate opposite of the current movement direction.
Does a molang query for a flying entity exist
I tried query.is_on_ground but no effect
Does query.ground_speed work on, as the name implies, on the ground or regarding general speed of the entity
What can I do so that one medelo I add in the player is only seen in the first person and another model so that it is only seen in the third person
you can reassign variables in animation controllers in on_entry/off_entry right?
and can you retrieve this entity variable in attachables with c.owning_entity?
I made the entity variable public.
!q.is_on_ground should work.
yup
still wondering difference between c. and v.
Context
Variable
yes, I mean the difference in usage
so context is like built-in vars that can't be changed??
Because those gets reset upon reload whereas the ones I mentioned don't.
what reload? u mean cmd /reload?
Did you read what I sent?
Does anyone know how to fix this error?😭😭😭
It's telling you
Then I must change all the files that use query.property for query.has_property?
@lilac flame
;-;
query.has_property('my:property') ? query.property('my:property') : 0
if the actor has the property, then get the value, else return 0
?
That's how you are meant to use it. You must check if the actor has the property before accessing it.
I don't understand 😭
What do you not understand?
All
You asked how to fix the error that occurs when trying to access a property that doesn't exist on an actor. I told you that you need to add a simple check to see if the actor has the property before accessing the value of the property. In conclusion, the simple solution would be to replace every reference of you trying to access the property with the fail-safe measure that I sent.
I would also recommend you check if your entity has that property to begin with
And if it has the client_sync property set to true
I think I'm getting it
Looking at the player.json file again
Missing wesl3y:mode
Do you think that's the problem?
It's very likely. Is the player.json file the one in your behavior or resource pack?
Behaviors, but I read wrong, in the end it was
Can you send your player.json file?
Sure, let's talk in private.
Yeah.
but how...
this one is for emitter
i want to run that per particle (each particle has its own random value)
Would it not be it's own emitter?
cause instead of running 5 emitters
i could just run 1
is something like this even possible?
I believe the wax particles does this.
there's a script to make that a entity summon a row of a ground attack like the Evocation Fang?
I have question - what's that mean: "Error: query.property does not have an actor"???
Can someone explain to me how I can detect the direction of movement of a flying entity? I think q.movement_direction doesn't work for flying entities. I have a helicopter. I want it to lean slightly forward or lower its nose when it moves forward, and when it goes in reverse it should raise the nose of the helicopter. If I move sideways, for example, if I move laterally to the right, the helicopter will also lean to the right, and if it moves to the left it will lean a little to the left, just like it would happen in real life.
.
Please, I have been investigating for months how to achieve this and I have not been able to, so I am asking one of you to help me in this regard.
q.movement_direction works like a vector3, you have to do maths to use it as local movement direction
How can I do that? To change it from global to local?
and what query or math accompanies it? because of course, that query detects the direction of movement, but how do I assign an action to it when it detects that movement is taking place in that direction?
? 🙂
well, there is a lot of formulas on the internet, you can search it by yourself, probably its like this, idk if this works
"v.x = (math.cos(query.body_y_rotation) * query.movement_direction[0] + math.sin(query.body_y_rotation) * query.movement_direction[2]);"
"v.z = (-math.sin(query.body_y_rotation) * query.movement_direction[0] + math.cos(query.body_y_rotation) * query.movement_direction[2])"
]
}
}
}
}
}
idk if the use of body_y_rotation is correct in this case
maybe q.target_y_rotation is better, idk
Where do I paste this code? In "rotation"? Or in the entity's json file in the resourcepack?
in pre_animation for client entity
How can I search for it on the internet? Motion calculator or convert from global to local? Or how? I'm still going to try your code to see if it works or not.
ok
Well, how do I call this variable in the "rotation" in the animation? Do I assign it a specific movement? Example: "q.has_rider ? math.clamp(query.modified_move_speed *30 0 60)"
.
I use this for the lever of my helicopter, when it moves forward the lever tilts forward, but I would like to add animations depending on whether it goes forward or in reverse or to the sides and so on,
I also use it to tilt my helicopter, logically with fewer degrees of inclination, but the problem is that it only works when the helicopter is moving, but it completely ignores the direction in which it is moving.
Well, I'll try it and see how it goes, thank you very much, my friend.
add v.x on the rotation
v.x > 0 ? 90 : 0
try that
and you will see if it works or not
wow, thanks a lot, that was already breaking my head trying to think of how to add it xD
90 is 90 degrees of inclination?
yes, if works, your helicopter will rotate 90 degress when you move to the side
its for testing if it works
I understand, I'll try it and see how it goes
hello someone knows how I can make a mob when attacking a player the mob grab it and the player does not oue to let go until the mob dies or something specific happens
something like that i would like to know how it is done
you can try forcing a ride to the mob
as I do
can i detect player attack?
previously i used variable.attack_time but in attachable it doesn't work
molang
anyone know how to make a smooth version of q.vertical_speed?
this is what I tried but it didn't work
"scripts": {
"initialize": [
"v.vertical_speed_prev = q.vertical_speed;"
],
"pre_animation": [
//didn't work, rat king ascension/descension animation still at low fps :(
"v.vertical_speed_smoothened = math.lerp(v.vertical_speed_prev, q.vertical_speed, q.frame_alpha);",
"v.vertical_speed_prev = q.vertical_speed;"
],
@rotund copper I would try incorporating query.time_stamp into this.
{
"initialize": [
"v.smooth_speed = 0;",
"v.vertical_speed_prev = 0;",
"v.time_stamp_prev = 0;"
],
"pre_animation": [
"q.time_stamp > v.time_stamp_prev ? {v.vertical_speed_prev = q.vertical_speed; v.time_stamp_prev = q.time_stamp;};",
"v.smooth_speed = math.lerp(v.vertical_speed_prev, q.vertical_speed, q.frame_alpha);"
]
}
Since frame_alpha returns the time between ticks, we want to update the previous vertical speed variable to a new(er) value every tick. This pairs nicely with the time_stamp query
i just thought of something that might be a game changer last night
offsets only occurring once per world
im only running into two problems
-
how do i detect if a variable has a value set?
-
how do i save the variable to disc so it never gets overwritten and always stays the same?
if anyone can help me with this, thatd be AMAZING
- Use null coalescing
??. E.g.v.test = v.test ?? math.random(0, 1);orv.test ?? {v.test = math.random(0, 1);}; - World gen? If so, then idk
- YAY
- it doesnt matter if its related to world gen or not, but yes im doing worldgen
im trynna find a way to do custom seeds
There isn't a way to save variable to disk with just molang, you have to use some other method like e.g. entity properties. But idk of any way to do that with world gen
great
so there are no variable types in molang that do this?
i just need to make sure that once the variable is set it can never change
yep no variables for this...
wtf mojang
ridiculous
Nope
this is literally the only thing stopping seeds
Is there any way to query something from world gen?
no
Even height map?
you cant query the world seed
oh you can use those
but those have nothing to do with this issue
q.noise is unseeded - meaning its not locked to the world seed, its locked to a specific seed
Aww
being able to apply odffsets can give a similar effect, but without the ability to permanently store a variable once per world...
its pointless
and i dont want to use a janky workaround (temp leaking)
Is there anything else you can do to read information about the world, other than q.noise? Like e.g. can you read the bedrock pattern at the bottom of the world?
bedrock pattern is unseeded
it has always been that way
its the same pattern across all seeds
and you cant read anything about the world anyways other than biome information which is completely separate from the terrain
If you can query biome at specific position, that can also be used to create a unique value per world seed
i dont think i can
not for what im doing at least
theres no biome query
hmm does anyone know if there is a molang query which i can use in an animation file like shield.animation.json to check whether the player holding the shield has a slim skin or classic skin?
uh is this the right thing to detect if the entity gets hurt?
for an animation controller
One message removed from a suspended account.
@red lintel I'm guessing this error comes up when you pause the game. If so, this happens when Minecraft renders the player model just above the Dressing Room button.
"Actor" means an entity in the world. That player model is not tied to your player entity in game, and thus there are no properties it can query, and query.property fails.
You need to check if the player being rendered has an actor; you could guard your query.property query with query.has_property, or you can use a combination of query.is_in_ui or variable.is_paperdoll
One message removed from a suspended account.
I'm currently doing
!v.is_paperdoll && !q.is_in_ui && q.has_property('yes:is_shooting') && q.property('yes:is_shooting'); in player.entity.json but it still gives this error
Error: query.property: property does not exist, consider using query.has_property.
like what am I supposed to do
Hm, I guess then Molang does not guard like I expected. May need to use a ternary then.
!v.is_paperdoll && !q.is_in_ui && query.has_property('yes:is_shooting') ? q.property ('yes:is_shooting') : 0
I tried something similar already, but let me just double check
If it was still throwing that error, that implies to me Molang is still executing all statements in the expression despite the fact that the earlier statements were false; it did not need to, since the entire set of Boolean operations would resolve to false anyway
let me make a new pack with only 1 property cuz I'm using a bunch & maybe it's caused by something else
ok !v.is_paperdoll && !q.is_in_ui does work
then I must be calling a q.property() elsewhere cuz all of the ones in player.entity.json are wrapped
ok turns out it's because I was calling a property that isn't defined in player.json. Error message was unclear; thanks for your help
but like holy crap this one error had taken up like 100 GB of logs
Oh yeah, those get evaluated every frame. Very dangerous stuff. That's why I have only the GUI enabled lol
Is it just me or math.random(0, 1) is always 0?
its just you
can you check if the block positioned 2m below an entity is not air?
So I just learned that q.get_nearby_entities was removed back in 1.20. I was really looking forward to using that. Did they have any kind of replacement for that for sending data between entities in a controlled way?
No.
What are you trying to do?
Have several entities sync their arbitrary molang data with some particular central entity.
These were added in the same update that q.get_nearby_entities was removed.
Though it is very restricted.
If you can use behaviour packs, I recommend ScriptAPI.
There will definitely be scripting going on behind the scenes, but one of the troubles is I should like the entities to have different molang values per client.
You're in luck, per client rendering is possible in 1.21.70.
And I gotta be careful with syncing them that way since the client doesn't seem to receive all the property updates in the same frame.
How? 👀
I helped Toycat put together a world and it showcases this:
Wild how much is changing so fast
thanks to @SmokeyStack for creating the world, and thanks to Dasha for recording her side of that weird interaction haha
Follow my Twitter for video updates and early news! → http://twitter.com/ibxtoycat
Become a Channel Member to access exclusive videos & community posts, special emojis to use in the comments ...
What new feature is being used here?
setPropertyOverride
In scripting.
I just updated my @minecraft/server node package and this function doesn't seem to be in there.
It's in preview 1.21.70 using the 2.0.0-beta.
Oh I see.
Hmm, it doesn't appear to be on the MS docs when looking through the experimental APIs. This is a method on the Entity class, yes?
Player.
You can also use playAnimation to set different molang values per client
Too bad this is locked behind a behavior pack meaning it's affected by server lag and latency and we can't update values at frame rate frequency or implement this functionality only through RP. It's not a replacement for removed entity queries :/
Yeah it definitely has its limits, and will be generally harder to use than what I will be using, but it works for my purposes.
I'm setting up a system to update the entity's Molang every tick, but I am having trouble with it only registering the data from the first application. What was the technique used to flush out the old stopExpression, if that is what's used?
Different controller name. But you should be careful with it as it actually creates logical controllers on the entity that remain until it gets unrendered, so it could be a source of memory or performance leaking
you could also split your values into binary and play animation for each bit, in this way you can just use pre-existing animations, but sometimes it may not play all animations at the same time, so you could loose some data in the process
That sounds extremely painful to maintain. lol
Or dedicate multiple properties to each client and then just sync only "client id" via animation, and use that to choose the right property
The number of properties needed per client is far too high. And I want it to support arbitrarily many players.
You could dynamically spawn new entities
I think I'll stick with setPropertyOverride for this since I am prototyping for future Marketplace projects, so it being experimental isn't an issue.
Yeah ok then that's the best option for sure
Btw are you part of the team or doing your own thing through a publisher?
I am a member of Yeggs.
Ah ok, I see
Why do you ask?
Was just curious about how that publisher thing works, in case you were doing that
Ah, yeah I have no idea. lol
I assume they just partner with randoms. I wouldn't suspect they give them assignments or anything.
how can i make this attachable scale the texture properly?
im trying to use the vanilla pumpkin blur which is 256x256
seems like it should be scaling on the 16x16 cube im putting it on but its not
what can i do to fix this?
these are the files
hey is it possible to get the remaining durability in the attachable, when I tried using query.remaining_durability in it, then it just throws an error that the item is not provided
what in the world is this even saying
sure looks like t.iterate = 98304 is an expression to me
nvm
used = not ==
Hey guys, how do I check if an attachable is used (q.is_using_item doesn't work)
that should work as long as you have use_modifiers on your item
Yeah, well…..
It turned out that I forgot to write c.owning_entity before that
at least you figured it out 👍
How do you call variables from bridge's .molang file to a feature json?
Can I use variables or something to make the tame particles max amount 0 for a certain entity?
I've tired it a few different ways, using variables on the entity but they were undefined for the other tameable entites. And I've also tried query.has_property but that needed context. (Which particles cant use owning_entity)
In attachable, is there a way to get rename item?
I want to render a entity that is only visible to a certain player
Does anybody have experience with q.bone_orientation_trs. I seem to get the error (no matter what bone name I use) query.bone_orientation_trs couldn't find the specified bone in the current entity's queryable geometry
Isn't there a client entity thing called queryable geometry. I would guess the model has to be defined in there first
I've been told there is a query that can disable the player camera bob animation. After some experimenting of my own, i haven't found any way to add a query to disable it, but I would appreciate some help if you can!! #1346955844209868871 message
uhhh whats molang?
MoLang is a simple expression-based language designed for fast, data-driven calculation of values at run-time. Molangs structure is largely based on simple 'C' language-family style syntax.
Documentation: https://bedrock.dev/docs/stable/Molang
Where is MoLang Used?
MoLang is used in various subsystems within Minecraft Addons. For example: Client Entities, Animations, Animation Controllers, and more.
I could be very wrong here but I think you can only use that query from where the bone is defined
so if you're querying for a bone defined in an attachable you can only query it from the attachable
Are you running this from an attachable?
Also, the format version for the model has to be at least 1.16.0 I think.
I was querying from an entity, and this entity had multiple geometries, I think the issue here is that it has multiple bones of the same name
What Text Editor can I use for molang? and how do I port it into minecraft
what exactly does q.movement_direction() output?
This sounds like a more general minecraft addon making question
Any text editor that has or can support type definitions is most reccomended, but any text editor can be used for molang.
Bridge v2, VScode are the 2 most used and most reccomended
Thank You!!!
Have you seen this
https://wiki.bedrock.dev/documentation/queries#query-movement-direction
No problem
Btw if you're new, I would strongly recommend bridge v2, it's less involved and easier for newcomers to get into addon making
I've used it before, it just never worked for me, not sure if its because I was mising line of code or not
If it didn't work you might want to check your content logs in case there was an error in either your queries or elsewhere
no not for molang, I didn't know it supported molang.
I'm talking about a custom ticket I made
not ticket
sorry item
Not sure why I said ticket
Bruh
I thought you meant custom ticket item😭
Well either way, content logs are a great way to find errors
ight
yup and it's too vague. edit: I thought you sent the .dev documentation, Im so sorry 😭 . Thanks a lot!
although I've tested it and its outputs seem to be 1 to -1 or exactly 1, 0, or -1 sometimes 😭
Hello, I'm trying to make a billboard entity. My entity has velocity and seemsto always try to face it no matter what i do. I have this animation script that tries to make it face the camera but it doesnt seem to be working
"rotation": ["-query.body_x_rotation + query.camera_rotation(0)", "-query.body_y_rotation + query.camera_rotation(1)", 0]
This seems to sort of wor except for axis X where entity still tilts down
Why isnt there a modulo operation in molang 💀
math.mod() tho it works a bit differently in negative numbers
It works like a remainder, right? If you need proper modulo, try the following.
a % b = Math.mod(Math.mod(a, b) + b, b)
Yeah I was doing it manually with a long expression. Tbh didn't even see mod was in the docs as I was searching fir % or modulo and it's called differently
I'm confused, what's the difference between math.die_roll and math.random_integer
I haven't seen die_roll used in anything at all, so what does it do differently, or does it not exist or something like that and bridge v2 is just lying to me
it exists
Ok, is there any difference between the two or do they just do the same thing?
ive never used it before, im not sure.
Damn, thanks for assuring me the fact that it's real at least
I'm sure I might eventually find information on how its used
math.random_integer rolls a random integer between min and max. math.die_roll_integer does the same thing given a roll count of 1; it differs when you give it a higher roll count.
It accumulates the total of all rolls. So with math.die_roll_integer(3, 1, 6), it should in theory roll three random numbers between 1..6 and give you the result; which would be between 3 and 18
Oh, OK, now it makes sense
Thanks Sprunkles
I've been trying to make an animation where the rotation is a random angle every 0.5 seconds but math.random_integer would always run seemingly every tick, and so I was wondering of there are alternatives, do you have any in mind
how can i store a variable in an animation? Say that my animation has an expression that calculates variable.foo and the animation in the next frame will depend on that previoys variable.foo value
also what is this error?
you have to save the q.bone_orientation_trs() value in a variable first and then call that varaible with .r.z
yeah but why? why the need for a redundant temporary variable
mojank?
should stop asking at this point 💀
The closest to what your looking for would probably be a mix of 2 queries
query.state_time
And
query.is_alive
Then you'd want to divide the value by 0.05 since state_time is in seconds
Well the first tick is within the first 0.05 seconds
So more like:
Query.is_alive && Query.state_time <= 0.05
Hope this helps
alright thanks
uhm ive tried this and it doesnt seem to work. i have it in a render controller. the entity always uses that dead geometry
You've used the incorrect query
I said to use this
Query.state_time is used as a query to return the amount of time a queried entity has been in its current state
So what I said would check if the entity is alive and then afterwards how long it has been for
On top of that, this looks for after the entity's first tick
hmm i thought is_alive was a boolean without side effect. Are you implying that calling is_alive would alter the subsequent call of state_time? itherwise i dont see how my thing above would not give some results at least
yeah thats what i wanted to do. hide on first tick
Oh, nvm, then
alternatively is there a way to get the entity movement speed vector? i was looking at minecraft:query_movement_direction and the docs dont even mention the data type
I'm pretty sure that ground_speed does that
It is
But you never asked the game to return it
Its kind of like trying to get if the entity is using an item without asking
the is alive? i didnt care for the entity to be alive or not, at least while testing
i dont understand how this works then. In my expresion above i was using state time to query the entity (supposedly) seconds its been alive for, time since it spawned
State time doesn't return how long the entity has been alive for
It returns how long it has been in any state
so my entity just has 1 state so that should be equivalent
So what I said you have to do is query the is alive state, and then test hiw long it's been there for
Is molang does true = 1 and false = 0 still
for the molang in block permutations, is it possivle to look for 2 individual values, like q.block_state(cmd:balls) = 2 || 3
Question:
Is there a way to allow for math.random_integer to be affected by slowing down an animation?
I'm trying to make an animation of several cubes at random rotations, for the entire duration of the animation, but math.random_integer is quicker than I would like it to be, so can I slow it down?
I've tried to use query.anim_time + query.delta_time / 10 and other math-related calculations, but to no avail
how do you check if the block above an entity is solid?
or at least it it's not air
you can get blocks relative to an entity's location with query.relative_block_has_any_tag, however, its tags only.
air does not have a tag.
Hi, can I check to see if the armor has a trim using molang?
there's no query relating to trims
Try variable.has_trim within the attachable @dawn vapor
Thanks! I'll try it
Is there an editor with syntax highlight for molang?
is it possible to get trim id via molang?
thank you
im trying to sync an entities bone roation and position to another entity is that possible?
query.graphics_mode_is_any does it work in behavior?
can we somehow get the camera position?
rotation_to_camera gives you a direction (normalized vector) while distance_from_camera gives you distance (magnitude of the vector). Combine the 2 and you'll have camera position, relative to the entity origin
did u solve this? Im getting the same error
Unfortunately not
anyone can help me why the second animation isnt canceling the first animation?
{
"format_version": "1.8.0",
"animations": {
"animation.ch.orkling.move_body": {
"loop": true,
"bones": {
"body": {
"rotation": ["math.sin(q.anim_time * 200) * 20", "math.cos(q.anim_time * 200) * 20", 0]
}
}
},
"animation.ch.orkling.physics": {
"loop": true,
"bones": {
"body": {
"rotation": ["-this", "-this", 0]
},
"leftChichi": {
"rotation": [0, 0, 0]
},
"rightChichi": {
"rotation": [0, 0, 0]
}
}
}
}
}```
why -this isnt working?
How are you playing the animation
And with what query specifically
from client entity with no conditions, Im just testing
I want to set a this value to a variable and use it in another animation, Idk if thats possible, but first I need to know if this works properly
Did it give you a content logs error
nope
How are you playing the other one?
same, both with no conditions from client entity
the animation are working when I change its values, so the problem is this argument :/
its weird
Could I see the entity file?
does anyone know why a texture pack would crash just pc players?
How to make a particle seeable through walls?
You probably need a custom material with no depth test
math.min(v.controls==1?1:0,math.sin(q.life_time)*300)
this play the scaling transition only when the animation started, sense v.controls==1?1:0 is always the min after q.life_time pass 1, how do i make it so the right side always reset after v.controls==1 condition is true, i think i should use a variable instead of q.life_time but how do i make it do the behavior i wanted
I believe custom materials don't work on particles
They do, but only some properties. None of the ones needed for rendering through blocks are available sadly
Has anyone ever accessed or modified variable.trim_path on armor render controllers ? I want to use a different path for a custom render controller I'm using for helmets specifically.
Anyone know why ?? doesn't allow direct queries on the left hand side? I already solved it by storing the query in a variable. I'm just intrigued why.
How would you use it on a query? It's meant to handle uninitialised variables and there is no such thing as uninitialised queries
Using it in regards to it may or may not have an actor.
And, q.property can also be undefined if said actor does not have that property.
q.has_property
I am aware, but why must I use that when ?? should work.
That still doesn't solve if it has an actor or not.
I don't think it should tbh. It's not truly a null coalescing operator like you may be used to in js, it's only meant to be used for variables. There is no null in molang, entity context specific queries that run outside of entity context either error or return 0
I took
Null coalescing operator, for handling missing variables or stale actor references
Stale actor as having no actors as well? That's not the case then?
There is probably some query you can use that returns a predictable value in the entity context vs outside and doesn't error. E.g. q.is_alive
Yes that was the solution I used.
That might be referring to entity references like q.self (deprecated btw) or c.owning_entity
I still find it hilariously painful that the examples in the HTML docs still use get_nearby_entities which is removed.
Also q.get_relative_block_state which never existed afaik
is this right for the player sleeping animation?
animation controller:
"sleeping": "(query.is_sleeping && query.is_alive) || query.any_tag('knocked')"
script:
player.addTag('knocked')
Queru.any_tag is for item ajd block tags sadly. You'd be better off using a scoreboard, as query.scoreboard can be used to query for that
There is an entity event filter for checking entity tags tho
the scoreboard query can only be used behavior side
resource pack side too, but only if the scoreboard is displayed
Used it some time ago, and when i removed it from the display i got confused why it stopped working
Gentlemen, I've cracked the case. The entities which I was using in my add-on had a lot going on in their pre_animation scripts. They would define several temp variables, and then those temps would be referenced in the animations of the entity. But as it turns out, a recent update seems to have changed how this is handled. There is a lot of unpredictable temp leakage now with this kind of setup. Switching it to use regular variables stopped the entanglement.
Yeah, using temps in this way is risky. I only use them within the same expression, or when ik for a fact that 2 expressions run one after another (e.g. x, y and z in particle position field)
So it seems. It's such a shame though, since I specifically used temps here to help the game save on some RAM.
The entity in my latest add-on passes a lot of data to the animations. So all that is just extra data that has to be stored on every instance of the entity.
@small citrus
¿how can i make that the lunge direction reaches towards directily to the player's location?
I've been scanning back on my old files and I found this. I know that it changes the texture based on my property however I forgot what query.property does and I cannot find any documentation on it, does somebody know what it does?
I mean with math you simply can do that by getting the displacement of both location then getting the magnitude from the entity to the player then you have a vector that points from the entity to the player
query.property reads from an entity's properties. These are defined in the entity's definition in the behavior pack.
It's the "properties" object in the description. e.g.
"description": {
"identifier": "foo:bar",
"properties": {
"property:ore_type": {
"type": "int",
"range": [0, 16],
"default": 0,
"client_sync": true
}
}
}
There's some documentation here: https://wiki.bedrock.dev/entities/entity-properties
Oh it's on the entity not on molang, Thanks
Are molang variables scoped? I'm actually implementing MoLang for a different reason, and there's nothing about that on the wiki (i'm going towards 1:1 copy of the bedrock one)
Like here it creates a loop, if I assign a variable in a loop, will it be accessible afterwards
well i'll assume it's not scoped
In theory they are scoped. In the loop expression, t.next only exists inside of the scope defined by loop.
I would test that very question you have. If you can access t.next, then the scope mechanic is not working.
Can I ask where is mo lang used for in add-ons?
Render controllers, animations, animation controllers, geometries, entities, attachables, particles off the top of my head
can you really not return a value from a brace scope? seems like it just returns the root expression regardless of the depth. e,g,
v.foo = { return 1; };
can you convert numeric values into string with molang?
I want to use sound variants for my entity, but it's only accepting strings and my entity property is using integers
what molang is used when an attachable is used to attack for example like sword? in the attachables animation controllers file?
variable.attack_time && context.owning_entity if I'm not mistaken
variable.attack_time doesn't work somehow
is it possible to make an animation play only for first person like without using any animation controllers like the animation itself only play for first person?
is there a list of which molang functions are availabe in each context?
for example, I'd like to know which functions are available when using molang in a feature_rule
math.clamp(-variable.tcos0,-variable.tcos0,0)
Could anyone tell me why the bone is still rotating in the positive direction? Even though the max rotation should be 0.
math.clamp(-variable.tcos0,-math.abs(variable.tcos0),0)
math wasn't mathing for me
Is there any way I can make my mobs run different animations when in different water depths, even combining molangs.
loop(10
Can this be filled with variables?
is there a molang to detect when an entity charges an attack using the charge shoot trigger?
I wanna change armor model depending on player's hand type. Is it possible to do so by using q.bone_aabb in armor attachable file?
If you mean whether they have a 3 pixel wide or 4 pixel wide arm then use this
https://wiki.bedrock.dev/documentation/queries#variable-short-arm-offset-right
Oh damn, I didn't know that. Thank you!
No problem, happy to help!
Wait.. I don't think it'll suit my needs
Darn
I want to change armor for every player
Like... Alex type players get different armor model
And steve type players have the standard one
Here's what it looks like. I made it on java and now I wanna port it to bedrock
Sorry, I have been offline the whole day
It doesn't say it only works in first person, to be specific
It means that you need to have been in first person at least one time when entering the world to make it function
But does it mean it won't work on other players?
No because it applies to every player at the same time
It makes things even worse
No you aren't understanding, im pretty sure
maybe
You cant use variables from one specific entity to another specific entity of the same type
Like if you use query.is_sprinting for example
A sprinting player cannot make the sprinting animation play on a different non sprinting player
Animations and render controllers will apply all entities with the same identifier but will only play if the entity is doing the thing the variable/query is action it is being tested for
hello i wanna ask how animation_update_time works cause i want an animation to never continue player if it doent have a taget anymore and if the animation time is at 0.5 something
how do i substring
Is there a way to query what the local client player's tags are? I want to make an entity render differently if the player viewing it has a specific tag. Maybe I could for_each over player entities and then check q.is_local_player somehow.... but I don't know how to do this.
Also, I know there's "entity.target->" to change the query context to the entity's target, but are there other members?
Microsoft's molang documentation just bloody sucks.
Did you try using q.tag already?
Yeah, it refers to the current entity rather than the local player. Doesn't work for my purposes.
Do you have any access to scripting. I guess it's way more convenient to use scripting
Oh you are modifying render controllers so no access to scripting?
I said I was working on a render controller, or at least I thought I did...
But yeah, render controller.
https://feedback.minecraft.net/hc/en-us/community/posts/38175267150733-Please-add-a-client-has-tag-moLang-query-to-check-client-player-s-tags
It's a hail mary, but hopefully I can get Mojang's attention.
I am currently working on a render controller that needs to change textures based on the tags the local player has, but I don't seem to have a way of doing so. a "q.client_has_tag('tag')" query wou...
You can query scoreboard (that's set to be displayed in some way)instead of tags.
The thing with tags is that they are entirely server side, the client has no idea whether they exist or not. You'd need to have some kind of mechanism for registering which tags should be synced to the client
The official recommended way to sync data from server to client is actor properties
I got the error message "query.scoreboard can only be used in behavior packs"
So, can't be used in render controllers.
Ahh riight, they removed this capability some time ago
Next best thing, provided you can't use properties, would be playing animations that set molang variable to some value
can we use molang to provide particle textures?
can we get item name via molang?
Impossible to get the name of an anvil renamed item
very sad 😦
Indeed 😢
How to detect slim skin
minecraft:query_is_riding_any_entity_of_type
Can someone send an example of how this works?
The explanation they gave wasn't clear enough for me...
Check the vanilla packs!
"variable.riding_y_offset_on_vehicle_where_other_entites_can_stand = query.is_riding_any_entity_of_type('minecraft:minecart', 'minecraft:boat', 'minecraft:chest_boat') ? -3.0 : 0.0;",
what is that variable name
Mojang moment.
oh it's actually used...
Yep, in vanilla.
Kinda
You can provide a texture and manipulate the uv to display different portions of it
yeah, that's what i ended up doing
is there a molang that checks what specific effect an entity has?
how to make player.entity.json compatible with other packs like JavaAnims 1.7
There is any way to query if the player has a tag?
No :/
do query scoreboard works with animations?
ty
query.scoreboard doesn't work in the resource pack and can only be used in the behaviour pack
So it can only be used with the playanimation command
Only specific effects have their own query, and there is sadly no query to get any effect on a player
Hey guys, quick question — what exactly does variable.trim_path return? I'm guessing it's a string like "textures/trims/wild". Is that correct?
its okay i have other methods
[Molang][error]-minecraft:player.0.c5045992-eba4-4c7e-ad4a-469df35178d5.tutorial_skin_1 | entity/player.entity.json | query.is_item_name_any('slot.weapon.mainhand','tst:sniper')&&variable.is_first_person&&v.attack_time > 0.0&&!query.is_sneaking | Error: query.is_item_name_any called without a specified entity.
How do I call q.is_item_name_any with a specific entity?
And if impossible, what is the alternative
I think the problem is you just did it wrong
You wrote the format as:
query.is_item_name_any('slot.weapon.mainhand', 'tst:sniper')
The actual format is:
query.is_item_name_any('slot.weapon.mainhand', 0, 'tst:sniper')
Thanks for trying to help, but that wasn’t actually the case, it turns out that this error happens when in ui or paperdoll, so !v.is_paperdoll && !q.is_in_ui ? code, just solves the problem
Well that's good to hear
I didnt have very much faith in what I said either way, so glad you found the solution
is there a query for blocks of a specific type in a specific direction
Isn't there also query.is_local_player?
not what i am looking for
Nvm then
can we conditionally change render controllers?
Yes (unless I misunderstood the question again, lol) it works the same way as scripts -> animate
I wonder if we'll ever see multi line molang
Wdym?
Idk tbh
I just remember that some of the json parsers used by Mojang while parsing addons do support multiline strings...
Query for detecting if the entity has a certain name?
q.is_name_any("name")
needs to be single quotation marks
oh yeah
q.is_name_any('name')
I make this mistake occasionally
we relay on tools to correct us a lot, lol
ty and ty minato
can we query rider from ride
i want to see if rider is in first person perspective from the ride
You can probably estimate this by checking camera position and direction and seeing if it's close enough from ride
my entity is 10 block tall 😅
Doesn't matter, you can get camera position and compute its distance from a point 10 blocks above the entity, or wherever player head is supposed to be
i think that leave a large area for errors
Never know until you try. And to clarify once again, I'm not suggesting that you simply check distance_from_camera query, because it measures distance from the entity origin, which will be 10 blocks below camera as you said. I'm saying that you can instead measure the distance to camera from a different point 10 blocks above the entity where the player head is supposed to be, by using direction_to_camera, distance_from_camera and some math. Whether it will be prone to errors or not depends on how riding entities works and how their movement interpolation affects molang camera queries, but I'd say unless your entity is moving at unreasonably high speeds, you'll have at most an error of 1 block, which imo is plenty of precision for this kind of thing
unless your entity is moving at unreasonably high speeds
uhhh... it does lol
i solved the problem with a simpler approach
thanks for your time tho
[Molang][error]-... animation_controllers | controller.animation.xxxx.yyyy | states | default | transitions | player_checks | v.player_check_time < q.life_time | Error: unhandled request for unknown variable 'variable.player_check_time'
how do i add a cooldown to an ac
q.state_time
why is this not working as expected in game
0.4 + (math.clamp(3 - query.item_in_use_duration, 0, 3)/5)
query.item_in_use_duration increase while the item is in use
so math.clamp(3 - query.item_in_use_duration, 0, 3) should make it decrease from 3 to 0
dividing by 5 make it from 0.6 to 0
+0.4 make it 1 to 0.4
but all i get in game is const value
hi there, can someone help me to identify where these errors came from? [Molang][error]-monster | Error:unknown token: monster [Molang][error]-monster | unrecognized token: monster
I tried to serach my entire project, but couldnt find what is generating this error at all
monster isn't in your project anywhere?
no, I have no molang refering to "monster" at all
Is there a query for detecting shooting? That is, snow golem shooting?
Ah, seems to be q.facing_target_to_range_attack
Is there a query that gets the rotation of a bone?
I've heard of bone_orientation_trs but also heard that it doesn't work for custom bones and wanted to know if it works on a custom entity
how can I replicate this function on molang?
2 % 3 == 0
% operator exists on molang?
Math.mod
ah, thank you!
math.mod is not one to one with modulo operator tho, math.mod returns negative results for negative numbers while % is always positive
Necroing, yet there's a workaround to Math.mod returning the remainder: ((a % b) + b) % b—or equivalently, Math.mod(Math.mod(a, b) + b, b)
A new sorcerer's channel?
Is it possible to read structs with brackets or somehow access multiple variables dynamically in a loop? 🤔 Similar to what template literals do in JavaScript
Like loop(10, {t.value = v.values[t.i];}) or loop(10, {t.value = v.value_${t.i};})
No. Inline the loop or make a giant if-else statement to imitate arrays and access different variables based on some index value
how do you query when a mob is range attacking?
#old-entities message
might be useful
it works perfectly. tysm!
i am using "anim_time_update":"v.animation_time"
and
/playanimation @e [type=myname:test22] animation.test22.test a 1 "v.animation_time=0.5;"
to set the animation to a specific time, but running the command sometimes do nothing after i use it multiple times
How to detect if the player is looking down according to the camera?
Wdym according to the camera
You can get the head rotation of the player using target rotation to get the angle of the player's head which is the looking direction
hm, okay
could anyone suggest a good way of debugging molang? I would love to have a way to inspect variables in real time
is this not how you check for entity properties?
I’m literally working on the same thing right now ahah
dude it's like not working for some reason, i setup the scripts to tell me the property values. Everything is updating but the animations
I can’t even get it to stop erroring “variable.x is being used by but no definition is found by “entity””
Wow gorgeous!!
Hmm obviously something to do with the transition of one of your airgaurd states but I couldn’t tell u why, I’m definitely no pro.
Are you properly querying to make sure the anim times are coming to and end before switching your states?
i believe so i mean the property query is updating
Search for "molang grapher"
From Blockbench dev
I think the latest Blockbench update have that too?
hmm thats useful for maths but not for some queries that returns values
Im interested in a way to debug molang values
Yeah it's not really possible.
Well, thats their dev builds lol.
I'm trying to use molang variables on an entity to execute some server stuff by using bp/animation_controllers, for some reason I get unknown variable error, could anyone help shed light on this?
Quick question
Is the below molang expression correct to play an anim on a attachable?
c.item_slot->q.remaining_durability < c.item_slot->q.max_durability
I'm not getting any errors which is the weird part but nothing is happening.
context.item_slot is a string, AFAICT. You should be able to simply query those two without needing an arrow function. @vital tartan
hi
Anyone knows how exactly does blockbench accept molang instructions scripts for particles? i have been trying to anymate fire breath but haven’t been sucessfull trying to shape the amount and direction of the fire
I dont understand the question, blockbench display the particle just how it works on snowstorm or ingame. If you are using custom variables in the particle that its values are defined through scripting api, it will not work on blockbench/snowstorm because the values are not defined.
before really asking the problem, you probably should attach ur code / screenshot so people can understand ur problem better
Just use snowstorm?
Does anyone know how to do that?
You haven't asked an actual question
And no cross posting
Sorry
It's fine
My question is how to skip the acceptance screen and go straight to the download of the resource packs
Since there is not much documentation about that
I've heard it's only possible in featured servers
I’ve also checked that but you have to see some way since the new server doesn’t have that
I work with PocketMine custom server
There's a misunderstanding here, let me clear it up
"All servers that use this feature are featured servers", is different to "All servers that are featured servers use this feature"
Only featured servers can use it but not all featured servers may choose to use it
Okey
Do we have any access to date/time in textures such that you could create seasonal packs, for example how we have chests turn to presents on Christmas?
I already know how to do it
Is there a way to detect player digging / mining with a query? 🤔
huh
ParticleEffect::_extractComponents | minecraft:particle_appearance_tinting | variable.gray = Math.random(0.5, 0.9); variable.chance = Math.random(0.0, 0.9); variable.chance > 0.2 ? variable.gray : 0.1725 | Error: complex expressions (contains either '=' or ';') must end with a ';'
Any idea what it wants?
this is directly from snowstorm where it seems to work 🤷♂️ :
"minecraft:particle_appearance_tinting": {
"color": ["variable.gray = Math.random(0.5, 0.9); variable.chance = Math.random(0.0, 0.9); variable.chance > 0.2 ? variable.gray : 0.1725", "variable.chance > 0.2 ? variable.gray : 0.7294", "variable.chance > 0.2 ? variable.gray : 0.6588", 1]
}
oh never mind, it seems it wanted ; also at the end where snowstorm did not ... the error message is confusing 🙂
q.is_digging ?
am assuming that works for players
if not, then accessing a property set in script I guess
thats for the warden
bleh. custom property from behaviour side then I guess.
which will be bad for compatibility because you need to edit player.json
you can detect if the player is swinging their arm with v.attack_time
not the best solution
lol, oh that's right, the entity in question is the PLAYER
I have been trying to pass this variable to the player using playAnimation, it works but there is a content log error saying unknown variable v.body_tilt. I know its because its not inititalised. But im not sure how to initialise it. I am trying to avoid using player.json. Ping me if anyone knows how i can initialse this variable
rider.playAnimation("animation.player.dragon.riding.base", { nextState: "animation.player.none", stopExpression: "v.body_tilt = math.lerp(v.body_tilt, v.attack_time == 0 ? math.clamp(-q.target_y_rotation * 0.5, -30, 30), 0.2); return 0;", controller: "controller.animation.player.ride"})
You can only use variables that are used within the animation that you are playing
Yes im indeed using those variables on the bones of the player
It works, but it still gives me content log error
Wherever you call it, if it's possible for it not to have been initialized, use ?? https://bedrock.dev/docs/stable/Molang#%3F%3F Null Coalescing Operator
(v.body_tilt??0) will return 0 if it has not been defined yet.
can we use molang to set the numebr of iterations a feature_rule places? like do 'x - 1' iterations for 'x' numbers of 'y specific block' found in this chunk?
i can post in world generation if no one here knows. i just have posted there a lot latelyXD
#1276385844407566426 message
This needs pinned
Maybe even under https://discord.com/channels/523663022053392405/1067869022273667152
Scatter iterations accept molang, yes
I have a question, can you store a math.random as a permanent variable?
math.random when used as a variable in an entity render controller to select a texture and/or geometry causes the value stored to constantly update and thus the textures are constantly changing every tick. What's a way to do this assign a randomly selected value to an entity one time and stick that way?
anyone know how to trigger animation when the entity get hurt?
recently using query.health, but I don't know how to use it🗿 whenever health decrease the animation scale it's not quite right, when health on 0.5 it's the right animation
Is there a thing like "query.has_tag"?
No, at least I never saw it before
Yes there is
But you guys should really just go look
Because it's a query for the tags of the item the entity is holding has
I’m 3k comment
did anyone manage to make a player face the body direction of a mount? kind of like boats
Does anyone know what query.bone_rotation does and how it's used? I couldn't find much documentation on it.
It just takes the rotation from the bone's rotation from the geometry, like its original rotation, and not from the animation
-# anyone can explain further if i didn't explain it right
I think you can use dis in some way, probably animation
query.ride_body_y_rotation
or
query.ride_body_x_rotation