From 92ae0408e8078bfabb361c49e94e34ec7ed672a0 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 6 Oct 2022 18:04:23 +0700 Subject: [PATCH] Split skinelement file --- .../mc/otm/client/render/SkinElement.kt | 54 ----------------- .../mc/otm/client/render/SkinGrid.kt | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 54 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt index ca2908c32..526f76608 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt @@ -20,60 +20,6 @@ import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.core.set import java.lang.reflect.Type -@Suppress("unused") -data class SkinGrid( - val texture: ResourceLocation, - val width: Float, - val height: Float, - val rows: Int = 16, - val columns: Int = 16, -) { - var row = 0 - var column = 0 - - val imageWidth get() = width * columns - val imageHeight get() = height * rows - - val currentX: Float get() = column * width - val currentY: Float get() = row * height - - fun skip(): SkinGrid { - column++ - - if (column >= columns) { - jump() - } - - return this - } - - fun jump(): SkinGrid { - row++ - column = 0 - return this - } - - fun next(): SkinElement { - val element = SkinElement(texture, currentX, currentY, width, height, imageWidth, imageHeight) - skip() - return element - } - - fun reset(): SkinGrid { - row = 0 - column = 0 - return this - } - - fun seek(row: Int, column: Int): SkinGrid { - this.row = row - this.column = column - return this - } - - operator fun get(column: Int, row: Int) = SkinElement(texture, column * width, row * height, width, height, imageWidth, imageHeight) -} - fun ResourceLocation.element( x: Float, y: Float, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt new file mode 100644 index 000000000..ca4e96896 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt @@ -0,0 +1,58 @@ +package ru.dbotthepony.mc.otm.client.render + +import net.minecraft.resources.ResourceLocation + +@Suppress("unused") +data class SkinGrid( + val texture: ResourceLocation, + val width: Float, + val height: Float, + val rows: Int = 16, + val columns: Int = 16, +) { + var row = 0 + var column = 0 + + val imageWidth get() = width * columns + val imageHeight get() = height * rows + + val currentX: Float get() = column * width + val currentY: Float get() = row * height + + fun skip(): SkinGrid { + column++ + + if (column >= columns) { + jump() + } + + return this + } + + fun jump(): SkinGrid { + row++ + column = 0 + return this + } + + fun next(): SkinElement { + val element = SkinElement(texture, currentX, currentY, width, height, imageWidth, imageHeight) + skip() + return element + } + + fun reset(): SkinGrid { + row = 0 + column = 0 + return this + } + + fun seek(row: Int, column: Int): SkinGrid { + this.row = row + this.column = column + return this + } + + operator fun get(column: Int, row: Int) = + SkinElement(texture, column * width, row * height, width, height, imageWidth, imageHeight) +}