2

I need help with commands. How do I teleport an armour stand relative to a players position in a datapack?

goober-'s Avatar goober-1/30/23 5:21 pm
2/5/2023 6:15 am
Waradu's Avatar Waradu
I'm not sure what the problem with my code is; it runs in a data pack, activating every tick, and the armour stand teleports away somewhere.
execute as @p[limit=1] run teleport @e[tag=gliderstand] ~ ~1 ~ ~ ~




The armour stand has the tag, work it won't work. If I put it in the chat, it works, but not when it is in a data pack.

In case you are wondering, here is the script to spawn in the armour stand:
summon armor_stand ~ ~1.5 ~ {Invulnerable:1b,NoBasePlate:1b,NoGravity:1b,ShowArms:1b,Tags:{gliderstand:1b},ArmorItems:[{},{},{id:"leather_chestplate",Count:1b,tag:{display:{color:7027459}}},{}],HandItems:[{},{}],Tags:["gliderstand"],DisabledSlots:4130824,Pose:{Body:[91f,0f,0f],Head:[285f,0f,0f],LeftLeg:[0f,0f,205f],RightLeg:[0f,0f,158f],LeftArm:[0f,0f,271f],RightArm:[0f,0f,90f]}}




I want it to teleport one block above the player, like in the attached image.
Posted by goober-'s Avatar
goober-
Level 32 : Artisan Caveman
4

Create an account or sign in to comment.

18

Waradu
02/05/2023 6:15 am
Level 46 : Master uwu
Waradu's Avatar
replace as with at
1
Aceplante
01/31/2023 1:09 am
Level 66 : High Grandmaster Spelunker
Aceplante's Avatar
execute at @p run tp @e[​tag=gliderstand] ~ ~1 ~ would be the most effeicient way
1
01/30/2023 11:07 pm
This reply was removed by the poster or a moderator.
anonpmc3692897
01/31/2023 1:35 am
Level 16 : Journeyman Miner
anonpmc3692897's Avatar
[deleted]
1
axe309
01/31/2023 9:21 am
Level 18 : Journeyman Warrior
axe309's Avatar
what box
1
anonpmc3692897
01/31/2023 9:35 am
Level 16 : Journeyman Miner
anonpmc3692897's Avatar
[deleted]
2
Kirbycope
01/30/2023 10:38 pm
Level 57 : Grandmaster Programmer
Kirbycope's Avatar
Try: execute as @p at @s...
2
Kefaku
01/31/2023 12:36 am
Level 42 : Master Nerd
history
Kefaku's Avatar
True

execute as @p[​limit=1] run teleport @e[​tag=gliderstand] ~ ~1 ~ ~ ~
If you only use as and not at, it is executed as the player, but still at the server position (0 0 0, I think), therefore the armorstand teleports relative to that location.

Also, @p automatically is limited to one player, you don't need the limit=1.

This should work:

execute as @p at @s run teleport @e[​tag=gliderstand] ~ ~1 ~ ~ ~
2
goober-
01/31/2023 3:05 am
Level 32 : Artisan Caveman
goober-'s Avatar
Hey, thanks for helping me! It works great, but I have another question (sorry to annoy you). I have a scoreboard that knows if you are on the ground, and if you are, the value is 1. If not, the value is 0. How would I make it so that it is 1 to give potion effects, but if it's at 0, remove them?
2
Kefaku
01/31/2023 8:22 am
Level 42 : Master Nerd
history
Kefaku's Avatar
Use execute if score combined with your effect command

(if you can't figure it out and need more tips, just ask)
1
goober-
01/31/2023 4:55 pm
Level 32 : Artisan Caveman
goober-'s Avatar
Thanks for replying; I'm not a very advanced coder, but I did manage to figure out what I had to do, but now the paraglider is spawned at 0,0,0 and won't teleport above. I haven't changed anything about the teleporting code. Here is my code.

Clearing (runs every tick) :
execute as @p if score @s onground matches 1 run effect clear @s minecraft:levitation
execute as @p if score @s onground matches 1 run effect clear @s minecraft:slow_falling

Giving (runs when right clicked the item to summon the armour stand.) :
execute as @p if score @s onground matches 0 run effect give @s levitation 3600 243 true
execute as @p if score @s onground matches 0 run effect give @s slow_falling 3600 243 true

Code to teleport armour stand (runs every tick) :
execute as @p at @s run teleport @e[tag=gliderstand] ~ ~0.8 ~ ~ ~

Code to detect item rightclicked (runs every tick) :
execute as @a[scores={rightclick=1..},nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{paraglider:1b}}}] run function glider:rightmouse
2
Kefaku
02/01/2023 9:47 am
Level 42 : Master Nerd
history
Kefaku's Avatar
the effect commands shouldn't affect the armorstand in any way, not sure what went wrong there 🤔
1
Aceplante
01/31/2023 1:08 am
Level 66 : High Grandmaster Spelunker
Aceplante's Avatar
This will always be the nearest player though. It might be better to do:

execute at @p run tp @e[​tag=gliderstand] ~ ~1 ~
2
Kefaku
01/31/2023 1:17 am
Level 42 : Master Nerd
Kefaku's Avatar
But if you leave out the as, you cant copy the rotation like he did with

teleport @e ~ ~1 ~ ~ ~
Right?
1
Aceplante
01/31/2023 1:24 am
Level 66 : High Grandmaster Spelunker
history
Aceplante's Avatar
He didnt say anything about saving rotation. If you wish to have the armor stand face in a certain direction, you would be best using data merge
2
Kefaku
01/31/2023 2:48 am
Level 42 : Master Nerd
Kefaku's Avatar
Isn't that what the 4th/5th "~" is for, or am I mixing things up?
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome