9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-26 18:19:11 +00:00

Initialize line of sight cache with low capacity

This commit is contained in:
Martijn Muijsers
2023-08-30 19:04:38 +02:00
parent 9ebba5cedd
commit 49a3022a23
6 changed files with 32 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ index 2868dab7b100d9c325b0e5056f86660d631dec4b..2acad4c3fd58178b0f8b22bdb04eeeeb
}
diff --git a/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java
new file mode 100644
index 0000000000000000000000000000000000000000..9bee7629dd00453dc4a712f3c48cf4f2ae3da5c5
index 0000000000000000000000000000000000000000..4c0ae932fd4ecc4ec103b19b32d0eb4ebef3cb74
--- /dev/null
+++ b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java
@@ -0,0 +1,37 @@
@@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..9bee7629dd00453dc4a712f3c48cf4f2
+ * The <code>patch</code> version is incremented for small changes that do not affect the goal of any feature,
+ * such as bug fixes, performance improvements or changes in wording.
+ */
+ public static final @NotNull String version = "0.6.5";
+ public static final @NotNull String version = "0.6.6";
+
+ /**
+ * The "<code>major.minor</code>" portion of the {@link #version}.

View File

@@ -7,7 +7,7 @@ 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 7327f3bb1c1f764ae1da88af27b1e9fb03fb89d9..aaefd728bb1a9fc398e55fe30c9337d51cf43785 100644
index 7327f3bb1c1f764ae1da88af27b1e9fb03fb89d9..72ede18890a7bf3dba1473e10319339ac0bbfa69 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -139,14 +139,26 @@ public class Mth {
@@ -25,12 +25,12 @@ index 7327f3bb1c1f764ae1da88af27b1e9fb03fb89d9..aaefd728bb1a9fc398e55fe30c9337d5
}
+ // Gale start - faster floating-point positive modulo
+ public static float positiveModuloForPositiveDivisor(float dividend, float divisor) {
+ public static float positiveModuloForPositiveIntegerDivisor(float dividend, float divisor) {
+ var modulo = dividend % divisor;
+ return modulo < 0 ? modulo + divisor : modulo;
+ }
+
+ public static double positiveModuloForPositiveDivisor(double dividend, double divisor) {
+ public static double positiveModuloForPositiveIntegerDivisor(double dividend, double divisor) {
+ var modulo = dividend % divisor;
+ return modulo < 0 ? modulo + divisor : modulo;
+ }
@@ -40,7 +40,7 @@ index 7327f3bb1c1f764ae1da88af27b1e9fb03fb89d9..aaefd728bb1a9fc398e55fe30c9337d5
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 a6434f2c2d1ddb33e7c51d0a099fd127d8a785e6..aeecd8fc0b9d514990e1fa1f1c790fa61d664a0b 100644
index a6434f2c2d1ddb33e7c51d0a099fd127d8a785e6..a7972d196c354ff175728f2b8e99590181c65451 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
@@ -141,7 +141,7 @@ public class Blender {
@@ -48,7 +48,7 @@ index a6434f2c2d1ddb33e7c51d0a099fd127d8a785e6..aeecd8fc0b9d514990e1fa1f1c790fa6
double d = 1.0D;
double e = height + 0.5D;
- double f = Mth.positiveModulo(e, 8.0D);
+ double f = Mth.positiveModuloForPositiveDivisor(e, 8.0D); // Gale - faster floating-point positive modulo
+ double f = Mth.positiveModuloForPositiveIntegerDivisor(e, 8.0D); // Gale - faster floating-point positive modulo
return 1.0D * (32.0D * (e - 128.0D) - 3.0D * (e - 120.0D) * f + 3.0D * f * f) / (128.0D * (32.0D - 3.0D * f));
}

View File

@@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Aug 2023 19:01:50 +0200
Subject: [PATCH] Initialize line of sight cache with low capacity
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/world/entity/ai/sensing/Sensing.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java
index ed440b9a84ac0e4619c075491515fa072d6aebec..57472cb54e9fd83e980e3c57f28d6e6643f422e8 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java
@@ -7,8 +7,10 @@ import net.minecraft.world.entity.Mob;
public class Sensing {
private final Mob mob;
- private final IntSet seen = new IntOpenHashSet();
- private final IntSet unseen = new IntOpenHashSet();
+ // Gale start - initialize line of sight cache with low capacity
+ private final IntSet seen = new IntOpenHashSet(2);
+ private final IntSet unseen = new IntOpenHashSet(2);
+ // Gale end - initialize line of sight cache with low capacity
public Sensing(Mob owner) {
this.mob = owner;