geforkt von Mirrors/Paper
4e958e229f
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: zml <zml@stellardrift.ca> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
37 Zeilen
1.7 KiB
Diff
37 Zeilen
1.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: JRoy <joshroy126@gmail.com>
|
|
Date: Sun, 10 May 2020 23:06:30 -0400
|
|
Subject: [PATCH] Potential bed API
|
|
|
|
Adds a new method to fetch the location of a player's bed without generating any sync loads.
|
|
|
|
getPotentialBedLocation - Gets the last known location of a player's bed. This does not preform any check if the bed is still valid and does not load any chunks.
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
|
index c6564ccfd6580ac5691dd864602eb6fbaf4a34be..f8be287a5c5e273eb71896c16064b1fd085faf7e 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
|
@@ -127,6 +127,22 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|
return getHandle().sleepTicks;
|
|
}
|
|
|
|
+ // Paper start - Potential bed api
|
|
+ @Override
|
|
+ public Location getPotentialBedLocation() {
|
|
+ EntityPlayer handle = (EntityPlayer) getHandle();
|
|
+ BlockPosition bed = handle.getSpawn();
|
|
+ if (bed == null) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ net.minecraft.server.WorldServer worldServer = handle.server.getWorldServer(handle.getSpawnDimension());
|
|
+ if (worldServer == null) {
|
|
+ return null;
|
|
+ }
|
|
+ return new Location(worldServer.getWorld(), bed.getX(), bed.getY(), bed.getZ());
|
|
+ }
|
|
+ // Paper end
|
|
@Override
|
|
public boolean sleep(Location location, boolean force) {
|
|
Preconditions.checkArgument(location != null, "Location cannot be null");
|