mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Correct handling of invalid maps (#6302)
This commit is contained in:
parent
b8f6b49552
commit
1c0ded9f9b
1 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue