#how to call a (block)event in a (block)event
1 messages · Page 1 of 1 (latest)
you can only really trigger events through a work around, like using block tags to complete a condition, or work with /setblock to pre set a property, which will trigger an event
but both have downsides
The direct way of calling a block event with commands is using /setblock or /fill like mentioned above. Personally, I don't see downsides on this.
i cant get it to work how i want it to, im just gonna go with an entity
you can't keep already existing data on the block, for example the rotation or something even more complex, unless you manually make all the combinations of properties as a function file
what's the exact situation
custom generating structures
but its annoying to have to edit the structures nbt the whole time when adding a new structure
so i wanted to make a block that does it automatically for me by adding a property when a player places a block, but removes it right after. i need two events for it, one that removes the property and one that triggers the generation.
but i cant figure out how to trigger both events with the right conditions, other then putting the condition in the first and redirecting it to the latter
but im on the verge of abandoning the block completely, as i have noticed that my block rotation doesnt automatically rotate in a structure, even though im using minecraft:cardinal_direction, for that im looking up the reason right now. if there is now way to make it automatically rotate, i will just use command blocks and entities
Natural generated structures is not very kind to rotated structures
I knew that from my personal experience with rotated custom blocks
it isnt naturally generated, its supposed to be generated live and random repeatedly
im just trying to avoid having to build 8 structures to account for mirroring, and direction
as far as i know those dont randomize structures in bedrock
they can in java im pretty sure
If you replace it for the same data, it is kept
i noticed also that when i used the event responce set_property or whatever it does reset the block
i had a qeued_ticking component which would restart as if the block had been replaced with loop being false ofcourse
Yeah, but for example. Let’s say your block has 4 rotations and 2 colors.
If you want to keep the rotation but change the color from blue to red, what you’ll do is use /setblock or /fill to replace your block. Keep the rotation values the same, so replace rotation 2 for rotation 2, but change the color property from blue to red. That way your block won’t reset in any way.
there's also the possibility to save 4 rotated variants of the same structure and use a randomize feature to choose one of them randomly
ya that's what I meant, in alot of cases it's simple just having 2 properties, but personally I've made lots of blocks who use up to 6 or 7 properties, and with multiple like that, going through every combination of those will become up to impossible. like 6 boolean properties are 64 possibilities together
set_block_property doesn't reset the block, it's probably something else
when creating 4 structure variations, they are very useful as you can rotate the structure when loading it from structure block. that way it's as easy as to load it, replace the needed blocks and export them
but all things aside, how would you even use an entity in that scenario?
reading through this again, are you trying to trigger another event from inside an event, in the same block? because there's a trigger events response to do that.
plus if you want multiple things happen in the same event, but with different conditions, you can use a sequence and inside add conditions
couldnt find it on either the wiki or the microsoft documentation
so if you would show me i would be gratefull
i know sequence its just not right in this situation
an entity can be summened and instantly trigger an event using /summon [entity] [location] [spawnevent]
this way you could also decide what cardinal direction you want to use
credit to creeping crypts for that one
trigger just works like calling an event from an event. It’s an event key.
"trigger": {
"event": "test:my_event",
"target": "self"
}
im trying to avoid making 4 structures for 1 room(or hallway for testing purposes), which i could do if the structure block would also rotate the block itself
using
a furnace in a structure and then setting it when loading to 90_degrees, the furnace will also rotate
a custom block will have the correct position in the structure, just facing the same way it used to
odd, in the dev wiki i saw a hyperlink to "trigger" at the bottom of the list
clicking on it dit nothing and going there manually, the list stops at the 1 to last one
on the microsoft documentation theres no mention at all
"shoot": {
"sequence": [
{
"set_block_property": {
"mashiene:charges_left": "query.block_property('mashiene:charges_left') -1"
}
},
{
"condition": "query.block_property('mashiene:rotation') == 2",
"trigger": {
"event": "shoot_south",
"target": "self"
}
},
{
"condition": "query.block_property('mashiene:rotation') == 3",
"trigger": {
"event": "shoot_north",
"target": "self"
}
},
{
"condition": "query.block_property('mashiene:rotation') == 4",
"trigger": {
"event": "shoot_east",
"target": "self"
}
},
{
"condition": "query.block_property('mashiene:rotation') == 5",
"trigger": {
"event": "shoot_west",
"target": "self"
}
}
]
},
I've used it to sort my events a little better, because have 100+ entries in a sequence is messy
The information about it can be found here, it’s just not only for entities https://wiki.bedrock.dev/entities/entity-events
funnily enough i had already found it that it works the other way around to
run_command isnt in entity doc but it is in block doc
Yeah it’s kinda messy right now… I think I’ll have a go on rewriting this page a little bit
thanks, that will be a huge help...
...if i can figure out why my custom block isnt rotating in structures
ya those things are weird
I found a lot out through bridge and other addons, they don't have the best documentary
I have personally not used trigger on blocks iirc, but it works right?
"borowing code" 🤣
ya
shhh
it's actually "observe and learn"
we don't talk about borrowing
Alright. If I have some free time I’ll write a page about events in general, having all the event keys in one place will be more organized.
im thankfull
bedrock dev is almost all the information there is out there(aside from microsoft documentation, which can be outdated at times), its a big help
one thing that interested me was testing entity behaviors being abled to trigger block events, I just never really took the time to test anything.
the idea is that mob is moving towards a block and upon arrived, triggers an events, but target set to block instead of self
so like a mob rushes to a custom lever and flicks it yk
block target works? last time I tried it was broken
well it probably doesn't work with alot situations, but block target work if the situation allows it, I used that to make an item once that run commands at the coords of the block which was broken
and even use queries to run different commands
ah lovely
Another option to trigger a block event from an entity would be this one here, I would say is the one that will work in most of situations
Triggering entity events from a block is also doable using /event, is fun to do this since you have full control of an entity from the block, since you can even activate component groups so
only really an option for blocks with up 3 properties, the more properties/permutations possible the effort it is to set up those commands
plus lag from running alot of commands
referring to this
Yeah that is true, plus the pain to create the commands for all combinations, a Phyton script will do so though
I just wish they made it so you could use 'keep' in the command to keep the rest of the block states
but it doesn't
oh well, what we can do
why do furnices use the blocktrait facing_direction while they clearly arent able to be placed up or down?
we don't know, vanilla blocks aren't data driven yet
thats not what i found
i made a block to test this:
`{
"format_version": "1.19.80",
"minecraft:block": {
"description": {
"identifier": "prototype:looping_block",
"properties": {
"prototype:looping_property": [false, true]
}
},
"components": {
"minecraft:destructible_by_mining": {
"seconds_to_destroy": 30
},
"minecraft:destructible_by_explosion": false,
"minecraft:friction": 0.4,
"minecraft:flammable": false,
"minecraft:map_color": "#210021",
"minecraft:light_dampening": 15,
"minecraft:light_emission": 4,
"minecraft:unit_cube": {},
"minecraft:material_instances": {
"*": {
"texture": "dungeon_block",
"render_method": "blend"
}
},
"minecraft:queued_ticking": {
"looping": false,
"interval_range": [60, 60],
"on_tick": {
"event": "prototype:looping_event",
"target": "self"
}
}
},
"events": {
"prototype:looping_event": {
"sequence": [
{
"condition": "query.block_property('prototype:looping_property') == true",
"run_command": {
"target":"self",
"command": "say hi"
}
},
{
"condition": "query.block_property('prototype:looping_property') == false",
"set_block_property": {
"prototype:looping_property": true
}
}
]
}
}
}
}`
when placing it with the setblock command to put looping property to true,
it does as expected, after 3 seconds it says "hi"
when its false(default) it does also say hi but after 6 seconds
my conclusion, when using setblockproperty it triggers some event triggers such as queued ticking or on_placed again, which is really annoying
oh ya I think I recall something like that, whenever a property changes the on_place event triggers.
that's interesting, I didn't expect queued_ticking to act similar, but it seems like it
to prevent this happening, try to add a second property, and use it as a negated condition for queued_ticking, and set together with looping_property: true, that way when it's turning looping property true, it doesn't tick again
but doesnt that prevent it from saying hi entirely
because when you do copy the block with for example a structure block, the negating property will again negate the saying hi part
hm
like when trying to prevent an event from triggering if a player places the block, i used on_player_placed, which would set a property, then qeueud ticking would activate an event which would check for that property like in the example, except the "say hi" part is replaced with "trigger"
this way the player place property would dissapear so that it could be used in structure blocks without editing its nbt
so the block doesn't rotate automatically if on_player_placing is present?
i dont understand the question entirely but here goes
the block (not the one above thats an example) starts/continues the generation proccess as soon as it is placed in the structure.
but i dont want that to happen if the player places the block, to make editing structures (which i expect to happen a lot) easier.
I see, lemme cook
Use on player placing to change the property to one where your queued ticking event is not present
thinking if you could a scoreboard as a temp data, as that doesn't update the block. but also should be abled to do everything with the same tick, because if it stays set, it's global
This means that your queued ticking component would be in a permutation and not in the components group
as I understand, once the block has been saved and loaded by structure again, it should run the generation commands again. so for that you'd have to reset that property to allow it. causing the same outcome of triggering the generation commands even when player placing
If that’s the case there is a problem in the order of events being done here
basically the problem is that you need to switch the block from editing mode, to generation mode, but when changing to generation mode automatically, you end up triggering the generation alr
May I see what the mission here is?
if you switch the two sequence parts, you first set the property from false to true, and then ask if it's true (which it now is). so this would both end up lastly 3 seconds, instead of 3 and 6 seconds
this
Well, what I said should be the solution unless there is something else that I am not considering
basically you place the block but nothing happens, structure loads it, it runs some events
could you elaborate i dont get it
Yeah if that’s all the information it’ll should work properly
Make a permutation that is set by default no matter if a player or command places the block, in here your minecraft:queued_ticking will be in charge of generating whatever you want to generate. It should have to options, either true or false, by default being on true.
On your components, make it so minecraft:on_player_placing this property changes to false, that way nothing generates but the block places.
Keep in mind that minecraft:on_player_placing ≠ minecraft:on_placed, this last one detects if a command for example, is what placed the block.
Problem is that you place the block, then the block changes it's property to be ready for structure load, but once you do that, queued_ticking also starts ticking (because there was a property change happened) so now the block is already in generation mode, and runs the generation event, even tho it should wait for being loading by the structure block first.
so what ends up happening is that player placing isn't preventing the generation event
Why would it be activated?
You mean queued ticking being faster than on player placing ?
If that’s the case, some ticks should do it
changing a block property retriggers the block, so on_placed and queued_ticking restart
no, queued_ticking starts tick (even when looping is false) once a property updated
so I thought, you could use a scoreboard because it's individual from the block
or even a temp variable
I feel like it should be possible within the block and just the block
yes
I’ll do it myself but describe me what the structure contains
just the same block im guessing
gl, it's really tricky
Thank you, I’m interested on this so is going to be good to have a template
currently, i could make a simple active property, that is false by default
place it in a the world, then using a structure block export it as .mcstructure
then edit the .mcstructure to edit the active property to set it to be true
but that requeres a lot of work, since im going to edit these structures alot, and not having to edit the nbt file would save a lot of time
What is on the structure?
its for generating a dungeon
so in the testing structures all i have yet is simple hallways, and in the structure the identifier(the block) to place the next hallway
Lemme see if I am understanding. This blocks generates a structure which contains the same block to generate another thing, it’ll have an end at some point though. And you want to prevent the structure to generate if a player places it?
4 testing structures currently, the start point, a hallway, a corner, and an endpoint,
in a function i randomize them and rotate them as i need,
then in that function i generate them
everyone of these hallways have a block, except the endpoint, to activate the function and gives it the identifiers it needs, for rotation, location, and other things that dont yet excist
So this block should generate 4 different structures, then stop
A generates B
B generates C
C generates D
i generate the startpoint
startpoint contains 4 identifier blocks for 4 hallway options(startpoint is shaped like a +) .
each identifier runs a function to chose a random structure - (straight, corner, or endpoint)
then it rotates it to how its supposed to go and places the structure
both the straight and the cornor have 1 identifier block at the end, but i could make a T shape which would have two
it continues to generate until it randomly choses the endpoint
it could theoretically go on forever, which i will ofcourse fix but thats not my priority
the function
scoreboard objectives add random-1294e dummy
scoreboard players random @s random-1294e 1 100
say hi
execute if entity @s[scores={random-1294e=1..33}] run structure load endhall ~10 ~ ~-10 270_degrees
execute if entity @s[scores={random-1294e=34..80}] run structure load hall ~10 ~ ~-10 270_degrees
execute if entity @s[scores={random-1294e=81..100}] run structure load cornerhall ~10 ~ ~-10 270_degrees
scoreboard objectives remove random-1294e
this is roughly the function, under construction
I’m very much confused.
whats the part what you dont get, to me its obvious but im making it
👆
quick check, did y'all figure something out yet?
Trying to understand the logic before starting anything
ima check if on_place or on_player_placing runs first
the block in the structure has a couple properties, but most importantly its cardinal direction
when the structure is loaded, the block triggers a function with its properties and location, so that the function can randomly choose a structure to continue the hallway
33% change to end
20% change to get a corner
47% change to go straight
wouldnt it be whatever you place first in the code?
or is that just other languages
Made something, time to test.
there's probably a hierarchy what triggers first
am I just stupid or why does my on_player_placing not run /say💀
I feel like I'm loosing brainmass
its you,
there are never any glitches in bugrock
bedrock*
are you doing "run_command" in an event trigger?
litterally just doing this,
"minecraft:on_placed": {
"event": "mashiene:on_placed"
},
"minecraft:on_player_placing": {
"event": "mashiene:on_player_placing"
}
},
"events": {
"mashiene:on_player_placing": {
"run_command": {
"command": "say on_player_place"
}
},
"mashiene:on_placed": {
"run_command": {
"command": "say on_place"
}
}
}
on place talks, player placing doesn't.
even tried removing placed in case it overrides player placing, but no, it just didn't say anything then.
they're basically identical
im not getting it to say hi either
but i can get it to change a property???
I think I got it
bruh now I'm consistently make my game crash.
I'm trying to make on place set a property to 2 and player place to set the same property to 1. both only do it if the property is 0 still.
I think it's having a hard time running two events the same time on the same property
now the big question is, if you save it in a structure (the block placed by a player) and then load the structure, does it or does it not say 1 2 3 4
now save the block in a structure, and load the structure, will the block run the commands
what does it has to do upon loading it?
yes
Yes what?
misread
No worries
it is supposed to do the same as if it has been loaded by a command
except you placed it inside the structure
So it has to say 1 2 3 4
yes
place the block save it in a structure, load the structure, and only then can it say 1 2 3 4
I can try doing that
Can you have a command block inside the structure or that will be a problem
Because that will make things easier here
I actually have a better idea nevermind
it depends
if i export the structure, do i have to edit the nbt to get it to work
no, but nevermind that
alright, what are you using anyway?
I’ll get it to do what you want and send a video
Give me a second
Got it
Fixing a small issue, one moment..
famous last words
not for a lack of trust, its just in my experience that small issues can be a huge pain
lmao
nice
the commands are run upon loading even when the saved block was the one placed by the player
ill send the file
nice thats what i need
It's a method that needs of the block to be placed just upside the structure block, if that is done everything will work just fine, and since you are building the structures I suppose this will not be a problem.
oop, format version can be 1.20.10, forgot to change
If that is a problem I could go for other ways, I just think this one will work just fine to you
I'd have a method that would work generally, without needing to place it on a structure block
on_player_placing event: set property to true;
queued_ticking event: if property is true, adds scoreboard objective and and set it to 1, otherwise to 0; execute if score is 0, load function; ececute if score is 1, set score to 0;
Will that work with many blocks at once?
should yes, as it's all in just one tick, if you set the range of queued_ticking to 0
but how likely is it that a player places one block per game tick?
it should be neglectable
could also try switching queued_ticking ticking to on_place but Idk which triggers first
im still trying to figure out how that even works
it only runs the commands if there's no structure save block under it
well i got that, just not the order in which things go
It detects if is placed by player, so it deactivates the block.
If it was placed by a command, it runs the commands.
If there is a structure block on load mode below it, it comes back to the state of places by command.
That way there’s a difference between;
Block placed by command
Block placed by player
Block loaded by structure block
I will add some comments for you, one second
so essentially what you did is make a trigger block, you put somewhere around it
that is a good idea, i think i might make some adjustments to merge it into an idea i had to fix the fact those blocks dont rotate in structures
i would still like the comments very much as i could learn from it
you confused by your own code 🤣
run_command just doesn't works if you use on_player_placing
oh no, is of what I just said
it's bugrock, what are you gonna do 🤷
ah this is way clearer, i understand now.
my error was that i thought both the permutation queued_ticking and the component queued ticking would run at the same time, thus i got confused, at everything
i think so, that was my last question
huge thanks
to both of you
No problem 
I think I’ll open a bug report of this thing
is there a bug report about set_block_property reactivating certain trigger as if the block got replaced? if not might want to make one of that too
or maybe its on purpose to make the permutations part rerun if you edit a property 🤔
same file, grammar error fixed, my bad
I have not experienced this... but we can talk about it better on #1067876948858118185
This question can be closed now that it was answered
didnt even notice xD
haha
i think ive said everything tho
If I experience the issue, ill report it
yes,
so,
how does one close a question?