Replace slot locking indicator with textures

This commit is contained in:
nea
2023-10-04 19:19:44 +02:00
parent 64523821d8
commit f7c1ef2dda
5 changed files with 26 additions and 12 deletions

View File

@@ -7,6 +7,7 @@
package moe.nea.firmament.features.inventory package moe.nea.firmament.features.inventory
import com.mojang.blaze3d.systems.RenderSystem
import java.util.* import java.util.*
import org.lwjgl.glfw.GLFW import org.lwjgl.glfw.GLFW
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@@ -15,6 +16,7 @@ import kotlinx.serialization.serializer
import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.gui.screen.ingame.HandledScreen
import net.minecraft.entity.player.PlayerInventory import net.minecraft.entity.player.PlayerInventory
import net.minecraft.screen.slot.SlotActionType import net.minecraft.screen.slot.SlotActionType
import net.minecraft.util.Identifier
import moe.nea.firmament.events.HandledScreenKeyPressedEvent import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.events.IsSlotProtectedEvent import moe.nea.firmament.events.IsSlotProtectedEvent
import moe.nea.firmament.events.SlotRenderEvents import moe.nea.firmament.events.SlotRenderEvents
@@ -157,25 +159,31 @@ object SlotLocking : FirmamentFeature {
if (IsSlotProtectedEvent.shouldBlockInteraction(null, SlotActionType.THROW, stack)) if (IsSlotProtectedEvent.shouldBlockInteraction(null, SlotActionType.THROW, stack))
anyBlocked = true anyBlocked = true
} }
if(anyBlocked) { if (anyBlocked) {
event.protectSilent() event.protectSilent()
} }
} }
SlotRenderEvents.Before.subscribe { SlotRenderEvents.After.subscribe {
val isSlotLocked = it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf()) val isSlotLocked = it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())
val isUUIDLocked = (it.slot.stack?.skyblockUUID) in (lockedUUIDs ?: setOf()) val isUUIDLocked = (it.slot.stack?.skyblockUUID) in (lockedUUIDs ?: setOf())
if (isSlotLocked || isUUIDLocked) { if (isSlotLocked || isUUIDLocked) {
it.context.fill( RenderSystem.disableDepthTest()
it.slot.x, it.context.drawSprite(
it.slot.y, it.slot.x, it.slot.y, 0,
it.slot.x + 16, 16, 16,
it.slot.y + 16, MC.guiAtlasManager.getSprite(
when { when {
isSlotLocked -> 0xFFFF0000.toInt() isSlotLocked ->
isUUIDLocked -> 0xFF00FF00.toInt() (Identifier("firmament:slot_locked"))
else -> error("Slot is locked, but not by slot or uuid")
} isUUIDLocked ->
(Identifier("firmament:uuid_locked"))
else ->
error("unreachable")
}
)
) )
RenderSystem.enableDepthTest()
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

View File

@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
SPDX-License-Identifier: CC0-1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

View File

@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
SPDX-License-Identifier: CC0-1.0