2
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.
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:
I want it to teleport one block above the player, like in the attached image.
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.
Create an account or sign in to comment.
18
replace as with at
execute at @p run tp @e[tag=gliderstand] ~ ~1 ~ would be the most effeicient way
01/30/2023 11:07 pm
This reply was removed by the poster or a moderator.
[deleted]
what box
[deleted]
Try: execute as @p at @s...
True
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[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 ~ ~ ~
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?
Use execute if score combined with your effect command
(if you can't figure it out and need more tips, just ask)
(if you can't figure it out and need more tips, just ask)
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
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
the effect commands shouldn't affect the armorstand in any way, not sure what went wrong there 🤔
This will always be the nearest player though. It might be better to do:
execute at @p run tp @e[tag=gliderstand] ~ ~1 ~
execute at @p run tp @e[tag=gliderstand] ~ ~1 ~
But if you leave out the as, you cant copy the rotation like he did with
Right?
teleport @e ~ ~1 ~ ~ ~
Right?
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
Isn't that what the 4th/5th "~" is for, or am I mixing things up?
view more replies ( 1 )