Created
February 17, 2015 21:51
-
-
Save nsporillo/418abf2a9ec85caffb69 to your computer and use it in GitHub Desktop.
Methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isOutsideWorldBorder1(FLocation flocation) { | |
World world = flocation.getWorld(); | |
WorldBorder border = world.getWorldBorder(); | |
Chunk chunk = border.getCenter().getChunk(); | |
// chunkToRegion for the fast divide by 32 | |
int lim = FLocation.chunkToRegion((int) border.getSize()); | |
int diffX = (int) Math.abs(chunk.getX() - flocation.getX()); | |
int diffZ = (int) Math.abs(chunk.getZ() - flocation.getZ()); | |
return diffX > lim || diffZ > lim; | |
} | |
public boolean isOutsideWorldBorder2(FLocation flocation) { | |
World world = flocation.getWorld(); | |
WorldBorder border = world.getWorldBorder(); | |
Chunk chunk = border.getCenter().getChunk(); | |
// blockToChunk for the fast divide by 16 | |
int lim = FLocation.blockToChunk((int) border.getSize()); | |
int diffX = (int) Math.abs(chunk.getX() - flocation.getX()); | |
int diffZ = (int) Math.abs(chunk.getZ() - flocation.getZ()); | |
return diffX + diffZ > lim; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment