mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 18:39:23 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939) PaperMC/Paper@1922be90 Update custom tags (#12183) PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009) PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949) PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992) PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974) PaperMC/Paper@42b653b1 Expose more argument types (#12665) PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010) PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996) PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
75 lines
5.0 KiB
Diff
75 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Mon, 14 Apr 2025 14:36:57 +0200
|
|
Subject: [PATCH] Optimize ThreadedTicketLevelPropagator
|
|
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
|
index 310a8f80debadd64c2d962ebf83b7d0505ce6e42..878f8beb769e87f1de70e7be963e88678a89dd0a 100644
|
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
|
@@ -998,6 +998,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
|
final int decodeOffsetZ = -this.encodeOffsetZ;
|
|
final int encodeOffset = this.coordinateOffset;
|
|
final int sectionOffset = this.sectionIndexOffset;
|
|
+ final Section[] sectionsArray = this.sections; // Leaf - Optimize ThreadedTicketLevelPropagator
|
|
|
|
final Long2ByteLinkedOpenHashMap updatedPositions = this.updatedPositions;
|
|
|
|
@@ -1012,13 +1013,27 @@ public abstract class ThreadedTicketLevelPropagator {
|
|
int propagateDirectionBitset = (int)(queueValue >>> (COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS)) & ((1 << 16) - 1);
|
|
|
|
if ((queueValue & FLAG_RECHECK_LEVEL) != 0L) {
|
|
- if (this.getLevel(posX, posZ) != propagatedLevel) {
|
|
+ // Leaf start - Optimize ThreadedTicketLevelPropagator
|
|
+ final int sectionX = posX >> SECTION_SHIFT;
|
|
+ final int sectionZ = posZ >> SECTION_SHIFT;
|
|
+ final Section section = sectionsArray[sectionX + (sectionZ * SECTION_CACHE_WIDTH) + sectionOffset];
|
|
+ final int localIdx = (posX & (SECTION_SIZE - 1)) | ((posZ & (SECTION_SIZE - 1)) << SECTION_SHIFT);
|
|
+ if ((section.levels[localIdx] & 0xFF) != propagatedLevel) {
|
|
+ // Leaf end - Optimize ThreadedTicketLevelPropagator
|
|
// not at the level we expect, so something changed.
|
|
continue;
|
|
}
|
|
} else if ((queueValue & FLAG_WRITE_LEVEL) != 0L) {
|
|
// these are used to restore sources after a propagation decrease
|
|
- this.setLevel(posX, posZ, propagatedLevel);
|
|
+ // Leaf start - Optimize ThreadedTicketLevelPropagator
|
|
+ final int sectionX = posX >> SECTION_SHIFT;
|
|
+ final int sectionZ = posZ >> SECTION_SHIFT;
|
|
+ final Section section = sectionsArray[sectionX + (sectionZ * SECTION_CACHE_WIDTH) + sectionOffset];
|
|
+ final int localIdx = (posX & (SECTION_SIZE - 1)) | ((posZ & (SECTION_SIZE - 1)) << SECTION_SHIFT);
|
|
+ final short currentLevel = section.levels[localIdx];
|
|
+ section.levels[localIdx] = (short) ((currentLevel & ~0xFF) | (propagatedLevel & 0xFF));
|
|
+ updatedPositions.put(CoordinateUtils.getChunkKey(posX, posZ), (byte) propagatedLevel);
|
|
+ // Leaf end - Optimize ThreadedTicketLevelPropagator
|
|
}
|
|
|
|
// this bitset represents the values that we have not propagated to
|
|
@@ -1093,7 +1108,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
|
currentPropagation ^= (bitsetLine1 | bitsetLine2 | bitsetLine3);
|
|
|
|
// now try to propagate
|
|
- final Section section = this.sections[sectionIndex];
|
|
+ final Section section = sectionsArray[sectionIndex]; // Leaf - Optimize ThreadedTicketLevelPropagator
|
|
|
|
// lower 8 bits are current level, next upper 7 bits are source level, next 1 bit is updated source flag
|
|
final short currentStoredLevel = section.levels[localIndex];
|
|
@@ -1144,6 +1159,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
|
final int decodeOffsetZ = -this.encodeOffsetZ;
|
|
final int encodeOffset = this.coordinateOffset;
|
|
final int sectionOffset = this.sectionIndexOffset;
|
|
+ final Section[] sectionsArray = this.sections; // Leaf - Optimize ThreadedTicketLevelPropagator
|
|
|
|
final Long2ByteLinkedOpenHashMap updatedPositions = this.updatedPositions;
|
|
|
|
@@ -1227,7 +1243,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
|
final long bitsetLine3 = currentPropagation & (7L << (start + (8 + 8)));
|
|
|
|
// now try to propagate
|
|
- final Section section = this.sections[sectionIndex];
|
|
+ final Section section = sectionsArray[sectionIndex]; // Leaf - Optimize ThreadedTicketLevelPropagator
|
|
|
|
// lower 8 bits are current level, next upper 7 bits are source level, next 1 bit is updated source flag
|
|
final short currentStoredLevel = section.levels[localIndex];
|