mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-20 23:39:29 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@681c013 Bundle spark (#11093) PaperMC/Paper@5fee9c6 Move configuration option to a system property PaperMC/Paper@aa3b356 Improve server startup logging (#11110) PaperMC/Paper@9aea240 Properly lookup plugin classes when looked up by spark PaperMC/Paper@7e91a2c Update the bundled spark version
55 lines
2.7 KiB
Diff
55 lines
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Tue, 29 Aug 2023 22:29:08 +0200
|
|
Subject: [PATCH] Faster floating-point positive modulo
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
|
|
index 3468b7fbc7440f220fce8039f237658a593df296..cb8cde3c1b65329f92b7c78e529e128f5a408fd6 100644
|
|
--- a/src/main/java/net/minecraft/util/Mth.java
|
|
+++ b/src/main/java/net/minecraft/util/Mth.java
|
|
@@ -149,14 +149,26 @@ public class Mth {
|
|
return Math.floorMod(dividend, divisor);
|
|
}
|
|
|
|
- public static float positiveModulo(float dividend, float divisor) {
|
|
+ public static float positiveModuloForAnyDivisor(float dividend, float divisor) { // Gale - faster floating-point positive modulo
|
|
return (dividend % divisor + divisor) % divisor;
|
|
}
|
|
|
|
- public static double positiveModulo(double dividend, double divisor) {
|
|
+ public static double positiveModuloForAnyDivisor(double dividend, double divisor) { // Gale - faster floating-point positive modulo
|
|
return (dividend % divisor + divisor) % divisor;
|
|
}
|
|
|
|
+ // Gale start - faster floating-point positive modulo
|
|
+ public static float positiveModuloForPositiveIntegerDivisor(float dividend, float divisor) {
|
|
+ var modulo = dividend % divisor;
|
|
+ return modulo < 0 ? modulo + divisor : modulo;
|
|
+ }
|
|
+
|
|
+ public static double positiveModuloForPositiveIntegerDivisor(double dividend, double divisor) {
|
|
+ var modulo = dividend % divisor;
|
|
+ return modulo < 0 ? modulo + divisor : modulo;
|
|
+ }
|
|
+ // Gale end - faster floating-point positive modulo
|
|
+
|
|
public static boolean isMultipleOf(int a, int b) {
|
|
return a % b == 0;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java b/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java
|
|
index ef73772bd3f9484efbcd521a86a34c6ec3fd0d14..45f6f74bcae3e3f27809d2ff3973b98edb169f0f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java
|
|
@@ -148,7 +148,7 @@ public class Blender {
|
|
private static double heightToOffset(double height) {
|
|
double d = 1.0;
|
|
double e = height + 0.5;
|
|
- double f = Mth.positiveModulo(e, 8.0);
|
|
+ double f = Mth.positiveModuloForPositiveIntegerDivisor(e, 8.0); // Gale - faster floating-point positive modulo
|
|
return 1.0 * (32.0 * (e - 128.0) - 3.0 * (e - 120.0) * f + 3.0 * f * f) / (128.0 * (32.0 - 3.0 * f));
|
|
}
|
|
|