Minecraft Prevention of Motion of Objects not Affected by Motion Tag

minecraft-commandsminecraft-java-edition

I have made, using scoreboards, a chestplate that makes a variety of projectiles stop moving around it. The problem is a select few items:

  • All types of fireballs (Fireball, Small Fireball, Dragon Fireball)
  • Wither Skull
  • Shulker Bullet
  • Llama Spit

These entities all appear to be completely unaffected by the Motion tag. If a wither shoots a wither skull, giving the skull the NBT data {NoGravity:1b,Motion:[0d,0d,0d]} doesn't affect its motion at all. How do I make these various objects still?

Best Answer

For some reason all types of fireballs (fireball, small_fireball and dragon_fireball) and wither skulls have an additional direction tag that acts the same as Motion and seems to overwrite whatever they have in their Motion tag. Additionally they have a power tag, which accelerates them in X, Y and Z direction every tick, even if you set direction to [0.0,0.0,0.0] every tick.
So the proper way to stop these is:

/execute as @e[type=fireball] run data merge entity @s {direction:[0.0,0.0,0.0],power:[0.0,0.0,0.0]}
/execute as @e[type=small_fireball] run data merge entity @s {direction:[0.0,0.0,0.0],power:[0.0,0.0,0.0]}
/execute as @e[type=dragon_fireball] run data merge entity @s {direction:[0.0,0.0,0.0],power:[0.0,0.0,0.0]}
/execute as @e[type=wither_skull] run data merge entity @s {direction:[0.0,0.0,0.0],power:[0.0,0.0,0.0]}

Shulker bullets have a completely different way of moving. The easiest way I found to stop them was this:

/execute as @e[type=shulker_bullet] run data merge entity @s {TXD:0,TYD:0,TZD:0}

Llama spit turned out to be the most difficult one of these, for some reason. It completely ignores its Motion tag, but it also has no direction or similar to replace it. In fact, it has no unique NBT tags at all, except Owner. So the brute force method is the only one that works:

/execute at @e[type=llama_spit,tag=!frozen] run summon armor_stand ~ ~ ~ {NoAI:1,NoGravity:1,Marker:1,Invisible:1,Tags:["freezeHelper"]}
/tag @e[type=llama_spit,tag=!frozen] add frozen
/execute as @e[type=llama_spit] at @s run tp @s @e[type=armor_stand,sort=nearest,limit=1]
/execute as @e[tag=freezeHelper] at @s unless entity @e[type=llama_spit,distance=...1] run kill @s

You summon an armour stand that doesn't interact with the world at the llama spit and then continuously teleport it there. When the llama spit doesn't exist anymore, the last command kills the armour stand to improve performance.

Mostly the llama spit just turns invisible, sometimes it reappears at its origin position a few times and visually moves in its regular direction, but it does not hurt you anymore. Directly after being shot by a llama it always visually moves in its usual direction at first, which is usually far enough to look like it would hit you. But it never damages you, unless you walk directly into the position where it actually is.

Related Topic