diff --git a/patches/server/0133-Canvas-Use-VT-executor-for-noise-generating.patch b/patches/server/0133-Canvas-Use-VT-executor-for-noise-generating.patch deleted file mode 100644 index cb02e4883..000000000 --- a/patches/server/0133-Canvas-Use-VT-executor-for-noise-generating.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dueris -Date: Fri, 18 Oct 2024 23:25:34 -0700 -Subject: [PATCH] Canvas: Use VT executor for noise generating - -Original project: https://github.com/CraftCanvasMC/Canvas - -diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -index c991da3d975e07f3e1e59d5b2e91ed629ea608e6..e3b6dd8a8cca9149aab63e68d0a513c06091b5fa 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -267,8 +267,32 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { - - } - -+ private static final java.util.concurrent.ExecutorService noiseGenExecutor = java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor(); // Canvas - Use VT executor for noise generating - @Override - public CompletableFuture fillFromNoise(Blender blender, RandomState noiseConfig, StructureManager structureAccessor, ChunkAccess chunk) { -+ // Canvas start - Use VT executor for noise generating -+ if (true) { -+ NoiseSettings settings = this.settings.value().noiseSettings().clampToHeightAccessor(chunk.getHeightAccessorForGeneration()); -+ int miny = settings.minY(); -+ int minyDiv = Mth.floorDiv(miny, settings.getCellHeight()); -+ int cellHeightDiv = Mth.floorDiv(settings.height(), settings.getCellHeight()); -+ -+ if (cellHeightDiv <= 0) return CompletableFuture.completedFuture(chunk); -+ -+ int startIndex = chunk.getSectionIndex(cellHeightDiv * settings.getCellHeight() - 1 + miny); -+ int minYIndex = chunk.getSectionIndex(miny); -+ -+ LevelChunkSection[] sections = chunk.getSections(); -+ for (int i = startIndex; i >= minYIndex; --i) sections[i].acquire(); -+ -+ return CompletableFuture.supplyAsync(Util.wrapThreadWithTaskName( -+ "wgen_fill_noise", -+ () -> this.doFill(blender, structureAccessor, noiseConfig, chunk, minyDiv, cellHeightDiv) -+ ), Util.backgroundExecutor()).whenCompleteAsync((result, ignored) -> { -+ for (int i = startIndex; i >= minYIndex; --i) sections[i].release(); -+ }, noiseGenExecutor); -+ } -+ // Canvas end - Use VT executor for noise generating - NoiseSettings noisesettings = ((NoiseGeneratorSettings) this.settings.value()).noiseSettings().clampToHeightAccessor(chunk.getHeightAccessorForGeneration()); - int i = noisesettings.minY(); - int j = Mth.floorDiv(i, noisesettings.getCellHeight()); diff --git a/patches/server/0135-Cache-chunk-key.patch b/patches/server/0135-Cache-chunk-key.patch deleted file mode 100644 index 2d0d34c19..000000000 --- a/patches/server/0135-Cache-chunk-key.patch +++ /dev/null @@ -1,214 +0,0 @@ -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 - - -diff --git a/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java b/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java -index 994456ea99d78aebe41398f72019d9f6842172ff..c79fd545a5c5789f74ff1b0ee76daa0c321363d4 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java -+++ b/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java -@@ -95,19 +95,19 @@ public final class NearbyPlayers { - } - - public TrackedChunk getChunk(final ChunkPos pos) { -- return this.byChunk.get(CoordinateUtils.getChunkKey(pos)); -+ return this.byChunk.get(pos.chunkKey); // Leaf - Cache chunk key - } - - public TrackedChunk getChunk(final BlockPos pos) { -- return this.byChunk.get(CoordinateUtils.getChunkKey(pos)); -+ return this.byChunk.get(pos.getChunkKey()); // Leaf - Cache chunk key - } - - public ReferenceList getPlayers(final BlockPos pos, final NearbyMapType type) { -- return this.directByChunk[type.ordinal()].get(CoordinateUtils.getChunkKey(pos)); // Moonrise - Add direct lookup by chunk for NearbyPlayers -+ return this.directByChunk[type.ordinal()].get(pos.getChunkKey()); // Moonrise - Add direct lookup by chunk for NearbyPlayers // Leaf - Cache chunk key - } - - public ReferenceList getPlayers(final ChunkPos pos, final NearbyMapType type) { -- return this.directByChunk[type.ordinal()].get(CoordinateUtils.getChunkKey(pos)); // Moonrise - Add direct lookup by chunk for NearbyPlayers -+ return this.directByChunk[type.ordinal()].get(pos.chunkKey); // Moonrise - Add direct lookup by chunk for NearbyPlayers // Leaf - Cache chunk key - } - - public ReferenceList getPlayersByChunk(final int chunkX, final int chunkZ, final NearbyMapType type) { -diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java b/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java -index 036c1a287db04c0191e5f84b027ea68d31447cbc..68a9e15e0e73351d0b693cf52150de1a0036ca9e 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java -+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/CoordinateUtils.java -@@ -12,7 +12,7 @@ public final class CoordinateUtils { - // the chunk keys are compatible with vanilla - - public static long getChunkKey(final BlockPos pos) { -- return ((long)(pos.getZ() >> 4) << 32) | ((pos.getX() >> 4) & 0xFFFFFFFFL); -+ return ((long)(pos.getZ() >> 4) << 32) | ((pos.getX() >> 4) & 0xFFFFFFFFL); // Leaf - Cache chunk key - } - - public static long getChunkKey(final Entity entity) { -diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -index 58d3d1a47e9f2423c467bb329c2d5f4b58a8b5ef..c4b054cee46076efdcadf4cbb16aca7f8d9c7037 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -@@ -485,7 +485,7 @@ public final class ChunkHolderManager { - - public boolean addTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, - final T identifier) { -- return this.addTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier); -+ return this.addTicketAtLevel(type, chunkPos.chunkKey, level, identifier); // Leaf - Cache chunk key - } - - public boolean addTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, -@@ -583,7 +583,7 @@ public final class ChunkHolderManager { - } - - public boolean removeTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, final T identifier) { -- return this.removeTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier); -+ return this.removeTicketAtLevel(type, chunkPos.chunkKey, level, identifier); // Leaf - Cache chunk key - } - - public boolean removeTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, final T identifier) { -@@ -1204,7 +1204,7 @@ public final class ChunkHolderManager { - } - - public static TicketOperation addOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { -- return addOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier); -+ return addOp(chunk.chunkKey, type, ticketLevel, identifier); // Leaf - Cache chunk key - } - - public static TicketOperation addOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { -@@ -1216,7 +1216,7 @@ public final class ChunkHolderManager { - } - - public static TicketOperation removeOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { -- return removeOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier); -+ return removeOp(chunk.chunkKey, type, ticketLevel, identifier); // Leaf - Cache chunk key - } - - public static TicketOperation removeOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { -diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java b/src/main/java/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java -index c64ab41198a5e0c7cbcbe6452af11f82f5938862..9dd2794bf444850e23d5079ea9bf8e29f8e97c54 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java -+++ b/src/main/java/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java -@@ -678,7 +678,7 @@ public final class StarLightInterface { - - @Override - public synchronized ClientChunkTasks queueBlockChange(final BlockPos pos) { -- final ClientChunkTasks tasks = this.getOrCreate(CoordinateUtils.getChunkKey(pos)); -+ final ClientChunkTasks tasks = this.getOrCreate(pos.getChunkKey()); // Leaf - Cache chunk key - tasks.addChangedPosition(pos); - return tasks; - } -@@ -782,7 +782,7 @@ public final class StarLightInterface { - - @Override - public ServerChunkTasks queueBlockChange(final BlockPos pos) { -- final ServerChunkTasks ret = this.chunkTasks.compute(CoordinateUtils.getChunkKey(pos), (final long keyInMap, ServerChunkTasks valueInMap) -> { -+ final ServerChunkTasks ret = this.chunkTasks.compute(pos.getChunkKey(), (final long keyInMap, ServerChunkTasks valueInMap) -> { // Leaf - Cache chunk key - if (valueInMap == null) { - valueInMap = new ServerChunkTasks( - keyInMap, ServerLightQueue.this.lightInterface, ServerLightQueue.this -@@ -817,7 +817,7 @@ public final class StarLightInterface { - } - - public ServerChunkTasks queueChunkLightTask(final ChunkPos pos, final BooleanSupplier lightTask, final PrioritisedExecutor.Priority priority) { -- final ServerChunkTasks ret = this.chunkTasks.compute(CoordinateUtils.getChunkKey(pos), (final long keyInMap, ServerChunkTasks valueInMap) -> { -+ final ServerChunkTasks ret = this.chunkTasks.compute(pos.chunkKey, (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/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java -index 7b0fc7135bc107103dcaed6dc0707b1829928fae..0e5474ec9b38ea8cb4be5e25a54c2bf03b27851c 100644 ---- a/src/main/java/net/minecraft/core/Vec3i.java -+++ b/src/main/java/net/minecraft/core/Vec3i.java -@@ -19,6 +19,7 @@ public class Vec3i implements Comparable { - protected int x; // Paper - Perf: Manually inline methods in BlockPosition; protected - protected int y; // Paper - Perf: Manually inline methods in BlockPosition; protected - protected int z; // Paper - Perf: Manually inline methods in BlockPosition; protected -+ protected long chunkKey; // Leaf - Cache chunk key - - public static Codec offsetCodec(int maxAbsValue) { - return CODEC.validate( -@@ -38,6 +39,7 @@ public class Vec3i implements Comparable { - this.x = x; - this.y = y; - this.z = z; -+ this.chunkKey = ((long)(this.z >> 4) << 32) | ((this.x >> 4) & 0xFFFFFFFFL); // Leaf - Cache chunk key - } - - @Override -@@ -71,6 +73,12 @@ public class Vec3i implements Comparable { - return this.z; - } - -+ // Leaf start - Cache chunk key -+ public final long getChunkKey() { -+ return this.chunkKey; -+ } -+ // Leaf end - Cache chunk key -+ - protected Vec3i setX(int x) { - this.x = x; - return this; -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 6d8fb4fe9733bd1e83af7f8c148bdb54fa26a14b..6ecb772156d22a5eabdbd4f0b4ab704cc3402b4b 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -2461,21 +2461,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - - public boolean isPositionEntityTicking(BlockPos pos) { - // 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(pos)); -+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(pos.getChunkKey()); // Leaf - Cache chunk key - return chunkHolder != null && chunkHolder.isEntityTickingReady(); - // Paper end - rewrite chunk system - } - - public boolean isNaturalSpawningAllowed(BlockPos pos) { - // 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(pos)); -+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(pos.getChunkKey()); // Leaf - Cache chunk key - return chunkHolder != null && chunkHolder.isEntityTickingReady(); - // Paper end - rewrite chunk system - } - - public boolean isNaturalSpawningAllowed(ChunkPos pos) { - // 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(pos)); -+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(pos.chunkKey); // Leaf - Cache chunk key - return chunkHolder != null && chunkHolder.isEntityTickingReady(); - // Paper end - rewrite chunk system - } -diff --git a/src/main/java/net/minecraft/world/level/ChunkPos.java b/src/main/java/net/minecraft/world/level/ChunkPos.java -index fa58eeec2b652f0fa251eedf11cfabde5fd3198b..c378b47034d846f425c9e519c450925911d36730 100644 ---- a/src/main/java/net/minecraft/world/level/ChunkPos.java -+++ b/src/main/java/net/minecraft/world/level/ChunkPos.java -@@ -21,6 +21,7 @@ public class ChunkPos { - public final int x; - public final int z; - public final long longKey; // Paper -+ public final long chunkKey; // Leaf - Cache chunk key - private static final int HASH_A = 1664525; - private static final int HASH_C = 1013904223; - private static final int HASH_Z_XOR = -559038737; -@@ -29,18 +30,21 @@ public class ChunkPos { - this.x = x; - this.z = z; - this.longKey = asLong(this.x, this.z); // Paper -+ this.chunkKey = ((long)this.z << 32) | (this.x & 0xFFFFFFFFL); // Leaf - Cache chunk key - } - - 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.chunkKey = ((long)this.z << 32) | (this.x & 0xFFFFFFFFL); // Leaf - Cache chunk key - } - - public ChunkPos(long pos) { - this.x = (int)pos; - this.z = (int)(pos >> 32); - this.longKey = asLong(this.x, this.z); // Paper -+ this.chunkKey = ((long)this.z << 32) | (this.x & 0xFFFFFFFFL); // Leaf - Cache chunk key - } - - public static ChunkPos minFromRegion(int x, int z) {