diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-11-24 23:42:00 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-11-24 23:42:00 +0100 |
| commit | 6dd14e7225ff60361fe9f87020c424c0eb89a68b (patch) | |
| tree | 6977d5a71850924becc71b1ac53f1865a1c8330a /src/main/kotlin/features/items | |
| parent | 3f33928c8fefe4816af9d538fa3fce48d5e76f7c (diff) | |
| download | Firmament-6dd14e7225ff60361fe9f87020c424c0eb89a68b.tar.gz Firmament-6dd14e7225ff60361fe9f87020c424c0eb89a68b.tar.bz2 Firmament-6dd14e7225ff60361fe9f87020c424c0eb89a68b.zip | |
feat: firmament api
Diffstat (limited to 'src/main/kotlin/features/items')
3 files changed, 33 insertions, 9 deletions
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) + } } |
