mojira.dev
MC-45134

Using negative values for dx, dy, and dz doesn't work

When testing for entity in cubic areas, placing - in dx,dy,dz won't work
Exact command used:

/testfor @p[x=9988,y=56,z=10000,dx=4,dy=-2,dz=4]

Linked issues

Comments 14

Technically speaking, the negatives aren't needed as your command could be rewritten:

/testfor @p[x=9988,y=54,z=10000,dx=4,dy=2,dz=4]

It is possible this may be intended.

CubeTheThird but that would mean the box is not positioned correctly :/ the negatives ARE needed to properly define the area

@Conor, perhaps there is something that I am not considering, but if you are searching for players from y 56 to 2 blocks below, is that not equivalent to y 54 to 2 blocks above?

Negatives cannot be used. Start your box in the lowest corner, you can define any region without negatives.

/testfor @p[x=9988,y=56,z=10000,dx=4,dy=-2,dz=4]

can be re-written as

/testfor @p[x=9988,y=54,z=10000,dx=4,dy=2,dz=4]

as CubeTheThird showed. If you test it I'd be very surprised if it doesn't work.

@CubeTheThird, remember these coordinates are absolute, not relative.

4 more comments

The given solution only works if the command block does not move. Minecart command blocks and those from /clone will still affect the original target.

I came across this problem while building a UFO that flies using /clone to move itself, /tp to move entities and /fill to remove the old copy. I want to add a tractor beam to suck up cows below (/tp) but there is no easy way to select a 3x20x3 pillar BELOW the ship.

@Alex, sounds to me like your issue is that selectors cannot use relative coordinates.

Ah... I see. I was thinking in terms [r=] being centered at the command block also applying to other selector terms. Nevermind then, that would be a feature request and not a bug.

replaces prison cell with fireball cannon

Comment of @unknown in MC-48402:

it's dx, dy and dz and you can not use negative values for them

And sadly relative coordinates aren't allowed either:

Using

/kill @e[x=~,y=~,z=~,dx=10,dy=10,dz=10]

drops out an error

The entity UUID provided is in an invalid format

Michael Salim

(Unassigned)

Confirmed

testfor

Minecraft 14w03b

Retrieved