mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
70 lines
4.7 KiB
Diff
70 lines
4.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Tue, 8 Aug 2023 21:12:58 +0200
|
|
Subject: [PATCH] Add xor-shift random
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Apply faster random"
|
|
By: AlphaKR93 <dev@alpha93.kr>
|
|
As part of: Plazma (https://github.com/PlazmaMC/Plazma)
|
|
Class `org.plazmamc.plazma.Random` licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
Other changes licensed under: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
* Plazma copyright *
|
|
|
|
The MIT License (MIT)
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java
|
|
index 54916fe57ceeab24936ce50709402ecf1fcd9a10..01631bbe14a4bed817a6de41fa268a3e4f949180 100644
|
|
--- a/io/papermc/paper/entity/activation/ActivationRange.java
|
|
+++ b/io/papermc/paper/entity/activation/ActivationRange.java
|
|
@@ -75,7 +75,7 @@ public final class ActivationRange {
|
|
}
|
|
|
|
// Gale start - variable entity wake-up duration
|
|
- private static final java.util.Random wakeUpDurationRandom = new java.util.Random();
|
|
+ public static java.util.Random wakeUpDurationRandom; // Gale - xor-shift random - set in GaleGlobalConfiguration
|
|
|
|
private static int getWakeUpDurationWithVariance(Entity entity, int wakeUpDuration) {
|
|
double deviation = entity.level().galeConfig().gameplayMechanics.entityWakeUpDurationRatioStandardDeviation;
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index 95972e7d5e0357ff5884f1cb2f7596c5029f999d..a5f76c81dfb148fc184d137395d5961229cb799b 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -174,7 +174,9 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE;
|
|
// Paper end - get block chunk optimisation
|
|
|
|
- this.lightningTick = this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick
|
|
+ this.lightningTick = org.galemc.gale.configuration.GaleGlobalConfiguration.get().smallOptimizations.useXorShiftRandom.lightningRandomTick
|
|
+ ? new org.galemc.gale.random.XorShiftRandom().nextInt(100000) << 1
|
|
+ : this.level.simpleRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick // Gale - xor-shift random
|
|
}
|
|
|
|
public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) {
|
|
diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
index 0c41177462cca5c4bbab6490e323b9535fd6300f..231d1905092532acf7e632197ba0e727adc4b1d7 100644
|
|
--- a/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
+++ b/net/minecraft/world/level/chunk/storage/RegionFile.java
|
|
@@ -104,7 +104,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche
|
|
}
|
|
|
|
private void backupRegionFile() {
|
|
- Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new java.util.Random().nextLong() + ".backup");
|
|
+ Path backup = this.path.getParent().resolve(this.path.getFileName() + "." + new org.galemc.gale.random.XorShiftRandom().nextLong() + ".backup"); // Gale - xor-shift random
|
|
this.backupRegionFile(backup);
|
|
}
|
|
|