Avoid NPE due to PlayerBedFailEnterEvent

fixes #5670
This commit is contained in:
Riley Park 2021-05-18 08:57:17 -07:00
parent d3c9a195cb
commit 322886c869
No known key found for this signature in database
GPG key ID: D831AF236C834E45

View file

@ -17,7 +17,7 @@ index 3a13e7a050db7f5c93d810afe56325495cec7aa4..c39c50e53549e9cb9d3520bc7e8b7e89
public IChatBaseComponent a() {
return this.g;
diff --git a/src/main/java/net/minecraft/world/level/block/BlockBed.java b/src/main/java/net/minecraft/world/level/block/BlockBed.java
index eca84595342756e3550883551e487aaf79574fde..abe0a1c309d526de37efcac44922fa259e1d112c 100644
index eca84595342756e3550883551e487aaf79574fde..00a01a157deec004bcf2f8587723a0ecd0bfef85 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockBed.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockBed.java
@@ -43,6 +43,8 @@ import net.minecraft.world.phys.shapes.VoxelShape;
@ -29,7 +29,7 @@ index eca84595342756e3550883551e487aaf79574fde..abe0a1c309d526de37efcac44922fa25
public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
@@ -101,14 +103,22 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
@@ -101,14 +103,23 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
BlockPosition finalblockposition = blockposition;
// CraftBukkit end
entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> {
@ -48,7 +48,8 @@ index eca84595342756e3550883551e487aaf79574fde..abe0a1c309d526de37efcac44922fa25
// CraftBukkit end
if (entityhuman_enumbedresult != null) {
- entityhuman.a(entityhuman_enumbedresult.a(), true);
+ entityhuman.a(PaperAdventure.asVanilla(event.getMessage()), true); // Paper
+ final net.kyori.adventure.text.Component message = event.getMessage(); // Paper
+ if(message != null) entityhuman.a(PaperAdventure.asVanilla(message), true); // Paper
}
+ } // Paper