mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
more patches (#5808)
This commit is contained in:
43
patches/api/Location.toBlockLocation-toCenterLocation.patch
Normal file
43
patches/api/Location.toBlockLocation-toCenterLocation.patch
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 24 May 2018 21:01:13 -0400
|
||||
Subject: [PATCH] Location.toBlockLocation/toCenterLocation()
|
||||
|
||||
Convert location objects to their block coordinates, or the center of the block
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -0,0 +0,0 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||||
}
|
||||
|
||||
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * @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
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
Reference in New Issue
Block a user