mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-29 11:59:24 +00:00
Cleanup
This commit is contained in:
@@ -743,10 +743,10 @@ index b17c8a2f5294ac28cc05fb05c84a041b2c6c8721..0b8b4658dbbad1bacc13e97b4fc0cdce
|
||||
serverPlayer.connection = player.connection;
|
||||
serverPlayer.restoreFrom(player, keepInventory);
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..2f98d035b32d3a9b3366dbea0ac52b24d06dd373 100644
|
||||
index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..334a47659ba75fade062bc79df3731d1e449114b 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -3370,15 +3370,41 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -3370,15 +3370,40 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (this.portalProcess != null) {
|
||||
if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) {
|
||||
this.setPortalCooldown();
|
||||
@@ -760,12 +760,11 @@ index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..2f98d035b32d3a9b3366dbea0ac52b24
|
||||
+ // TCRF SparklyPaper (Pathothingi) start - parallel world ticking
|
||||
+ java.util.function.Consumer<Entity> portalEntityTask = entity -> {
|
||||
+ assert entity.portalProcess != null;
|
||||
+ // Leaf start - Fix NPE when portalProcess becomes null before task execution
|
||||
+ // Fix NPE when portalProcess becomes null before task execution
|
||||
+ // Portal process was likely nulled out (e.g., expired) between scheduling and execution.
|
||||
+ if (entity.portalProcess == null) {
|
||||
+ // Portal process was likely nulled out (e.g., expired) between scheduling and execution.
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf end - Fix NPE
|
||||
+
|
||||
+ if (entity.portalProcess.isParallelCancelledByPlugin()) {
|
||||
+ entity.portalProcess = null;
|
||||
@@ -795,7 +794,7 @@ index 9bc978ca290ca772b0367e89b69fe16b502b0cd2..2f98d035b32d3a9b3366dbea0ac52b24
|
||||
} else if (this.portalProcess.hasExpired()) {
|
||||
this.portalProcess = null;
|
||||
}
|
||||
@@ -3908,6 +3934,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -3908,6 +3933,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
private Entity teleportCrossDimension(ServerLevel level, TeleportTransition teleportTransition) {
|
||||
|
||||
@@ -11,10 +11,10 @@ As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 2f98d035b32d3a9b3366dbea0ac52b24d06dd373..90879616842cc61d15854b07f56f6fcb89f11074 100644
|
||||
index 334a47659ba75fade062bc79df3731d1e449114b..0903508d2cd3c78602e62dbcff4aa70285bc4c4f 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4622,10 +4622,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4621,10 +4621,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
// Paper start - optimise collisions
|
||||
public boolean updateFluidHeightAndDoFluidPushing(final TagKey<Fluid> fluid, final double flowScale) {
|
||||
@@ -26,7 +26,7 @@ index 2f98d035b32d3a9b3366dbea0ac52b24d06dd373..90879616842cc61d15854b07f56f6fcb
|
||||
final AABB boundingBox = this.getBoundingBox().deflate(1.0E-3);
|
||||
|
||||
final Level world = this.level;
|
||||
@@ -4661,7 +4658,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4660,7 +4657,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
|
||||
for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
|
||||
|
||||
@@ -6,7 +6,7 @@ Subject: [PATCH] Replace ConcurrentLong2ReferenceChainedHashTable with custom
|
||||
|
||||
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java b/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java
|
||||
index 7eafc5b7cba23d8dec92ecc1050afe3fd8c9e309..7a299490d502147ddfd533637da36ea0d2ac918a 100644
|
||||
index 7eafc5b7cba23d8dec92ecc1050afe3fd8c9e309..9b421f0681fe740520457951b1a1632ada59438a 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java
|
||||
@@ -16,7 +16,7 @@ public final class ChunkUnloadQueue {
|
||||
@@ -14,61 +14,58 @@ index 7eafc5b7cba23d8dec92ecc1050afe3fd8c9e309..7a299490d502147ddfd533637da36ea0
|
||||
public final int coordinateShift;
|
||||
private final AtomicLong orderGenerator = new AtomicLong();
|
||||
- private final ConcurrentLong2ReferenceChainedHashTable<UnloadSection> unloadSections = new ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<UnloadSection> unloadSections = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<UnloadSection> unloadSections = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>(); // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
|
||||
/*
|
||||
* Note: write operations do not occur in parallel for any given section.
|
||||
@@ -32,8 +32,8 @@ public final class ChunkUnloadQueue {
|
||||
@@ -32,8 +32,10 @@ public final class ChunkUnloadQueue {
|
||||
public List<SectionToUnload> retrieveForAllRegions() {
|
||||
final List<SectionToUnload> ret = new ArrayList<>();
|
||||
|
||||
- for (final Iterator<ConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection>> iterator = this.unloadSections.entryIterator(); iterator.hasNext();) {
|
||||
- final ConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection> entry = iterator.next();
|
||||
+ // Leaf start - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
+ for (final Iterator<org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection>> iterator = this.unloadSections.entryIterator(); iterator.hasNext(); ) {
|
||||
+ final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection> entry = iterator.next();
|
||||
+ // Leaf end - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
final long key = entry.getKey();
|
||||
final UnloadSection section = entry.getValue();
|
||||
final int sectionX = CoordinateUtils.getChunkX(key);
|
||||
@@ -141,4 +141,4 @@ public final class ChunkUnloadQueue {
|
||||
this.order = order;
|
||||
}
|
||||
}
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+}
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
||||
index 06ac3537f5655d048d770bb004243f207fad9faa..647354efeb18694ac56a542bf4a88be61136f6a8 100644
|
||||
index 06ac3537f5655d048d770bb004243f207fad9faa..e399fa14e4a28b4fd93d06c603fd70b6fadeb6b0 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
||||
@@ -71,11 +71,11 @@ public final class ChunkHolderManager {
|
||||
@@ -71,11 +71,13 @@ public final class ChunkHolderManager {
|
||||
private static final long PROBE_MARKER = Long.MIN_VALUE + 1;
|
||||
public final ReentrantAreaLock ticketLockArea;
|
||||
|
||||
- private final ConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket<?>>> tickets = new ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
- private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ // Leaf start - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket<?>>> tickets = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ // Leaf end - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
final ChunkUnloadQueue unloadQueue;
|
||||
|
||||
- private final ConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f); // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
private final ServerLevel world;
|
||||
private final ChunkTaskScheduler taskScheduler;
|
||||
private long currentTick;
|
||||
@@ -1422,9 +1422,9 @@ public final class ChunkHolderManager {
|
||||
@@ -1422,9 +1424,9 @@ public final class ChunkHolderManager {
|
||||
final JsonArray allTicketsJson = new JsonArray();
|
||||
ret.add("tickets", allTicketsJson);
|
||||
|
||||
- for (final Iterator<ConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator();
|
||||
+ for (final Iterator<org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator();
|
||||
+ for (final Iterator<org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator(); // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
iterator.hasNext();) {
|
||||
- final ConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>> coordinateTickets = iterator.next();
|
||||
+ final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>> coordinateTickets = iterator.next();
|
||||
+ final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>> coordinateTickets = iterator.next(); // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
final long coordinate = coordinateTickets.getKey();
|
||||
final SortedArraySet<Ticket<?>> tickets = coordinateTickets.getValue();
|
||||
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
||||
index 310a8f80debadd64c2d962ebf83b7d0505ce6e42..01598347ea545f2ff2ac337086345d7369a64520 100644
|
||||
index 310a8f80debadd64c2d962ebf83b7d0505ce6e42..3a7fad46465cac8d2c1b0933b457f5b075586709 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
||||
@@ -35,11 +35,11 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
@@ -76,17 +73,17 @@ index 310a8f80debadd64c2d962ebf83b7d0505ce6e42..01598347ea545f2ff2ac337086345d73
|
||||
|
||||
private final UpdateQueue updateQueue;
|
||||
- private final ConcurrentLong2ReferenceChainedHashTable<Section> sections;
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<Section> sections;
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<Section> sections; // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
|
||||
public ThreadedTicketLevelPropagator() {
|
||||
this.updateQueue = new UpdateQueue();
|
||||
- this.sections = new ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ this.sections = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ this.sections = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>(); // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
}
|
||||
|
||||
// must hold ticket lock for:
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
|
||||
index 1487b7d8be435b3fbad2aabd05796965b4775a87..a1459e3bc2076575e3f52d9e2b7d49630afeb799 100644
|
||||
index 1487b7d8be435b3fbad2aabd05796965b4775a87..57a702bafb36858979427809f8ae4fc1b001c8d6 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
|
||||
@@ -740,7 +740,7 @@ public final class StarLightInterface {
|
||||
@@ -94,12 +91,12 @@ index 1487b7d8be435b3fbad2aabd05796965b4775a87..a1459e3bc2076575e3f52d9e2b7d4963
|
||||
public static final class ServerLightQueue extends LightQueue {
|
||||
|
||||
- private final ConcurrentLong2ReferenceChainedHashTable<ServerChunkTasks> chunkTasks = new ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<ServerChunkTasks> chunkTasks = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<ServerChunkTasks> chunkTasks = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>(); // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
|
||||
public ServerLightQueue(final StarLightInterface lightInterface) {
|
||||
super(lightInterface);
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index b1f1b596a597d559aa672a3cb46a03917ad746af..d75f85208da0c7424fc95ae0d8ebb0a725dda0a7 100644
|
||||
index b1f1b596a597d559aa672a3cb46a03917ad746af..0860a700106e8c1afe58c77150a0f3aee8393fdd 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -72,7 +72,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -107,7 +104,7 @@ index b1f1b596a597d559aa672a3cb46a03917ad746af..d75f85208da0c7424fc95ae0d8ebb0a7
|
||||
private NaturalSpawner.SpawnState lastSpawnState;
|
||||
// Paper start
|
||||
- private final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<net.minecraft.world.level.chunk.LevelChunk> fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<LevelChunk> fullChunks = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<LevelChunk> fullChunks = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>(); // Leaf - Replace ConcurrentLong2ReferenceChainedHashTable with custom map
|
||||
public int getFullChunksCount() {
|
||||
return this.fullChunks.size();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,33 +5,36 @@ 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 01598347ea545f2ff2ac337086345d7369a64520..fbea9d83b7458760d4b1b5e1c8bd77ff46072b97 100644
|
||||
index 3a7fad46465cac8d2c1b0933b457f5b075586709..a2d76e6fabf2749a1a9f21fe6bdf6524af8bb9b7 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;
|
||||
+ final Section[] sectionsArray = this.sections; // Leaf - Optimize ThreadedTicketLevelPropagator
|
||||
|
||||
final Long2ByteLinkedOpenHashMap updatedPositions = this.updatedPositions;
|
||||
|
||||
@@ -1012,13 +1013,23 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
@@ -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];
|
||||
@@ -39,32 +42,33 @@ index 01598347ea545f2ff2ac337086345d7369a64520..fbea9d83b7458760d4b1b5e1c8bd77ff
|
||||
+ 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 +1104,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
@@ -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];
|
||||
+ 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 +1155,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
@@ -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;
|
||||
+ final Section[] sectionsArray = this.sections; // Leaf - Optimize ThreadedTicketLevelPropagator
|
||||
|
||||
final Long2ByteLinkedOpenHashMap updatedPositions = this.updatedPositions;
|
||||
|
||||
@@ -1227,7 +1239,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
@@ -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];
|
||||
+ 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];
|
||||
|
||||
@@ -5,25 +5,35 @@ Subject: [PATCH] Optimise MobEffectUtil#getDigSpeedAmplification
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/effect/MobEffectUtil.java b/net/minecraft/world/effect/MobEffectUtil.java
|
||||
index cbf1b6af928aa439c3264b302e5f1a1ddd4c14f0..c59a503ef8bc2dabcf9f7c85c8d93fb1fcadf71f 100644
|
||||
index cbf1b6af928aa439c3264b302e5f1a1ddd4c14f0..e4126bbfb46f2d3df9aac4c9362b9d81b3ecb713 100644
|
||||
--- a/net/minecraft/world/effect/MobEffectUtil.java
|
||||
+++ b/net/minecraft/world/effect/MobEffectUtil.java
|
||||
@@ -29,12 +29,14 @@ public final class MobEffectUtil {
|
||||
@@ -27,17 +27,21 @@ public final class MobEffectUtil {
|
||||
}
|
||||
|
||||
public static int getDigSpeedAmplification(LivingEntity entity) {
|
||||
int i = 0;
|
||||
int i1 = 0;
|
||||
- int i = 0;
|
||||
- int i1 = 0;
|
||||
- if (entity.hasEffect(MobEffects.DIG_SPEED)) {
|
||||
- i = entity.getEffect(MobEffects.DIG_SPEED).getAmplifier();
|
||||
+ // Leaf start - Optimise MobEffectUtil#getDigSpeedAmplification
|
||||
+ int digAmplifier = 0;
|
||||
+ int conduitAmplifier = 0;
|
||||
+ MobEffectInstance digEffect = entity.getEffect(MobEffects.DIG_SPEED);
|
||||
+ if (digEffect != null) {
|
||||
+ i = digEffect.getAmplifier();
|
||||
+ digAmplifier = digEffect.getAmplifier();
|
||||
}
|
||||
|
||||
- if (entity.hasEffect(MobEffects.CONDUIT_POWER)) {
|
||||
- i1 = entity.getEffect(MobEffects.CONDUIT_POWER).getAmplifier();
|
||||
+ MobEffectInstance conduitEffect = entity.getEffect(MobEffects.CONDUIT_POWER);
|
||||
+ if (conduitEffect != null) {
|
||||
+ i1 = conduitEffect.getAmplifier();
|
||||
+ conduitAmplifier = conduitEffect.getAmplifier();
|
||||
}
|
||||
|
||||
return Math.max(i, i1);
|
||||
- return Math.max(i, i1);
|
||||
+ return Math.max(digAmplifier, conduitAmplifier);
|
||||
+ // Leaf end - Optimise MobEffectUtil#getDigSpeedAmplification
|
||||
}
|
||||
|
||||
public static boolean hasWaterBreathing(LivingEntity entity) {
|
||||
|
||||
@@ -212,10 +212,10 @@ index b8ac6a9ba7b56ccd034757f7d135d272b8e69e90..dc158e981199b507531af810ff9ced3c
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||
index e9ece9b618b0a9eb82b9f07a09ee6cb60cf7ec16..18d2ec110fc6670edb079eccf448389dc365eb88 100644
|
||||
index e9ece9b618b0a9eb82b9f07a09ee6cb60cf7ec16..dff2fed559a274ee7896ee136999eaf288cf82bb 100644
|
||||
--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
|
||||
@@ -526,14 +526,14 @@ public record SerializableChunkData(
|
||||
@@ -526,14 +526,16 @@ public record SerializableChunkData(
|
||||
throw new IllegalArgumentException("Chunk can't be serialized: " + chunk);
|
||||
} else {
|
||||
ChunkPos pos = chunk.getPos();
|
||||
@@ -227,16 +227,19 @@ index e9ece9b618b0a9eb82b9f07a09ee6cb60cf7ec16..18d2ec110fc6670edb079eccf448389d
|
||||
final int minLightSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinLightSection(level);
|
||||
final int maxLightSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxLightSection(level);
|
||||
final int minBlockSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(level);
|
||||
+ // Leaf start - Optimize chunkUnload
|
||||
+ // Pre-allocate with correct capacity to avoid resizing
|
||||
+ final int expectedSectionCount = maxLightSection - minLightSection + 1;
|
||||
+ List<SerializableChunkData.SectionData> list = new ArrayList<>(expectedSectionCount);
|
||||
+ // Leaf end - Optimize chunkUnload
|
||||
|
||||
final LevelChunkSection[] chunkSections = chunk.getSections();
|
||||
final ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles = ((ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk)chunk).starlight$getBlockNibbles();
|
||||
@@ -551,10 +551,18 @@ public record SerializableChunkData(
|
||||
@@ -551,10 +553,20 @@ public record SerializableChunkData(
|
||||
continue;
|
||||
}
|
||||
|
||||
+ // Leaf start - Optimize chunkUnload
|
||||
+ DataLayer blockDataLayer = null;
|
||||
+ if (blockNibble != null && blockNibble.data != null) {
|
||||
+ blockDataLayer = new DataLayer(blockNibble.data);
|
||||
@@ -246,50 +249,48 @@ index e9ece9b618b0a9eb82b9f07a09ee6cb60cf7ec16..18d2ec110fc6670edb079eccf448389d
|
||||
+ if (skyNibble != null && skyNibble.data != null) {
|
||||
+ skyDataLayer = new DataLayer(skyNibble.data);
|
||||
+ }
|
||||
+ // Leaf end - Optimize chunkUnload
|
||||
+
|
||||
final SerializableChunkData.SectionData sectionData = new SerializableChunkData.SectionData(
|
||||
- lightSection, chunkSection,
|
||||
- blockNibble == null ? null : (blockNibble.data == null ? null : new DataLayer(blockNibble.data)),
|
||||
- skyNibble == null ? null : (skyNibble.data == null ? null : new DataLayer(skyNibble.data))
|
||||
+ lightSection, chunkSection, blockDataLayer, skyDataLayer
|
||||
+ lightSection, chunkSection, blockDataLayer, skyDataLayer // Leaf - Optimize chunkUnload
|
||||
);
|
||||
|
||||
if (blockNibble != null) {
|
||||
@@ -565,28 +573,42 @@ public record SerializableChunkData(
|
||||
@@ -565,12 +577,16 @@ public record SerializableChunkData(
|
||||
((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)sectionData).starlight$setSkyLightState(skyNibble.state);
|
||||
}
|
||||
|
||||
- sectionsList.add(sectionData);
|
||||
+ list.add(sectionData);
|
||||
+ list.add(sectionData); // Leaf - Optimize chunkUnload
|
||||
}
|
||||
// Paper end - starlight
|
||||
|
||||
- List<CompoundTag> list1 = new ArrayList<>(chunk.getBlockEntitiesPos().size());
|
||||
+ // Leaf start - Optimize chunkUnload
|
||||
+ // Pre-allocate block entities list with exact size needed
|
||||
+ final int blockEntityCount = chunk.getBlockEntitiesPos().size();
|
||||
+ List<CompoundTag> list1 = blockEntityCount > 0 ? new ArrayList<>(blockEntityCount) : java.util.Collections.emptyList();
|
||||
|
||||
- for (BlockPos blockPos : chunk.getBlockEntitiesPos()) {
|
||||
- CompoundTag blockEntityNbtForSaving = chunk.getBlockEntityNbtForSaving(blockPos, level.registryAccess());
|
||||
- if (blockEntityNbtForSaving != null) {
|
||||
- list1.add(blockEntityNbtForSaving);
|
||||
+ if (blockEntityCount > 0) {
|
||||
+ for (BlockPos blockPos : chunk.getBlockEntitiesPos()) {
|
||||
+ CompoundTag blockEntityNbtForSaving = chunk.getBlockEntityNbtForSaving(blockPos, level.registryAccess());
|
||||
+ if (blockEntityNbtForSaving != null) {
|
||||
+ list1.add(blockEntityNbtForSaving);
|
||||
+ }
|
||||
+ if (blockEntityCount > 0) // Leaf - Optimize chunkUnload
|
||||
for (BlockPos blockPos : chunk.getBlockEntitiesPos()) {
|
||||
CompoundTag blockEntityNbtForSaving = chunk.getBlockEntityNbtForSaving(blockPos, level.registryAccess());
|
||||
if (blockEntityNbtForSaving != null) {
|
||||
@@ -578,15 +594,27 @@ public record SerializableChunkData(
|
||||
}
|
||||
}
|
||||
|
||||
- List<CompoundTag> list2 = new ArrayList<>();
|
||||
+ // Leaf start - Optimize chunkUnload
|
||||
+ // For entities, use an initial estimated capacity if it's a ProtoChunk
|
||||
+ List<CompoundTag> list2;
|
||||
long[] longs = null;
|
||||
+
|
||||
if (chunk.getPersistedStatus().getChunkType() == ChunkType.PROTOCHUNK) {
|
||||
ProtoChunk protoChunk = (ProtoChunk)chunk;
|
||||
- list2.addAll(protoChunk.getEntities());
|
||||
+ // Leaf start - Optimize chunkUnload
|
||||
+ int entitySize = protoChunk.getEntities().size();
|
||||
+ if (entitySize > 0) {
|
||||
+ list2 = new ArrayList<>(Math.max(16, entitySize));
|
||||
@@ -297,21 +298,22 @@ index e9ece9b618b0a9eb82b9f07a09ee6cb60cf7ec16..18d2ec110fc6670edb079eccf448389d
|
||||
+ } else {
|
||||
+ list2 = java.util.Collections.emptyList();
|
||||
+ }
|
||||
+ // Leaf end - Optimize chunkUnload
|
||||
CarvingMask carvingMask = protoChunk.getCarvingMask();
|
||||
if (carvingMask != null) {
|
||||
longs = carvingMask.toArray();
|
||||
}
|
||||
+ } else {
|
||||
+ list2 = java.util.Collections.emptyList();
|
||||
+ list2 = java.util.Collections.emptyList(); // Leaf - Optimize chunkUnload
|
||||
}
|
||||
|
||||
Map<Heightmap.Types, long[]> map = new EnumMap<>(Heightmap.Types.class);
|
||||
@@ -594,14 +616,25 @@ public record SerializableChunkData(
|
||||
@@ -594,14 +622,26 @@ public record SerializableChunkData(
|
||||
for (Entry<Heightmap.Types, Heightmap> entry : chunk.getHeightmaps()) {
|
||||
if (chunk.getPersistedStatus().heightmapsAfter().contains(entry.getKey())) {
|
||||
long[] rawData = entry.getValue().getRawData();
|
||||
- map.put(entry.getKey(), (long[])rawData.clone());
|
||||
+ map.put(entry.getKey(), Arrays.copyOf(rawData, rawData.length));
|
||||
+ map.put(entry.getKey(), Arrays.copyOf(rawData, rawData.length)); // Leaf - Optimize chunkUnload
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +321,7 @@ index e9ece9b618b0a9eb82b9f07a09ee6cb60cf7ec16..18d2ec110fc6670edb079eccf448389d
|
||||
- ShortList[] lists = Arrays.stream(chunk.getPostProcessing())
|
||||
- .map(list3 -> list3 != null ? new ShortArrayList(list3) : null)
|
||||
- .toArray(ShortList[]::new);
|
||||
+ // Leaf start - Some Optimizations on SerializableChunkData
|
||||
+ // Leaf start - Optimize chunkUnload - remove stream
|
||||
+ ShortList[] postProcessing = chunk.getPostProcessing();
|
||||
+ ShortList[] lists = new ShortList[postProcessing.length];
|
||||
+ for (int i = 0; i < postProcessing.length; i++) {
|
||||
@@ -333,6 +335,7 @@ index e9ece9b618b0a9eb82b9f07a09ee6cb60cf7ec16..18d2ec110fc6670edb079eccf448389d
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Optimize chunkUnload - remove stream
|
||||
CompoundTag compoundTag = packStructureData(
|
||||
StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences()
|
||||
);
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: hayanesuru <mc@jvavav.com>
|
||||
Date: Sat, 19 Apr 2025 22:12:19 +0800
|
||||
Subject: [PATCH] optimize BlockEntityType#isValid
|
||||
Subject: [PATCH] Optimize BlockEntityType#isValid
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/BlockEntityType.java b/net/minecraft/world/level/block/entity/BlockEntityType.java
|
||||
index a2a674f18d7f2c2e50a6b25f9ac3bf4534275976..073b2ca9f1af94934afc39104e0916c97b84ef0e 100644
|
||||
index a2a674f18d7f2c2e50a6b25f9ac3bf4534275976..6be69dcd9faa76ef999daaecc237ee3b4d04c182 100644
|
||||
--- a/net/minecraft/world/level/block/entity/BlockEntityType.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BlockEntityType.java
|
||||
@@ -252,6 +252,14 @@ public class BlockEntityType<T extends BlockEntity> {
|
||||
private BlockEntityType(BlockEntityType.BlockEntitySupplier<? extends T> factory, Set<Block> validBlocks) {
|
||||
this.factory = factory;
|
||||
this.validBlocks = validBlocks;
|
||||
+ // Leaf start
|
||||
+ // Leaf start - Optimize BlockEntityType#isValid
|
||||
+ for (Block validBlock : validBlocks) {
|
||||
+ if (validBlock.blockEntityType != null) {
|
||||
+ throw new IllegalStateException("Duplicate block entity type");
|
||||
+ }
|
||||
+ validBlock.blockEntityType = this;
|
||||
+ }
|
||||
+ // Leaf end
|
||||
+ // Leaf end - Optimize BlockEntityType#isValid
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -28,19 +28,19 @@ index a2a674f18d7f2c2e50a6b25f9ac3bf4534275976..073b2ca9f1af94934afc39104e0916c9
|
||||
|
||||
public boolean isValid(BlockState state) {
|
||||
- return this.validBlocks.contains(state.getBlock());
|
||||
+ return state.getBlock().blockEntityType == this; // Leaf - remove hash lookup
|
||||
+ return state.getBlock().blockEntityType == this; // Leaf - Optimize BlockEntityType#isValid - remove hash lookup
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index d35211b0cae66b1a40e89539507e55973313f46f..fa6d4217f222e8d9decde18e967e951dd833a1c7 100644
|
||||
index d35211b0cae66b1a40e89539507e55973313f46f..3a49690672bc49259e863e5cde7f14d57c89fcd5 100644
|
||||
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -100,6 +100,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||
protected final BlockBehaviour.Properties properties;
|
||||
protected final Optional<ResourceKey<LootTable>> drops;
|
||||
protected final String descriptionId;
|
||||
+ @Nullable public net.minecraft.world.level.block.entity.BlockEntityType blockEntityType = null; // Leaf
|
||||
+ @Nullable public net.minecraft.world.level.block.entity.BlockEntityType blockEntityType = null; // Leaf - Optimize BlockEntityType#isValid
|
||||
|
||||
public BlockBehaviour(BlockBehaviour.Properties properties) {
|
||||
this.hasCollision = properties.hasCollision;
|
||||
Reference in New Issue
Block a user