From 303ff90cd3586eb76cfea4b5f970f97bf6781e96 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Thu, 8 May 2025 17:11:08 +0300 Subject: [PATCH] implement back some old patches --- .../features/0008-Misc-Optimizations.patch | 168 ++++++++++++- .../0009-Chunk-System-Optimizations.patch | 236 +++++++++++++++++- .../features/0030-Configurable-MC-67.patch | 4 +- .../0043-Parallel-world-ticking.patch | 14 +- .../0045-Catch-update-suppressors.patch | 4 +- ...0049-Carpet-Fixes-Sheep-Optimization.patch | 126 ++++++++++ .../advancements/Advancement.java.patch | 11 + .../org/bxteam/divinemc/DivineConfig.java | 3 + .../server/0007-lithium-CompactSineLUT.patch | 131 ---------- ...ver-showing-in-ping-before-server-fu.patch | 21 -- ...d-Higher-Java-Version-for-Pufferfish.patch | 19 -- ...0040-Carpet-Fixes-Sheep-Optimization.patch | 131 ---------- ...her-Java-Version-for-Pufferfish-SIMD.patch | 28 --- 13 files changed, 550 insertions(+), 346 deletions(-) create mode 100644 divinemc-server/minecraft-patches/features/0049-Carpet-Fixes-Sheep-Optimization.patch create mode 100644 divinemc-server/minecraft-patches/sources/net/minecraft/advancements/Advancement.java.patch delete mode 100644 patches/removed/1.19.2/server/0007-lithium-CompactSineLUT.patch delete mode 100644 patches/removed/1.19.3/server/0011-Fix-outdated-server-showing-in-ping-before-server-fu.patch delete mode 100644 patches/removed/1.21/api/0008-Add-Higher-Java-Version-for-Pufferfish.patch delete mode 100644 patches/removed/1.21/server/0040-Carpet-Fixes-Sheep-Optimization.patch delete mode 100644 patches/removed/1.21/server/0052-Add-Higher-Java-Version-for-Pufferfish-SIMD.patch diff --git a/divinemc-server/minecraft-patches/features/0008-Misc-Optimizations.patch b/divinemc-server/minecraft-patches/features/0008-Misc-Optimizations.patch index 340ed4b..ff4d573 100644 --- a/divinemc-server/minecraft-patches/features/0008-Misc-Optimizations.patch +++ b/divinemc-server/minecraft-patches/features/0008-Misc-Optimizations.patch @@ -45,6 +45,24 @@ index 761e583a56b1c4a605b0cbb04b61c4df60b8b9bb..c07155589ef44cbbacafe03b36d2cd4c private Lifecycle registryLifecycle; private final Map, HolderSet.Named> frozenTags = new IdentityHashMap<>(); MappedRegistry.TagSet allTags = MappedRegistry.TagSet.unbound(); +diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java +index 00a82873d226f113278632a53c0faca420dd67d4..b28829f9f4c084a8dba35219dae9f4a9f293c416 100644 +--- a/net/minecraft/network/Connection.java ++++ b/net/minecraft/network/Connection.java +@@ -610,13 +610,7 @@ public class Connection extends SimpleChannelInboundHandler> { + if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) + || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.VERIFYING + || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { +- // Paper start - detailed watchdog information +- net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener); +- try { + tickablePacketListener.tick(); +- } finally { +- net.minecraft.network.protocol.PacketUtils.packetProcessing.pop(); +- } // Paper end - detailed watchdog information + } // Paper end - Buffer joins to world + } + diff --git a/net/minecraft/network/VarInt.java b/net/minecraft/network/VarInt.java index 4897ff4648083ebe737ae5b32bae344af27357e4..0d103821d7220daa5cc0d5d3231e794fca0ca055 100644 --- a/net/minecraft/network/VarInt.java @@ -102,6 +120,55 @@ index 4897ff4648083ebe737ae5b32bae344af27357e4..0d103821d7220daa5cc0d5d3231e794f return buffer; } public static ByteBuf writeOld(ByteBuf buffer, int value) { +diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java +index 4535858701b2bb232b9d2feb2af6551526232ddc..e65c62dbe4c1560ae153e4c4344e9194c783a2f4 100644 +--- a/net/minecraft/network/protocol/PacketUtils.java ++++ b/net/minecraft/network/protocol/PacketUtils.java +@@ -21,8 +21,6 @@ public class PacketUtils { + public static void ensureRunningOnSameThread(Packet packet, T processor, BlockableEventLoop executor) throws RunningOnDifferentThreadException { + if (!executor.isSameThread()) { + executor.executeIfPossible(() -> { +- packetProcessing.push(processor); // Paper - detailed watchdog information +- try { // Paper - detailed watchdog information + if (processor instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players + if (processor.shouldHandleMessage(packet)) { + try { +@@ -37,12 +35,6 @@ public class PacketUtils { + } else { + LOGGER.debug("Ignoring packet due to disconnection: {}", packet); + } +- // Paper start - detailed watchdog information +- } finally { +- totalMainThreadPacketsProcessed.getAndIncrement(); +- packetProcessing.pop(); +- } +- // Paper end - detailed watchdog information + }); + throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; + } +@@ -69,22 +61,4 @@ public class PacketUtils { + + packetListener.fillCrashReport(crashReport); + } +- +- // Paper start - detailed watchdog information +- public static final java.util.concurrent.ConcurrentLinkedDeque packetProcessing = new java.util.concurrent.ConcurrentLinkedDeque<>(); +- static final java.util.concurrent.atomic.AtomicLong totalMainThreadPacketsProcessed = new java.util.concurrent.atomic.AtomicLong(); +- +- public static long getTotalProcessedPackets() { +- return totalMainThreadPacketsProcessed.get(); +- } +- +- public static java.util.List getCurrentPacketProcessors() { +- java.util.List listeners = new java.util.ArrayList<>(4); +- for (PacketListener listener : packetProcessing) { +- listeners.add(listener); +- } +- +- return listeners; +- } +- // Paper end - detailed watchdog information + } diff --git a/net/minecraft/server/level/ChunkTrackingView.java b/net/minecraft/server/level/ChunkTrackingView.java index bee90335677f7d8b01589ce5cfd81a40fd422886..a5e488d14fd2016ee188b114d0e681562b5b09cc 100644 --- a/net/minecraft/server/level/ChunkTrackingView.java @@ -125,6 +192,38 @@ index bee90335677f7d8b01589ce5cfd81a40fd422886..a5e488d14fd2016ee188b114d0e68156 } public record Positioned(ChunkPos center, int viewDistance) implements ChunkTrackingView { +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 8fa3af0ebcb92138d0dae858c131db0a710df693..6268bfc05fd9d3669bef20a1ddc5477fbae0f957 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -1312,13 +1312,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + // Paper end - log detailed entity tick information + + public void tickNonPassenger(Entity entity) { +- // Paper start - log detailed entity tick information + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot tick an entity off-main"); +- try { +- if (currentlyTickingEntity.get() == null) { +- currentlyTickingEntity.lazySet(entity); +- } +- // Paper end - log detailed entity tick information + entity.setOldPosAndRot(); + entity.tickCount++; + entity.totalEntityAge++; // Paper - age-like counter for all entities +@@ -1331,13 +1325,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + for (Entity entity1 : entity.getPassengers()) { + this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2 + } +- // Paper start - log detailed entity tick information +- } finally { +- if (currentlyTickingEntity.get() == entity) { +- currentlyTickingEntity.lazySet(null); +- } +- } +- // Paper end - log detailed entity tick information + } + + private void tickPassenger(Entity ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2 diff --git a/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java index 2a708ae0d5bb209650b525e3c56051f8b5655074..4c7670224f0c90c1d0d833ff0b3d908846133b4a 100644 --- a/net/minecraft/util/ClassInstanceMultiMap.java @@ -466,7 +565,7 @@ index a18240418a19a95147341a634527d774f3d5bb92..66f74ad2a194a6676574da2932cf4677 public DebugSampleSubscriptionTracker(PlayerList playerList) { this.playerList = playerList; diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 02adfa3f0ddd86be320156ff18b8e5af5071811b..55713194c53a23b6a6e2d6ffa67d23a71a4d584e 100644 +index 02adfa3f0ddd86be320156ff18b8e5af5071811b..28a4473c1c49098d670031026cc2a52a19214157 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -149,7 +149,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -478,7 +577,50 @@ index 02adfa3f0ddd86be320156ff18b8e5af5071811b..55713194c53a23b6a6e2d6ffa67d23a7 // Paper start - replace random private static final class RandomRandomSource extends ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom { public RandomRandomSource() { -@@ -4503,10 +4503,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1082,28 +1082,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + return this.onGround; + } + +- // Paper start - detailed watchdog information +- public final Object posLock = new Object(); // Paper - log detailed entity tick information +- +- @Nullable +- private Vec3 moveVector; +- private double moveStartX; +- private double moveStartY; +- private double moveStartZ; +- // Paper end - detailed watchdog information +- + public void move(MoverType type, Vec3 movement) { + final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity +- // Paper start - detailed watchdog information + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main"); +- synchronized (this.posLock) { +- this.moveStartX = this.getX(); +- this.moveStartY = this.getY(); +- this.moveStartZ = this.getZ(); +- this.moveVector = movement; +- } +- try { +- // Paper end - detailed watchdog information + if (this.noPhysics) { + this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); + } else { +@@ -1228,13 +1209,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + this.setDeltaMovement(this.getDeltaMovement().multiply(blockSpeedFactor, 1.0, blockSpeedFactor)); + } + } +- // Paper start - detailed watchdog information +- } finally { +- synchronized (this.posLock) { // Paper +- this.moveVector = null; +- } // Paper +- } +- // Paper end - detailed watchdog information + } + + private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { +@@ -4503,10 +4477,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper start - optimise collisions public boolean updateFluidHeightAndDoFluidPushing(final TagKey fluid, final double flowScale) { @@ -489,7 +631,7 @@ index 02adfa3f0ddd86be320156ff18b8e5af5071811b..55713194c53a23b6a6e2d6ffa67d23a7 final AABB boundingBox = this.getBoundingBox().deflate(1.0E-3); final Level world = this.level; -@@ -4542,7 +4538,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4542,7 +4512,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) { for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) { @@ -502,6 +644,26 @@ index 02adfa3f0ddd86be320156ff18b8e5af5071811b..55713194c53a23b6a6e2d6ffa67d23a7 // bound y for (int currChunkY = minChunkY; currChunkY <= maxChunkY; ++currChunkY) { +@@ -4699,9 +4673,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + + public void setDeltaMovement(Vec3 deltaMovement) { +- synchronized (this.posLock) { // Paper - detailed watchdog information + this.deltaMovement = deltaMovement; +- } // Paper - detailed watchdog information + } + + public void addDeltaMovement(Vec3 addend) { +@@ -4809,9 +4781,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + // Paper end - Fix MC-4 + if (this.position.x != x || this.position.y != y || this.position.z != z) { +- synchronized (this.posLock) { // Paper - detailed watchdog information + this.position = new Vec3(x, y, z); +- } // Paper - detailed watchdog information + int floor = Mth.floor(x); + int floor1 = Mth.floor(y); + int floor2 = Mth.floor(z); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java index 5bcbebf35eb726a43b957aca5b8b7a1dca7648cd..d618752727e2f2f5c0c1afa97f455e349cb7e76c 100644 --- a/net/minecraft/world/entity/Mob.java diff --git a/divinemc-server/minecraft-patches/features/0009-Chunk-System-Optimizations.patch b/divinemc-server/minecraft-patches/features/0009-Chunk-System-Optimizations.patch index 314ceec..115ab14 100644 --- a/divinemc-server/minecraft-patches/features/0009-Chunk-System-Optimizations.patch +++ b/divinemc-server/minecraft-patches/features/0009-Chunk-System-Optimizations.patch @@ -1032,7 +1032,7 @@ index 4d4139b5f42a4db6e22bf1d063a23dc7b9914f85..9a65321ce62f21b150d29be30dbae7db } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 8fa3af0ebcb92138d0dae858c131db0a710df693..e351b75f03b7096dcd0378b49987d27c04474116 100644 +index 6268bfc05fd9d3669bef20a1ddc5477fbae0f957..2ebd77db2d13d04513689ff332404c6af6a3c11d 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -177,6 +177,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1139,7 +1139,7 @@ index 8fa3af0ebcb92138d0dae858c131db0a710df693..e351b75f03b7096dcd0378b49987d27c } // Paper end - optimise random ticking -@@ -2532,16 +2534,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2519,16 +2521,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean isPositionTickingWithEntitiesLoaded(long chunkPos) { // Paper start - rewrite chunk system @@ -3245,6 +3245,238 @@ index bb8b5ca9044ecb33687e7f20cfb0acbf55f887c7..df3a1b9ed4ad836bd3358b6b440964e4 private Vec3i size = Vec3i.ZERO; private String author = "?"; // CraftBukkit start - data containers +diff --git a/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java b/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java +index 46e98a99442523614284150964ba528d0c91493f..75df6465823ebacad48f3a0b3560c89ab3b6b093 100644 +--- a/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java ++++ b/net/minecraft/world/level/levelgen/synth/ImprovedNoise.java +@@ -11,6 +11,27 @@ public final class ImprovedNoise { + public final double yo; + public final double zo; + ++ // DivineMC start - Chunk System Optimizations ++ private static final double[] FLAT_SIMPLEX_GRAD = new double[]{ ++ 1, 1, 0, 0, ++ -1, 1, 0, 0, ++ 1, -1, 0, 0, ++ -1, -1, 0, 0, ++ 1, 0, 1, 0, ++ -1, 0, 1, 0, ++ 1, 0, -1, 0, ++ -1, 0, -1, 0, ++ 0, 1, 1, 0, ++ 0, -1, 1, 0, ++ 0, 1, -1, 0, ++ 0, -1, -1, 0, ++ 1, 1, 0, 0, ++ 0, -1, 1, 0, ++ -1, 1, 0, 0, ++ 0, -1, -1, 0, ++ }; ++ // DivineMC end - Chunk System Optimizations ++ + public ImprovedNoise(RandomSource random) { + this.xo = random.nextDouble() * 256.0; + this.yo = random.nextDouble() * 256.0; +@@ -38,9 +59,11 @@ public final class ImprovedNoise { + double d = x + this.xo; + double d1 = y + this.yo; + double d2 = z + this.zo; +- int floor = Mth.floor(d); +- int floor1 = Mth.floor(d1); +- int floor2 = Mth.floor(d2); ++ // DivineMC start - Chunk System Optimizations ++ double floor = Math.floor(d); ++ double floor1 = Math.floor(d1); ++ double floor2 = Math.floor(d2); ++ // DivineMC end - Chunk System Optimizations + double d3 = d - floor; + double d4 = d1 - floor1; + double d5 = d2 - floor2; +@@ -53,25 +76,27 @@ public final class ImprovedNoise { + d6 = d4; + } + +- d7 = Mth.floor(d6 / yScale + 1.0E-7F) * yScale; ++ d7 = Math.floor(d6 / yScale + 1.0E-7F) * yScale; // DivineMC - Chunk System Optimizations + } else { + d7 = 0.0; + } + +- return this.sampleAndLerp(floor, floor1, floor2, d3, d4 - d7, d5, d4); ++ return this.sampleAndLerp((int) floor, (int) floor1, (int) floor2, d3, d4 - d7, d5, d4); // DivineMC - Chunk System Optimizations + } + + public double noiseWithDerivative(double x, double y, double z, double[] values) { + double d = x + this.xo; + double d1 = y + this.yo; + double d2 = z + this.zo; +- int floor = Mth.floor(d); +- int floor1 = Mth.floor(d1); +- int floor2 = Mth.floor(d2); ++ // DivineMC start - Chunk System Optimizations ++ double floor = Math.floor(d); ++ double floor1 = Math.floor(d1); ++ double floor2 = Math.floor(d2); ++ // DivineMC end - Chunk System Optimizations + double d3 = d - floor; + double d4 = d1 - floor1; + double d5 = d2 - floor2; +- return this.sampleWithDerivative(floor, floor1, floor2, d3, d4, d5, values); ++ return this.sampleWithDerivative((int) floor, (int) floor1, (int) floor2, d3, d4, d5, values); // DivineMC - Chunk System Optimizations + } + + private static double gradDot(int gradIndex, double xFactor, double yFactor, double zFactor) { +@@ -83,24 +108,69 @@ public final class ImprovedNoise { + } + + private double sampleAndLerp(int gridX, int gridY, int gridZ, double deltaX, double weirdDeltaY, double deltaZ, double deltaY) { +- int i = this.p(gridX); +- int i1 = this.p(gridX + 1); +- int i2 = this.p(i + gridY); +- int i3 = this.p(i + gridY + 1); +- int i4 = this.p(i1 + gridY); +- int i5 = this.p(i1 + gridY + 1); +- double d = gradDot(this.p(i2 + gridZ), deltaX, weirdDeltaY, deltaZ); +- double d1 = gradDot(this.p(i4 + gridZ), deltaX - 1.0, weirdDeltaY, deltaZ); +- double d2 = gradDot(this.p(i3 + gridZ), deltaX, weirdDeltaY - 1.0, deltaZ); +- double d3 = gradDot(this.p(i5 + gridZ), deltaX - 1.0, weirdDeltaY - 1.0, deltaZ); +- double d4 = gradDot(this.p(i2 + gridZ + 1), deltaX, weirdDeltaY, deltaZ - 1.0); +- double d5 = gradDot(this.p(i4 + gridZ + 1), deltaX - 1.0, weirdDeltaY, deltaZ - 1.0); +- double d6 = gradDot(this.p(i3 + gridZ + 1), deltaX, weirdDeltaY - 1.0, deltaZ - 1.0); +- double d7 = gradDot(this.p(i5 + gridZ + 1), deltaX - 1.0, weirdDeltaY - 1.0, deltaZ - 1.0); +- double d8 = Mth.smoothstep(deltaX); +- double d9 = Mth.smoothstep(deltaY); +- double d10 = Mth.smoothstep(deltaZ); +- return Mth.lerp3(d8, d9, d10, d, d1, d2, d3, d4, d5, d6, d7); ++ // DivineMC start - Chunk System Optimizations ++ final int var0 = gridX & 0xFF; ++ final int var1 = (gridX + 1) & 0xFF; ++ final int var2 = this.p[var0] & 0xFF; ++ final int var3 = this.p[var1] & 0xFF; ++ final int var4 = (var2 + gridY) & 0xFF; ++ final int var5 = (var3 + gridY) & 0xFF; ++ final int var6 = (var2 + gridY + 1) & 0xFF; ++ final int var7 = (var3 + gridY + 1) & 0xFF; ++ final int var8 = this.p[var4] & 0xFF; ++ final int var9 = this.p[var5] & 0xFF; ++ final int var10 = this.p[var6] & 0xFF; ++ final int var11 = this.p[var7] & 0xFF; ++ ++ final int var12 = (var8 + gridZ) & 0xFF; ++ final int var13 = (var9 + gridZ) & 0xFF; ++ final int var14 = (var10 + gridZ) & 0xFF; ++ final int var15 = (var11 + gridZ) & 0xFF; ++ final int var16 = (var8 + gridZ + 1) & 0xFF; ++ final int var17 = (var9 + gridZ + 1) & 0xFF; ++ final int var18 = (var10 + gridZ + 1) & 0xFF; ++ final int var19 = (var11 + gridZ + 1) & 0xFF; ++ final int var20 = (this.p[var12] & 15) << 2; ++ final int var21 = (this.p[var13] & 15) << 2; ++ final int var22 = (this.p[var14] & 15) << 2; ++ final int var23 = (this.p[var15] & 15) << 2; ++ final int var24 = (this.p[var16] & 15) << 2; ++ final int var25 = (this.p[var17] & 15) << 2; ++ final int var26 = (this.p[var18] & 15) << 2; ++ final int var27 = (this.p[var19] & 15) << 2; ++ final double var60 = deltaX - 1.0; ++ final double var61 = weirdDeltaY - 1.0; ++ final double var62 = deltaZ - 1.0; ++ final double var87 = FLAT_SIMPLEX_GRAD[(var20) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var20) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var20) | 2] * deltaZ; ++ final double var88 = FLAT_SIMPLEX_GRAD[(var21) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var21) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var21) | 2] * deltaZ; ++ final double var89 = FLAT_SIMPLEX_GRAD[(var22) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var22) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var22) | 2] * deltaZ; ++ final double var90 = FLAT_SIMPLEX_GRAD[(var23) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var23) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var23) | 2] * deltaZ; ++ final double var91 = FLAT_SIMPLEX_GRAD[(var24) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var24) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var24) | 2] * var62; ++ final double var92 = FLAT_SIMPLEX_GRAD[(var25) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var25) | 1] * weirdDeltaY + FLAT_SIMPLEX_GRAD[(var25) | 2] * var62; ++ final double var93 = FLAT_SIMPLEX_GRAD[(var26) | 0] * deltaX + FLAT_SIMPLEX_GRAD[(var26) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var26) | 2] * var62; ++ final double var94 = FLAT_SIMPLEX_GRAD[(var27) | 0] * var60 + FLAT_SIMPLEX_GRAD[(var27) | 1] * var61 + FLAT_SIMPLEX_GRAD[(var27) | 2] * var62; ++ ++ final double var95 = deltaX * 6.0 - 15.0; ++ final double var96 = deltaY * 6.0 - 15.0; ++ final double var97 = deltaZ * 6.0 - 15.0; ++ final double var98 = deltaX * var95 + 10.0; ++ final double var99 = deltaY * var96 + 10.0; ++ final double var100 = deltaZ * var97 + 10.0; ++ final double var101 = deltaX * deltaX * deltaX * var98; ++ final double var102 = deltaY * deltaY * deltaY * var99; ++ final double var103 = deltaZ * deltaZ * deltaZ * var100; ++ ++ final double var113 = var87 + var101 * (var88 - var87); ++ final double var114 = var93 + var101 * (var94 - var93); ++ final double var115 = var91 + var101 * (var92 - var91); ++ final double var116 = var89 + var101 * (var90 - var89); ++ final double var117 = var114 - var115; ++ final double var118 = var102 * (var116 - var113); ++ final double var119 = var102 * var117; ++ final double var120 = var113 + var118; ++ final double var121 = var115 + var119; ++ return var120 + (var103 * (var121 - var120)); ++ // DivineMC end - Chunk System Optimizations + } + + private double sampleWithDerivative(int gridX, int gridY, int gridZ, double deltaX, double deltaY, double deltaZ, double[] noiseValues) { +diff --git a/net/minecraft/world/level/levelgen/synth/PerlinNoise.java b/net/minecraft/world/level/levelgen/synth/PerlinNoise.java +index ffac5b7b1eb1364ab8442d7145a7b4ebde68ee10..d331259b0bcf2d3c27718497ff2593a29d1558d0 100644 +--- a/net/minecraft/world/level/levelgen/synth/PerlinNoise.java ++++ b/net/minecraft/world/level/levelgen/synth/PerlinNoise.java +@@ -26,6 +26,10 @@ public class PerlinNoise { + public final double lowestFreqValueFactor; + public final double lowestFreqInputFactor; + private final double maxValue; ++ // DivineMC start - Chunk System Optimizations ++ private final int octaveSamplersCount; ++ private final double [] amplitudesArray; ++ // DivineMC end - Chunk System Optimizations + + @Deprecated + public static PerlinNoise createLegacyForBlendedNoise(RandomSource random, IntStream octaves) { +@@ -127,6 +131,10 @@ public class PerlinNoise { + this.lowestFreqInputFactor = Math.pow(2.0, -i); + this.lowestFreqValueFactor = Math.pow(2.0, size - 1) / (Math.pow(2.0, size) - 1.0); + this.maxValue = this.edgeValue(2.0); ++ // DivineMC start - Chunk System Optimizations ++ this.octaveSamplersCount = this.noiseLevels.length; ++ this.amplitudesArray = this.amplitudes.toDoubleArray(); ++ // DivineMC end - Chunk System Optimizations + } + + protected double maxValue() { +@@ -138,7 +146,26 @@ public class PerlinNoise { + } + + public double getValue(double x, double y, double z) { +- return this.getValue(x, y, z, 0.0, 0.0, false); ++ // DivineMC start - Chunk System Optimizations ++ double d = 0.0; ++ double e = this.lowestFreqInputFactor; ++ double f = this.lowestFreqValueFactor; ++ ++ for (int i = 0; i < this.octaveSamplersCount; ++i) { ++ ImprovedNoise perlinNoiseSampler = this.noiseLevels[i]; ++ if (perlinNoiseSampler != null) { ++ double g = perlinNoiseSampler.noise( ++ wrap(x * e), wrap(y * e), wrap(z * e), 0.0, 0.0 ++ ); ++ d += this.amplitudesArray[i] * g * f; ++ } ++ ++ e *= 2.0; ++ f /= 2.0; ++ } ++ ++ return d; ++ // DivineMC end - Chunk System Optimizations + } + + @Deprecated +@@ -187,7 +214,7 @@ public class PerlinNoise { + } + + public static double wrap(double value) { +- return value - Mth.lfloor(value / 3.3554432E7 + 0.5) * 3.3554432E7; ++ return value - Math.floor(value / 3.3554432E7 + 0.5) * 3.3554432E7; // DivineMC - Chunk System Optimizations + } + + protected int firstOctave() { diff --git a/net/minecraft/world/ticks/LevelChunkTicks.java b/net/minecraft/world/ticks/LevelChunkTicks.java index 66d0a6390febe929ef774b0a7813329015bc8cc2..d1917dee4ca6bba5f2c92475811c724caf2948cb 100644 --- a/net/minecraft/world/ticks/LevelChunkTicks.java diff --git a/divinemc-server/minecraft-patches/features/0030-Configurable-MC-67.patch b/divinemc-server/minecraft-patches/features/0030-Configurable-MC-67.patch index 5816c78..246f3d6 100644 --- a/divinemc-server/minecraft-patches/features/0030-Configurable-MC-67.patch +++ b/divinemc-server/minecraft-patches/features/0030-Configurable-MC-67.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable MC-67 diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 55713194c53a23b6a6e2d6ffa67d23a71a4d584e..76f56340a8d18d893e15b3909856a5e73cdee644 100644 +index 28a4473c1c49098d670031026cc2a52a19214157..7c0d9fa1f98d25fe3271a054a3da98e94fd9da52 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -3962,6 +3962,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3936,6 +3936,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public boolean canTeleport(Level fromLevel, Level toLevel) { diff --git a/divinemc-server/minecraft-patches/features/0043-Parallel-world-ticking.patch b/divinemc-server/minecraft-patches/features/0043-Parallel-world-ticking.patch index 3903d80..7c48cb7 100644 --- a/divinemc-server/minecraft-patches/features/0043-Parallel-world-ticking.patch +++ b/divinemc-server/minecraft-patches/features/0043-Parallel-world-ticking.patch @@ -228,7 +228,7 @@ index 3f9b26de801b2d8e85c56d219ca7bd61c41b3f9d..8fa8cd1a06c86c8424d43b588ff13a91 this.setFlightAllowed(properties.allowFlight); this.setMotd(properties.motd); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 27ff3ae4400de969c95eb337cfd88f8137c77d3b..857439f7b59549cff75e318fdf9c1effe83c7e17 100644 +index 04ef12b1cff4d7baf0835b48825db82b2657123e..86d4a41195ade54c2bdc8b44141a458337cc98bc 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -179,7 +179,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -292,7 +292,7 @@ index 27ff3ae4400de969c95eb337cfd88f8137c77d3b..857439f7b59549cff75e318fdf9c1eff } // Paper start - log detailed entity tick information -@@ -1560,6 +1562,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1547,6 +1549,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } private void addPlayer(ServerPlayer player) { @@ -300,7 +300,7 @@ index 27ff3ae4400de969c95eb337cfd88f8137c77d3b..857439f7b59549cff75e318fdf9c1eff Entity entity = this.getEntity(player.getUUID()); if (entity != null) { LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID()); -@@ -1572,7 +1575,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1559,7 +1562,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit start private boolean addEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { @@ -404,10 +404,10 @@ index 9f3afab438199dbaf40fa1a64b6ecdae74c0a34d..8923a30daf515262e4bdbfbd55e3cb82 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 ffa39efc1a3edcf3242305138a0571f2af4abcec..cba128337fbf96a3af167d8cbcd8057a78f8faf2 100644 +index 4ffccdb6295d850e1e089633f2ee85c2c6f5fd47..c6accc73532be89b9c3c2115a2d784b7636af6bc 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -3249,14 +3249,34 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3223,14 +3223,34 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess if (this.portalProcess != null) { if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) { this.setPortalCooldown(); @@ -448,7 +448,7 @@ index ffa39efc1a3edcf3242305138a0571f2af4abcec..cba128337fbf96a3af167d8cbcd8057a } else if (this.portalProcess.hasExpired()) { this.portalProcess = null; } -@@ -3821,6 +3841,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3795,6 +3815,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } private Entity teleportCrossDimension(ServerLevel level, TeleportTransition teleportTransition) { @@ -669,7 +669,7 @@ index 6575e8ef16f6011f7a799ba31531a2ebefee0c4d..407f00af5aac495eb116e4cf8a05fcc6 } else { Entity entity = owner.teleport( diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index 8e97a20306652cdfc757b7102a07c58ce0e339e3..8b691f9b0283cf1847c40a57892395763751aad3 100644 +index c4721eb0efe34f5e313bc890b4e960144eca4fe1..5965d2844713072d81a16a64a047a4907ba2b016 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java @@ -96,8 +96,14 @@ public abstract class AbstractContainerMenu { diff --git a/divinemc-server/minecraft-patches/features/0045-Catch-update-suppressors.patch b/divinemc-server/minecraft-patches/features/0045-Catch-update-suppressors.patch index ca73e6e..ef05dff 100644 --- a/divinemc-server/minecraft-patches/features/0045-Catch-update-suppressors.patch +++ b/divinemc-server/minecraft-patches/features/0045-Catch-update-suppressors.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Catch update suppressors diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java -index 4535858701b2bb232b9d2feb2af6551526232ddc..aa4dd7517e8be167aef1eaf7aa907e3ce7cc0e62 100644 +index e65c62dbe4c1560ae153e4c4344e9194c783a2f4..e3d3b062e273fee4a9d3ba3cadc212787096dc54 100644 --- a/net/minecraft/network/protocol/PacketUtils.java +++ b/net/minecraft/network/protocol/PacketUtils.java -@@ -27,6 +27,10 @@ public class PacketUtils { +@@ -25,6 +25,10 @@ public class PacketUtils { if (processor.shouldHandleMessage(packet)) { try { packet.handle(processor); diff --git a/divinemc-server/minecraft-patches/features/0049-Carpet-Fixes-Sheep-Optimization.patch b/divinemc-server/minecraft-patches/features/0049-Carpet-Fixes-Sheep-Optimization.patch new file mode 100644 index 0000000..c4ee115 --- /dev/null +++ b/divinemc-server/minecraft-patches/features/0049-Carpet-Fixes-Sheep-Optimization.patch @@ -0,0 +1,126 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> +Date: Thu, 8 May 2025 16:49:29 +0300 +Subject: [PATCH] Carpet-Fixes: Sheep Optimization + +This patch is based on the following mixins and classes: +* "carpetfixes/helpers/Utils.java" +* "carpetfixes/mixins/optimizations/SheepEntity_childColorMixin.java" +By: fxmorin <28154542+fxmorin@users.noreply.github.com> +As part of: carpet-fixes (https://github.com/fxmorin/carpet-fixes) +Licensed under: MIT (https://opensource.org/licenses/MIT) + +Patch description: + +The game determines the child sheep's color by getting a wool block from the parents, putting them in a crafting +recipe, getting the output wool and getting the color from that. +I don't know in what world we would consider a data-driven method with that much overhead as a smart idea. Instead, +we used a prebaked list of all the possible colors and combinations, however this means that you can't use a +datapack to change it. + +diff --git a/net/minecraft/world/item/DyeColor.java b/net/minecraft/world/item/DyeColor.java +index 6bac07817d2916c64f703586599a2cab226872e6..0b6eb7da40b1dc956da06abfb6145a69525fb89b 100644 +--- a/net/minecraft/world/item/DyeColor.java ++++ b/net/minecraft/world/item/DyeColor.java +@@ -112,6 +112,15 @@ public enum DyeColor implements StringRepresentable { + } + + public static DyeColor getMixedColor(ServerLevel level, DyeColor first, DyeColor second) { ++ // DivineMC start - Carpet-Fixes: Sheep Optimization ++ if (org.bxteam.divinemc.DivineConfig.sheepOptimization) { ++ DyeColor col = properDye(first, second); ++ ++ if (col == null) col = level.random.nextBoolean() ? first : second; ++ ++ return col; ++ } ++ // DivineMC end - Carpet-Fixes: Sheep Optimization + CraftingInput craftingInput = makeCraftColorInput(first, second); + return level.recipeAccess() + .getRecipeFor(RecipeType.CRAFTING, craftingInput, level) +@@ -132,4 +141,85 @@ public enum DyeColor implements StringRepresentable { + return values()[random.nextInt(values().length)]; + } + // Purpur end - Shulker spawn from bullet options ++ ++ // DivineMC start - Carpet-Fixes: Sheep Optimization ++ private static DyeColor properDye(DyeColor firstColor, DyeColor secondColor) { ++ if (firstColor.equals(secondColor)) return firstColor; ++ ++ switch (firstColor) { ++ case WHITE -> { ++ switch (secondColor) { ++ case BLUE -> { ++ return DyeColor.LIGHT_BLUE; ++ } ++ case GRAY -> { ++ return DyeColor.LIGHT_GRAY; ++ } ++ case BLACK -> { ++ return DyeColor.GRAY; ++ } ++ case GREEN -> { ++ return DyeColor.LIME; ++ } ++ case RED -> { ++ return DyeColor.PINK; ++ } ++ } ++ } ++ case BLUE -> { ++ switch (secondColor) { ++ case WHITE -> { ++ return DyeColor.LIGHT_BLUE; ++ } ++ case GREEN -> { ++ return DyeColor.CYAN; ++ } ++ case RED -> { ++ return DyeColor.PURPLE; ++ } ++ } ++ } ++ case RED -> { ++ switch (secondColor) { ++ case YELLOW -> { ++ return DyeColor.ORANGE; ++ } ++ case WHITE -> { ++ return DyeColor.PINK; ++ } ++ case BLUE -> { ++ return DyeColor.PURPLE; ++ } ++ } ++ } ++ case GREEN -> { ++ switch (secondColor) { ++ case BLUE -> { ++ return DyeColor.CYAN; ++ } ++ case WHITE -> { ++ return DyeColor.LIME; ++ } ++ } ++ } ++ case YELLOW -> { ++ if (secondColor.equals(DyeColor.RED)) return DyeColor.ORANGE; ++ } ++ case PURPLE -> { ++ if (secondColor.equals(DyeColor.PINK)) return DyeColor.MAGENTA; ++ } ++ case PINK -> { ++ if (secondColor.equals(DyeColor.PURPLE)) return DyeColor.MAGENTA; ++ } ++ case GRAY -> { ++ if (secondColor.equals(DyeColor.WHITE)) return DyeColor.LIGHT_GRAY; ++ } ++ case BLACK -> { ++ if (secondColor.equals(DyeColor.WHITE)) return DyeColor.GRAY; ++ } ++ } ++ ++ return null; ++ } ++ // DivineMC end - Carpet-Fixes: Sheep Optimization + } diff --git a/divinemc-server/minecraft-patches/sources/net/minecraft/advancements/Advancement.java.patch b/divinemc-server/minecraft-patches/sources/net/minecraft/advancements/Advancement.java.patch new file mode 100644 index 0000000..fc813cb --- /dev/null +++ b/divinemc-server/minecraft-patches/sources/net/minecraft/advancements/Advancement.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/advancements/Advancement.java ++++ b/net/minecraft/advancements/Advancement.java +@@ -61,7 +_,7 @@ + AdvancementRequirements requirements, + boolean sendsTelemetryEvent + ) { +- this(parent, display, rewards, Map.copyOf(criteria), requirements, sendsTelemetryEvent, display.map(Advancement::decorateName)); ++ this(parent, display, rewards, criteria, requirements, sendsTelemetryEvent, display.map(Advancement::decorateName)); // DivineMC - Mirai - skip cloning advancement criteria + } + + private static DataResult validate(Advancement advancement) { diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java index c7bd453..40adb0a 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java @@ -281,6 +281,7 @@ public class DivineConfig { public static boolean disableLeafDecay = false; public static boolean commandBlockParseResultsCaching = true; public static boolean enableAsyncSpawning = true; + public static boolean sheepOptimization = true; public static boolean hopperThrottleWhenFull = false; public static int hopperThrottleSkipTicks = 0; private static void miscSettings() { @@ -304,6 +305,8 @@ public class DivineConfig { "Caches the parse results of command blocks, can significantly reduce performance impact."); enableAsyncSpawning = getBoolean("settings.misc.enable-async-spawning", enableAsyncSpawning, "Enables optimization that will offload much of the computational effort involved with spawning new mobs to a different thread."); + sheepOptimization = getBoolean("settings.misc.sheep-optimization", sheepOptimization, + "Enables optimization from Carpet Fixes mod, using a prebaked list of all the possible colors and combinations for sheep."); hopperThrottleWhenFull = getBoolean("settings.misc.hopper-throttle-when-full.enabled", hopperThrottleWhenFull, "When enabled, hoppers will throttle if target container is full."); diff --git a/patches/removed/1.19.2/server/0007-lithium-CompactSineLUT.patch b/patches/removed/1.19.2/server/0007-lithium-CompactSineLUT.patch deleted file mode 100644 index 00ad946..0000000 --- a/patches/removed/1.19.2/server/0007-lithium-CompactSineLUT.patch +++ /dev/null @@ -1,131 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: JellySquid -Date: Fri, 5 Feb 2021 00:16:30 -0600 -Subject: [PATCH] lithium: CompactSineLUT - -Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0 -You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings) - -diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java b/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java -new file mode 100644 -index 0000000000000000000000000000000000000000..b8c9cb28876c2c1781cd72870076d528b9647916 ---- /dev/null -+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java -@@ -0,0 +1,90 @@ -+package me.jellysquid.mods.lithium.common.util.math; -+ -+import net.minecraft.util.Mth; -+ -+/** -+ * A replacement for the sine angle lookup table used in {@link Mth}, both reducing the size of LUT and improving -+ * the access patterns for common paired sin/cos operations. -+ * -+ * sin(-x) = -sin(x) -+ * ... to eliminate negative angles from the LUT. -+ * -+ * sin(x) = sin(pi/2 - x) -+ * ... to eliminate supplementary angles from the LUT. -+ * -+ * Using these identities allows us to reduce the LUT from 64K entries (256 KB) to just 16K entries (64 KB), enabling -+ * it to better fit into the CPU's caches at the expense of some cycles on the fast path. The implementation has been -+ * tightly optimized to avoid branching where possible and to use very quick integer operations. -+ * -+ * Generally speaking, reducing the size of a lookup table is always a good optimization, but since we need to spend -+ * extra CPU cycles trying to maintain parity with vanilla, there is the potential risk that this implementation ends -+ * up being slower than vanilla when the lookup table is able to be kept in cache memory. -+ * -+ * Unlike other "fast math" implementations, the values returned by this class are *bit-for-bit identical* with those -+ * from {@link Mth}. Validation is performed during runtime to ensure that the table is correct. -+ * -+ * @author coderbot16 Author of the original (and very clever) implementation in Rust: -+ * https://gitlab.com/coderbot16/i73/-/tree/master/i73-trig/src -+ * @author jellysquid3 Additional optimizations, port to Java -+ */ -+public class CompactSineLUT { -+ private static final int[] SINE_TABLE_INT = new int[16384 + 1]; -+ private static final float SINE_TABLE_MIDPOINT; -+ -+ static { -+ final float[] SINE_TABLE = Mth.getSinTable(); -+ // Copy the sine table, covering to raw int bits -+ for (int i = 0; i < SINE_TABLE_INT.length; i++) { -+ SINE_TABLE_INT[i] = Float.floatToRawIntBits(SINE_TABLE[i]); -+ } -+ -+ SINE_TABLE_MIDPOINT = SINE_TABLE[SINE_TABLE.length / 2]; -+ -+ // Test that the lookup table is correct during runtime -+ for (int i = 0; i < SINE_TABLE.length; i++) { -+ float expected = SINE_TABLE[i]; -+ float value = lookup(i); -+ -+ if (expected != value) { -+ throw new IllegalArgumentException(String.format("LUT error at index %d (expected: %s, found: %s)", i, expected, value)); -+ } -+ } -+ } -+ -+ // [VanillaCopy] MathHelper#sin(float) -+ public static float sin(float f) { -+ return lookup((int) (f * 10430.378f) & 0xFFFF); -+ } -+ -+ // [VanillaCopy] MathHelper#cos(float) -+ public static float cos(float f) { -+ return lookup((int) (f * 10430.378f + 16384.0f) & 0xFFFF); -+ } -+ -+ private static float lookup(int index) { -+ // A special case... Is there some way to eliminate this? -+ if (index == 32768) { -+ return SINE_TABLE_MIDPOINT; -+ } -+ -+ // Trigonometric identity: sin(-x) = -sin(x) -+ // Given a domain of 0 <= x <= 2*pi, just negate the value if x > pi. -+ // This allows the sin table size to be halved. -+ int neg = (index & 0x8000) << 16; -+ -+ // All bits set if (pi/2 <= x), none set otherwise -+ // Extracts the 15th bit from 'half' -+ int mask = (index << 17) >> 31; -+ -+ // Trigonometric identity: sin(x) = sin(pi/2 - x) -+ int pos = (0x8001 & mask) + (index ^ mask); -+ -+ // Wrap the position in the table. Moving this down to immediately before the array access -+ // seems to help the Hotspot compiler optimize the bit math better. -+ pos &= 0x7fff; -+ -+ // Fetch the corresponding value from the LUT and invert the sign bit as needed -+ // This directly manipulate the sign bit on the float bits to simplify logic -+ return Float.intBitsToFloat(SINE_TABLE_INT[pos] ^ neg); -+ } -+} -\ No newline at end of file -diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java -index 9b22034aa655ceb0da151d9d8ca3147f6487889a..ec587cf6592a1dc0d90d6f54af1bdfab97aec7c6 100644 ---- a/src/main/java/net/minecraft/util/Mth.java -+++ b/src/main/java/net/minecraft/util/Mth.java -@@ -32,6 +32,7 @@ public class Mth { - - }); - private static final RandomSource RANDOM = RandomSource.createThreadSafe(); -+ public static float[] getSinTable() { return SIN; } // DivineMC - lithium: CompactSineLUT - private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; - private static final double ONE_SIXTH = 0.16666666666666666D; - private static final int FRAC_EXP = 8; -@@ -41,11 +42,11 @@ public class Mth { - private static final double[] COS_TAB = new double[257]; - - public static float sin(float value) { -- return SIN[(int)(value * 10430.378F) & '\uffff']; -+ return me.jellysquid.mods.lithium.common.util.math.CompactSineLUT.sin(value); // DivineMC - lithium: CompactSineLUT - } - - public static float cos(float value) { -- return SIN[(int)(value * 10430.378F + 16384.0F) & '\uffff']; -+ return me.jellysquid.mods.lithium.common.util.math.CompactSineLUT.cos(value); // DivineMC - lithium: CompactSineLUT - } - - public static float sqrt(float value) { diff --git a/patches/removed/1.19.3/server/0011-Fix-outdated-server-showing-in-ping-before-server-fu.patch b/patches/removed/1.19.3/server/0011-Fix-outdated-server-showing-in-ping-before-server-fu.patch deleted file mode 100644 index 604e96c..0000000 --- a/patches/removed/1.19.3/server/0011-Fix-outdated-server-showing-in-ping-before-server-fu.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Tue, 4 Jun 2019 15:50:08 -0500 -Subject: [PATCH] Fix 'outdated server' showing in ping before server fully - boots - -Original code by PurpurMC, licensed under MIT (removed now) -You can find the original code on https://github.com/PurpurMC/Purpur - -diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -index 0725c39d9cbec3282f93975a0ae76f060f70d86d..b1afe7d9fff390cc9668ce9bbb408d64147553e6 100644 ---- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -@@ -152,6 +152,7 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - this.connection.send(new ClientboundStatusResponsePacket(ping)); - // CraftBukkit end - */ -+ if (this.server.getStatus().getVersion() == null) return; // Purpur - do not respond to pings before we know the protocol version - com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(this.server, this.connection); - // Paper end - } diff --git a/patches/removed/1.21/api/0008-Add-Higher-Java-Version-for-Pufferfish.patch b/patches/removed/1.21/api/0008-Add-Higher-Java-Version-for-Pufferfish.patch deleted file mode 100644 index e303f9a..0000000 --- a/patches/removed/1.21/api/0008-Add-Higher-Java-Version-for-Pufferfish.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> -Date: Sat, 13 Jan 2024 14:57:08 +0300 -Subject: [PATCH] Add Higher Java Version for Pufferfish - - -diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java -index 3441cdad70da1bd523c5933b1a914688718c2657..f0c33c55bcbbd93c658179b1b573354fc9480b79 100644 ---- a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java -+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java -@@ -15,7 +15,7 @@ public class SIMDChecker { - @Deprecated - public static boolean canEnable(Logger logger) { - try { -- if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) { -+ if (SIMDDetection.getJavaVersion() < 17) { // DivineMC - Add Higher Java Version for Pufferfish - return false; - } else { - SIMDDetection.testRun = true; diff --git a/patches/removed/1.21/server/0040-Carpet-Fixes-Sheep-Optimization.patch b/patches/removed/1.21/server/0040-Carpet-Fixes-Sheep-Optimization.patch deleted file mode 100644 index caa537f..0000000 --- a/patches/removed/1.21/server/0040-Carpet-Fixes-Sheep-Optimization.patch +++ /dev/null @@ -1,131 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> -Date: Sat, 13 Jan 2024 20:59:28 +0300 -Subject: [PATCH] Carpet-Fixes: Sheep Optimization - -Original project: https://github.com/fxmorin/carpet-fixes - -diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -index a13ce089bacfb6644eea81fbe7c6d640aedaea96..9cde7eafbf6d8dbb13087379e567bc0dfd24f4a6 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java -@@ -60,6 +60,7 @@ import net.minecraft.world.item.DyeItem; - import net.minecraft.world.item.Item; - import org.bukkit.craftbukkit.event.CraftEventFactory; - import org.bukkit.event.entity.SheepRegrowWoolEvent; -+import space.bxteam.divinemc.util.carpetfixes.ProperDyeMixin; // DivineMC - // CraftBukkit end - - public class Sheep extends Animal implements Shearable { -@@ -376,21 +377,30 @@ public class Sheep extends Animal implements Shearable { - return super.finalizeSpawn(world, difficulty, spawnReason, entityData); - } - -+ // DivineMC start - Carpet-Fixes: Sheep Optimization - private DyeColor getOffspringColor(ServerLevel world, Sheep firstParent, Sheep secondParent) { -- DyeColor enumcolor = firstParent.getColor(); -- DyeColor enumcolor1 = secondParent.getColor(); -- CraftingInput craftinginput = Sheep.makeCraftInput(enumcolor, enumcolor1); -- Optional optional = world.recipeAccess().getRecipeFor(RecipeType.CRAFTING, craftinginput, world).map((recipeholder) -> { // CraftBukkit - decompile error -- return ((CraftingRecipe) recipeholder.value()).assemble(craftinginput, world.registryAccess()); -- }).map(ItemStack::getItem); -- -- Objects.requireNonNull(DyeItem.class); -- optional = optional.filter(DyeItem.class::isInstance); -- Objects.requireNonNull(DyeItem.class); -- return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> { -- return world.random.nextBoolean() ? enumcolor : enumcolor1; -- }); -+ DyeColor firstColor = firstParent.getColor(); -+ DyeColor secondColor = secondParent.getColor(); -+ -+ if (space.bxteam.divinemc.configuration.DivineConfig.sheepOptimization) { -+ DyeColor col = ProperDyeMixin.properDye(firstColor, secondColor); -+ if (col == null) col = world.random.nextBoolean() ? firstColor : secondColor; -+ return col; -+ } else { -+ CraftingInput craftinginput = Sheep.makeCraftInput(firstColor, secondColor); -+ Optional optional = world.recipeAccess().getRecipeFor(RecipeType.CRAFTING, craftinginput, world).map((recipeholder) -> { // CraftBukkit - decompile error -+ return ((CraftingRecipe) recipeholder.value()).assemble(craftinginput, world.registryAccess()); -+ }).map(ItemStack::getItem); -+ -+ Objects.requireNonNull(DyeItem.class); -+ optional = optional.filter(DyeItem.class::isInstance); -+ Objects.requireNonNull(DyeItem.class); -+ return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> { -+ return world.random.nextBoolean() ? firstColor : secondColor; -+ }); -+ } - } -+ // DivineMC end - - private static CraftingInput makeCraftInput(DyeColor firstColor, DyeColor secondColor) { - return CraftingInput.of(2, 1, List.of(new ItemStack(DyeItem.byColor(firstColor)), new ItemStack(DyeItem.byColor(secondColor)))); -diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java -index aaf3afd0fe1f13ed7375d272e2690e9db0410417..bc6642e1a6dd8254efe65cbac1acdcd4462e430b 100644 ---- a/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java -+++ b/src/main/java/space/bxteam/divinemc/configuration/DivineConfig.java -@@ -163,9 +163,11 @@ public class DivineConfig { - public static boolean biomeManagerOptimization = true; - public static boolean optimizedDragonRespawn = true; - public static boolean optimizeNoiseGeneration = true; -+ public static boolean sheepOptimization = true; - private static void optimizations() { - biomeManagerOptimization = getBoolean("settings.optimizations.biome-manager-optimization", biomeManagerOptimization); - optimizedDragonRespawn = getBoolean("settings.optimizations.optimized-dragon-respawn", optimizedDragonRespawn); - optimizeNoiseGeneration = getBoolean("settings.optimizations.optimize-noise-generation", optimizeNoiseGeneration); -+ sheepOptimization = getBoolean("settings.optimizations.sheep-optimization", sheepOptimization); - } - } -diff --git a/src/main/java/space/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java b/src/main/java/space/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java -new file mode 100644 -index 0000000000000000000000000000000000000000..6cbcf1580312a9275e41813a26b36e42a2481a2c ---- /dev/null -+++ b/src/main/java/space/bxteam/divinemc/util/carpetfixes/ProperDyeMixin.java -@@ -0,0 +1,46 @@ -+package space.bxteam.divinemc.util.carpetfixes; -+ -+import net.minecraft.world.item.DyeColor; -+ -+public class ProperDyeMixin { -+ public static DyeColor properDye(DyeColor firstColor, DyeColor secondColor) { -+ if (firstColor.equals(secondColor)) return firstColor; -+ switch (firstColor) { -+ case WHITE -> { -+ switch (secondColor) { -+ case BLUE -> {return DyeColor.LIGHT_BLUE;} -+ case GRAY -> {return DyeColor.LIGHT_GRAY;} -+ case BLACK -> {return DyeColor.GRAY;} -+ case GREEN -> {return DyeColor.LIME;} -+ case RED -> {return DyeColor.PINK;} -+ } -+ } -+ case BLUE -> { -+ switch (secondColor) { -+ case WHITE -> {return DyeColor.LIGHT_BLUE;} -+ case GREEN -> {return DyeColor.CYAN;} -+ case RED -> {return DyeColor.PURPLE;} -+ } -+ } -+ case RED -> { -+ switch (secondColor) { -+ case YELLOW -> {return DyeColor.ORANGE;} -+ case WHITE -> {return DyeColor.PINK;} -+ case BLUE -> {return DyeColor.PURPLE;} -+ } -+ } -+ case GREEN -> { -+ switch (secondColor) { -+ case BLUE -> {return DyeColor.CYAN;} -+ case WHITE -> {return DyeColor.LIME;} -+ } -+ } -+ case YELLOW -> {if (secondColor.equals(DyeColor.RED)) return DyeColor.ORANGE;} -+ case PURPLE -> {if (secondColor.equals(DyeColor.PINK)) return DyeColor.MAGENTA;} -+ case PINK -> {if (secondColor.equals(DyeColor.PURPLE)) return DyeColor.MAGENTA;} -+ case GRAY -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.LIGHT_GRAY;} -+ case BLACK -> {if (secondColor.equals(DyeColor.WHITE)) return DyeColor.GRAY;} -+ } -+ return null; -+ } -+} diff --git a/patches/removed/1.21/server/0052-Add-Higher-Java-Version-for-Pufferfish-SIMD.patch b/patches/removed/1.21/server/0052-Add-Higher-Java-Version-for-Pufferfish-SIMD.patch deleted file mode 100644 index 91a4f56..0000000 --- a/patches/removed/1.21/server/0052-Add-Higher-Java-Version-for-Pufferfish-SIMD.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> -Date: Tue, 16 Apr 2024 01:20:51 +0300 -Subject: [PATCH] Add Higher Java Version for Pufferfish SIMD - - -diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -index 8afc58f35deb49084a20b803e91ce4692ce6e4d6..581eb4ca8d7a09729ad9194d35f3cceeb291ecf7 100644 ---- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java -@@ -87,7 +87,7 @@ public class PufferfishConfig { - // Attempt to detect vectorization - try { - SIMDDetection.isEnabled = SIMDDetection.canEnable(PufferfishLogger.LOGGER); -- SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21; -+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17; // DivineMC - Add Higher Java Version for Pufferfish SIMD - } catch (NoClassDefFoundError | Exception ignored) { - ignored.printStackTrace(); - } -@@ -95,7 +95,7 @@ public class PufferfishConfig { - if (SIMDDetection.isEnabled) { - PufferfishLogger.LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions."); - } else if (SIMDDetection.versionLimited) { -- PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17 through Java 21."); -+ PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17 and higher."); - } else { - PufferfishLogger.LOGGER.warning("SIMD operations are available for your server, but are not configured!"); - PufferfishLogger.LOGGER.warning("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");