Split skinelement file
This commit is contained in:
parent
4801ff01ad
commit
92ae0408e8
@ -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,
|
||||
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user