Use immutableSet provided by kommons

This commit is contained in:
DBotThePony 2025-03-30 18:18:59 +07:00
parent 1241d2368e
commit 118f5e1b5c
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 4 additions and 12 deletions

View File

@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.capability
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import net.minecraft.world.item.Item
import ru.dbotthepony.kommons.guava.immutableSet
import ru.dbotthepony.mc.otm.client.ShiftPressedCond
import ru.dbotthepony.mc.otm.config.MachinesConfig
import ru.dbotthepony.mc.otm.util.TextComponent
import ru.dbotthepony.mc.otm.util.TranslatableComponent
import ru.dbotthepony.mc.otm.util.collect.SupplierList
import ru.dbotthepony.mc.otm.util.immutableSet
import ru.dbotthepony.mc.otm.util.math.Decimal
import ru.dbotthepony.mc.otm.util.formatMatter
import ru.dbotthepony.mc.otm.util.formatPower
@ -200,16 +200,14 @@ enum class UpgradeType {
fun set() = sets[flag]
companion object {
private val cached = values()
private val sets = Array(2 shl cached.size) {
private val sets = Array(2 shl entries.size) {
immutableSet {
for (u in values()) if (it.and(u.flag) != 0) accept(u)
for (u in entries) if (it.and(u.flag) != 0) accept(u)
}
}
@JvmField
val ALL = set(*values())
val ALL = set(*entries.toTypedArray())
@JvmField
val BASIC = set(SPEED, ENERGY_STORAGE, ENERGY_CONSUMPTION, ENERGY_THROUGHPUT)

View File

@ -167,12 +167,6 @@ inline fun <K : Any, V : Any> immutableMultimap(initializer: ImmutableMultimap.B
return builder.build()
}
inline fun <V : Any> immutableSet(initializer: Consumer<V>.() -> Unit): ImmutableSet<V> {
val builder = ImmutableSet.Builder<V>()
initializer.invoke(builder::add)
return builder.build()
}
inline fun itemAttributes(builder: ItemAttributeModifiers.Builder.() -> Unit): ItemAttributeModifiers {
val value = ItemAttributeModifiers.builder()
builder(value)