Remove randomGenerator
from editable panel
This commit is contained in:
parent
9b27ed7fb6
commit
b921658eb2
@ -52,7 +52,7 @@ open class DecimalHistoryChartPanel<out S : MatteryScreen<*>>(
|
||||
|
||||
map[1f] = formatText(maximum)
|
||||
|
||||
for (cluster in chart.asIterable().clusterize(randomGenerator)) {
|
||||
for (cluster in chart.asIterable().clusterize(random)) {
|
||||
val perc = (cluster.center / maximum).toFloat()
|
||||
|
||||
if (map.keys.none { (it - perc).absoluteValue < 0.08f }) {
|
||||
|
@ -232,10 +232,6 @@ open class EditablePanel<out S : Screen>(
|
||||
}
|
||||
}
|
||||
|
||||
val randomGenerator: RandomGenerator by lazy {
|
||||
RandomSource2Generator(random)
|
||||
}
|
||||
|
||||
/**
|
||||
* Bigger values means lesser priority while docking, rendering and processing inputs.
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.util.RandomSource
|
||||
import net.minecraft.world.entity.player.Inventory
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.neoforged.neoforge.network.PacketDistributor
|
||||
@ -34,6 +35,7 @@ import ru.dbotthepony.mc.otm.config.MachinesConfig
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.player.matteryPlayer
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.button.BooleanButtonPanel
|
||||
import ru.dbotthepony.mc.otm.core.nextFloat
|
||||
import ru.dbotthepony.mc.otm.menu.tech.AndroidStationMenu
|
||||
import ru.dbotthepony.mc.otm.network.AndroidResearchRequestPacket
|
||||
import java.util.*
|
||||
@ -443,8 +445,8 @@ private class AndroidResearchButton(
|
||||
}
|
||||
|
||||
private enum class PreviewScrollers(
|
||||
val init: (EditablePanel<*>, RandomGenerator) -> Unit,
|
||||
val scroll: (EditablePanel<*>, RandomGenerator) -> Boolean
|
||||
val init: (EditablePanel<*>, RandomSource) -> Unit,
|
||||
val scroll: (EditablePanel<*>, RandomSource) -> Boolean
|
||||
) {
|
||||
LEFT_TO_RIGHT(
|
||||
init = { it, random ->
|
||||
@ -540,14 +542,14 @@ class AndroidStationScreen(p_97741_: AndroidStationMenu, p_97742_: Inventory, p_
|
||||
|
||||
if (isPreview && !layoutInvalidated) {
|
||||
if (firstTick) {
|
||||
scroller.init.invoke(this, randomGenerator)
|
||||
scroller.init.invoke(this, random)
|
||||
}
|
||||
|
||||
val status = scroller.scroll.invoke(this, randomGenerator)
|
||||
val status = scroller.scroll.invoke(this, random)
|
||||
|
||||
if (!status) {
|
||||
scroller = PreviewScrollers.entries.let { it[random.nextInt(it.size)] }
|
||||
scroller.init.invoke(this, randomGenerator)
|
||||
scroller.init.invoke(this, random)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.core.math
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList
|
||||
import net.minecraft.util.RandomSource
|
||||
import ru.dbotthepony.mc.otm.core.random
|
||||
import java.util.random.RandomGenerator
|
||||
import kotlin.math.min
|
||||
@ -88,7 +89,7 @@ private class MutableCluster<V : Comparable<V>>(var center: V) {
|
||||
}
|
||||
|
||||
private fun <V : Comparable<V>> Iterable<V>.clusterize(
|
||||
random: RandomGenerator,
|
||||
random: RandomSource,
|
||||
initialClusters: Int = 1,
|
||||
zeroBound: Boolean = false,
|
||||
identity: V,
|
||||
@ -202,7 +203,7 @@ private fun <V : Comparable<V>> Iterable<V>.clusterize(
|
||||
// TODO: could use some tweaking
|
||||
private val DECIMAL_ERROR_TOLERANCE = Decimal("0.02")
|
||||
|
||||
fun Iterable<Decimal>.clusterize(random: RandomGenerator, clusters: Int? = null, zeroBound: Boolean = false): List<Cluster<Decimal>> {
|
||||
fun Iterable<Decimal>.clusterize(random: RandomSource, clusters: Int? = null, zeroBound: Boolean = false): List<Cluster<Decimal>> {
|
||||
return clusterize(random, clusters ?: 1, zeroBound, Decimal.ZERO, Decimal::plus, Decimal::minus, Decimal::div, Decimal::absoluteValue) { min, max, error ->
|
||||
if (clusters != null)
|
||||
false
|
||||
|
Loading…
Reference in New Issue
Block a user