9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 17:09:29 +00:00
Files
Leaf/patches/server/0055-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch
2024-01-20 07:57:59 -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 6cfd169c2c32b644d70907358c2d4a2087c00a68..c065ee1e68b5274d30f252d296b0c16a2adbf3c8 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 635f09b234c723b79d35686105c2c3335f868e6a..3368e4d398132c64969b018e4fe8b7bbe8f2f364 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;