mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Location.toBlockLocation/toCenterLocation()
Convert location objects to their block coordinates, or the center of the block
This commit is contained in:
parent
9970e9dfde
commit
0432bbd3a8
1 changed files with 26 additions and 0 deletions
|
@ -534,6 +534,32 @@ public class Location implements Cloneable, ConfigurationSerializable, io.paperm
|
|||
}
|
||||
|
||||
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
|
||||
|
||||
// Paper start - expand Location API
|
||||
/**
|
||||
* @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z)
|
||||
*/
|
||||
@NotNull
|
||||
public Location toBlockLocation() {
|
||||
Location blockLoc = clone();
|
||||
blockLoc.setX(getBlockX());
|
||||
blockLoc.setY(getBlockY());
|
||||
blockLoc.setZ(getBlockZ());
|
||||
return blockLoc;
|
||||
}
|
||||
/**
|
||||
* @return A new location where X/Y/Z are the center of the block
|
||||
*/
|
||||
@NotNull
|
||||
public Location toCenterLocation() {
|
||||
Location centerLoc = clone();
|
||||
centerLoc.setX(getBlockX() + 0.5);
|
||||
centerLoc.setY(getBlockY() + 0.5);
|
||||
centerLoc.setZ(getBlockZ() + 0.5);
|
||||
return centerLoc;
|
||||
}
|
||||
// Paper end - expand Location API
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
|
|
Loading…
Reference in a new issue