#Mannequin, teleport and execute
1 messages · Page 1 of 1 (latest)
maybe it's a little messy how i explained it
1- player right-click on mannequin
2- new message on chat
3- player clicks on it
4- player gets teleported
i'm trying to leand how to use execute command, but it's pretty confusing to me
i've been thinking, instead of using a chat message for the player to interact, use a dialog, but i don't have idea how to use that
what you can do is summon an interaction at the mannequin unless there already is one within 0.3 blocks of the mannequin. Set it to 0.6 blocks in width and 2 blocks in height, and give it a tag to identify it. Make sure to kil the interaction if it gets more than 0.3 blocks away from the mannequin, so old ones don't linger. Then use an advancement to detect interacting with the interaction. Then you'll need a trigger to execute the teleport.
If you choose to use tellraw, then you do: tellraw @s {text: "your_text", click_event:{action: "run_command", command: "execute as @s run trigger your_tp_trigger set 1"}}
If you use a dialog, you'll need a separate trigger to show the dialog that right-clicking the mannequin will trigger, and use a multi-action to set the tp trigger value to 1
Lastly, don't forget to reset the trigger for the executing player in your tp function.
If you're not already using it, I highly recommend using VS Code to help you, and use the misode generator to help you with the dialog.
oh yea, /execute as @s
sure
execute as @s very useful
@haughty oracle @elfin zinc Yeah because if you just do trigger, will it not set the trigger to 1 for everyone?
/execute as @s NEVER does ANYTHING
But I can do this just with commands, right? It's not that I don't want to use datapacks, but i'm practicing my command knowledge in a flat world
pretty much
I mean, yesterday went to sleep happy just because I made a command that applies blindness and get teleported to 0 0 to a player that stands on a specific location
Sorry of my English is bad, it's been a while since I exercised it
Also, I was happy because made another command that gives to every player in creative mode a particle effect on its feet
I know it's pretty basic stuff
Just wanted to tell you guys I'm very new in this things
glad you could make progress
So, if I want to do this with the tellraw (for now) what order should i follow?
Sorry if I sound very anoying
I really want to understand
in load.mcfunction:
scoreboard objectives add your_tp_trigger trigger
in tick.mcfunction
scoreboard players enable @s your_tp_trigger
execute at @e[type=mannequin] unless entity @n[type=interaction, tag=chat_interaction, distance=..0.3] run summon interaction ~ ~ ~ {width:0.6, height:2, Tags:["chat_interaction"], interaction:{}}
execute at @e[type=interaction, tag=chat_interaction] unless entity @e[type=mannequin, distance=..0.3] run kill @s
execute as @a if score @s your_tp_trigger matches 1 run tp @s X Y Z
execute as @a if score @s your_tp_trigger matches 1 run scoreboard players reset @s your_tp_trigger
make an advancement file {ex: your_namespace/advancement/chat_interaction) and put this in it:
"criteria" : {
"chat_interaction": {
"trigger": "player_interacted_with_entity",
"conditions": {
"entity": {
"type": "interaction",
"nbt": {
"Tags": ["chat_interaction"]
}
}
},
"rewards": {
"function": "your_namespace:your_trigger_function"
}
}
then create your trigger function (ex: your_namespace:function/your_trigger_function) and put this in it:
advancement revoke @s your_namespace/chat_interaction
tellraw @s {text: "your chat message", click_event:{action: "run command", command: "trigger your_tp_trigger set 1"}}
Note: Anywhere you see "your...", replace it with whatever you actually set; it's just placeholder naming convention for the example.
this could only work in datapack?
i mean
it's the best way, right?
Datapack is defintely the most streamlined way, because of the advancement method. You don't have to keep clearing the interaction field on the interaction entity. It can be done with command blocks, but that's a block entity that has to register all the commands, which adds more tick overhead than making a datapack would.
the mcfunctions can work in a command block since they're just minecraft commands
the advancements can't work without a datapack
neither mob variants
but predicates can
i wrote it in tick.mcfunction but an error is shown
any solution?
ok
i made something
thanks to you guy
i still have some problems tho
i made the npc spawneable, but the interaction doesn't spawn with it
oh wait
my bad. it's supposed to be if score @s
execute as @a[scores={your_tp_trigger=1..}] run tp @s 7 59 18 0.0 0.0
execute as @a[scores={your_tp_trigger=1..}] run scoreboard players reset @s your_tp_trigger
i did it like this
that works too. if score @s just turns it into a boolean (true/false) which is technically easier to process
and optimized
But when I write it in the way you did Vs code tells me it wrong
Ok, and what about dialogs, are they easy to use?
i been cheking on them and the don't seem hard to use
until you make use of triggers and more stuff
what i want to make is the same thing but more complicated
1- player right-click on mannequin
2- dialog pop-up "Where do you want to go?" Option 1: "Spawn"
3- player clicks on "Spawn"
4- player gets teleported
but what i think it's more complicated is
0- Player only has one option on mannequin dialog
1- player gets near x:1000 z:11000 and gets a notification (an advancement pop-up) and it says "You discovered 'Khrona Vel' now you can get teleported there!"
2- player now can right-click on mannequin
3- dialog pop-up "Where do you want to go?" Option 1: Spawn, Option 2: Khrona Vel"
4- player clicks on "Khrona Vel"
5- player gets teleported
i know i have to use trigger, but it's still complicated
Because I accidentally typed "if score entity @s" it needs to just be "if score @s"
I fixed it now, so you can copy/paste.