TransWikia.com

How to detect death in Minecraft in a certain area

Arqade Asked by Jers on June 20, 2021

I am making a PVP game and I need to detect when a player dies, but I also only want to detect that if the player is in the PVP arena. I want to be able to detect the last man standing and the one that died only inside the arena (part of the game mode). I have seen how to detect the death, but never how to limit it to a certain area/while they are in that game.

One Answer

depending on the shape of your arena (square or circle), you can restrict a command to run only if entity is within a certain range. i usually use, also, execute as @a at @s, as it quite literally targets (as) everyone (@a) as if (at) they were the individual (@s).

in the instance of a cuboid (square/rectangular area), you'd want to use the x, y, z, dx, dy, and dz arguments (or settings you need to specify) to choose the area you want to limit it to;

  • x is the X coordinate of your first corner.
  • y is the Y coordinate.
  • z is the Z.
  • dx is the distance on the X axis to the opposite corner.
  • dy is the distance on Y.
  • dz is the distance on Z.

so, for an example, if i want to make a player say "hi" while in a 5x5x5 cube area, assuming the center is x0 y3 z0;

execute as @a at @s if entity @s[x=2,y=1,z=2,dx=-4,dy=4,dz=-4] run say hi

this would make it so if someone is in the area between the block at x2 y1 z2 and x-2 y5 z-2, it will run "say hi" as if that person ran the command itself.

Answered by EarthToAccess on June 20, 2021

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