From 1c0ded9f9b9b8b33dfee149e34815a708243d4f4 Mon Sep 17 00:00:00 2001 From: PaulBGD Date: Sat, 31 Jul 2021 15:47:01 -0500 Subject: [PATCH] Correct handling of invalid maps (#6302) --- ...n-item-frames-performance-and-bug-fixe.patch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch b/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch index 9d27823353..5179a1f4f2 100644 --- a/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch +++ b/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch @@ -51,12 +51,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - remove player from map on drop + if (stack.getItem() == Items.FILLED_MAP) { + MapItemSavedData worldmap = MapItem.getSavedData(stack, this.level); -+ worldmap.tickCarriedBy(this, stack); ++ if (worldmap != null) { ++ worldmap.tickCarriedBy(this, stack); ++ } + } + // Paper end return entityitem; } +diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/MapItem.java ++++ b/src/main/java/net/minecraft/world/item/MapItem.java +@@ -0,0 +0,0 @@ public class MapItem extends ComplexItem { + + @Nullable + public static MapItemSavedData getSavedData(@Nullable Integer id, Level world) { +- return id == null ? null : world.getMapData(MapItem.makeKey(id)); ++ return id == null || id < 0 ? null : world.getMapData(MapItem.makeKey(id)); // Paper - map ids under 0 are invalid + } + + @Nullable diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java