PaperMC/patches/server/0416-Potential-bed-API.patch
Jake Potrebic cfe3ad1b0f
Updated Upstream (Bukkit/CraftBukkit/Spigot)
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:
45d9c73c SPIGOT-7043: EnderChest does not implement Lidded
86b95f34 SPIGOT-7047: Add Player#getLastDeathLocation

CraftBukkit Changes:
b2557f6ac SPIGOT-7041: Custom BiomeProvider not used when world set to type FLAT
732c50cab SPIGOT-7043: EnderChest does not implement Lidded
6209029ea SPIGOT-7048: addPassenger() not working when vehicle is player
3aa7836df SPIGOT-7047: Add Player#getLastDeathLocation
7d522cd26 SPIGOT-7050: Enchantment data of items will not be saved correctly when saved in YAML configuration file

Spigot Changes:
1dffefb4 Rebuild patches
2022-06-09 18:20:55 -07:00

44 lines
2.1 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 9d6c3cb06cf1096fc9bffe5123bf19df13fdded6..b68e1f8c9acb05ef38ec9d35ee68748c5a31abe7 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;
@@ -126,6 +127,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");