mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-20 07:29:24 +00:00
53 lines
2.7 KiB
Diff
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 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..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;
|
|
+}
|