mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-21 07:59:26 +00:00
50 lines
2.6 KiB
Diff
50 lines
2.6 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 608390ed36710a419de1542b80340dd3fcc7299c..98449cfbad78833808a6ad069baaa723e701231f 100644
|
|
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
|
@@ -277,7 +277,7 @@ public class MapItem extends ComplexItem {
|
|
mapItemSavedData.tickCarriedBy(player, stack);
|
|
}
|
|
|
|
- if (!mapItemSavedData.locked && (selected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) {
|
|
+ if (!mapItemSavedData.locked && (!org.dreeam.leaf.config.modules.opt.SkipMapItemDataUpdates.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);
|
|
}
|
|
}
|
|
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..61687c05b5996115a40c364fbd013ee72f5de72e
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/SkipMapItemDataUpdates.java
|
|
@@ -0,0 +1,18 @@
|
|
+package org.dreeam.leaf.config.modules.opt;
|
|
+
|
|
+import org.dreeam.leaf.config.ConfigModules;
|
|
+import org.dreeam.leaf.config.EnumConfigCategory;
|
|
+
|
|
+public class SkipMapItemDataUpdates extends ConfigModules {
|
|
+
|
|
+ public String getBasePath() {
|
|
+ return EnumConfigCategory.PERF.getBaseKeyName();
|
|
+ }
|
|
+
|
|
+ public static boolean enabled = true;
|
|
+
|
|
+ @Override
|
|
+ public void onLoaded() {
|
|
+ enabled = config.getBoolean(getBasePath() + ".skip-map-item-data-updates-if-map-does-not-have-craftmaprenderer", enabled);
|
|
+ }
|
|
+}
|