Advanced Peripherals

Advanced Peripherals

29M Downloads

PlayerDetector.getPlayersInRange will use the -x and -z as the center point, not the center of the block

zyxkad opened this issue ยท 8 comments

commented

Describe

As the title, player detector get player in range will use the min x and min z (and/or min y, not sure) as the center point to detect, but I except it will use the center point of itself.

Steps to reproduce

  1. Place a player detector
  2. Place a computer next to it
  3. enter lua environment, wrap the player detector
  4. stand at the +x pos next to the detector, and do .getPlayerInRange(1), there are nothing
  5. stand at the -x pos next to the detector, and do .getPlayerInRange(1), you will be there

Multiplayer?

Yes

Version

1.19.2-0.7.26r

Minecraft, Forge and maybe other related mods versions

Forge 43.2.8 Minecraft 1.19.2

Screenshots or Videos

My.Movie.mp4

Crashlog/log

No response

commented

That really should not happen, have you test that with the feet position or the eye position of the player?
I also can't really reproduce this, the block is always the center

commented

That really should not happen, have you test that with the feet position or the eye position of the player?

I tried both, I will make a screenrecording for it

commented
My.Movie.mp4
commented
commented

Okay, something is wrong with the way how we search the area.
image

The center block is right, it's still the block as you can see in the console. Just the method we're using isn't right.
I'll see what I can do.

commented

Yes, I didn't describe it clearly, I mean if the block at (0, 0, 0), it will use (0, 0, 0) as the center search point, but I expect it will use (0.5, 0.5, 0.5) as the searching point

commented

@SirEndii I decide to make a pr for this issue, now your arguments for playerDetector are all ints, but getNearbyPlayers accept doubles https://nekoyue.github.io/ForgeJavaDocs-NG/javadoc/1.19.3/net/minecraft/world/phys/AABB.html. I am not sure the int is on purpose for some reason?

Edit:
BlockPos also accept doubles

commented

getPlayersInRange fixed in #450, but I'm not sure if getPlayersInCubic have the same problem too.