From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Mon, 29 Jul 2024 20:06:27 +0800 Subject: [PATCH] SparklyPaper Skip "MapItem#update()" if the map does not have the CraftMapRenderer present diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..6235ff18455a21695bdc2d65367558d3936a45c5 --- /dev/null +++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java @@ -0,0 +1,20 @@ +package me.earthme.luminol.config.modules.optimizations; + +import me.earthme.luminol.config.ConfigInfo; +import me.earthme.luminol.config.EnumConfigCategory; +import me.earthme.luminol.config.IConfigModule; + +public class MapItemUpdateSkipConfig implements IConfigModule { + @ConfigInfo(baseName = "enabled") + public static boolean enabled = true; + + @Override + public EnumConfigCategory getCategory() { + return EnumConfigCategory.OPTIMIZATIONS; + } + + @Override + public String getBaseName() { + return "skip_map_item_updates_if_no_bukkit_render"; + } +} diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java index 957396b145b1d1adf265f8b9aaeba052758f007a..6d0f67882885373b4772b9f747e68e490dd8797e 100644 --- a/src/main/java/net/minecraft/world/item/MapItem.java +++ b/src/main/java/net/minecraft/world/item/MapItem.java @@ -281,7 +281,7 @@ public class MapItem extends ComplexItem { mapItemSavedData.tickCarriedBy(player, stack); } - if (!mapItemSavedData.locked && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) { + if (!mapItemSavedData.locked && (!me.earthme.luminol.config.modules.optimizations.MapItemUpdateSkipConfig.enabled || 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); } } // Folia - region threading