Paper/patches/server/0970-Fix-possible-NPE-on-painting-creation.patch
Jake Potrebic 90fe0d58a5
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9825)
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:
897a0a23 SPIGOT-5753: Back PotionType by a minecraft registry
255b2aa1 SPIGOT-7080: Add World#locateNearestBiome
ff984826 Remove javadoc.io doc links

CraftBukkit Changes:
71b0135cc SPIGOT-5753: Back PotionType by a minecraft registry
a6bcb8489 SPIGOT-7080: Add World#locateNearestBiome
ad0e57434 SPIGOT-7502: CraftMetaItem - cannot deserialize BlockStateTag
b3efca57a SPIGOT-6400: Use Mockito instead of InvocationHandler
38c599f9d PR-1272: Only allow one entity in CraftItem instead of two
f065271ac SPIGOT-7498: ChunkSnapshot.getBlockEmittedLight() gets 64 blocks upper in Overworld

Spigot Changes:
e0e223fe Remove javadoc.io doc links
2023-10-22 20:12:00 +01:00

29 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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 6f3598c12ad8f5d35863669c1f85b5581aa82a60..3de391034dc8367c538008893615514c628d948e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
@@ -917,6 +917,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<net.minecraft.world.entity.Entity> list = (List<net.minecraft.world.entity.Entity>) this.getHandle().getEntities(null, bb);
for (Iterator<net.minecraft.world.entity.Entity> it = list.iterator(); !taken && it.hasNext(); ) {
net.minecraft.world.entity.Entity e = it.next();
@@ -943,7 +944,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);