WorldBorder

WorldBorder

1M Downloads

Bad performance on teleports to extreme y-values

Kagamul opened this issue ยท 0 comments

commented

Teleporting outside a set WorldBorder (without bypass permissions) can cause the server to hang for a long period of time (potentially multiple minutes) if and only if the target location's Y coordinates are either extremely large or extremely small (I have not tested the latter, but it'll most likely suffer from the same issue).

How to reproduce:

  • set a WorldBorder of a reasonably small size
  • use the command /tp 9999999999999999 999999999999999 99999999999999
  • server (most likely) freezes (for a couple Minutes)

Why does it happen:
The Method BorderData.getSafeY, especially the

Expanding Y search method adapted from Acru's code in the Nether plugin

is not built to handle extreme Y-values correctly and causes huge performance issues because of this.

How to solve (suggestion, pull request):

  • make some checks for extreme Y-values and adjust them if neccessary before using the algorithm mentioned above
  • avoid using the algorithm if we don't have to (player is flying and teleporting above the non-nether world)
  • make absoluetely sure that the Y-value entering the algorithm will not cause invalid Y values in the getBlockTypeIdAt Method-calls (they get called for y, y+1 and in some cases y-1 in the isSafeSpot Method used by the algorithm)
  • further improve performance by making use of the getHighestBlockYAt Method that Bukkit provides instead of relying only on maximum world height alone