mirror of
https://github.com/SparklyPower/SparklyPaper.git
synced 2025-12-19 15:09:27 +00:00
Make the new map data skip optimization configurable per world
This commit is contained in:
@@ -225,10 +225,10 @@ index 0000000000000000000000000000000000000000..6398c7b40ba82ffc8588eca458ce92c2
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fbbb11c1a62a28a251c35261fb29e6267a08c1a3
|
||||
index 0000000000000000000000000000000000000000..4c736abcf64855e8fdfdeb2ba646288283ae278a
|
||||
--- /dev/null
|
||||
+++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt
|
||||
@@ -0,0 +1,49 @@
|
||||
@@ -0,0 +1,50 @@
|
||||
+package net.sparklypower.sparklypaper.configs
|
||||
+
|
||||
+import com.charleskorn.kaml.Yaml
|
||||
@@ -255,6 +255,7 @@ index 0000000000000000000000000000000000000000..fbbb11c1a62a28a251c35261fb29e626
|
||||
+ ),
|
||||
+ mapOf(
|
||||
+ "default" to SparklyPaperWorldConfig(
|
||||
+ skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer = true,
|
||||
+ SparklyPaperWorldConfig.TickRates(
|
||||
+ farmWhenMoisturised = 1
|
||||
+ )
|
||||
@@ -281,10 +282,10 @@ index 0000000000000000000000000000000000000000..fbbb11c1a62a28a251c35261fb29e626
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..190954d4533e53247f9a4af878a08ce96eee2ebd
|
||||
index 0000000000000000000000000000000000000000..1b0851f6c66910773f99e9a6c6a99abc90164f51
|
||||
--- /dev/null
|
||||
+++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt
|
||||
@@ -0,0 +1,16 @@
|
||||
@@ -0,0 +1,18 @@
|
||||
+package net.sparklypower.sparklypaper.configs
|
||||
+
|
||||
+import kotlinx.serialization.SerialName
|
||||
@@ -292,6 +293,8 @@ index 0000000000000000000000000000000000000000..190954d4533e53247f9a4af878a08ce9
|
||||
+
|
||||
+@Serializable
|
||||
+class SparklyPaperWorldConfig(
|
||||
+ @SerialName("skip-map-item-data-updates-if-map-does-not-have-craftmaprenderer")
|
||||
+ val skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer: Boolean,
|
||||
+ @SerialName("tick-rates")
|
||||
+ val tickRates: TickRates
|
||||
+) {
|
||||
|
||||
@@ -9,7 +9,7 @@ Optimizes "image in map" maps, without requiring the map to be locked, which som
|
||||
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 us
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
index c368b437597edf7e165326727ae778a69c3fcc83..3d812694c6ca2f211ff4f2bdd4d0c1336652b421 100644
|
||||
index c368b437597edf7e165326727ae778a69c3fcc83..c54498c662fef50ffb16441e1480f4e048ff99d6 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
@@ -333,7 +333,14 @@ public class MapItem extends ComplexItem {
|
||||
@@ -18,7 +18,7 @@ index c368b437597edf7e165326727ae778a69c3fcc83..3d812694c6ca2f211ff4f2bdd4d0c133
|
||||
if (!worldmap.locked && (selected || entity instanceof Player && ((Player) entity).getOffhandItem() == stack)) {
|
||||
- this.update(world, entity, worldmap);
|
||||
+ // SparklyPaper - don't update maps if they don't have the CraftMapRenderer in the render list
|
||||
+ if (worldmap.mapView.getRenderers().stream().anyMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) {
|
||||
+ if (!world.sparklyPaperConfig.getSkipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer() || worldmap.mapView.getRenderers().stream().anyMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) {
|
||||
+ this.update(world, entity, worldmap);
|
||||
+ } else {
|
||||
+ if (entity instanceof Player)
|
||||
|
||||
Reference in New Issue
Block a user