mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 19:07:40 +01:00
Expand Location Manipulation API
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
This commit is contained in:
parent
431acee6c7
commit
134ca58ee1
@ -545,6 +545,59 @@ 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 manipulation API
|
||||
|
||||
/**
|
||||
* Sets the position of this Location and returns itself
|
||||
* <p>
|
||||
* This mutates this object, clone first.
|
||||
*
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @param z Z coordinate
|
||||
* @return self (not cloned)
|
||||
*/
|
||||
@NotNull
|
||||
public Location set(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the x/y/z from base and adds the specified x/y/z to it and returns self
|
||||
* <p>
|
||||
* This mutates this object, clone first.
|
||||
*
|
||||
* @param base The base coordinate to modify
|
||||
* @param x X coordinate to add to base
|
||||
* @param y Y coordinate to add to base
|
||||
* @param z Z coordinate to add to base
|
||||
* @return self (not cloned)
|
||||
*/
|
||||
@NotNull
|
||||
public Location add(@NotNull Location base, double x, double y, double z) {
|
||||
return this.set(base.x + x, base.y + y, base.z + z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the x/y/z from base and subtracts the specified x/y/z to it and returns self
|
||||
* <p>
|
||||
* This mutates this object, clone first.
|
||||
*
|
||||
* @param base The base coordinate to modify
|
||||
* @param x X coordinate to subtract from base
|
||||
* @param y Y coordinate to subtract from base
|
||||
* @param z Z coordinate to subtract from base
|
||||
* @return self (not cloned)
|
||||
*/
|
||||
@NotNull
|
||||
public Location subtract(@NotNull Location base, double x, double y, double z) {
|
||||
return this.set(base.x - x, base.y - y, base.z - z);
|
||||
}
|
||||
// Paper end - expand location manipulation API
|
||||
|
||||
// Paper start - expand Location API
|
||||
/**
|
||||
* @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z)
|
||||
|
Loading…
Reference in New Issue
Block a user