Paper/patches/api/0104-Location.toBlockLocation-toCenterLocation.patch
Jason bc127ea819
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#6222)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
eec4aab0 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent
205213c6 SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron

CraftBukkit Changes:
b8c522d5 SPIGOT-6657: Add getPlayer to SheepDyeWoolEvent
f04a77dc SPIGOT-6656: CauldronLevelChangeEvent is not fired correctly when dripstone fills the cauldron
d1dbcebc SPIGOT-6653: Canceling snow bucket placement removes snow from bucket
4f34a67b #891: Fix scheduler task ID overflow and duplication issues

Spigot Changes:
d03d7f12 BUILDTOOLS-604: Rebuild patches
2021-07-18 09:41:53 +02:00

44 lines
1.6 KiB
Diff

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 3be91f6c9b355c9e8562796d719f5a6ce566d85a..a90010fea189c5ac9a59a0e6d04c0457243a3280 100644
--- a/src/main/java/org/bukkit/Location.java
+++ b/src/main/java/org/bukkit/Location.java
@@ -534,6 +534,31 @@ 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) {