From 68b68c42194da5091d800d688431eb5c1b92998f Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Fri, 13 Jan 2023 15:30:39 +0700 Subject: [PATCH] Rename Skin Element to Mattery Sprite --- .../mc/otm/android/AndroidResearch.kt | 7 - .../mc/otm/android/AndroidResearchType.kt | 7 +- .../dbotthepony/mc/otm/client/MatteryGUI.kt | 4 +- ...kinElement.kt => AbstractMatterySprite.kt} | 46 +--- .../mc/otm/client/render/AtlasSkinElement.kt | 215 ------------------ .../otm/client/render/DynamicBufferSource.kt | 6 +- .../{SkinElement.kt => MatterySprite.kt} | 30 +-- .../mc/otm/client/render/ResearchIcons.kt | 48 ++-- .../mc/otm/client/render/SkinElementType.kt | 64 +++--- .../mc/otm/client/render/SkinGrid.kt | 6 +- .../render/StretchingRectangleElement.kt | 18 +- ...{SubSkinElement.kt => SubMatterySprite.kt} | 14 +- .../mc/otm/client/render/SubSkinGrid.kt | 6 +- .../mc/otm/client/render/WidgetAtlasHolder.kt | 99 -------- .../mc/otm/client/render/WidgetLocation.kt | 12 +- .../mc/otm/client/render/Widgets8.kt | 2 +- .../client/render/blockentity/BankRenderer.kt | 11 +- .../client/screen/panels/AbstractSlotPanel.kt | 2 +- .../mc/otm/client/screen/panels/FramePanel.kt | 4 +- .../client/screen/panels/HeightControls.kt | 10 +- .../screen/panels/ScrollBarConstants.kt | 24 +- .../mc/otm/client/screen/panels/SlotPanel.kt | 5 +- .../buttons/BooleanRectangleButtonPanel.kt | 6 +- .../screen/panels/buttons/CheckBoxPanel.kt | 18 +- .../buttons/EnumRectangleButtonPanel.kt | 14 +- .../LargeBooleanRectangleButtonPanel.kt | 6 +- .../buttons/LargeRectangleButtonPanel.kt | 4 +- .../panels/buttons/RectangleButtonPanel.kt | 10 +- .../SmallBooleanRectangleButtonPanel.kt | 4 +- .../buttons/SmallRectangleButtonPanel.kt | 4 +- .../mc/otm/compat/cos/CosmeticArmorCompat.kt | 18 +- .../mc/otm/compat/jei/SkinDrawable.kt | 4 +- 32 files changed, 171 insertions(+), 557 deletions(-) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{AbstractSkinElement.kt => AbstractMatterySprite.kt} (89%) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{SkinElement.kt => MatterySprite.kt} (60%) rename src/main/kotlin/ru/dbotthepony/mc/otm/client/render/{SubSkinElement.kt => SubMatterySprite.kt} (80%) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index 0b1fc9484..20466b6a5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -9,27 +9,20 @@ import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.player.Player -import net.minecraft.world.item.ItemStack import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.awareItemsStream -import ru.dbotthepony.mc.otm.capability.itemsStream -import ru.dbotthepony.mc.otm.client.render.SkinElement -import ru.dbotthepony.mc.otm.container.iterator import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.addAll import ru.dbotthepony.mc.otm.core.getCompoundList -import ru.dbotthepony.mc.otm.core.nonEmpty import ru.dbotthepony.mc.otm.core.registryName import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.milliTime -import ru.dbotthepony.mc.otm.nanoTime import ru.dbotthepony.mc.otm.network.FieldSynchronizer import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.triggers.AndroidResearchTrigger -import java.io.DataInputStream import java.io.InputStream import kotlin.math.absoluteValue diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt index 7b5b67288..cc4cf4670 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearchType.kt @@ -21,8 +21,7 @@ import net.minecraft.world.item.Items import net.minecraft.world.item.crafting.Ingredient import net.minecraft.world.level.ItemLike import net.minecraftforge.registries.ForgeRegistries -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.SkinElementType import ru.dbotthepony.mc.otm.core.ListSet import ru.dbotthepony.mc.otm.core.TranslatableComponent @@ -625,7 +624,7 @@ class AndroidResearchType( var description: MutableList? = null, var descriptionSuppliers: MutableList? = null, var itemIcon: Item? = null, - var skinIcon: AbstractSkinElement? = null, + var skinIcon: AbstractMatterySprite? = null, var iconText: Component? = null, ) { private val items = ArrayList>() @@ -639,7 +638,7 @@ class AndroidResearchType( return this } - fun withIcon(icon: AbstractSkinElement? = null): Builder { + fun withIcon(icon: AbstractMatterySprite? = null): Builder { this.skinIcon = icon this.itemIcon = null return this diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt index bdca96c1e..830d1e3da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/MatteryGUI.kt @@ -12,8 +12,6 @@ import net.minecraft.world.entity.LivingEntity import net.minecraft.world.entity.player.Player import net.minecraftforge.client.event.RenderGuiEvent import net.minecraftforge.client.event.RenderGuiOverlayEvent -import net.minecraftforge.client.event.RenderLevelLastEvent -import net.minecraftforge.client.event.RenderLevelStageEvent import net.minecraftforge.client.event.ScreenEvent import net.minecraftforge.client.gui.overlay.ForgeGui import net.minecraftforge.client.gui.overlay.GuiOverlayManager @@ -30,7 +28,7 @@ import java.util.* import kotlin.math.ceil object MatteryGUI { - private val BARS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f) + private val BARS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "player_bars"), 80f, 36f) val CHARGE = BARS.subElement(height = 9f) val CHARGE_BG = BARS.subElement(y = 9f, height = 9f) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractSkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt similarity index 89% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractSkinElement.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt index 2805c30d2..af06604b7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractSkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AbstractMatterySprite.kt @@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.core.RGBAColor import ru.dbotthepony.mc.otm.core.linearInterpolation import java.lang.ref.WeakReference -sealed class AbstractSkinElement { +sealed class AbstractMatterySprite { /** * Expected image width in pixels, used in calculations * and as default width argument in render methods @@ -28,14 +28,6 @@ sealed class AbstractSkinElement { abstract val u1: Float abstract val v1: Float - internal open fun addListener(listener: AbstractSkinElement) { - // no-op by default - } - - internal open fun parentChanges(parent: AbstractSkinElement) { - - } - fun partialU(offset: Float): Float { return u0 + (offset / width) * (u1 - u0) } @@ -313,40 +305,4 @@ sealed class AbstractSkinElement { fun toNetwork(buff: FriendlyByteBuf) { type.toActualNetwork(this, buff) } - - abstract class Mutable : AbstractSkinElement() { - private val listeners = ArrayList>(0) - - override fun addListener(listener: AbstractSkinElement) { - synchronized(listeners) { - val iterator = listeners.listIterator() - - for (ref in iterator) { - if (ref.get() == null) { - iterator.remove() - } else if (ref.get() === listener) { - return - } - } - - listeners.add(WeakReference(listener)) - } - } - - protected fun notifyListeners() { - synchronized(listeners) { - val iterator = listeners.listIterator() - - for (ref in iterator) { - val value = ref.get() - - if (value == null) { - iterator.remove() - } else { - value.parentChanges(this) - } - } - } - } - } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt deleted file mode 100644 index c2380e795..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/AtlasSkinElement.kt +++ /dev/null @@ -1,215 +0,0 @@ -package ru.dbotthepony.mc.otm.client.render - -import com.mojang.blaze3d.systems.RenderSystem -import com.mojang.blaze3d.vertex.DefaultVertexFormat -import com.mojang.blaze3d.vertex.VertexFormat -import net.minecraft.client.renderer.GameRenderer -import net.minecraft.client.renderer.RenderStateShard -import net.minecraft.client.renderer.RenderStateShard.TextureStateShard -import net.minecraft.client.renderer.RenderType -import net.minecraft.client.renderer.texture.TextureAtlasSprite -import net.minecraft.resources.ResourceLocation -import net.minecraft.util.Mth -import org.lwjgl.opengl.GL11.GL_ALWAYS -import ru.dbotthepony.mc.otm.isClient -import java.lang.ref.WeakReference -import java.util.stream.Stream - -class AtlasSkinElement( - val location: ResourceLocation, - override val width: Float, - override val height: Float, - val spriteWidth: Float = Mth.smallestEncompassingPowerOfTwo(width.toInt()).toFloat(), - val spriteHeight: Float = Mth.smallestEncompassingPowerOfTwo(height.toInt()).toFloat(), - override val winding: UVWindingOrder = UVWindingOrder.NORMAL, -) : AbstractSkinElement.Mutable() { - init { - synchronized(keys) { - if (keys.add(location)) { - if (isWidgetAtlasAvailable) { - queueRebuild() - } - } - } - - // optimistic: we should not create a lot of instances of this class - synchronized(atlasListeners) { - atlasListeners.add(WeakReference(this)) - val iterator = atlasListeners.listIterator() - - for (ref in iterator) { - val value = ref.get() - - if (value == null) { - iterator.remove() - } - } - } - - if (isWidgetAtlasAvailable) { - earlyBindingImpl() - } - } - - private fun earlyBindingImpl() { - if (WidgetAtlasHolder.INSTANCE.once) { - textureAtlasSpriteImpl - } - } - - private var changeset = -1 - private var _textureAtlasSprite: TextureAtlasSprite? = null - - private val textureAtlasSpriteImpl: TextureAtlasSprite get(): TextureAtlasSprite { - check(isClient) { "Invalid realm" } - val _textureAtlasSprite = _textureAtlasSprite - - if ( - _textureAtlasSprite == null || - _textureAtlasSprite.contents().name().let { it.namespace == "minecraft" && it.path == "missingno" } || - changeset != WidgetAtlasHolder.INSTANCE.changeset - ) { - val get = WidgetAtlasHolder.INSTANCE.getSprite(location) - this._textureAtlasSprite = get - changeset = WidgetAtlasHolder.INSTANCE.changeset - - u0 = get.u0 - v0 = get.v0 - u1 = get.u1 - (get.u1 - get.u0) * (1f - width / spriteWidth) - v1 = get.v1 - (get.v1 - get.v0) * (1f - height / spriteHeight) - - notifyListeners() - - return get - } - - return _textureAtlasSprite - } - - val textureAtlasSprite: TextureAtlasSprite get(): TextureAtlasSprite { - check(isWidgetAtlasAvailable) { "Atlas is not available; either we are not a client, or we are running datagen" } - return textureAtlasSpriteImpl - } - - override var u0 = 0f - private set - override var v0 = 0f - private set - override var u1 = 0f - private set - override var v1 = 0f - private set - - override val texture: ResourceLocation get() = WidgetAtlasHolder.LOCATION - - override fun equals(other: Any?): Boolean { - if (other is AtlasSkinElement) - return location == other.location - - return super.equals(other) - } - - override fun hashCode(): Int { - return WidgetAtlasHolder.INSTANCE.hashCode() xor location.hashCode() - } - - override fun toString(): String { - return "AtlasSkinElement[$location]" - } - - override val type: SkinElementType - get() = SkinElementType.ATLAS - - companion object { - private val keys = HashSet() - private val atlasListeners = ArrayList>() - val keysStream: Stream get() = keys.stream() - - fun notifyListeners() { - synchronized(atlasListeners) { - val iterator = atlasListeners.listIterator() - - for (ref in iterator) { - val value = ref.get() - - if (value == null) { - iterator.remove() - } else { - value.textureAtlasSpriteImpl - } - } - } - } - - private fun queueRebuild() { - WidgetAtlasHolder.INSTANCE.queueRebuild() - } - - val renderTypeNoDepth by lazy { - val builder = RenderType.CompositeState.builder() - - builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, false, false)) - builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) - builder.setDepthTestState(RenderStateShard.DepthTestStateShard("always", GL_ALWAYS)) - builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - }, { - RenderSystem.disableBlend() - })) - - @Suppress("INACCESSIBLE_TYPE") - RenderType.create("otm_gui_element_no_depth", - DefaultVertexFormat.POSITION_COLOR_TEX, - VertexFormat.Mode.QUADS, - 2048, - false, - false, - builder.createCompositeState(false)) as RenderType - } - - val renderTypeDepth by lazy { - val builder = RenderType.CompositeState.builder() - - builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, false, false)) - builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) - builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - }, { - RenderSystem.disableBlend() - })) - - @Suppress("INACCESSIBLE_TYPE") - RenderType.create("otm_gui_element_depth", - DefaultVertexFormat.POSITION_COLOR_TEX, - VertexFormat.Mode.QUADS, - 2048, - false, - false, - builder.createCompositeState(false)) as RenderType - } - - val renderTypeWorld by lazy { - val builder = RenderType.CompositeState.builder() - - builder.setTextureState(TextureStateShard(WidgetAtlasHolder.LOCATION, false, false)) - builder.setShaderState(RenderStateShard.ShaderStateShard(GameRenderer::getPositionColorTexShader)) - builder.setTransparencyState(RenderStateShard.TransparencyStateShard("normal_blend", { - RenderSystem.enableBlend() - RenderSystem.defaultBlendFunc() - }, { - RenderSystem.disableBlend() - })) - - @Suppress("INACCESSIBLE_TYPE") - RenderType.create("otm_gui_element_world", - DefaultVertexFormat.POSITION_COLOR_TEX, - VertexFormat.Mode.QUADS, - 8192, - false, - false, - builder.createCompositeState(false)) as RenderType - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt index 2e54a7fee..29c5c343d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/DynamicBufferSource.kt @@ -143,9 +143,9 @@ class DynamicBufferSource(val minimalInitialBufferSize: Int = 0, val maximalInit next = State(RenderType.waterMask(), ImmutableList.of(next.type), true, false) it.add(next) - it.add(State(AtlasSkinElement.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasSkinElement.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) - it.add(State(AtlasSkinElement.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) + it.add(State(AtlasMatterySprite.renderTypeDepth, ImmutableList.of(RenderType.waterMask()), true)) + it.add(State(AtlasMatterySprite.renderTypeNoDepth, ImmutableList.of(RenderType.waterMask()), true)) + it.add(State(AtlasMatterySprite.renderTypeWorld, ImmutableList.of(Sheets.signSheet()), true)) } private fun determineHeight(input: State, seen: MutableSet) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt similarity index 60% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt index b590d5b72..afd08f149 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/MatterySprite.kt @@ -1,21 +1,6 @@ package ru.dbotthepony.mc.otm.client.render -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer -import com.google.gson.JsonSyntaxException -import com.google.gson.TypeAdapter -import com.google.gson.internal.bind.TypeAdapters -import com.google.gson.stream.JsonReader -import com.google.gson.stream.JsonWriter -import net.minecraft.network.FriendlyByteBuf import net.minecraft.resources.ResourceLocation -import ru.dbotthepony.mc.otm.core.set -import java.lang.reflect.Type fun ResourceLocation.element( x: Float, @@ -24,14 +9,14 @@ fun ResourceLocation.element( height: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, width, height, textureWidth, textureHeight) +) = MatterySprite(this, x, y, width, height, textureWidth, textureHeight) fun ResourceLocation.pixel( x: Float, y: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, 1f, 1f, textureWidth, textureHeight) +) = MatterySprite(this, x, y, 1f, 1f, textureWidth, textureHeight) fun ResourceLocation.hLine( x: Float, @@ -39,7 +24,7 @@ fun ResourceLocation.hLine( width: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, width, 1f, textureWidth, textureHeight) +) = MatterySprite(this, x, y, width, 1f, textureWidth, textureHeight) fun ResourceLocation.vLine( x: Float, @@ -47,10 +32,10 @@ fun ResourceLocation.vLine( height: Float, textureWidth: Float = 256f, textureHeight: Float = 256f -) = SkinElement(this, x, y, 1f, height, textureWidth, textureHeight) +) = MatterySprite(this, x, y, 1f, height, textureWidth, textureHeight) @Suppress("unused") -data class SkinElement @JvmOverloads constructor( +data class MatterySprite @JvmOverloads constructor( override val texture: ResourceLocation, val x: Float, val y: Float, @@ -59,7 +44,7 @@ data class SkinElement @JvmOverloads constructor( val imageWidth: Float = 256f, val imageHeight: Float = 256f, override val winding: UVWindingOrder = UVWindingOrder.NORMAL, -) : AbstractSkinElement() { +) : AbstractMatterySprite() { init { require(x >= 0f) { "Invalid x $x" } require(y >= 0f) { "Invalid y $y" } @@ -67,6 +52,9 @@ data class SkinElement @JvmOverloads constructor( require(height > 0f) { "Invalid height $height" } require(imageWidth > 0f) { "Invalid image width $imageWidth" } require(imageHeight > 0f) { "Invalid image height $imageHeight" } + + require(width <= imageWidth) { "$width <= $imageWidth" } + require(height <= imageHeight) { "$height <= $imageHeight" } } override val u0 = this.x / imageWidth diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt index 02abfc9ee..c80ea1ee3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/ResearchIcons.kt @@ -4,37 +4,37 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object ResearchIcons { - val ICON_TRANSFER: AbstractSkinElement - val ICON_ATTACK_BOOST: AbstractSkinElement - val ICON_PLASMA_SHIELD_BOOST: AbstractSkinElement - val ICON_CLOAK: AbstractSkinElement - val ICON_GRAVITATIONAL_STABILIZER: AbstractSkinElement - val ICON_AIR_BAGS: AbstractSkinElement - val ICON_JUMP_BOOST: AbstractSkinElement + val ICON_TRANSFER: AbstractMatterySprite + val ICON_ATTACK_BOOST: AbstractMatterySprite + val ICON_PLASMA_SHIELD_BOOST: AbstractMatterySprite + val ICON_CLOAK: AbstractMatterySprite + val ICON_GRAVITATIONAL_STABILIZER: AbstractMatterySprite + val ICON_AIR_BAGS: AbstractMatterySprite + val ICON_JUMP_BOOST: AbstractMatterySprite - val ICON_FEATHER_FALLING: AbstractSkinElement - val ICON_ITEM_MAGNET: AbstractSkinElement - val ICON_ARROW: AbstractSkinElement - val ICON_ARMOR: AbstractSkinElement - val ICON_NANOBOTS: AbstractSkinElement - val ICON_NIGHT_VISION: AbstractSkinElement - val ICON_OXYGEN_SUPPLY: AbstractSkinElement + val ICON_FEATHER_FALLING: AbstractMatterySprite + val ICON_ITEM_MAGNET: AbstractMatterySprite + val ICON_ARROW: AbstractMatterySprite + val ICON_ARMOR: AbstractMatterySprite + val ICON_NANOBOTS: AbstractMatterySprite + val ICON_NIGHT_VISION: AbstractMatterySprite + val ICON_OXYGEN_SUPPLY: AbstractMatterySprite - val ICON_PLASMA_SHIELD: AbstractSkinElement - val ICON_SHOCKWAVE: AbstractSkinElement - val ICON_LIMB_OVERCLOCKING: AbstractSkinElement - val ICON_STEP_ASSIST: AbstractSkinElement - val ICON_ENDER_TELEPORT: AbstractSkinElement - val ICON_WIRELESS_CHARGING: AbstractSkinElement - val ICON_UNKNOWN: AbstractSkinElement + val ICON_PLASMA_SHIELD: AbstractMatterySprite + val ICON_SHOCKWAVE: AbstractMatterySprite + val ICON_LIMB_OVERCLOCKING: AbstractMatterySprite + val ICON_STEP_ASSIST: AbstractMatterySprite + val ICON_ENDER_TELEPORT: AbstractMatterySprite + val ICON_WIRELESS_CHARGING: AbstractMatterySprite + val ICON_UNKNOWN: AbstractMatterySprite - val ICON_EXTENDED_REACH: AbstractSkinElement - val ICON_PHANTOM_ATTRACTOR: AbstractSkinElement + val ICON_EXTENDED_REACH: AbstractMatterySprite + val ICON_PHANTOM_ATTRACTOR: AbstractMatterySprite val KOT = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/block/ph_kitty.png").element(0f, 0f, 32f, 32f, 32f, 32f) init { - val grid = SubSkinGrid(AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7) + val grid = SubSkinGrid(AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "android_upgrades"), 126f, 126f), 18f, 18f, 7, 7) ICON_TRANSFER = grid.next() ICON_ATTACK_BOOST = grid.next() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt index e8af0c1a5..6a729cf7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinElementType.kt @@ -9,8 +9,8 @@ import ru.dbotthepony.mc.otm.core.set enum class SkinElementType { SINGLE { - override fun toJson(value: AbstractSkinElement): JsonObject { - require(value is SkinElement) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } + override fun toJson(value: AbstractMatterySprite): JsonObject { + require(value is MatterySprite) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } return JsonObject().also { it["texture"] = JsonPrimitive(value.texture.toString()) @@ -24,8 +24,8 @@ enum class SkinElementType { } } - override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { - require(value is SkinElement) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } + override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { + require(value is MatterySprite) { "Invalid skin element provided, expected SkinElement, got ${value::class.qualifiedName}" } buff.writeUtf(value.texture.toString()) buff.writeFloat(value.x) @@ -37,7 +37,7 @@ enum class SkinElementType { buff.writeEnum(value.winding) } - override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val texture = ResourceLocation(buff.readUtf()) val x = buff.readFloat() val y = buff.readFloat() @@ -47,10 +47,10 @@ enum class SkinElementType { val imageHeight = buff.readFloat() val winding = buff.readEnum(UVWindingOrder::class.java) - return SkinElement(texture, x, y, width, height, imageWidth, imageHeight, winding) + return MatterySprite(texture, x, y, width, height, imageWidth, imageHeight, winding) } - override fun fromJson(element: JsonObject): AbstractSkinElement { + override fun fromJson(element: JsonObject): AbstractMatterySprite { val texture = element["texture"]?.asString ?: throw JsonSyntaxException("Missing texture element") val x = element["x"]?.asFloat ?: throw JsonSyntaxException("Missing x element") val y = element["y"]?.asFloat ?: throw JsonSyntaxException("Missing y element") @@ -60,12 +60,12 @@ enum class SkinElementType { val imageHeight = element["imageHeight"]?.asFloat ?: throw JsonSyntaxException("Missing imageHeight element") val winding = element["winding"]?.asString ?: throw JsonSyntaxException("Missing winding element") - return SkinElement(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding)) + return MatterySprite(ResourceLocation.tryParse(texture) ?: throw JsonSyntaxException("Invalid resource location: $texture"), x, y, width, height, imageWidth, imageHeight, UVWindingOrder.valueOf(winding)) } }, ATLAS { - override fun toJson(value: AbstractSkinElement): JsonObject { - require(value is AtlasSkinElement) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } + override fun toJson(value: AbstractMatterySprite): JsonObject { + require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } return JsonObject().also { it["location"] = JsonPrimitive(value.location.toString()) @@ -74,33 +74,33 @@ enum class SkinElementType { } } - override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { - require(value is AtlasSkinElement) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } + override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { + require(value is AtlasMatterySprite) { "Invalid skin element provided, expected AtlasSkinElement, got ${value::class.qualifiedName}" } buff.writeResourceLocation(value.location) buff.writeFloat(value.width) buff.writeFloat(value.height) } - override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val location = ResourceLocation(buff.readUtf()) val width = buff.readFloat() val height = buff.readFloat() - return AtlasSkinElement(location, width, height) + return AtlasMatterySprite(location, width, height) } - override fun fromJson(element: JsonObject): AbstractSkinElement { + override fun fromJson(element: JsonObject): AbstractMatterySprite { val location = element["location"]?.asString ?: throw JsonSyntaxException("Missing location element") val width = element["width"]?.asFloat ?: throw JsonSyntaxException("Missing width element") val height = element["height"]?.asFloat ?: throw JsonSyntaxException("Missing height element") - return AtlasSkinElement(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height) + return AtlasMatterySprite(ResourceLocation.tryParse(location) ?: throw JsonSyntaxException("Invalid resource location: $location"), width, height) } }, SUBELEMENT { - override fun toJson(value: AbstractSkinElement): JsonObject { - require(value is SubSkinElement) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } + override fun toJson(value: AbstractMatterySprite): JsonObject { + require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } return JsonObject().also { it["parent"] = value.parent.toJson() @@ -111,8 +111,8 @@ enum class SkinElementType { } } - override fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { - require(value is SubSkinElement) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } + override fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { + require(value is SubMatterySprite) { "Invalid skin element provided, expected SubSkinElement, got ${value::class.qualifiedName}" } value.parent.toNetwork(buff) buff.writeFloat(value.xOffset) @@ -121,50 +121,50 @@ enum class SkinElementType { buff.writeFloat(value.height) } - override fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + override fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val parent = Companion.fromNetwork(buff) val xOffset = buff.readFloat() val yOffset = buff.readFloat() val subWidth = buff.readFloat() val subHeight = buff.readFloat() - return SubSkinElement(parent, xOffset, yOffset, subWidth, subHeight) + return SubMatterySprite(parent, xOffset, yOffset, subWidth, subHeight) } - override fun fromJson(element: JsonObject): AbstractSkinElement { + override fun fromJson(element: JsonObject): AbstractMatterySprite { val parent = element["parent"] as? JsonObject ?: throw JsonSyntaxException("Invalid parent") val xOffset = element["xOffset"].asFloat val yOffset = element["yOffset"].asFloat val subWidth = element["subWidth"].asFloat val subHeight = element["subHeight"].asFloat - return SubSkinElement(Companion.fromJson(parent), xOffset, yOffset, subWidth, subHeight) + return SubMatterySprite(Companion.fromJson(parent), xOffset, yOffset, subWidth, subHeight) } }; - protected abstract fun toJson(value: AbstractSkinElement): JsonObject - protected abstract fun toNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) - protected abstract fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement - protected abstract fun fromJson(element: JsonObject): AbstractSkinElement + protected abstract fun toJson(value: AbstractMatterySprite): JsonObject + protected abstract fun toNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) + protected abstract fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite + protected abstract fun fromJson(element: JsonObject): AbstractMatterySprite - fun toActualJson(value: AbstractSkinElement): JsonObject { + fun toActualJson(value: AbstractMatterySprite): JsonObject { return toJson(value).also { it["type"] = JsonPrimitive(name) } } - fun toActualNetwork(value: AbstractSkinElement, buff: FriendlyByteBuf) { + fun toActualNetwork(value: AbstractMatterySprite, buff: FriendlyByteBuf) { buff.writeEnum(this) toNetwork(value, buff) } companion object { - fun fromNetwork(buff: FriendlyByteBuf): AbstractSkinElement { + fun fromNetwork(buff: FriendlyByteBuf): AbstractMatterySprite { val type = buff.readEnum(SkinElementType::class.java) return type.fromNetwork(buff) } - fun fromJson(element: JsonObject): AbstractSkinElement { + fun fromJson(element: JsonObject): AbstractMatterySprite { val type = SkinElementType.valueOf(element["type"].asString) return type.fromJson(element) } 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 index ca4e96896..7861590dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SkinGrid.kt @@ -35,8 +35,8 @@ data class SkinGrid( return this } - fun next(): SkinElement { - val element = SkinElement(texture, currentX, currentY, width, height, imageWidth, imageHeight) + fun next(): MatterySprite { + val element = MatterySprite(texture, currentX, currentY, width, height, imageWidth, imageHeight) skip() return element } @@ -54,5 +54,5 @@ data class SkinGrid( } operator fun get(column: Int, row: Int) = - SkinElement(texture, column * width, row * height, width, height, imageWidth, imageHeight) + MatterySprite(texture, column * width, row * height, width, height, imageWidth, imageHeight) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt index 8fe0010fb..4af924f63 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/StretchingRectangleElement.kt @@ -5,15 +5,15 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty data class StretchingRectangleElement( - val topLeft: AbstractSkinElement, - val topRight: AbstractSkinElement, - val bottomLeft: AbstractSkinElement, - val bottomRight: AbstractSkinElement, - val left: AbstractSkinElement, - val right: AbstractSkinElement, - val top: AbstractSkinElement, - val bottom: AbstractSkinElement, - val middle: AbstractSkinElement, + val topLeft: AbstractMatterySprite, + val topRight: AbstractMatterySprite, + val bottomLeft: AbstractMatterySprite, + val bottomRight: AbstractMatterySprite, + val left: AbstractMatterySprite, + val right: AbstractMatterySprite, + val top: AbstractMatterySprite, + val bottom: AbstractMatterySprite, + val middle: AbstractMatterySprite, val padding: DockProperty = DockProperty.EMPTY ) { fun render( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinElement.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt similarity index 80% rename from src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinElement.kt rename to src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt index 61dc54c57..196317389 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinElement.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubMatterySprite.kt @@ -2,14 +2,14 @@ package ru.dbotthepony.mc.otm.client.render import net.minecraft.resources.ResourceLocation -class SubSkinElement( - val parent: AbstractSkinElement, +class SubMatterySprite( + val parent: AbstractMatterySprite, val xOffset: Float = 0f, val yOffset: Float = 0f, override val width: Float = parent.width, override val height: Float = parent.height, private val overrideWinding: UVWindingOrder? = null -) : AbstractSkinElement.Mutable() { +) : AbstractMatterySprite.Mutable() { override var u0: Float = 0f private set override var v0: Float = 0f @@ -28,7 +28,7 @@ class SubSkinElement( notifyListeners() } - override fun parentChanges(parent: AbstractSkinElement) = calculateUVs() + override fun parentChanges(parent: AbstractMatterySprite) = calculateUVs() init { parent.addListener(this) @@ -53,12 +53,12 @@ class SubSkinElement( width: Float = this.width, height: Float = this.height, overrideWinding: UVWindingOrder? = this.overrideWinding - ) = SubSkinElement(parent, xOffset, yOffset, width, height, overrideWinding) + ) = SubMatterySprite(parent, xOffset, yOffset, width, height, overrideWinding) } -fun AbstractSkinElement.subElement( +fun AbstractMatterySprite.subElement( x: Float = 0f, y: Float = 0f, width: Float = this.width, height: Float = this.height, -) = SubSkinElement(this, x, y, width, height) +) = SubMatterySprite(this, x, y, width, height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt index 65cabcfec..ea740df7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/SubSkinGrid.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.render @Suppress("unused") data class SubSkinGrid( - val parent: AbstractSkinElement, + val parent: AbstractMatterySprite, val width: Float, val height: Float, val columns: Int = 16, @@ -30,7 +30,7 @@ data class SubSkinGrid( return this } - fun next(): AbstractSkinElement { + fun next(): AbstractMatterySprite { val element = parent.subElement(currentX, currentY, width, height) skip() return element @@ -52,7 +52,7 @@ data class SubSkinGrid( parent.subElement(column * width, row * height, width, height) } -fun AbstractSkinElement.subGrid( +fun AbstractMatterySprite.subGrid( width: Float, height: Float, columns: Int = 16, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt deleted file mode 100644 index 9825bcc07..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetAtlasHolder.kt +++ /dev/null @@ -1,99 +0,0 @@ -package ru.dbotthepony.mc.otm.client.render - -import net.minecraft.client.renderer.texture.TextureAtlas -import net.minecraft.client.renderer.texture.TextureAtlasSprite -import net.minecraft.client.renderer.texture.TextureManager -import net.minecraft.client.resources.TextureAtlasHolder -import net.minecraft.resources.ResourceLocation -import net.minecraft.server.packs.resources.ResourceManager -import net.minecraft.util.profiling.ProfilerFiller -import net.minecraftforge.client.event.RegisterClientReloadListenersEvent -import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.isClientThread -import ru.dbotthepony.mc.otm.core.WriteOnce -import java.util.stream.Stream -import kotlin.properties.Delegates - -var isWidgetAtlasAvailable: Boolean = false - private set - -class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAtlasHolder(manager, LOCATION, INFO_LOCATION) { - var changeset = 0 - private set - - var once = false - private set - var demandsRebuild = false - private set - - private var resourceManager by Delegates.notNull() - private var profileManager by Delegates.notNull() - - override fun prepare(p_118891_: ResourceManager, p_118892_: ProfilerFiller): TextureAtlas.Preparations { - resourceManager = p_118891_ - profileManager = p_118892_ - changeset++ - return super.prepare(p_118891_, p_118892_) - } - - override fun apply(p_118894_: TextureAtlas.Preparations, p_118895_: ResourceManager, p_118896_: ProfilerFiller) { - once = true - resourceManager = p_118895_ - profileManager = p_118896_ - changeset++ - super.apply(p_118894_, p_118895_, p_118896_) - AtlasSkinElement.notifyListeners() - } - - fun rebuildIfRequired(): Boolean { - if (once && demandsRebuild && isClientThread()) { - apply(prepare(resourceManager, profileManager), resourceManager, profileManager) - } - - return demandsRebuild - } - - public override fun getSprite(p_118902_: ResourceLocation): TextureAtlasSprite { - if (!once) { - throw IllegalStateException("Trying to get sprite too early") - } - - return super.getSprite(p_118902_) - } - - fun queueRebuild() { - demandsRebuild = true - } - - override fun getResourcesToLoad(): Stream { - demandsRebuild = false - return AtlasSkinElement.keysStream - } - - companion object { - @JvmStatic - val LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/atlas/gui.png") - - @JvmStatic - val INFO_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "fuck/you/mojang") - - @JvmStatic - var INSTANCE: WidgetAtlasHolder by WriteOnce() - private set - - @JvmStatic - fun register(event: RegisterClientReloadListenersEvent) { - INSTANCE = WidgetAtlasHolder(minecraft.textureManager) - event.registerReloadListener(INSTANCE) - isWidgetAtlasAvailable = true - } - - @JvmStatic - fun renderGameHook() { - if (isWidgetAtlasAvailable) { - INSTANCE.rebuildIfRequired() - } - } - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt index 85b3a3bb3..813924b33 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/WidgetLocation.kt @@ -6,11 +6,11 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters object WidgetLocation { val WIDGETS_18 = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/widgets_18.png") - val MISC = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f) - val PATTERN_PANEL_TABS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f) + val MISC = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/misc"), 64f, 64f) + val PATTERN_PANEL_TABS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/pattern_panel_tabs"), 64f, 32f) - val CHECKBOX = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f) - val PROGRESS_ARROWS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f) - val HORIZONTAL_GAUGES = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f) - val VERTICAL_GAUGES = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f) + val CHECKBOX = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/checkbox"), 32f, 64f) + val PROGRESS_ARROWS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/progress_arrows"), 32f, 32f) + val HORIZONTAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/horizontal_gauges"), 128f, 64f) + val VERTICAL_GAUGES = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/vertical_gauges"), 128f, 48f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt index 4b39a9136..0a631c678 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/Widgets8.kt @@ -4,7 +4,7 @@ import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters object Widgets8 { - val GRID = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8) + val GRID = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets_8"), 64f, 32f).subGrid(8f, 8f, 64 / 8, 32 / 8) val BUTTON_IDLE = GRID[0, 0] val BUTTON_HOVERED = GRID[0, 1] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt index 038fe9ec9..716a5c5ce 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BankRenderer.kt @@ -9,8 +9,7 @@ import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement -import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel @@ -20,7 +19,7 @@ import kotlin.math.PI abstract class BankRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer { protected abstract fun gaugeLevel(entity: T): Float - protected abstract val texture: AbstractSkinElement + protected abstract val texture: AbstractMatterySprite override fun render( blockEntity: T, @@ -53,7 +52,7 @@ abstract class BankRenderer(private val context: BlockEn val width = 9f val heightMax = 39.36f - val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasSkinElement.renderTypeWorld) + val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasMatterySprite.renderTypeWorld) texture.uploadOntoPartialColor( stack, @@ -85,7 +84,7 @@ class BatteryBankRenderer(context: BlockEntityRendererProvider.Context) : BankRe return entity.gaugeLevel } - override val texture: AbstractSkinElement + override val texture: AbstractMatterySprite get() = PowerGaugePanel.GAUGE_FOREGROUND } @@ -94,7 +93,7 @@ class MatterBatteryBankRenderer(context: BlockEntityRendererProvider.Context) : return entity.gaugeLevel } - override val texture: AbstractSkinElement + override val texture: AbstractMatterySprite get() = MatterGaugePanel.GAUGE_FOREGROUND } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt index d7bcb2480..8c07d8624 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/AbstractSlotPanel.kt @@ -19,7 +19,7 @@ abstract class AbstractSlotPanel> @JvmOverloads constru y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - open val noItemIcon: SkinElement? = null + open val noItemIcon: MatterySprite? = null ) : EditablePanel(screen, parent, x, y, width, height), IItemStackPanel { protected open fun renderSlotBackground(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { SLOT_BACKGROUND.render(stack, width = width, height = height) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt index 25f731094..fc9688dd9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/FramePanel.kt @@ -25,8 +25,8 @@ open class FramePanel( open inner class Tab( var onOpen: Runnable? = null, var onClose: Runnable? = null, - var activeIcon: AbstractSkinElement? = null, - var inactiveIcon: AbstractSkinElement? = null, + var activeIcon: AbstractMatterySprite? = null, + var inactiveIcon: AbstractMatterySprite? = null, ) : EditablePanel(this@FramePanel.screen, this@FramePanel, 0f, 0f, 28f, 28f) { var isActive = tabs.isEmpty() var initial = false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt index 4ebe6a900..68013d638 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/HeightControls.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels import com.mojang.blaze3d.platform.InputConstants import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel @@ -45,10 +45,10 @@ open class HeightControls( } open inner class Control(val isIncrease: Boolean) : RectangleButtonPanel(screen, this@HeightControls, width = BUTTON_WIDTH, height = BUTTON_HEIGHT) { - override val PRESSED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED - override val HOVERED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED - override val IDLE: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE - override val DISABLED: AbstractSkinElement = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_DISABLED else Widgets.ARROW_UP_BUTTON_DISABLED + override val PRESSED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_PRESSED else Widgets.ARROW_UP_BUTTON_PRESSED + override val HOVERED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_HOVERED else Widgets.ARROW_UP_BUTTON_HOVERED + override val IDLE: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_IDLE else Widgets.ARROW_UP_BUTTON_IDLE + override val DISABLED: AbstractMatterySprite = if (isIncrease) Widgets.ARROW_DOWN_BUTTON_DISABLED else Widgets.ARROW_UP_BUTTON_DISABLED init { dock = Dock.TOP diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt index ab67f2dca..46242cf9c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/ScrollBarConstants.kt @@ -2,34 +2,30 @@ package ru.dbotthepony.mc.otm.client.screen.panels import net.minecraft.resources.ResourceLocation import ru.dbotthepony.mc.otm.OverdriveThatMatters -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement -import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement -import ru.dbotthepony.mc.otm.client.render.WidgetLocation -import ru.dbotthepony.mc.otm.client.render.element import ru.dbotthepony.mc.otm.client.render.subElement object ScrollBarConstants { const val WIDTH = 14f const val SLIM_WIDTH = 8f - val BACKGROUND = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f) - val BACKGROUND_SLIM = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f) + val BACKGROUND = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/background"), 14f, 8f) + val BACKGROUND_SLIM = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/background"), 8f, 8f) val TOP = BACKGROUND.subElement(height = 2f) val BODY = BACKGROUND.subElement(y = 2f, height = 5f) val BOTTOM = BACKGROUND.subElement(y = 6f, height = 2f) - val BUTTON = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f) - val BUTTON_HOVER = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f) - val BUTTON_PRESS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f) - val BUTTON_DISABLED = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f) + val BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/idle"), 12f, 15f) + val BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/hovered"), 12f, 15f) + val BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/pressed"), 12f, 15f) + val BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar/disabled"), 12f, 15f) val SLIM_TOP = BACKGROUND_SLIM.subElement(height = 2f) val SLIM_BODY = BACKGROUND_SLIM.subElement(y = 2f, height = 5f) val SLIM_BOTTOM = BACKGROUND_SLIM.subElement(y = 6f, height = 2f) - val SLIM_BUTTON = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f) - val SLIM_BUTTON_HOVER = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f) - val SLIM_BUTTON_PRESS = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f) - val SLIM_BUTTON_DISABLED = AtlasSkinElement(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f) + val SLIM_BUTTON = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/idle"), 6f, 15f) + val SLIM_BUTTON_HOVER = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/hovered"), 6f, 15f) + val SLIM_BUTTON_PRESS = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/pressed"), 6f, 15f) + val SLIM_BUTTON_DISABLED = AtlasMatterySprite(ResourceLocation(OverdriveThatMatters.MOD_ID, "widgets/scrollbar_slim/disabled"), 6f, 15f) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt index f2d037a88..f411c6a7d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/SlotPanel.kt @@ -6,13 +6,12 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.GuiComponent -import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen import net.minecraft.client.renderer.GameRenderer import net.minecraft.world.inventory.AbstractContainerMenu import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.render.drawRect import ru.dbotthepony.mc.otm.client.render.setDrawColor @@ -28,7 +27,7 @@ open class SlotPanel, out T : Slot> @JvmOverloads const y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: SkinElement? = null + noItemIcon: MatterySprite? = null ) : AbstractSlotPanel(screen, parent, x, y, width, height, noItemIcon), ISlotPanel { override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { screen.returnSlot = slot diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt index 3fa9707d0..11da9ffe8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/BooleanRectangleButtonPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter import ru.dbotthepony.mc.otm.core.value @@ -16,8 +16,8 @@ abstract class BooleanRectangleButtonPanel( width: Float, height: Float, val prop: GetterSetter, - val skinElementActive: AbstractSkinElement? = null, - val skinElementInactive: AbstractSkinElement? = null, + val skinElementActive: AbstractMatterySprite? = null, + val skinElementInactive: AbstractMatterySprite? = null, val onChange: ((newValue: Boolean) -> Unit)? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { override fun onClick(clickButton: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt index 084ee8479..6db631948 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/CheckBoxPanel.kt @@ -4,7 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.WidgetLocation import ru.dbotthepony.mc.otm.client.render.subGrid import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -81,14 +81,14 @@ open class CheckBoxPanel @JvmOverloads constructor( companion object { const val REGULAR_DIMENSIONS = 15f - val IDLE_UNCHECKED: AbstractSkinElement - val IDLE_CHECKED: AbstractSkinElement - val HOVERED_UNCHECKED: AbstractSkinElement - val HOVERED_CHECKED: AbstractSkinElement - val PRESSED_UNCHECKED: AbstractSkinElement - val PRESSED_CHECKED: AbstractSkinElement - val DISABLED_UNCHECKED: AbstractSkinElement - val DISABLED_CHECKED: AbstractSkinElement + val IDLE_UNCHECKED: AbstractMatterySprite + val IDLE_CHECKED: AbstractMatterySprite + val HOVERED_UNCHECKED: AbstractMatterySprite + val HOVERED_CHECKED: AbstractMatterySprite + val PRESSED_UNCHECKED: AbstractMatterySprite + val PRESSED_CHECKED: AbstractMatterySprite + val DISABLED_UNCHECKED: AbstractMatterySprite + val DISABLED_CHECKED: AbstractMatterySprite init { val grid = WidgetLocation.CHECKBOX.subGrid(REGULAR_DIMENSIONS, REGULAR_DIMENSIONS, 2, 4) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt index 3649a5e45..840cb3d85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/EnumRectangleButtonPanel.kt @@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.ChatFormatting import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -30,7 +30,7 @@ abstract class EnumRectangleButtonPanel>( ) : RectangleButtonPanel(screen, parent, x, y, width, height, null) { private var building = true - protected val enumMapping = EnumMap>(enum) + protected val enumMapping = EnumMap>(enum) protected val tooltipMapping = EnumMap(enum) fun addTooltip(value: T, component: Component): EnumRectangleButtonPanel { @@ -69,19 +69,19 @@ abstract class EnumRectangleButtonPanel>( return missing } - fun add(value: T, skinElement: AbstractSkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + fun add(value: T, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(value, skinElement to winding) } - fun add(value: T, skinElement: AbstractSkinElement, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + fun add(value: T, skinElement: AbstractMatterySprite, component: Component, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(value, component, skinElement to winding) } - fun add(value: T, component: Component, skinElement: AbstractSkinElement, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { + fun add(value: T, component: Component, skinElement: AbstractMatterySprite, winding: UVWindingOrder = UVWindingOrder.NORMAL): EnumRectangleButtonPanel { return add(value, component, skinElement to winding) } - fun add(value: T, pair: Pair): EnumRectangleButtonPanel { + fun add(value: T, pair: Pair): EnumRectangleButtonPanel { check(building) { "Not building" } check(enumMapping.put(value, pair) == null) { "Already has mapping for $value" } @@ -92,7 +92,7 @@ abstract class EnumRectangleButtonPanel>( return this } - fun add(value: T, component: Component, pair: Pair): EnumRectangleButtonPanel { + fun add(value: T, component: Component, pair: Pair): EnumRectangleButtonPanel { addTooltip(value, component) return add(value, pair) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt index 506bb2f8d..f541cab21 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeBooleanRectangleButtonPanel.kt @@ -1,7 +1,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.core.GetterSetter @@ -14,8 +14,8 @@ open class LargeBooleanRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, prop: GetterSetter, - skinElementActive: AbstractSkinElement? = null, - skinElementInactive: AbstractSkinElement? = null, + skinElementActive: AbstractMatterySprite? = null, + skinElementInactive: AbstractMatterySprite? = null, onChange: ((newValue: Boolean) -> Unit)? = null, ) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) { final override val IDLE = Widgets18.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt index 4ebf8e9d9..f18cfc5ab 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/LargeRectangleButtonPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets18 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -15,7 +15,7 @@ open class LargeRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, onPress: ((clickButton: Int) -> Unit)? = null, - val skinElement: AbstractSkinElement? = null, + val skinElement: AbstractMatterySprite? = null, val skinElementWinding: UVWindingOrder? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, onPress) { final override val IDLE = Widgets18.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt index fe808675d..91f7bde54 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/RectangleButtonPanel.kt @@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen import ru.dbotthepony.mc.otm.client.playGuiClickSound -import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement +import ru.dbotthepony.mc.otm.client.render.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @Suppress("PropertyName") @@ -22,10 +22,10 @@ abstract class RectangleButtonPanel( onPress?.invoke(clickButton) } - abstract val PRESSED: AbstractSkinElement - abstract val HOVERED: AbstractSkinElement - abstract val IDLE: AbstractSkinElement - abstract val DISABLED: AbstractSkinElement + abstract val PRESSED: AbstractMatterySprite + abstract val HOVERED: AbstractMatterySprite + abstract val IDLE: AbstractMatterySprite + abstract val DISABLED: AbstractMatterySprite var isDisabled = false set(value) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt index 60babbc23..f255df62d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallBooleanRectangleButtonPanel.kt @@ -13,8 +13,8 @@ open class SmallBooleanRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, prop: GetterSetter, - skinElementActive: AbstractSkinElement? = null, - skinElementInactive: AbstractSkinElement? = null, + skinElementActive: AbstractMatterySprite? = null, + skinElementInactive: AbstractMatterySprite? = null, onChange: ((newValue: Boolean) -> Unit)? = null, ) : BooleanRectangleButtonPanel(screen, parent, x, y, width, height, prop, skinElementActive, skinElementInactive, onChange) { final override val IDLE = Widgets8.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt index 55db58e60..82a504e70 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/buttons/SmallRectangleButtonPanel.kt @@ -2,7 +2,7 @@ package ru.dbotthepony.mc.otm.client.screen.panels.buttons import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.gui.screens.Screen -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.UVWindingOrder import ru.dbotthepony.mc.otm.client.render.Widgets8 import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel @@ -15,7 +15,7 @@ open class SmallRectangleButtonPanel( width: Float = SIZE, height: Float = SIZE, onPress: ((clickButton: Int) -> Unit)? = null, - val skinElement: SkinElement? = null, + val skinElement: MatterySprite? = null, val skinElementWinding: UVWindingOrder? = null, ) : RectangleButtonPanel(screen, parent, x, y, width, height, onPress) { final override val IDLE = Widgets8.BUTTON_IDLE diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt index f3f98b207..ced32ebc1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/cos/CosmeticArmorCompat.kt @@ -17,7 +17,7 @@ import net.minecraft.world.inventory.Slot import net.minecraft.world.item.ItemStack import net.minecraftforge.fml.ModList import ru.dbotthepony.mc.otm.client.minecraft -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite import ru.dbotthepony.mc.otm.client.render.element import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.buttons.RectangleButtonPanel @@ -149,13 +149,13 @@ class CosmeticToggleButton( width: Float = 5f, height: Float = 5f ) : RectangleButtonPanel(screen, parent, x, y, width, height) { - override val PRESSED: SkinElement + override val PRESSED: MatterySprite get() = BUTTON_ACTIVE - override val HOVERED: SkinElement + override val HOVERED: MatterySprite get() = BUTTON_ACTIVE - override val IDLE: SkinElement + override val IDLE: MatterySprite get() = BUTTON_INACTIVE - override val DISABLED: SkinElement + override val DISABLED: MatterySprite get() = BUTTON_INACTIVE private val index = when (index) { @@ -198,13 +198,13 @@ class CosmeticToggleRenderButton( width: Float = 5f, height: Float = 5f ) : RectangleButtonPanel(screen, parent, x, y, width, height) { - override val PRESSED: SkinElement + override val PRESSED: MatterySprite get() = BUTTON_ACTIVE - override val HOVERED: SkinElement + override val HOVERED: MatterySprite get() = BUTTON_ACTIVE - override val IDLE: SkinElement + override val IDLE: MatterySprite get() = BUTTON_INACTIVE - override val DISABLED: SkinElement + override val DISABLED: MatterySprite get() = BUTTON_INACTIVE override fun onClick(clickButton: Int) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt index 8a7eaf3fd..b6d66e1f8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/SkinDrawable.kt @@ -2,9 +2,9 @@ package ru.dbotthepony.mc.otm.compat.jei import com.mojang.blaze3d.vertex.PoseStack import mezz.jei.api.gui.drawable.IDrawable -import ru.dbotthepony.mc.otm.client.render.SkinElement +import ru.dbotthepony.mc.otm.client.render.MatterySprite -class SkinDrawable(val element: SkinElement) : IDrawable { +class SkinDrawable(val element: MatterySprite) : IDrawable { override fun getWidth(): Int { return element.width.toInt() }