Teleport entities relatively to the center of a block
I just wanted to teleport an entity relatively, but the entity is not exactly in the middle of a block.
For example the coordinates are 0.3, 63.0, 0.76 and I teleport the entity relatively using ~1 ~0 ~1. The resulting coordinated will be 1.3, 63.0, 1.76 but I want the entity to be in the center of the block. So it has to be 1.5, 63.0, 1.5 instead.
Is it possible to achieve this? Thank you!
Best Answer
You can use Leash Knots like this:
/execute @e[name=Name] ~ ~ ~ /summon leash_knot ~ ~ ~ {CustomName:Centre}
/tp @e[name=Name] @e[name=Centre,c=1]
/kill @e[name=Centre]
(This is for 1.11, for 1.10 or lower use LeashKnot instead of leash_knot)
For 1.13+:
/execute as @e[name=Name] at ~ ~ ~ /summon leash_knot ~ ~ ~ {Tags:["Centre"]}
/tp @e[name=Name] @e[tag=Centre,limit=1]
/kill @e[tag=Centre]
Pictures about "Teleport entities relatively to the center of a block"



How do you center an entity on a block?
There are a few ways to center an entity on a block. Some of the more clunky methods involve teleporting the entity elsewhere, shoving it against the corner and then teleporting it ~0.3 ~ ~0.3, or similar things. They're horizontally centered, and -0.469 off on the Z axis.How do you teleport to a specific block?
Type this command in when having the command block GUI open /teleport @p <x> <y> <z> . Then, activate the command block with redstone (including buttons, levers, and pressure plates), and they will be sent to their destination. The player can set up multiple different teleports.Can you tp entities in Minecraft?
You can use the /teleport command to teleport a player or entity to a set of coordinates in the game (see also /tp command).How do you coordinate teleport?
You can teleport to any location as long as you have its coordinates. To do it, type your command like this: /tp X Y Z. So for example, if you're trying to teleport to the location 70, 70, 70, you'll type: /tp 70 70 70.Minecraft Command Basics: /tp and Coordinates
More answers regarding teleport entities relatively to the center of a block
Answer 2
When summoning relatively to command blocks, like ~ ~5 ~, it will summon it in the middle of the block.
Or, you can use a spawn egg, because when you use a spawn egg to spawn a zombie, the zombie will be in the middle of the block. So you can use execute and summon something at the zombie then kill the zombie.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: John Lee, Samson Katt, Andreea Ch, Charles Parker
