13
0
geforkt von Mirrors/Paper

rename method for center to toCenterLocation()

Dieser Commit ist enthalten in:
Aikar 2018-05-24 21:06:06 -04:00
Ursprung b70c406245
Commit b4d7828a4f

Datei anzeigen

@ -1,12 +1,12 @@
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
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 1ddebf3c..5c70e80d 100644
index 1ddebf3c..916238c4 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 {
@ -19,23 +19,21 @@ index 1ddebf3c..5c70e80d 100644
+ * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z)
+ */
+ public Location toBlockLocation() {
+ return toBlockLocation(false);
+ Location blockLoc = clone();
+ blockLoc.setX(getBlockX());
+ blockLoc.setY(getBlockY());
+ blockLoc.setZ(getBlockZ());
+ return blockLoc;
+ }
+ /**
+ * @return A new location where X/Y/Z are on the Block location (integer value of X/Y/Z), or optionally the center
+ * @return A new location where X/Y/Z are the center of the block
+ */
+ public Location toBlockLocation(boolean center) {
+ Location blockLoc = clone();
+ if (center) {
+ blockLoc.setX(getBlockX() + 0.5);
+ blockLoc.setY(getBlockY() + 0.5);
+ blockLoc.setZ(getBlockZ() + 0.5);
+ } else {
+ blockLoc.setX(getBlockX());
+ blockLoc.setY(getBlockY());
+ blockLoc.setZ(getBlockZ());
+ }
+ return blockLoc;
+ 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