diff options
Diffstat (limited to 'src/main/kotlin/moe/nea')
3 files changed, 7 insertions, 18 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt index 777cbe9..c1ac993 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlay.kt @@ -14,7 +14,6 @@ import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.entity.player.PlayerInventory import net.minecraft.item.Items import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket -import net.minecraft.text.Text import moe.nea.firmament.annotations.Subscribe import moe.nea.firmament.events.ScreenChangeEvent import moe.nea.firmament.events.SlotClickEvent @@ -34,7 +33,8 @@ object StorageOverlay : FirmamentFeature { get() = "storage-overlay" object TConfig : ManagedConfig(identifier) { - val rows by integer("rows", 1, 5) { 3 } + val alwaysReplace by toggle("always-replace") { true } + val columns by integer("rows", 1, 10) { 3 } val scrollSpeed by integer("scroll-speed", 1, 50) { 10 } val inverseScroll by toggle("inverse-scroll") { false } val padding by integer("padding", 1, 20) { 5 } @@ -105,7 +105,7 @@ object StorageOverlay : FirmamentFeature { screen.customGui = StorageOverlayCustom( currentHandler ?: return, screen, - storageOverlayScreen ?: return) + storageOverlayScreen ?: (if (TConfig.alwaysReplace) StorageOverlayScreen() else return)) } fun rememberContent(handler: StorageBackingHandle?) { diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt index ac89f8c..c371eb4 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverlayScreen.kt @@ -33,22 +33,11 @@ class StorageOverlayScreen : Screen(Text.literal("")) { val MAIN_INVENTORY_Y = 9 val SCROLL_BAR_WIDTH = 8 val SCROLL_BAR_HEIGHT = 16 - - @Subscribe - fun onCommand(event: CommandEvent.SubCommand) { - event.subcommand("teststorage") { - executes { - ScreenUtil.setScreenLater(StorageOverlayScreen()) - MC.sendCommand("ec") - 0 - } - } - } } var isExiting: Boolean = false var scroll: Float = 0F - var pageWidthCount = StorageOverlay.TConfig.rows + var pageWidthCount = StorageOverlay.TConfig.columns inner class Measurements { val innerScrollPanelWidth = PAGE_WIDTH * pageWidthCount + (pageWidthCount - 1) * PADDING @@ -66,7 +55,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) { var lastRenderedInnerHeight = 0 override fun init() { super.init() - pageWidthCount = StorageOverlay.TConfig.rows + pageWidthCount = StorageOverlay.TConfig.columns .coerceAtMost((width - PADDING) / (PAGE_WIDTH + PADDING)) .coerceAtLeast(1) measurements = Measurements() diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt index dc2bd48..fb77ff2 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/storageoverlay/StorageOverviewScreen.kt @@ -51,7 +51,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) { var currentMaxHeight = StorageOverlay.config.margin - StorageOverlay.config.padding - scroll var totalHeight = -currentMaxHeight content.storageInventories.onEachIndexed { index, (key, value) -> - val pageX = (index % StorageOverlay.config.rows) + val pageX = (index % StorageOverlay.config.columns) if (pageX == 0) { currentMaxHeight += StorageOverlay.config.padding offsetY += currentMaxHeight @@ -59,7 +59,7 @@ class StorageOverviewScreen() : Screen(Text.empty()) { currentMaxHeight = 0 } val xPosition = - width / 2 - (StorageOverlay.config.rows * (pageWidth + StorageOverlay.config.padding) - StorageOverlay.config.padding) / 2 + pageX * (pageWidth + StorageOverlay.config.padding) + width / 2 - (StorageOverlay.config.columns * (pageWidth + StorageOverlay.config.padding) - StorageOverlay.config.padding) / 2 + pageX * (pageWidth + StorageOverlay.config.padding) onEach(Pair(key, value), xPosition, offsetY) val height = getStorePageHeight(value) currentMaxHeight = max(currentMaxHeight, height) |