Force location queries to check center of block #1000
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes a
LocationQuery
use the center of a block when checking if the player is inside a region. Region checks use the PlayerCoarseMoveEvent which happens when a player enters or leaves a whole block, when combined with acontains
check using the player's actual coordinates results in counting them as being in a region below them when they're not.This was noticed when shifting/standing above a scorebox/portal that shared the same region. Take the below example:
If a player was stood on top of the block at the max of this region (y = 9.0 exactly) then the portal's
contains
check matches but the scoreboxesenters
check does not. Portals (dynamic)(and other regioncontains
LocationQuery checks) are currently using the players location to detect if they are in the region which triggers the portal when they're not inside the region causing them to be prematurely teleport and not receive points.This can be seen here: https://discord.com/channels/86514356862320640/172382420954251264/962731072234328214
Whilst tinkering with the above checking through the stack of events and methods the below changes were also identified.
- Replace the usage ofPlayerQuery
(without location) in theRegionMatchModule
with the player itself as the player is already a query (due to the dynamic changes). This allows thePlayerQuery
to be changed to be aPlayerWithLocationQuery
used only for checking locations that are not the player's current location (only used in flag drop locations atm).- The above change also means that theevent
is passed with therfa
check andquery
as it is no longer contained in thePlayerQuery
wrapper (so needs to be passed so it can be cancelled if needed).FilterMatchModule
.Signed-off-by: Pugzy [email protected]