From 0126d4d9767f5a0fccf339dd1dbc700d5788abf2 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 22 Mar 2025 00:30:03 +0700 Subject: [PATCH] Don't override nextGaussian, because JVM implementation should be generally faster --- .../dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt | 8 -------- .../mc/otm/core/util/IRandomSourceGenerator.kt | 4 +++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt index c8adbfa13..f26a4aaae 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/GJRAND64RandomSource.kt @@ -2,15 +2,12 @@ package ru.dbotthepony.mc.otm.core.util import net.minecraft.util.Mth import net.minecraft.util.RandomSource -import net.minecraft.world.level.levelgen.MarsagliaPolarGaussian import net.minecraft.world.level.levelgen.PositionalRandomFactory import net.minecraft.world.level.levelgen.RandomSupport import ru.dbotthepony.kommons.random.GJRAND64Random import java.lang.StringBuilder class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator { - private val gaussian = MarsagliaPolarGaussian(this) - constructor() : super(RandomSupport.generateUniqueSeed(), RandomSupport.generateUniqueSeed()) constructor(seed: Long) : super(seed) constructor(seed0: Long, seed1: Long) : super(seed0, seed1) @@ -19,10 +16,6 @@ class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator { return nextLong().ushr(32).toInt() } - override fun nextGaussian(): Double { - return gaussian.nextGaussian() - } - override fun fork(): RandomSource { return GJRAND64RandomSource(nextLong(), nextLong()) } @@ -33,7 +26,6 @@ class GJRAND64RandomSource : GJRAND64Random, IRandomSourceGenerator { override fun setSeed(seed: Long) { reinitialize(seed) - gaussian.reset() } class Positional(private val seed0: Long, private val seed1: Long) : PositionalRandomFactory { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt index 999e39cfd..cd0fa1e47 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/IRandomSourceGenerator.kt @@ -26,5 +26,7 @@ interface IRandomSourceGenerator : RandomSource, RandomGenerator { return super.nextDouble() } - override fun nextGaussian(): Double + override fun nextGaussian(): Double { + return super.nextGaussian() + } }