Player sensor incorrectly reading distance
AppliedEM opened this issue ยท 2 comments
Description
The player sensor's x reading is 1.3 blocks too high in the x direction, and roughly .3 blocks too high in the y direction. Could not get it to change its reading based on the z direction distance and I expect it is simply not reading any values based on that axis.
Steps to Reproduce
- place player sensor to right of computer
- call player.getNearbyPlayers(200)
- correlate the distance from the nearest player to the distance reported by the block. It is cutting out the contribution from the z axis and using inaccurate values from the x and y axis.
...
Expected behavior:
A true cartesian floating point distance from the player to the center of the block
Actual behavior:
The cartesian distance from the player's x.y plane, with significant error
Version affected:
1.3.6
forge 1.7.10
Additional Information
something to note is that my tests were conducted in a mystcraft dimension. Not sure if that would have any affect
This mod got taken over, please head to https://github.com/rolandoislas/PeripheralsPlusOne for any further questions.
After looking at the code, the issue is in \src\main\java\com\austinv11\peripheralsplusplus\tiles\TileEntityPlayerSensor.java. The distance was being calculated incorrectly on line 89. I changed the line to
map.put(player.getDisplayName(), Math.sqrt(Math.pow(location.getX() - player.posX,2) + Math.pow(location.getY() - player.posY,2) + Math.pow(location.getZ() - player.posZ,2)));
And the sensor began working mostly correctly again.