From f7c1ef2dda6ef954456cd7eed809323ba3cd66ec Mon Sep 17 00:00:00 2001 From: nea Date: Wed, 4 Oct 2023 19:19:44 +0200 Subject: [PATCH] Replace slot locking indicator with textures --- .../features/inventory/SlotLocking.kt | 32 +++++++++++------- .../textures/gui/sprites/slot_locked.png | Bin 0 -> 595 bytes .../gui/sprites/slot_locked.png.license | 3 ++ .../textures/gui/sprites/uuid_locked.png | Bin 0 -> 597 bytes .../gui/sprites/uuid_locked.png.license | 3 ++ 5 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 src/main/resources/assets/firmament/textures/gui/sprites/slot_locked.png create mode 100644 src/main/resources/assets/firmament/textures/gui/sprites/slot_locked.png.license create mode 100644 src/main/resources/assets/firmament/textures/gui/sprites/uuid_locked.png create mode 100644 src/main/resources/assets/firmament/textures/gui/sprites/uuid_locked.png.license diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt index 6ef9cf4..2f4f84b 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt @@ -7,6 +7,7 @@ package moe.nea.firmament.features.inventory +import com.mojang.blaze3d.systems.RenderSystem import java.util.* import org.lwjgl.glfw.GLFW import kotlinx.serialization.Serializable @@ -15,6 +16,7 @@ import kotlinx.serialization.serializer import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.entity.player.PlayerInventory import net.minecraft.screen.slot.SlotActionType +import net.minecraft.util.Identifier import moe.nea.firmament.events.HandledScreenKeyPressedEvent import moe.nea.firmament.events.IsSlotProtectedEvent import moe.nea.firmament.events.SlotRenderEvents @@ -157,25 +159,31 @@ object SlotLocking : FirmamentFeature { if (IsSlotProtectedEvent.shouldBlockInteraction(null, SlotActionType.THROW, stack)) anyBlocked = true } - if(anyBlocked) { + if (anyBlocked) { event.protectSilent() } } - SlotRenderEvents.Before.subscribe { + SlotRenderEvents.After.subscribe { val isSlotLocked = it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf()) val isUUIDLocked = (it.slot.stack?.skyblockUUID) in (lockedUUIDs ?: setOf()) if (isSlotLocked || isUUIDLocked) { - it.context.fill( - it.slot.x, - it.slot.y, - it.slot.x + 16, - it.slot.y + 16, - when { - isSlotLocked -> 0xFFFF0000.toInt() - isUUIDLocked -> 0xFF00FF00.toInt() - else -> error("Slot is locked, but not by slot or uuid") - } + RenderSystem.disableDepthTest() + it.context.drawSprite( + it.slot.x, it.slot.y, 0, + 16, 16, + MC.guiAtlasManager.getSprite( + when { + isSlotLocked -> + (Identifier("firmament:slot_locked")) + + isUUIDLocked -> + (Identifier("firmament:uuid_locked")) + else -> + error("unreachable") + } + ) ) + RenderSystem.enableDepthTest() } } } diff --git a/src/main/resources/assets/firmament/textures/gui/sprites/slot_locked.png b/src/main/resources/assets/firmament/textures/gui/sprites/slot_locked.png new file mode 100644 index 0000000000000000000000000000000000000000..612d2e3b18b9b2bc56d421201e8185b67774b096 GIT binary patch literal 595 zcmV-Z0<8UsP)EX>4Tx04R}tkv&MmKpe$i(~43m6)Y&?kfA!+MMWHI6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfb#YR3krMxx7Fxu3aNLh~_a1le0HIM~niYrxnr@rv zWJ1j5R>j^|1QEah!Wfd7Wz0!Z3ZCQZ9zMR_#dwzYxj#q0nztC>6N%%@Fm2)u;+aj` z;Ji;9VI^55J|~_q>4L>zBx-kgE(v zjs;YqL3aJ%fAG6ot1va$N(v=_o)^dY7z28Dfo9!tzK?&Kfh)b^uQq_$Ptxlh zEqVlmw}Ff6j;8DZmpj1llOdb3EBR>(g#z$?M&FbJ25*7jTC2DAK29Hi40V;d0S*p< z@gilfd%U}^ySIPOwEO!3MILgLpTsw-00006VoOIv00000008+zyMF)x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=L!T65jXV(D+2%k02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{001jVL_t(I%VS`mH~7!M@c%yp!+)|hqqCVPbrB;uwj%?I hUBJXJ3P! + +SPDX-License-Identifier: CC0-1.0 diff --git a/src/main/resources/assets/firmament/textures/gui/sprites/uuid_locked.png b/src/main/resources/assets/firmament/textures/gui/sprites/uuid_locked.png new file mode 100644 index 0000000000000000000000000000000000000000..9e66cb5be622856c4c2abe13e7c646ea782b8251 GIT binary patch literal 597 zcmV-b0;>IqP)EX>4Tx04R}tkv&MmKpe$i(~43m6)Y&?kfA!+MMWHI6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfb#YR3krMxx7Fxu3aNLh~_a1le0HIM~niYrxnr@rv zWJ1j5R>j^|1QEah!Wfd7Wz0!Z3ZCQZ9zMR_#dwzYxj#q0nztC>6N%%@Fm2)u;+aj` z;Ji;9VI^55J|~_q>4L>zBx-kgE(v zjs;YqL3aJ%fAG6ot1va$N(v=_o)^dY7z28Dfo9!tzK?&Kfh)b^uQq_$Ptxlh zEqVlmw}Ff6j;8DZmpj1llOdb3EBR>(g#z$?M&FbJ25*7jTC2DAK29Hi40V;d0S*p< z@gilfd%U}^ySIPOwEO!3MILgLpTsw-00006VoOIv00000008+zyMF)x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=L!T65fLW{uKoZ302y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{001pXL_t(I%VS`mJNU2lADPQYu11LNYmAI!+s=56kt!}= jA~_78Hjjc)Ft`8!2!{*?!kh6q00000NkvXXu0mjfHYD(< literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/firmament/textures/gui/sprites/uuid_locked.png.license b/src/main/resources/assets/firmament/textures/gui/sprites/uuid_locked.png.license new file mode 100644 index 0000000..c01d463 --- /dev/null +++ b/src/main/resources/assets/firmament/textures/gui/sprites/uuid_locked.png.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2023 Linnea Gräf + +SPDX-License-Identifier: CC0-1.0