TransWikia.com

Run command when motion is a certain value near player

Arqade Asked on July 5, 2021

My brain refuses to explain a problem without context, so please bear with me.

I’m attempting to make a PVP map, but I want there to be a specific and custom "death message" for arrows being "hit" because there are multiple different arrows I intend on having (custom tipped arrows); e.g. I have an arrow that should be an instant kill that I want to have announce *target* was sniped by *source*. Because I have showDeathMessages disabled for this and other ways of dying, and I also want there to be a specific set of commands to run post-death, I can’t simply kill the target with the arrow and let Minecraft’s main death messages handle it.

Here’s the actual problem. In order to do this while still keeping it accurate to the target’s health, I want to calculate the speed of an arrow and, provided it causes the damage of the arrow to be equal to or higher than said health, run a command; in this case, I want to teleport the target back to spawn.

As of this moment in time. I already have the following set up;

  • A scoreboard (uuid) set up to find and match UUIDs from an Arrow’s Owner[0] to a player’s UUID[0] — this was made assuming that the first object in the IntArray will always be unique (due in part to UUID’s meaning);
  • A tag for it having been found, named "ping";
  • A command chain running every tick to find, compare, and match said UUIDs;
  • Scoreboards (vx, vy, and vz) set up to find and store an Arrow’s three Motion tags;
  • Command chains running every tick to do the above, provided the Arrow isn’t in the ground

The primary issue is that the command (below) I’m attempting to use to determine a "hit" isn’t doing anything. For this, I’m assuming a fully charged bow and that an arrow needs to be less than half a block near the target before Minecraft actually recognizes it as a hit;

execute as @e[tag=ping,scores={vx=2..}] at @s if entity @p[distance=..0.5,scores={health=..6}] unless score @p uuid = @s uuid run tp @p 127 179 8

What I understand the command to be doing should be;

  • As every entity with the tag ping whose vx score is 2 or larger,
    • …if the nearest player is within .5 blocks and has <=6 health,
    • …unless that player has the same UUID as the Owner tag of the entity,
  • teleport the player to the coordinates.

Instead, the arrow simply hits and damages the player regardless of health, and thus so will kill the player before they teleport anywhere. Since I want other commands and death messages to run and be displayed after teleporting, I can’t let it just kill them.

Is the syntax of the command wrong? I thought it was a problem with the distance selector (at if entity @p [distance=..0.5]...), but even after setting that to ..1 instead of ..0.5, it still did nothing.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP