aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features/inventory
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features/inventory')
-rw-r--r--src/main/kotlin/features/inventory/SlotLocking.kt19
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt7
2 files changed, 17 insertions, 9 deletions
diff --git a/src/main/kotlin/features/inventory/SlotLocking.kt b/src/main/kotlin/features/inventory/SlotLocking.kt
index 09afe80..fca40c8 100644
--- a/src/main/kotlin/features/inventory/SlotLocking.kt
+++ b/src/main/kotlin/features/inventory/SlotLocking.kt
@@ -42,6 +42,7 @@ import moe.nea.firmament.util.CommonSoundEffects
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.SBData
import moe.nea.firmament.util.SkyBlockIsland
+import moe.nea.firmament.util.accessors.castAccessor
import moe.nea.firmament.util.data.Config
import moe.nea.firmament.util.data.ManagedConfig
import moe.nea.firmament.util.data.ProfileSpecificDataHolder
@@ -295,7 +296,7 @@ object SlotLocking {
fun onLockUUID(it: HandledScreenKeyPressedEvent) {
if (!it.matches(TConfig.lockUUID)) return
val inventory = MC.handledScreen ?: return
- inventory as AccessorHandledScreen
+ inventory.castAccessor()
val slot = inventory.focusedSlot_Firmament ?: return
val stack = slot.item ?: return
@@ -330,7 +331,7 @@ object SlotLocking {
@Subscribe
fun onLockSlotKeyRelease(it: HandledScreenKeyReleasedEvent) {
val inventory = MC.handledScreen ?: return
- inventory as AccessorHandledScreen
+ inventory.castAccessor()
val slot = inventory.focusedSlot_Firmament
val storedSlot = storedLockingSlot ?: return
@@ -364,7 +365,7 @@ object SlotLocking {
fun onRenderAllBoundSlots(event: HandledScreenForegroundEvent) {
val boundSlots = currentWorldData?.boundSlots ?: return
fun findByIndex(index: Int) = event.screen.getSlotByIndex(index, true)
- val accScreen = event.screen as AccessorHandledScreen
+ val accScreen = event.screen.castAccessor()
val sx = accScreen.x_Firmament
val sy = accScreen.y_Firmament
val highlitSlots = mutableSetOf<Slot>()
@@ -409,14 +410,20 @@ object SlotLocking {
@Subscribe
fun onRenderCurrentDraggingSlot(event: HandledScreenForegroundEvent) {
val draggingSlot = storedLockingSlot ?: return
- val accScreen = event.screen as AccessorHandledScreen
+ val accScreen = event.screen.castAccessor()
val hoveredSlot = accScreen.focusedSlot_Firmament
?.takeIf { it.container is Inventory }
?.takeIf { it == draggingSlot || it.isHotbar() != draggingSlot.isHotbar() }
val sx = accScreen.x_Firmament
val sy = accScreen.y_Firmament
val (borderX, borderY) = draggingSlot.lineCenter()
- event.context.submitOutline(draggingSlot.x + sx, draggingSlot.y + sy, 16, 16, 0xFF00FF00u.toInt()) // TODO: 1.21.10
+ event.context.submitOutline(
+ draggingSlot.x + sx,
+ draggingSlot.y + sy,
+ 16,
+ 16,
+ 0xFF00FF00u.toInt()
+ ) // TODO: 1.21.10
if (hoveredSlot == null) {
event.context.drawLine(
borderX + sx, borderY + sy,
@@ -477,7 +484,7 @@ object SlotLocking {
@Subscribe
fun onLockSlot(it: HandledScreenKeyPressedEvent) {
val inventory = MC.handledScreen ?: return
- inventory as AccessorHandledScreen
+ inventory.castAccessor()
val slot = inventory.focusedSlot_Firmament ?: return
if (slot.container !is Inventory) return
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
index f291dba..98e8085 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
@@ -11,6 +11,7 @@ import net.minecraft.client.input.KeyEvent
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.Slot
import moe.nea.firmament.mixins.accessor.AccessorHandledScreen
+import moe.nea.firmament.util.accessors.castAccessor
import moe.nea.firmament.util.customgui.CustomGui
import moe.nea.firmament.util.focusedItemStack
@@ -42,7 +43,7 @@ class StorageOverlayCustom(
override fun onInit() {
overview.init(Minecraft.getInstance(), screen.width, screen.height)
overview.init()
- screen as AccessorHandledScreen
+ screen.castAccessor()
screen.x_Firmament = overview.measurements.x
screen.y_Firmament = overview.measurements.y
screen.backgroundWidth_Firmament = overview.measurements.totalWidth
@@ -96,7 +97,7 @@ class StorageOverlayCustom(
delta,
(handler as? StorageBackingHandle.Page)?.storagePageSlot,
screen.menu.slots.take(screen.menu.rowCount * 9).drop(9),
- Point((screen as AccessorHandledScreen).x_Firmament, screen.y_Firmament)
+ Point((screen.castAccessor()).x_Firmament, screen.y_Firmament)
)
overview.drawScrollBar(drawContext)
overview.drawControls(drawContext, mouseX, mouseY)
@@ -106,7 +107,7 @@ class StorageOverlayCustom(
val index = slot.containerSlot
if (index in 0..<36) {
val (x, y) = overview.getPlayerInventorySlotPosition(index)
- slot.x = x - (screen as AccessorHandledScreen).x_Firmament
+ slot.x = x - (screen.castAccessor()).x_Firmament
slot.y = y - screen.y_Firmament
} else {
slot.x = -100000