Skip to content

Commit

Permalink
refactor: replace until ranges with ..<
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Dec 14, 2023
1 parent 42a4efe commit 99cc178
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/gg/skytils/skytilsmod/core/GuiManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object GuiManager : PersistentSave(File(Skytils.modDir, "guipositions.json")) {
}

fun addToast(toast: Toast) {
val index = (0 until maxToasts).firstOrNull { it !in takenSlots }
val index = (0..<maxToasts).firstOrNull { it !in takenSlots }
if (index != null) {
gui.addChild(toast)
toast.constraints.y = (index * 32).pixels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object SimonSaysSolver {
if (Skytils.config.simonSaysSolver && clickNeeded < clickInOrder.size) {
val matrixStack = UMatrixStack()

for (i in clickNeeded until clickInOrder.size) {
for (i in clickNeeded..<clickInOrder.size) {
val pos = clickInOrder[i]
val x = pos.x - viewerX
val y = pos.y - viewerY + .372
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object MinionFeatures {
if (!item.isItemEnchanted && item.item != Items.skull) {
if (event.chestName == "Minion Chest") {
if (!blockUnenchanted) {
for (i in 0 until inventory.sizeInventory) {
for (i in 0..<inventory.sizeInventory) {
val stack = inventory.getStackInSlot(i) ?: continue
if (stack.isItemEnchanted || stack.item == Items.skull) {
blockUnenchanted = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ data class GIFResource(
).use { stream ->
ImageIO.getImageReaders(stream).nextOrNull()?.run {
input = stream
(0 until getNumImages(true)).map {
(0..<getNumImages(true)).map {
DynamicResource("skytils_${name}_frame", read(it))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class WardrobeComponent(val profileState: State<Member?>) : UIContainer() {
Window.enqueueRenderOperation {
wardrobeContainer.clearChildren()
profile?.wardrobe?.items?.run {
(0 until size / 4).map { slot ->
(0..<size / 4).map { slot ->
val page = slot / 9
profileState.alwaysMap { prof ->
Inventory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ object DungeonListener {
return
}
println("There are $partyCount members in this party")
for (i in 0 until partyCount) {
for (i in 0..<partyCount) {
val pos = 1 + i * 4
val text = tabEntries[pos].second
val matcher = classPattern.find(text)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/gg/skytils/skytilsmod/utils/ItemUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ object ItemUtil {
if (display.hasKey("Lore", NBT_LIST)) {
val lore = display.getTagList("Lore", NBT_STRING)
val loreAsList = ArrayList<String>(lore.tagCount())
for (lineNumber in 0 until lore.tagCount()) {
for (lineNumber in 0..<lore.tagCount()) {
loreAsList.add(lore.getStringTagAt(lineNumber))
}
return Collections.unmodifiableList(loreAsList)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/gg/skytils/skytilsmod/utils/SkillUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ object SkillUtils {
get() {
val offset = petRarityOffset[tier]!!
val maxLevel = if (type == "GOLDEN_DRAGON") 200 else 100
val levels = petLevels.sliceArray(offset until offset + maxLevel - 1)
val levels = petLevels.sliceArray(offset..<offset + maxLevel - 1)

var xpRemaining = xp
for ((i, xp) in levels.withIndex()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/gg/skytils/skytilsmod/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ operator fun Vec3.times(scaleValue: Double): Vec3 = Vec3(xCoord * scaleValue, yC
*/
fun <T> List<T>.elementPairs() = sequence {
val arr = this@elementPairs
for (i in 0 until arr.size - 1)
for (j in i + 1 until arr.size)
for (i in 0..<arr.size - 1)
for (j in i + 1..<arr.size)
yield(arr[i] to arr[j])
}
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ class ScreenRenderer {
/** refresh
* Triggered by a slower loop(client tick), refresh
* updates the screen resolution to match the window
* size and sets the font renderer in until its ok.
* size and sets the font renderer in..<its ok.
* Do not call this method from anywhere in the mod!
*/
@JvmStatic
Expand Down
18 changes: 9 additions & 9 deletions src/main/kotlin/gg/skytils/skytilsmod/utils/tictactoe/Board.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ class Board internal constructor() {
* available at the start of the game).
*/
private fun initialize() {
for (row in 0 until BOARD_WIDTH) {
for (col in 0 until BOARD_WIDTH) {
for (row in 0..<BOARD_WIDTH) {
for (col in 0..<BOARD_WIDTH) {
board[row][col] = State.Blank
}
}
availableMoves.clear()
for (i in 0 until BOARD_WIDTH * BOARD_WIDTH) {
for (i in 0..<BOARD_WIDTH * BOARD_WIDTH) {
availableMoves.add(i)
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ class Board internal constructor() {
* @param row the row to check
*/
private fun checkRow(row: Int) {
for (i in 1 until BOARD_WIDTH) {
for (i in 1..<BOARD_WIDTH) {
if (board[row][i] != board[row][i - 1]) {
break
}
Expand All @@ -194,7 +194,7 @@ class Board internal constructor() {
* @param column the column to check
*/
private fun checkColumn(column: Int) {
for (i in 1 until BOARD_WIDTH) {
for (i in 1..<BOARD_WIDTH) {
if (board[i][column] != board[i - 1][column]) {
break
}
Expand All @@ -212,7 +212,7 @@ class Board internal constructor() {
*/
private fun checkDiagonalFromTopLeft(x: Int, y: Int) {
if (x == y) {
for (i in 1 until BOARD_WIDTH) {
for (i in 1..<BOARD_WIDTH) {
if (board[i][i] != board[i - 1][i - 1]) {
break
}
Expand All @@ -231,7 +231,7 @@ class Board internal constructor() {
*/
private fun checkDiagonalFromTopRight(x: Int, y: Int) {
if (BOARD_WIDTH - 1 - x == y) {
for (i in 1 until BOARD_WIDTH) {
for (i in 1..<BOARD_WIDTH) {
if (board[BOARD_WIDTH - 1 - i][i] != board[BOARD_WIDTH - i][i - 1]) {
break
}
Expand Down Expand Up @@ -264,8 +264,8 @@ class Board internal constructor() {

override fun toString(): String {
val sb = StringBuilder()
for (y in 0 until BOARD_WIDTH) {
for (x in 0 until BOARD_WIDTH) {
for (y in 0..<BOARD_WIDTH) {
for (x in 0..<BOARD_WIDTH) {
if (board[y][x] == State.Blank) {
sb.append("-")
} else {
Expand Down

0 comments on commit 99cc178

Please sign in to comment.