mojira.dev
MC-30925

/testforblock positions are one off

To reproduce: type /testforblock -532 56 394 69 12.
The error will say: The block at -531,56,394 had the data value of 4 (expected: 12).

This is probably because for /tp, it centers players, so .5 is added automatically if there is no decimal, and then the .5 is detected in checking and is rounded the wrong way.

Linked issues

Comments 12

Actualy, this is only on the x acsess, as far as I can tell,

Nope, its only with negative numbers.
Looks like a rounding issue here.

Can confirm. This seems to be because the rounding of the coordinates is using the floor function, meaning all the values are rounded down. This unfortunately means that negative values are rounded to the incorrect value. If you look at the unrounded coordinates, they show the correct value. For this to be corrected, the function would have to truncate the decimals instead.

Strongly related to MC-30870 (same issue with setblock)

I can confirm it only happens in the negative directions. Placing a block at 0,Y,0 and trying again at -1,Y,-1 will atempt to place the block at the exact same location. The testforblock is doing the same.

2 more comments

Oops, somehow that pasted in the wrong place.... The error was "The block at -326,41,-518 is air (expected: Wool)."

Wait, so it is 2 off even?
Ok, that is some crazy rounding.

It's the same amount off as setblock, so I think the problem in the code is the same for the two commands

What does "CHK" mean? Last time you checked to see if it was still valid?

"CHK" = Mod has confirmed this ticket.
But duplicate of the (generalized) MC-30870

pokechu22

(Unassigned)

Confirmed

Minecraft 13w37a

Retrieved