From db97147724cb5f8ef1c960f86f379195a462e3df Mon Sep 17 00:00:00 2001 From: BlackHole Date: Mon, 22 Jul 2019 23:41:39 +0200 Subject: [PATCH] SPIGOT-5199: Fix NPE if setting the book of the ItemMeta of a lectern --- nms-patches/TileEntityLectern.patch | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nms-patches/TileEntityLectern.patch b/nms-patches/TileEntityLectern.patch index d670e06b34..ee37d5fb56 100644 --- a/nms-patches/TileEntityLectern.patch +++ b/nms-patches/TileEntityLectern.patch @@ -66,7 +66,7 @@ @Override public int getSize() { return 1; -@@ -49,11 +102,18 @@ +@@ -49,11 +102,20 @@ } @Override @@ -75,7 +75,9 @@ + public void setItem(int i, ItemStack itemstack) { + if (i == 0) { + TileEntityLectern.this.setBook(itemstack); -+ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook()); ++ if (TileEntityLectern.this.getWorld() != null) { ++ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook()); ++ } + } + } + // CraftBukkit end @@ -87,7 +89,7 @@ } @Override -@@ -158,6 +218,32 @@ +@@ -158,6 +220,32 @@ return itemstack; } @@ -120,7 +122,7 @@ private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) { String s; Object object; -@@ -172,7 +258,8 @@ +@@ -172,7 +260,8 @@ Vec3D vec3d = new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D); @@ -130,7 +132,7 @@ } @Override -@@ -211,7 +298,7 @@ +@@ -211,7 +300,7 @@ @Override public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {