9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-21 07:59:26 +00:00
Files
Leaf/patches/server/0060-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch
2024-02-29 09:31:12 -05:00

53 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrPowerGamerBR <git@mrpowergamerbr.com>
Date: Fri, 17 Nov 2023 14:22:41 -0300
Subject: [PATCH] SparklyPaper: Skip "MapItem#update()" if the map does not
have the CraftMapRenderer present
Original project: https://github.com/SparklyPower/SparklyPaper
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 u
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
index 8d3c1897044f9a2bbe1911e1a72dc9a00fb246df..c97bfd7396ec419fe3a8f6c88ccf864d52ad7e68 100644
--- a/src/main/java/net/minecraft/world/item/MapItem.java
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
@@ -325,7 +325,7 @@ public class MapItem extends ComplexItem {
worldmap.tickCarriedBy(entityhuman, stack);
}
- if (!worldmap.locked && (selected || entity instanceof Player && ((Player) entity).getOffhandItem() == stack)) {
+ if (!worldmap.locked && (!org.dreeam.leaf.config.modules.opt.SkipMapItemDataUpdates.enabled || worldmap.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, worldmap);
}
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/SkipMapItemDataUpdates.java b/src/main/java/org/dreeam/leaf/config/modules/opt/SkipMapItemDataUpdates.java
new file mode 100644
index 0000000000000000000000000000000000000000..014de86c0fe97d7b7ad789191dfc121419fda8a0
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/SkipMapItemDataUpdates.java
@@ -0,0 +1,21 @@
+package org.dreeam.leaf.config.modules.opt;
+
+import org.dreeam.leaf.config.ConfigInfo;
+import org.dreeam.leaf.config.EnumConfigCategory;
+import org.dreeam.leaf.config.IConfigModule;
+
+public class SkipMapItemDataUpdates implements IConfigModule {
+
+ @Override
+ public EnumConfigCategory getCategory() {
+ return EnumConfigCategory.PERFORMANCE;
+ }
+
+ @Override
+ public String getBaseName() {
+ return "skip_map_item_data_updates_if_map_does_not_have_craftmaprenderer";
+ }
+
+ @ConfigInfo(baseName = "enabled")
+ public static boolean enabled = true;
+}