From de3f149185a3b654eaf9af1144f4c85b8ef2f9bc Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 13 Jul 2023 17:22:15 -0700 Subject: [PATCH] Fix possible NPE on painting creation (#9391) --- ...ix-possible-NPE-on-painting-creation.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 patches/server/0987-Fix-possible-NPE-on-painting-creation.patch diff --git a/patches/server/0987-Fix-possible-NPE-on-painting-creation.patch b/patches/server/0987-Fix-possible-NPE-on-painting-creation.patch new file mode 100644 index 0000000000..3abab01251 --- /dev/null +++ b/patches/server/0987-Fix-possible-NPE-on-painting-creation.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sat, 24 Jun 2023 09:42:53 -0700 +Subject: [PATCH] Fix possible NPE on painting creation + + +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +index b305941aaf50b417bb054a9327c67a0891f2fe9e..995b3e31c5725f3d8879df349351eae3bcdfdddf 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +@@ -916,6 +916,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { + AABB bb = (ItemFrame.class.isAssignableFrom(clazz)) + ? net.minecraft.world.entity.decoration.ItemFrame.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height) + : HangingEntity.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).getOpposite(), width, height); ++ if (!this.getHandle().noCollision(bb)) continue; // Paper - add collision check + List list = (List) this.getHandle().getEntities(null, bb); + for (Iterator it = list.iterator(); !taken && it.hasNext(); ) { + net.minecraft.world.entity.Entity e = it.next(); +@@ -942,7 +943,8 @@ public abstract class CraftRegionAccessor implements RegionAccessor { + if (Painting.class.isAssignableFrom(clazz)) { + if (this.isNormalWorld() && randomizeData) { + entity = net.minecraft.world.entity.decoration.Painting.create(world, pos, dir).orElse(null); +- } else { ++ } // Paper ++ if (entity == null) { // Paper - if randomizeData fails, force it + entity = new net.minecraft.world.entity.decoration.Painting(net.minecraft.world.entity.EntityType.PAINTING, this.getHandle().getMinecraftWorld()); + entity.absMoveTo(x, y, z, yaw, pitch); + ((net.minecraft.world.entity.decoration.Painting) entity).setDirection(dir);