aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0363-Potential-bed-API.patch
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2024-05-29 13:58:57 -0700
committerGitHub <[email protected]>2024-05-29 22:58:57 +0200
commita31dc90741ed9c121a13a3c124c9ebf5bafd0da7 (patch)
tree81963bd94fe7772ee08bd21710230de21b6b25da /patches/server/0363-Potential-bed-API.patch
parented85aac53cfd93d29fa24e6071dbdddd0e49624b (diff)
downloadPaper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.tar.gz
Paper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.zip
Several fixes and new api for experience merging/stacking (#9242)
Diffstat (limited to 'patches/server/0363-Potential-bed-API.patch')
-rw-r--r--patches/server/0363-Potential-bed-API.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/patches/server/0363-Potential-bed-API.patch b/patches/server/0363-Potential-bed-API.patch
new file mode 100644
index 0000000000..34470bcfc1
--- /dev/null
+++ b/patches/server/0363-Potential-bed-API.patch
@@ -0,0 +1,44 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: JRoy <[email protected]>
+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 eb2d39d408e7f46a8f047a2b0d76981f24e1320a..bbd3f0981eb95348ef12c9af8fa1712c022ed869 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+@@ -12,6 +12,7 @@ import net.minecraft.nbt.CompoundTag;
+ import net.minecraft.network.chat.Component;
+ import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
+ import net.minecraft.network.protocol.game.ServerboundContainerClosePacket;
++import net.minecraft.server.level.ServerLevel;
+ import net.minecraft.server.level.ServerPlayer;
+ import net.minecraft.world.MenuProvider;
+ import net.minecraft.world.entity.Entity;
+@@ -129,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;
++ }
++
++ 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");