#how to call a (block)event in a (block)event

1 messages · Page 1 of 1 (latest)

tame steeple
#

is there an event response or a command that lets me trigger a blockevent?
im pretty sure its possible with /event but it only has an entity option.
couldnt find an answer so im just gonna ask

crisp sinew
#

No

#

you can't trigger block event with commands yet

spiral violet
#

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

fiery acorn
#

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.

tame steeple
#

i cant get it to work how i want it to, im just gonna go with an entity

spiral violet
spiral violet
tame steeple
# spiral violet 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

crisp sinew
#

Natural generated structures is not very kind to rotated structures

#

I knew that from my personal experience with rotated custom blocks

tame steeple
crisp sinew
#

Wouldn't structure blocks be good for that then?

#

actually, nevermind

tame steeple
#

as far as i know those dont randomize structures in bedrock

#

they can in java im pretty sure

fiery acorn
tame steeple
fiery acorn
#

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.

spiral violet
spiral violet
spiral violet
spiral violet
#

but all things aside, how would you even use an entity in that scenario?

spiral violet
tame steeple
tame steeple
tame steeple
fiery acorn
#

trigger just works like calling an event from an event. It’s an event key.

"trigger": {
          "event": "test:my_event",
          "target": "self"
        }
tame steeple
tame steeple
spiral violet
#
            "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

fiery acorn
tame steeple
fiery acorn
#

Yeah it’s kinda messy right now… I think I’ll have a go on rewriting this page a little bit

tame steeple
spiral violet
#

ya those things are weird

#

I found a lot out through bridge and other addons, they don't have the best documentary

fiery acorn
#

I have personally not used trigger on blocks iirc, but it works right?

spiral violet
#

ya

spiral violet
#

we don't talk about borrowing

fiery acorn
#

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.

tame steeple
spiral violet
#

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

fiery acorn
#

block target works? last time I tried it was broken

spiral violet
#

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

fiery acorn
#

ah lovely

fiery acorn
#

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

spiral violet
#

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

fiery acorn
#

Yeah that is true, plus the pain to create the commands for all combinations, a Phyton script will do so though

spiral violet
#

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

fiery acorn
#

oh well, what we can do

tame steeple
#

why do furnices use the blocktrait facing_direction while they clearly arent able to be placed up or down?

spiral violet
#

we don't know, vanilla blocks aren't data driven yet

tame steeple
#

