mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 00:49:31 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@13c80a5e [ci/skip] Fix PlayerShearBlockEvent javadoc typos (#12101) PaperMC/Paper@db2aa180 [ci/skip] Fix incomplete example in javadocs for PreFlattenTagRegistrar (#12102) PaperMC/Paper@cf7c6c74 [ci/skip] Fix incomplete example in javadocs for PostFlattenTagRegistrar (#12103) PaperMC/Paper@072a8317 Add proper attached blocks API to AbstractArrow (#12099) PaperMC/Paper@1be2e5f3 Fix vanilla map decorations sending when not dirty (#12098) PaperMC/Paper@a06179a0 Update entity effect (#12104) PaperMC/Paper@e616498e Add Vault block API (#12068) PaperMC/Paper@0a04c3fe Fix some NPEs (#12105) PaperMC/Paper@06804850 Expand TrialSpawner API (#12025) PaperMC/Paper@46f4fdaa Add support for rotation argument handling (#12090) PaperMC/Paper@6cfa2f7f [ci/skip] Add missing nullability annotation to sendEquipmentChange method (#12112) PaperMC/Paper@9b9de827 Update Alternate Current patch to v1.9.1 (#12115) PaperMC/Paper@c62252e1 Add lore content guard (#12116) PaperMC/Paper@40416784 [ci/skip] Mention missing World#regenerateChunk implementation in jd (#12109) PaperMC/Paper@a6e82d90 [ci/skip] Clarify getChunkAtAsyncUrgently javadocs (#12125) PaperMC/Paper@cb25c0cf [ci/skip] Fix annotation fields used in NMS getBukkitEntity (#12120) PaperMC/Paper@00701267 [ci/skip] improvement example in javadoc for DatapackRegistrar (#12122) PaperMC/Paper@608f004a add method on ItemStack to edit pdc (#12022) PaperMC/Paper@7bee9971 Cleanup damage source a bit (#12106) PaperMC/Paper@b9023b5d Add EntityAttemptSmashAttackEvent (#12113) PaperMC/Paper@a3781ff3 Separate tick count to ensure vanilla parity (#12077) PaperMC/Paper@2a4a1154 Add EntityEquipmentChangedEvent (#12011) PaperMC/Paper@06f96dd6 Improvement in /plugins command (#12121) PaperMC/Paper@28d07dc5 use correct spigot plugin count PaperMC/Paper@60394c5b Fix PlayerReadyArrowEvent cancellation desync (#12111) PaperMC/Paper@b27e11cc Fix bad world to chunk coordinate example in javadocs (#12131) PaperMC/Paper@88cdd220 Fixup luck and random implementation in CB loot-tables (#11926) PaperMC/Paper@84609dc0 Don't auto-create any brig redirects (#11954) PaperMC/Paper@8eb8e44a Allow For Default Titles in InventoryView Builders (#12013) Gale Changes: Dreeam-qwq/Gale@a224af13 Updated Upstream (Paper) Dreeam-qwq/Gale@82f1e30e Updated Upstream (Paper) Dreeam-qwq/Gale@a41cd227 Updated Upstream (Paper) Dreeam-qwq/Gale@73519d55 Updated Upstream (Paper) Purpur Changes: PurpurMC/Purpur@9b046f36 Updated Upstream (Paper) PurpurMC/Purpur@22bd4186 Updated Upstream (Paper)
144 lines
8.5 KiB
Diff
144 lines
8.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
Date: Sat, 2 Nov 2024 04:15:20 -0400
|
|
Subject: [PATCH] Cache chunk key
|
|
|
|
Cache convert process between ChunkPos < - > chunkKey
|
|
This patch didn't cahce SectionPos or BlockPos to chunkKey, since it needs to consider the mutable blockpos siutation.
|
|
|
|
TODO: Cache block pos and section pos, whether need?
|
|
|
|
diff --git a/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java b/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java
|
|
index 1b8193587814225c2ef2c5d9e667436eb50ff6c5..288a3eb57f3431dd624ad8a4b08684563abbc5ad 100644
|
|
--- a/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java
|
|
+++ b/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java
|
|
@@ -127,7 +127,7 @@ public final class NearbyPlayers {
|
|
}
|
|
|
|
public TrackedChunk getChunk(final ChunkPos pos) {
|
|
- return this.byChunk.get(CoordinateUtils.getChunkKey(pos));
|
|
+ return this.byChunk.get(pos.longKey); // Leaf - Cache chunk key
|
|
}
|
|
|
|
public TrackedChunk getChunk(final BlockPos pos) {
|
|
@@ -143,7 +143,7 @@ public final class NearbyPlayers {
|
|
}
|
|
|
|
public ReferenceList<ServerPlayer> getPlayers(final ChunkPos pos, final NearbyMapType type) {
|
|
- return this.directByChunk[type.ordinal()].get(CoordinateUtils.getChunkKey(pos));
|
|
+ return this.directByChunk[type.ordinal()].get(pos.longKey); // Leaf - Cache chunk key
|
|
}
|
|
|
|
public ReferenceList<ServerPlayer> getPlayersByChunk(final int chunkX, final int chunkZ, final NearbyMapType type) {
|
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
|
index b5817aa8f537593f6d9fc6b612c82ccccb250ac7..be820c6093dd2ae7642b9bee11edf65e3a8d7242 100644
|
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
|
@@ -506,7 +506,7 @@ public final class ChunkHolderManager {
|
|
|
|
public <T> boolean addTicketAtLevel(final TicketType<T> type, final ChunkPos chunkPos, final int level,
|
|
final T identifier) {
|
|
- return this.addTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier);
|
|
+ return this.addTicketAtLevel(type, chunkPos.longKey, level, identifier); // Leaf - Cache chunk key
|
|
}
|
|
|
|
public <T> boolean addTicketAtLevel(final TicketType<T> type, final int chunkX, final int chunkZ, final int level,
|
|
@@ -604,7 +604,7 @@ public final class ChunkHolderManager {
|
|
}
|
|
|
|
public <T> boolean removeTicketAtLevel(final TicketType<T> type, final ChunkPos chunkPos, final int level, final T identifier) {
|
|
- return this.removeTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier);
|
|
+ return this.removeTicketAtLevel(type, chunkPos.longKey, level, identifier); // Leaf - Cache chunk key
|
|
}
|
|
|
|
public <T> boolean removeTicketAtLevel(final TicketType<T> type, final int chunkX, final int chunkZ, final int level, final T identifier) {
|
|
@@ -1224,7 +1224,7 @@ public final class ChunkHolderManager {
|
|
}
|
|
|
|
public static <T> TicketOperation<T, T> addOp(final ChunkPos chunk, final TicketType<T> type, final int ticketLevel, final T identifier) {
|
|
- return addOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier);
|
|
+ return addOp(chunk.longKey, type, ticketLevel, identifier); // Leaf - Cache chunk key
|
|
}
|
|
|
|
public static <T> TicketOperation<T, T> addOp(final int chunkX, final int chunkZ, final TicketType<T> type, final int ticketLevel, final T identifier) {
|
|
@@ -1236,7 +1236,7 @@ public final class ChunkHolderManager {
|
|
}
|
|
|
|
public static <T> TicketOperation<T, T> removeOp(final ChunkPos chunk, final TicketType<T> type, final int ticketLevel, final T identifier) {
|
|
- return removeOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier);
|
|
+ return removeOp(chunk.longKey, type, ticketLevel, identifier); // Leaf - Cache chunk key
|
|
}
|
|
|
|
public static <T> TicketOperation<T, T> removeOp(final int chunkX, final int chunkZ, final TicketType<T> type, final int ticketLevel, final T identifier) {
|
|
diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
|
|
index 571db5f9bf94745a8afe2cd313e593fb15db5e37..1487b7d8be435b3fbad2aabd05796965b4775a87 100644
|
|
--- a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
|
|
+++ b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
|
|
@@ -818,7 +818,7 @@ public final class StarLightInterface {
|
|
}
|
|
|
|
public ServerChunkTasks queueChunkLightTask(final ChunkPos pos, final BooleanSupplier lightTask, final Priority priority) {
|
|
- final ServerChunkTasks ret = this.chunkTasks.compute(CoordinateUtils.getChunkKey(pos), (final long keyInMap, ServerChunkTasks valueInMap) -> {
|
|
+ final ServerChunkTasks ret = this.chunkTasks.compute(pos.longKey, (final long keyInMap, ServerChunkTasks valueInMap) -> { // Leaf - Cache chunk key
|
|
if (valueInMap == null) {
|
|
valueInMap = new ServerChunkTasks(
|
|
keyInMap, ServerLightQueue.this.lightInterface, ServerLightQueue.this, priority
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 623d5e02090b18b2b54dd6fc0da5e579021caca5..26223a3c26691303a91b988b6d84373a303785dd 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -508,7 +508,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
@Override
|
|
public final void moonrise$markChunkForPlayerTicking(final LevelChunk chunk) {
|
|
final ChunkPos pos = chunk.getPos();
|
|
- if (!this.playerTickingRequests.containsKey(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(pos))) {
|
|
+ if (!this.playerTickingRequests.containsKey(pos.longKey)) { // Leaf - Cache chunk key
|
|
return;
|
|
}
|
|
|
|
@@ -2570,7 +2570,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
|
|
public boolean isNaturalSpawningAllowed(ChunkPos chunkPos) {
|
|
// Paper start - rewrite chunk system
|
|
- final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos));
|
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos.longKey); // Leaf - Cache chunk key
|
|
return chunkHolder != null && chunkHolder.isEntityTickingReady();
|
|
// Paper end - rewrite chunk system
|
|
}
|
|
diff --git a/net/minecraft/world/level/ChunkPos.java b/net/minecraft/world/level/ChunkPos.java
|
|
index 6e2b2d258e47dcca30a5ad9f4f492598f2bc21fb..f9af074e833a6dab96414750314a27b35ec07bfc 100644
|
|
--- a/net/minecraft/world/level/ChunkPos.java
|
|
+++ b/net/minecraft/world/level/ChunkPos.java
|
|
@@ -54,19 +54,19 @@ public class ChunkPos {
|
|
public ChunkPos(int x, int y) {
|
|
this.x = x;
|
|
this.z = y;
|
|
- this.longKey = asLong(this.x, this.z); // Paper
|
|
+ this.longKey = asLong(this.x, this.z); // Paper // Leaf - Cache chunk key - diff on change
|
|
}
|
|
|
|
public ChunkPos(BlockPos pos) {
|
|
this.x = SectionPos.blockToSectionCoord(pos.getX());
|
|
this.z = SectionPos.blockToSectionCoord(pos.getZ());
|
|
- this.longKey = asLong(this.x, this.z); // Paper
|
|
+ this.longKey = asLong(this.x, this.z); // Paper // Leaf - Cache chunk key - diff on change
|
|
}
|
|
|
|
public ChunkPos(long packedPos) {
|
|
this.x = (int)packedPos;
|
|
this.z = (int)(packedPos >> 32);
|
|
- this.longKey = asLong(this.x, this.z); // Paper
|
|
+ this.longKey = asLong(this.x, this.z); // Paper // Leaf - Cache chunk key - diff on change
|
|
}
|
|
|
|
public static ChunkPos minFromRegion(int chunkX, int chunkZ) {
|
|
@@ -82,7 +82,7 @@ public class ChunkPos {
|
|
}
|
|
|
|
public static long asLong(int x, int z) {
|
|
- return x & 4294967295L | (z & 4294967295L) << 32;
|
|
+ return x & 4294967295L | (z & 4294967295L) << 32; // Leaf - Cache chunk key - diff on change
|
|
}
|
|
|
|
public static long asLong(BlockPos pos) {
|