minecraft-java-edition,minecraft-commands – How to Teleport Minecart with Chests Above a Player’s Head in Minecraft

minecraft-commandsminecraft-java-edition

I've been having trouble making menu GUIs in 1.16. My best idea so far was to create a command making it so when ever there is a nether star in my inventory it teleports a minecart with a chest in it to me. But the problem is it teleports it to my feet, and not my head. Here are the commands I used:

/execute if entity @p[nbt={Inventory:[{id:"minecraft:nether_star",tag:{display:{Name:'{"text":"Menu"}'}}}]}] (to find a nether star in my inventory)

/teleport @e[type=minecraft:chest_minecart,y=3] @p (to teleport the minecart)

Best Answer

You must use ~ ~2 ~ instead of @p! If you teleport an entity to another entity the entity you teleport will always get teleported to the feat! But if you only replace @p with ~ ~2~ the minecart will be teleported to the command block! To fix that you must do it like this: /execute as @p at @s run tp @e[type=minecraft:chest_minecart,y=3] ~ ~2 ~

I hope that solve your problem!

Do you know you dont need to type /teleport! /tp will also work :)