`{
"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

spiral violet
#

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

tame steeple
#

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

spiral violet
#

hm

tame steeple
#

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

spiral violet
#

so the block doesn't rotate automatically if on_player_placing is present?

tame steeple
#

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.

spiral violet
#

I see, lemme cook

fiery acorn
#

Use on player placing to change the property to one where your queued ticking event is not present

spiral violet
#

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

fiery acorn
spiral violet
fiery acorn
#

If that’s the case there is a problem in the order of events being done here

spiral violet
#

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

fiery acorn
#

May I see what the mission here is?

spiral violet
fiery acorn
#

Well, what I said should be the solution unless there is something else that I am not considering

spiral violet
#

basically you place the block but nothing happens, structure loads it, it runs some events

tame steeple
fiery acorn
fiery acorn
# tame steeple could you elaborate i dont get it

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_placingminecraft:on_placed, this last one detects if a command for example, is what placed the block.

spiral violet
# fiery acorn Well, what I said should be the solution unless there is something else that I a...

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

fiery acorn
#

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

tame steeple
#

changing a block property retriggers the block, so on_placed and queued_ticking restart

spiral violet
#

no, queued_ticking starts tick (even when looping is false) once a property updated

fiery acorn
#

hm, I see

#

May I have the block and the structure?

#

I’ll try to solve the issue

spiral violet
#

so I thought, you could use a scoreboard because it's individual from the block

#

or even a temp variable

fiery acorn
#

I feel like it should be possible within the block and just the block

spiral violet
#

yes

fiery acorn
#

just the same block im guessing

spiral violet
#

gl, it's really tricky

fiery acorn
#

Thank you, I’m interested on this so is going to be good to have a template

tame steeple
#

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

fiery acorn
#

What is on the structure?

tame steeple
#

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

fiery acorn
#

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?

tame steeple
fiery acorn
#

So this block should generate 4 different structures, then stop

#

A generates B
B generates C
C generates D

tame steeple
#

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

fiery acorn
#

huh, what randomly chooses the endpoint?

#

The block or the function

tame steeple
#

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

fiery acorn
#

I’m very much confused.

tame steeple
#

whats the part what you dont get, to me its obvious but im making it

fiery acorn
spiral violet
#

quick check, did y'all figure something out yet?

fiery acorn
#

Trying to understand the logic before starting anything

spiral violet
#

ima check if on_place or on_player_placing runs first

tame steeple
#

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

tame steeple
fiery acorn
#

Made something, time to test.

spiral violet
#

am I just stupid or why does my on_player_placing not run /say💀
I feel like I'm loosing brainmass

tame steeple
#

bedrock*

spiral violet
#

must be lol

#

starting to think on_player_placing can't run commands
maan

tame steeple
#

are you doing "run_command" in an event trigger?

spiral violet
#

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

tame steeple
#

yep

#

i have no idea why it isnt working

fiery acorn
#

yeah… on Player placing seems to be off

#

For me it is not running the event

tame steeple
#

im not getting it to say hi either

tame steeple
fiery acorn
#

I think I got it

spiral violet
#

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

spiral violet
#

(or evil intention)

fiery acorn
#

runs the events upon being placed by a command but not by player

tame steeple
#

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

spiral violet
# fiery acorn

now save the block in a structure, and load the structure, will the block run the commands

fiery acorn
#

what does it has to do upon loading it?

spiral violet
#

yes

fiery acorn
#

Yes what?

spiral violet
#

misread

fiery acorn
#

No worries

tame steeple
fiery acorn
#

So it has to say 1 2 3 4

tame steeple
#

yes

#

place the block save it in a structure, load the structure, and only then can it say 1 2 3 4

fiery acorn
#

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

tame steeple
fiery acorn
#

no, but nevermind that

tame steeple
#

alright, what are you using anyway?

fiery acorn
#

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..

tame steeple
#

famous last words

fiery acorn
#

Don’t worry, you can trust on me

#

Making the video now…

tame steeple
#

not for a lack of trust, its just in my experience that small issues can be a huge pain

fiery acorn
#

nah I’m just too focused to the music lol sorry

#

I’m definitely not singing

#

haha

tame steeple
#

lmao

spiral violet
#

think I found an alternative just in case

#

using a score value

fiery acorn
spiral violet
#

nice

fiery acorn
#

the commands are run upon loading even when the saved block was the one placed by the player

#

ill send the file

tame steeple
fiery acorn
#

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

spiral violet
#

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;

fiery acorn
#

Will that work with many blocks at once?

spiral violet
#

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

tame steeple
spiral violet
#

it only runs the commands if there's no structure save block under it

tame steeple
fiery acorn
#

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

tame steeple
fiery acorn
#

however I am very much confused by something

tame steeple
#

you confused by your own code 🤣

fiery acorn
#

run_command just doesn't works if you use on_player_placing

fiery acorn
tame steeple
fiery acorn
#

What I did, find a workaround 😌

#

Well I think my work here is done

tame steeple
# fiery acorn

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

tame steeple
#

huge thanks

#

to both of you

fiery acorn
tame steeple
#

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 🤔

fiery acorn
fiery acorn
#

This question can be closed now that it was answered

tame steeple
fiery acorn
#

haha

tame steeple
fiery acorn
#

If I experience the issue, ill report it

tame steeple
fiery acorn
#

Press the post and select close

#

It is a good practice to do this on every post that has been answered, that way our channels are more organized for everyone.

#

Nothing is deleted, as the post can be found later if needed.

tame steeple
#

except that i cant search for anything to low on the list or it resets the search

#

but thats a discord issue im pretty sure

#

so anyway