mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
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.
This commit is contained in:
parent
5729115aab
commit
7be16c7ef0
1 changed files with 16 additions and 0 deletions
|
@ -130,6 +130,22 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return this.getHandle().sleepCounter;
|
||||
}
|
||||
|
||||
// Paper start - Potential bed api
|
||||
@Override
|
||||
public Location getPotentialBedLocation() {
|
||||
ServerPlayer handle = (ServerPlayer) getHandle();
|
||||
BlockPos bed = handle.getRespawnPosition();
|
||||
if (bed == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
net.minecraft.server.level.ServerLevel worldServer = handle.server.getLevel(handle.getRespawnDimension());
|
||||
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");
|
||||
|
|
Loading…
Reference in a new issue