Skip to content

Commit

Permalink
Check for world different world
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Feb 13, 2024
1 parent 667f102 commit 62d6e28
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ class PlayerNearLocationEventEntry(
@EntryListener(PlayerNearLocationEventEntry::class)
fun onPlayerNearLocation(event: PlayerMoveEvent, query: Query<PlayerNearLocationEventEntry>) {
// Only check if the player moved a block
if (event.from.blockX == event.to.blockX && event.from.blockY == event.to.blockY && event.from.blockZ == event.to.blockZ) return
if (!event.hasChangedBlock()) return

query findWhere { entry ->
event.player.isInRange(entry.location, entry.range)
} startDialogueWithOrNextDialogue event.player
}

fun Player.isInRange(location: Location, range: Double): Boolean {
if (location.world != world) return false
return this.location.distanceSquared(location) <= range * range
}

0 comments on commit 62d6e28

Please sign in to comment.