Skip to content

Commit

Permalink
fix(ItemGroup): stream to array (#5325)
Browse files Browse the repository at this point in the history
  • Loading branch information
MukjepScarlet authored Jan 15, 2025
1 parent 6e729d8 commit 59a88d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package net.ccbluex.liquidbounce.features.itemgroup.groups

import net.ccbluex.liquidbounce.features.itemgroup.ClientItemGroup
import net.ccbluex.liquidbounce.utils.item.createSplashPotion
import net.ccbluex.liquidbounce.utils.kotlin.mapArray
import net.ccbluex.liquidbounce.utils.kotlin.toTypedArray
import net.minecraft.block.Blocks
import net.minecraft.entity.effect.StatusEffectInstance
import net.minecraft.entity.effect.StatusEffects
Expand Down Expand Up @@ -47,9 +49,9 @@ class ExploitsItemGroup : ClientItemGroup(

// Add unobtainable potions
it.add(createSplashPotion("Troll Potion",
effects = Registries.STATUS_EFFECT.streamEntries().map { statusEffect ->
effects = Registries.STATUS_EFFECT.streamEntries().toTypedArray().mapArray { statusEffect ->
StatusEffectInstance(statusEffect, Int.MAX_VALUE, 127)
}.toArray(::arrayOfNulls)))
}))

it.add(createSplashPotion("Kill Potion",
StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 0, 125),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import it.unimi.dsi.fastutil.doubles.DoubleIterator
import it.unimi.dsi.fastutil.doubles.DoubleIterators
import it.unimi.dsi.fastutil.ints.IntArrayList
import it.unimi.dsi.fastutil.ints.IntList
import java.util.stream.Stream

inline infix operator fun IntRange.contains(range: IntRange): Boolean {
return this.first <= range.first && this.last >= range.last
Expand Down Expand Up @@ -180,3 +181,6 @@ inline fun <T> Collection<T>.mapString(transform: (T) -> Char) = with(iterator()
transform(next())
})
}

@Suppress("UNCHECKED_CAST")
fun <T> Stream<T>.toTypedArray(): Array<T> = toArray() as Array<T>

0 comments on commit 59a88d1

Please sign in to comment.