9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-22 08:29:28 +00:00
Files
Leaf/patches/server/0056-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch
2024-02-03 11:03:22 -05:00

46 lines
3.1 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..03112a42d1cf3460af5d5ce9d1fdd03854d5e8c1 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.LeafConfig.skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer || 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/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index 26c7a5020e9fd9dac212c6540dc79cad26e64796..ac21530de2ecb4c5b1ded30abf2bca473c813701 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -206,6 +206,7 @@ public class LeafConfig {
public static int asyncPathfindingMaxThreads = 0;
public static int asyncPathfindingKeepalive = 60;
public static boolean cacheMinecartCollision = false;
+ public static boolean skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer = true;
private static void performance() {
boolean asyncMobSpawning = getBoolean("performance.enable-async-mob-spawning", enableAsyncMobSpawning,
"Whether or not asynchronous mob spawning should be enabled.",
@@ -269,6 +270,7 @@ public class LeafConfig {
cacheMinecartCollision = getBoolean("performance.cache-minecart-collision", cacheMinecartCollision,
"Cache the minecart collision result to prevent massive stacked minecart lag the server.",
"The known issue: entity can't enter the minecart after enabling this!");
+ skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer = getBoolean("performance.skip-map-item-data-updates-if-map-does-not-have-craftmaprenderer", skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer);
}
public static boolean jadeProtocol = false;