mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
[ci skip] Fix SparklyPaper: Skip "MapItem#update()" if the map does not have the CraftMapRenderer present
This commit is contained in:
@@ -11,26 +11,32 @@ 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 u
|
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/net/minecraft/world/item/MapItem.java b/net/minecraft/world/item/MapItem.java
|
diff --git a/net/minecraft/world/item/MapItem.java b/net/minecraft/world/item/MapItem.java
|
||||||
index 780793750c99185e8139a1cd0ad52bc7b80899a9..dd20922e25710fe79fb4d37d04dd5cb59cb896fe 100644
|
index 780793750c99185e8139a1cd0ad52bc7b80899a9..0073f21245c98e7b5791f9db1ad221aef7cb594a 100644
|
||||||
--- a/net/minecraft/world/item/MapItem.java
|
--- a/net/minecraft/world/item/MapItem.java
|
||||||
+++ b/net/minecraft/world/item/MapItem.java
|
+++ b/net/minecraft/world/item/MapItem.java
|
||||||
@@ -275,7 +275,18 @@ public class MapItem extends Item {
|
@@ -275,12 +275,24 @@ public class MapItem extends Item {
|
||||||
savedData.tickCarriedBy(player, stack);
|
savedData.tickCarriedBy(player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
- if (!savedData.locked && slot != null && slot.getType() == EquipmentSlot.Type.HAND) {
|
- if (!savedData.locked && slot != null && slot.getType() == EquipmentSlot.Type.HAND) {
|
||||||
+ // SparklyPaper start - don't update maps if they don't have the CraftMapRenderer in the render list
|
+ if (!savedData.locked && (!org.dreeam.leaf.config.modules.opt.SkipMapItemDataUpdates.enabled || shouldUpdateMap(savedData)) && slot != null && slot.getType() == EquipmentSlot.Type.HAND) { // SparklyPaper - don't update maps if they don't have the CraftMapRenderer in the render list
|
||||||
+ boolean shouldUpdateMap = !savedData.locked && slot != null && slot.getType() == EquipmentSlot.Type.HAND;
|
|
||||||
+ if (org.dreeam.leaf.config.modules.opt.SkipMapItemDataUpdates.enabled) {
|
|
||||||
+ for (org.bukkit.map.MapRenderer mapRenderer : savedData.mapView.getRenderers()) {
|
|
||||||
+ if (mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class) {
|
|
||||||
+ shouldUpdateMap = true;
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ if (shouldUpdateMap) {
|
|
||||||
+ // SparklyPaper end - don't update maps if they don't have the CraftMapRenderer in the render list
|
|
||||||
this.update(level, entity, savedData);
|
this.update(level, entity, savedData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // SparklyPaper start - don't update maps if they don't have the CraftMapRenderer in the render list
|
||||||
|
+ private static boolean shouldUpdateMap(MapItemSavedData savedData) {
|
||||||
|
+ for (org.bukkit.map.MapRenderer mapRenderer : savedData.mapView.getRenderers()) {
|
||||||
|
+ if (mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ // SparklyPaper end - don't update maps if they don't have the CraftMapRenderer in the render list
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void onCraftedPostProcess(ItemStack stack, Level level) {
|
||||||
|
MapPostProcessing mapPostProcessing = stack.remove(DataComponents.MAP_POST_PROCESSING);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ and, in my opinion, worth the low risk of minor mob-spawning-related
|
|||||||
inconsistencies.
|
inconsistencies.
|
||||||
|
|
||||||
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
||||||
index ece6db7b9a0dfd535141c0c756947c4898140503..13df153d7b63a5c36a2fd14d3292e7eb32a394df 100644
|
index ece6db7b9a0dfd535141c0c756947c4898140503..82b84d72bf1b3c43d734fe381b67377de5f30187 100644
|
||||||
--- a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
--- a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
||||||
+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
|
||||||
@@ -11,7 +11,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
@@ -11,7 +11,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||||
@@ -88,7 +88,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..13df153d7b63a5c36a2fd14d3292e7eb
|
|||||||
this.defrag();
|
this.defrag();
|
||||||
}
|
}
|
||||||
//this.check();
|
//this.check();
|
||||||
@@ -169,14 +172,16 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
@@ -169,14 +172,17 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void defrag() {
|
private void defrag() {
|
||||||
@@ -98,6 +98,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..13df153d7b63a5c36a2fd14d3292e7eb
|
|||||||
+ if (firstInvalidIndex < 0) {
|
+ if (firstInvalidIndex < 0) {
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
}
|
}
|
||||||
|
+ // Leaf end - Pufferfish - Async mob spawning
|
||||||
|
|
||||||
if (this.indexMap.isEmpty()) {
|
if (this.indexMap.isEmpty()) {
|
||||||
Arrays.fill(this.listElements, 0, this.listSize, null);
|
Arrays.fill(this.listElements, 0, this.listSize, null);
|
||||||
@@ -107,7 +108,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..13df153d7b63a5c36a2fd14d3292e7eb
|
|||||||
//this.check();
|
//this.check();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -186,11 +191,11 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
@@ -186,11 +192,11 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||||
int lastValidIndex;
|
int lastValidIndex;
|
||||||
java.util.Iterator<Reference2IntMap.Entry<E>> iterator;
|
java.util.Iterator<Reference2IntMap.Entry<E>> iterator;
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..13df153d7b63a5c36a2fd14d3292e7eb
|
|||||||
final E key = backingArray[lastValidIndex - 1];
|
final E key = backingArray[lastValidIndex - 1];
|
||||||
iterator = this.indexMap.reference2IntEntrySet().fastIterator(new Reference2IntMap.Entry<E>() {
|
iterator = this.indexMap.reference2IntEntrySet().fastIterator(new Reference2IntMap.Entry<E>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -221,7 +226,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
@@ -221,7 +227,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||||
// cleanup end
|
// cleanup end
|
||||||
Arrays.fill(backingArray, lastValidIndex, this.listSize, null);
|
Arrays.fill(backingArray, lastValidIndex, this.listSize, null);
|
||||||
this.listSize = lastValidIndex;
|
this.listSize = lastValidIndex;
|
||||||
@@ -130,7 +131,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..13df153d7b63a5c36a2fd14d3292e7eb
|
|||||||
//this.check();
|
//this.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +240,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
@@ -235,7 +241,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IteratorSafeOrderedReferenceSet.Iterator<E> iterator(final int flags) {
|
public IteratorSafeOrderedReferenceSet.Iterator<E> iterator(final int flags) {
|
||||||
@@ -139,7 +140,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..13df153d7b63a5c36a2fd14d3292e7eb
|
|||||||
return new BaseIterator<>(this, true, (flags & ITERATOR_FLAG_SEE_ADDITIONS) != 0 ? Integer.MAX_VALUE : this.listSize);
|
return new BaseIterator<>(this, true, (flags & ITERATOR_FLAG_SEE_ADDITIONS) != 0 ? Integer.MAX_VALUE : this.listSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +327,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
@@ -322,7 +328,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
|
||||||
}
|
}
|
||||||
this.lastReturned = null;
|
this.lastReturned = null;
|
||||||
this.finished = true;
|
this.finished = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user