aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt33
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt1
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt11
-rw-r--r--src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt18
-rw-r--r--src/main/kotlin/features/items/EtherwarpOverlay.kt3
-rw-r--r--src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt3
6 files changed, 60 insertions, 9 deletions
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
index 548552c..f59b293 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlay.kt
@@ -11,6 +11,7 @@ import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.ScreenChangeEvent
import moe.nea.firmament.events.SlotClickEvent
+import moe.nea.firmament.events.SlotRenderEvents
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.gui.config.ManagedConfig
@@ -40,13 +41,45 @@ object StorageOverlay : FirmamentFeature {
}
val columns by integer("rows", 1, 10) { 3 }
val height by integer("height", 80, 3000) { 3 * 18 * 6 }
+ val retainScroll by toggle("retain-scroll") { true }
val scrollSpeed by integer("scroll-speed", 1, 50) { 10 }
val inverseScroll by toggle("inverse-scroll") { false }
val padding by integer("padding", 1, 20) { 5 }
val margin by integer("margin", 1, 60) { 20 }
val itemsBlockScrolling by toggle("block-item-scrolling") { true }
+ val highlightSearchResults by toggle("highlight-search-results") { true }
+ val highlightSearchResultsColour by colour("highlight-search-results-colour") {
+ ChromaColour.fromRGB(
+ 0,
+ 176,
+ 0,
+ 0,
+ 255
+ )
+ }
}
+ @Subscribe
+ fun highlightSlots(event: SlotRenderEvents.Before) {
+ if (!TConfig.highlightSearchResults) return
+ val storageOverlayScreen =
+ (MC.screen as? StorageOverlayScreen)
+ ?: (MC.handledScreen?.customGui as? StorageOverlayCustom)?.overview
+ ?: return
+ val stack = event.slot.stack ?: return
+ val search = storageOverlayScreen.searchText.get().takeIf { it.isNotBlank() } ?: return
+ if (storageOverlayScreen.matchesSearch(stack, search)) {
+ event.context.fill(
+ event.slot.x,
+ event.slot.y,
+ event.slot.x + 16,
+ event.slot.y + 16,
+ TConfig.highlightSearchResultsColour.getEffectiveColourRGB()
+ )
+ }
+ }
+
+
fun adjustScrollSpeed(amount: Double): Double {
return amount * TConfig.scrollSpeed * (if (TConfig.inverseScroll) 1 else -1)
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
index 81f058e..e4d4e42 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayCustom.kt
@@ -18,6 +18,7 @@ class StorageOverlayCustom(
) : CustomGui() {
override fun onVoluntaryExit(): Boolean {
overview.isExiting = true
+ StorageOverlayScreen.resetScroll()
return super.onVoluntaryExit()
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
index 460a949..267799d 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverlayScreen.kt
@@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.screen.slot.Slot
import net.minecraft.text.Text
import net.minecraft.util.Identifier
+import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.SlotRenderEvents
import moe.nea.firmament.gui.EmptyComponent
import moe.nea.firmament.gui.FirmButtonComponent
@@ -59,10 +60,16 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
val CONTROL_WIDTH = 70
val CONTROL_BACKGROUND_WIDTH = CONTROL_WIDTH + CONTROL_X_INSET + 1
val CONTROL_HEIGHT = 50
+
+ var scroll: Float = 0F
+ var lastRenderedInnerHeight = 0
+
+ fun resetScroll() {
+ if (!StorageOverlay.TConfig.retainScroll) scroll = 0F
+ }
}
var isExiting: Boolean = false
- var scroll: Float = 0F
var pageWidthCount = StorageOverlay.TConfig.columns
inner class Measurements {
@@ -85,7 +92,6 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
var measurements = Measurements()
- var lastRenderedInnerHeight = 0
public override fun init() {
super.init()
pageWidthCount = StorageOverlay.TConfig.columns
@@ -122,6 +128,7 @@ class StorageOverlayScreen : Screen(Text.literal("")) {
override fun close() {
isExiting = true
+ resetScroll()
super.close()
}
diff --git a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
index 9112fab..3462d3d 100644
--- a/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
+++ b/src/main/kotlin/features/inventory/storageoverlay/StorageOverviewScreen.kt
@@ -22,13 +22,23 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
Items.GRAY_DYE
)
val pageWidth get() = 19 * 9
+
+ var scroll = 0
+ var lastRenderedHeight = 0
}
val content = StorageOverlay.Data.data ?: StorageData()
var isClosing = false
- var scroll = 0
- var lastRenderedHeight = 0
+ override fun init() {
+ super.init()
+ scroll = scroll.coerceAtMost(getMaxScroll()).coerceAtLeast(0)
+ }
+
+ override fun close() {
+ if (!StorageOverlay.TConfig.retainScroll) scroll = 0
+ super.close()
+ }
override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
super.render(context, mouseX, mouseY, delta)
@@ -88,10 +98,12 @@ class StorageOverviewScreen() : Screen(Text.empty()) {
): Boolean {
scroll =
(scroll + StorageOverlay.adjustScrollSpeed(verticalAmount)).toInt()
- .coerceAtMost(lastRenderedHeight - height + 2 * StorageOverlay.config.margin).coerceAtLeast(0)
+ .coerceAtMost(getMaxScroll()).coerceAtLeast(0)
return true
}
+ private fun getMaxScroll() = lastRenderedHeight - height + 2 * StorageOverlay.config.margin
+
private fun renderStoragePage(context: DrawContext, page: StorageData.StorageInventory, mouseX: Int, mouseY: Int) {
context.drawText(MC.font, page.title, 2, 2, -1, true)
val inventory = page.inventory
diff --git a/src/main/kotlin/features/items/EtherwarpOverlay.kt b/src/main/kotlin/features/items/EtherwarpOverlay.kt
index b1f695a..f6ab1a2 100644
--- a/src/main/kotlin/features/items/EtherwarpOverlay.kt
+++ b/src/main/kotlin/features/items/EtherwarpOverlay.kt
@@ -19,6 +19,7 @@ object EtherwarpOverlay : FirmamentFeature {
object TConfig : ManagedConfig(identifier, Category.ITEMS) {
var etherwarpOverlay by toggle("etherwarp-overlay") { false }
+ var onlyShowWhileSneaking by toggle("only-show-while-sneaking") { true }
var cube by toggle("cube") { true }
val cubeColour by colour("cube-colour") { ChromaColour.fromStaticRGB(172, 0, 255, 60) }
var wireframe by toggle("wireframe") { false }
@@ -32,7 +33,7 @@ object EtherwarpOverlay : FirmamentFeature {
fun renderEtherwarpOverlay(event: WorldRenderLastEvent) {
if (!TConfig.etherwarpOverlay) return
val player = MC.player ?: return
- if (!player.isSneaking) return
+ if (TConfig.onlyShowWhileSneaking && !player.isSneaking) return
val world = player.world
val camera = MC.camera ?: return
val heldItem = MC.stackInHand
diff --git a/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt b/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt
index 6506f13..2d7a978 100644
--- a/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt
+++ b/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomBlockTextures.kt
@@ -247,9 +247,6 @@ object CustomBlockTextures {
@JvmStatic
fun getReplacementModel(block: BlockState, blockPos: BlockPos?): BlockStateModel? {
- if (block.block == Blocks.SMOOTH_SANDSTONE_STAIRS) {
- println("WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEWOOOOOOOOOOOOOOOOOOOOOOOOOO")
- }
return getReplacement(block, blockPos)?.replace(block)
}