diff --git a/README.md b/README.md index dfaaafd..a724e60 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,9 @@ SparklyPaper's config file is `sparklypaper.yml`, the file is, by default, place * The `isNearWater` check is costly, especially if you have a lot of farm lands. If the block is already moistured, we can change the tick rate of it to avoid these expensive `isNearWater` checks. * Skip `distanceToSqr` call in `ServerEntity#sendChanges` if the delta movement hasn't changed * The `distanceToSqr` call is a bit expensive, so avoiding it is pretty nice, around ~15% calls are skipped with this check. Currently, we only check if both Vec3 objects have the same identity, that means, if they are literally the same object. (that works because Minecraft's code reuses the Vec3 object when caching the current delta movement) +* Skip `MapItem#update()` if the map does not have the CraftMapRenderer present + * By default, custom maps, even those with custom renderers, are still fetching world data to update the map data. With this change, "image in map" maps can avoid these hefty updates, 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, so if you readd the default renderer, the server will need to update the map data, but that's not a huuuge problem for us. * Check how much MSPT (milliseconds per tick) each world is using in `/mspt` * Useful to figure out which worlds are lagging your server. ![Per World MSPT](docs/per-world-mspt.png) diff --git a/patches/server/0006-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch b/patches/server/0006-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch new file mode 100644 index 0000000..5e6cdd2 --- /dev/null +++ b/patches/server/0006-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch @@ -0,0 +1,30 @@ +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 c368b437597edf7e165326727ae778a69c3fcc83..3d812694c6ca2f211ff4f2bdd4d0c1336652b421 100644 +--- a/src/main/java/net/minecraft/world/item/MapItem.java ++++ b/src/main/java/net/minecraft/world/item/MapItem.java +@@ -333,7 +333,14 @@ public class MapItem extends ComplexItem { + } + + if (!worldmap.locked && (selected || entity instanceof Player && ((Player) entity).getOffhandItem() == stack)) { +- this.update(world, entity, worldmap); ++ // SparklyPaper - don't update maps if they don't have the CraftMapRenderer in the render list ++ if (worldmap.mapView.getRenderers().stream().anyMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) { ++ this.update(world, entity, worldmap); ++ } else { ++ if (entity instanceof Player) ++ worldmap.getHoldingPlayer((Player) entity); // Required to add the player to the carriedBy list, which causes a map update ++ } ++ // SparklyPaper end + } + + } diff --git a/patches/server/0006-Track-how-much-MSPT-each-world-used.patch b/patches/server/0007-Track-how-much-MSPT-each-world-used.patch similarity index 100% rename from patches/server/0006-Track-how-much-MSPT-each-world-used.patch rename to patches/server/0007-Track-how-much-MSPT-each-world-used.patch diff --git a/patches/server/0007-Parallel-world-ticking.patch b/patches/server/0008-Parallel-world-ticking.patch similarity index 100% rename from patches/server/0007-Parallel-world-ticking.patch rename to patches/server/0008-Parallel-world-ticking.patch