aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0700-Fix-incosistency-issue-with-empty-map-items-in-CB.patch
blob: 77196f4ae2894b3e6a9efa0d26a1d1925ff85989 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 1 Aug 2021 09:49:06 +0100
Subject: [PATCH] Fix incosistency issue with empty map items in CB


diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
index 602e6bc05c053baf821c11c30b24538320b9ac61..7baf8039c5cf2bd68ba79d4a095ed4b58a847081 100644
--- a/src/main/java/net/minecraft/world/item/MapItem.java
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
@@ -71,7 +71,7 @@ public class MapItem extends ComplexItem {
     public static Integer getMapId(ItemStack stack) {
         CompoundTag nbttagcompound = stack.getTag();
 
-        return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
+        return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : null; // CraftBukkit - make new maps for no tag // Paper - don't return invalid ID
     }
 
     public static int createNewSavedData(Level world, int x, int z, int scale, boolean showIcons, boolean unlimitedTracking, ResourceKey<Level> dimension) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
index 96ab7d53f4e089c7666872f9fd0f09283259a726..8e634ccb91b58000412c572903e57d30ddb2caba 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
@@ -144,6 +144,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
 
     @Override
     public int getMapId() {
+        Preconditions.checkState(this.hasMapView(), "Item does not have map associated - check hasMapView() first!"); // Paper - more friendly message
         return this.mapId;
     }