aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/features')
-rw-r--r--src/main/kotlin/features/debug/PowerUserTools.kt3
-rw-r--r--src/main/kotlin/features/inventory/WardrobeKeybinds.kt2
-rw-r--r--src/main/kotlin/features/inventory/buttons/InventoryButtons.kt7
-rw-r--r--src/main/kotlin/features/items/recipes/ItemSlotWidget.kt17
-rw-r--r--src/main/kotlin/features/items/recipes/RecipeRegistry.kt21
-rw-r--r--src/main/kotlin/features/items/recipes/RecipeWidget.kt4
6 files changed, 42 insertions, 12 deletions
diff --git a/src/main/kotlin/features/debug/PowerUserTools.kt b/src/main/kotlin/features/debug/PowerUserTools.kt
index 1a14f73..145ea35 100644
--- a/src/main/kotlin/features/debug/PowerUserTools.kt
+++ b/src/main/kotlin/features/debug/PowerUserTools.kt
@@ -13,6 +13,7 @@ import net.minecraft.world.item.Items
import net.minecraft.nbt.ListTag
import net.minecraft.nbt.NbtOps
import net.minecraft.advancements.critereon.NbtPredicate
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.ComponentSerialization
import net.minecraft.resources.ResourceLocation
@@ -202,7 +203,7 @@ object PowerUserTools {
.orThrow
ClipboardUtils.setTextContent(nbt.toPrettyString())
lastCopiedStack = Pair(item, Component.translatableEscape("firmament.tooltip.copied.stack"))
- } else if (it.matches(TConfig.copyTitle)) {
+ } else if (it.matches(TConfig.copyTitle) && it.screen is AbstractContainerScreen<*>) {
val allTitles = ListTag()
val inventoryNames =
it.screen.menu.slots
diff --git a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
index b3d4bfd..8d4760b 100644
--- a/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
+++ b/src/main/kotlin/features/inventory/WardrobeKeybinds.kt
@@ -1,6 +1,7 @@
package moe.nea.firmament.features.inventory
import org.lwjgl.glfw.GLFW
+import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
import net.minecraft.world.item.Items
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
@@ -29,6 +30,7 @@ object WardrobeKeybinds {
@Subscribe
fun switchSlot(event: HandledScreenKeyPressedEvent) {
if (MC.player == null || MC.world == null || MC.interactionManager == null) return
+ if (event.screen !is AbstractContainerScreen<*>) return
val regex = Regex("Wardrobe \\([12]/2\\)")
if (!regex.matches(event.screen.title.string)) return
diff --git a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
index fa376bc..eaa6138 100644
--- a/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
+++ b/src/main/kotlin/features/inventory/buttons/InventoryButtons.kt
@@ -11,6 +11,7 @@ import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenClickEvent
import moe.nea.firmament.events.HandledScreenForegroundEvent
import moe.nea.firmament.events.HandledScreenPushREIEvent
+import moe.nea.firmament.impl.v1.FirmamentAPIImpl
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.ScreenUtil
import moe.nea.firmament.util.TimeMark
@@ -40,9 +41,11 @@ object InventoryButtons {
)
fun getValidButtons(screen: AbstractContainerScreen<*>): Sequence<InventoryButton> {
- return DConfig.data.buttons.asSequence().filter { button ->
- button.isValid() && (!TConfig.onlyInv || screen is InventoryScreen)
+ if (TConfig.onlyInv && screen !is InventoryScreen) return emptySequence()
+ if (FirmamentAPIImpl.extensions.any { it.shouldHideInventoryButtons(screen) }) {
+ return emptySequence()
}
+ return DConfig.data.buttons.asSequence().filter(InventoryButton::isValid)
}
diff --git a/src/main/kotlin/features/items/recipes/ItemSlotWidget.kt b/src/main/kotlin/features/items/recipes/ItemSlotWidget.kt
index b9832b7..c47c8ca 100644
--- a/src/main/kotlin/features/items/recipes/ItemSlotWidget.kt
+++ b/src/main/kotlin/features/items/recipes/ItemSlotWidget.kt
@@ -10,6 +10,7 @@ import net.minecraft.network.chat.Component
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag
+import moe.nea.firmament.api.v1.FirmamentItemWidget
import moe.nea.firmament.events.ItemTooltipEvent
import moe.nea.firmament.keybindings.SavedKeyBinding
import moe.nea.firmament.repo.ExpensiveItemCacheApi
@@ -27,7 +28,8 @@ class ItemSlotWidget(
var content: List<SBItemStack>,
val slotKind: RecipeLayouter.SlotKind
) : RecipeWidget(),
- RecipeLayouter.CyclingItemSlot {
+ RecipeLayouter.CyclingItemSlot,
+ FirmamentItemWidget {
override var position = point
override val size get() = Dimension(16, 16)
val itemRect get() = Rectangle(position, Dimension(16, 16))
@@ -122,4 +124,17 @@ class ItemSlotWidget(
// SAFE: content was just assigned to a non-empty list
index = index.coerceIn(content.indices)
}
+
+ override fun getPlacement(): FirmamentItemWidget.Placement {
+ return FirmamentItemWidget.Placement.RECIPE_SCREEN
+ }
+
+ @OptIn(ExpensiveItemCacheApi::class)
+ override fun getItemStack(): ItemStack {
+ return current().asImmutableItemStack()
+ }
+
+ override fun getSkyBlockId(): String {
+ return current().skyblockId.neuItem
+ }
}
diff --git a/src/main/kotlin/features/items/recipes/RecipeRegistry.kt b/src/main/kotlin/features/items/recipes/RecipeRegistry.kt
index cbe1558..c2df46f 100644
--- a/src/main/kotlin/features/items/recipes/RecipeRegistry.kt
+++ b/src/main/kotlin/features/items/recipes/RecipeRegistry.kt
@@ -3,7 +3,6 @@ package moe.nea.firmament.features.items.recipes
import com.mojang.blaze3d.platform.InputConstants
import io.github.moulberry.repo.IReloadable
import io.github.moulberry.repo.NEURepository
-import net.fabricmc.fabric.mixin.client.gametest.input.InputUtilMixin
import moe.nea.firmament.annotations.Subscribe
import moe.nea.firmament.events.HandledScreenKeyPressedEvent
import moe.nea.firmament.events.ReloadRegistrationEvent
@@ -29,13 +28,19 @@ object RecipeRegistry {
@Subscribe
- fun onDebugRecipe(event: HandledScreenKeyPressedEvent) {
- if (event.matches(SavedKeyBinding.keyWithoutMods(InputConstants.KEY_R))) {
- val stack = event.screen.focusedItemStack ?: return
- val recipes = getRecipesFor(SBItemStack(stack))
- if (recipes.isEmpty()) return
- MC.screen = RecipeScreen(recipes.toList())
- }
+ fun showUsages(event: HandledScreenKeyPressedEvent) {
+ val provider =
+ if (event.matches(SavedKeyBinding.keyWithoutMods(InputConstants.KEY_R))) {
+ ::getRecipesFor
+ } else if (event.matches(SavedKeyBinding.keyWithoutMods(InputConstants.KEY_U))) {
+ ::getUsagesFor
+ } else {
+ return
+ }
+ val stack = event.screen.focusedItemStack ?: return
+ val recipes = provider(SBItemStack(stack))
+ if (recipes.isEmpty()) return
+ MC.screen = RecipeScreen(recipes.toList())
}
diff --git a/src/main/kotlin/features/items/recipes/RecipeWidget.kt b/src/main/kotlin/features/items/recipes/RecipeWidget.kt
index 5884129..b0591b2 100644
--- a/src/main/kotlin/features/items/recipes/RecipeWidget.kt
+++ b/src/main/kotlin/features/items/recipes/RecipeWidget.kt
@@ -34,4 +34,8 @@ abstract class RecipeWidget : GuiEventListener, Renderable, NarratableEntry {
override fun isFocused(): Boolean {
return this._focused
}
+
+ override fun isMouseOver(mouseX: Double, mouseY: Double): Boolean {
+ return rect.contains(mouseX, mouseY)
+ }
}