From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Fri, 17 Nov 2023 14:22:41 -0300 Subject: [PATCH] Skip "MapItem#update()" if the map does not have the CraftMapRenderer present Optimizes "image in map" maps, without requiring the map to be locked, which some old map plugins may not do This has the disadvantage that the vanilla map data will never be updated while the CraftMapRenderer is not present, but that's not a huuuge problem for us diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java index 571f2540a1e9422025efe651167e26b44b437daa..70dd7d49807d8290b3a306550c2e1999c7e3553e 100644 --- a/src/main/java/net/minecraft/world/item/MapItem.java +++ b/src/main/java/net/minecraft/world/item/MapItem.java @@ -275,7 +275,7 @@ public class MapItem extends Item { mapItemSavedData.tickCarriedBy(player, stack); } - if (!mapItemSavedData.locked && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) { + if (!mapItemSavedData.locked && (!world.sparklyPaperConfig.getSkipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer() || mapItemSavedData.mapView.getRenderers().stream().anyMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) { // SparklyPaper - don't update maps if they don't have the CraftMapRenderer in the render list this.update(world, entity, mapItemSavedData); } }