#Mannequin, teleport and execute

1 messages · Page 1 of 1 (latest)

forest oasis
#

Hello, i'm trying to learn commands right now, my objective is to summon a mannequin, and if the player clicks on him the game sends a message in the chat saying something, the player clicks on that and he get teleported to a especific location

forest oasis
#

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

forest oasis
drifting panther
#

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.

tranquil acornBOT
elfin zinc
#

execute as @s very useful

drifting panther
#

@haughty oracle @elfin zinc Yeah because if you just do trigger, will it not set the trigger to 1 for everyone?

haughty oracle
elfin zinc
#

yes i know

#

:)

forest oasis
#

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

elfin zinc
#

pretty much

forest oasis
#

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

forest oasis
#

I know it's pretty basic stuff

#

Just wanted to tell you guys I'm very new in this things

elfin zinc
#

glad you could make progress

forest oasis
#

Sorry if I sound very anoying

#

I really want to understand

drifting panther
#

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.

forest oasis
#

i mean

#

it's the best way, right?

drifting panther
#

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.

elfin zinc
#

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

forest oasis
#

any solution?

elfin zinc
#

you're supposed to change the X Y Z

#

and actually create the scoreboard in load

forest oasis
#

a

#

yeah yeah

forest oasis
#

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

forest oasis
#

I DID IT

#

i took me so long

#

sorry haha

drifting panther
#

my bad. it's supposed to be if score @s

forest oasis
#

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

drifting panther
#

that works too. if score @s just turns it into a boolean (true/false) which is technically easier to process

elfin zinc
#

and optimized

forest oasis
forest oasis
#

Ok, and what about dialogs, are they easy to use?

elfin zinc
#

they're pretty easy to understand

#

if you know what you're doing with it

forest oasis
#

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

drifting panther
#

I fixed it now, so you can copy/paste.