From 8091f54cd04140220bb62a5db47c0b520980573e Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 13 Dec 2024 10:00:31 +0100 Subject: [PATCH 1/2] Fix rare RandomSource cross-thread crash --- .../java/org/cyclops/cyclopscore/helper/WorldHelpers.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cyclops/cyclopscore/helper/WorldHelpers.java b/src/main/java/org/cyclops/cyclopscore/helper/WorldHelpers.java index cfa865042d..118c8ca74d 100644 --- a/src/main/java/org/cyclops/cyclopscore/helper/WorldHelpers.java +++ b/src/main/java/org/cyclops/cyclopscore/helper/WorldHelpers.java @@ -1,8 +1,9 @@ package org.cyclops.cyclopscore.helper; import net.minecraft.core.BlockPos; -import net.minecraft.world.level.LevelAccessor; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; import javax.annotation.Nullable; @@ -20,6 +21,8 @@ public class WorldHelpers { private static final double TICK_LAG_REDUCTION_MODULUS_MODIFIER = 1.0D; + private static final RandomSource RANDOM = RandomSource.create(); + /** * Check if an efficient tick can happen. * This is useful for opererations that should happen frequently, but not strictly every tick. @@ -33,7 +36,7 @@ public static boolean efficientTick(Level world, int baseModulus, int... params) if(mod == 0) mod = 1; int offset = 0; for(int param : params) offset += param; - return world.random.nextInt(mod) == Math.abs(offset) % mod; + return RANDOM.nextInt(mod) == Math.abs(offset) % mod; } /** From 1cdcfa8bd6f07c08f59ea305112eec5068a81e1a Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 13 Dec 2024 10:00:56 +0100 Subject: [PATCH 2/2] Bump mod version --- gradle.properties | 2 +- resources/changelog/1.19.2-1.19.6.txt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 resources/changelog/1.19.2-1.19.6.txt diff --git a/gradle.properties b/gradle.properties index 8dc2a3fad8..0eda8c100f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -mod_version=1.19.5 +mod_version=1.19.6 minecraft_version=1.19.2 forge_version=43.0.8 release_type=release diff --git a/resources/changelog/1.19.2-1.19.6.txt b/resources/changelog/1.19.2-1.19.6.txt new file mode 100644 index 0000000000..fa8a3d1924 --- /dev/null +++ b/resources/changelog/1.19.2-1.19.6.txt @@ -0,0 +1,5 @@ +As always, don't forget to backup your world before updating! + +Fixes: +* Fix rare RandomSource cross-thread crash +