mojira.dev

CirCole

Assigned

No issues.

Reported

MC-17312 Detecting players farther than ~46340 with command blocks Incomplete MC-16340 Tab autocomplete causes disconnect from server Duplicate MC-5027 Fireworks on multiplayer Duplicate

Comments

There now seems to be a check for if the player is farther than 46340 that the command always returns false in 1.6.2

The detection overflow pattern is still present with the rm variable.

eg. Using these commands in the chat:

/say @p[rm=0]
/say @p[rm=1]
/say @p[rm=46340]
/say @p[rm=46341]
/say @p[rm=65536]
/say @p[rm=65537]

I don't think it's a short type because the player's xyz coordinates have to be squared if it is using an Euclidean formula. Now, I haven't seen at the actual code, nor do I know Java's syntax very well, but I think it could be something like this:

int displacementX = playerX - selectorX;
int displacementY = playerY - selectorY;
int displacementZ = playerZ - selectorZ;
// =============================
int squaredDisX = Math.pow(displacementX,2);
int squaredDisY = Math.pow(displacementY,2);
int squaredDisZ = Math.pow(displacementZ,2);

int squaredSum = squaredDisX + squaredDisY +squaredDisZ;
// =============================
int calculatedRadius = sqrt(squaredSum);
if (selectorR < calculatedRadius < selectorRM) {
    playerDetected() //do something
}

If the player's x and y displacement are 0 and their z displacement is 46341, the squaredDisZ would be -2147479015 because of the overflow. After square-root, the calculated radius would be equal to NaN. This continues until the players radius is greater than 65536 when the overflowed value becomes greater than 0.

I think this issue can be fixed if the "squaredDisX", "squaredDisZ" and, "squaredSum" were declared as long instead of int. This would expand the maximum radius to 3,037,000,499; about 100 times the radius of the playable Minecraft map.

This issue has not been resolved in version 13w21b. The same error occurs.

It just disconnects the clients; you're able to reconnect almost instantly.