diff options
Diffstat (limited to 'src/main/java/at')
4 files changed, 64 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java new file mode 100644 index 000000000..3211354fe --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/FocusModeConfig.java @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.config.features.inventory; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import org.lwjgl.input.Keyboard; + +public class FocusModeConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "In focus mode you only see the name of the item instead of the whole description.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigOption(name = "Toggle Key", desc = "Key to toggle the focus mode on and off.") + @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE) + public int toggleKey = Keyboard.KEY_NONE; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 6e064ced6..71ab7c792 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -85,6 +85,11 @@ public class InventoryConfig { public PersonalCompactorConfig personalCompactor = new PersonalCompactorConfig(); @Expose + @ConfigOption(name = "Focus Mode", desc="") + @Accordion + public FocusModeConfig focusMode = new FocusModeConfig(); + + @Expose @ConfigOption(name = "RNG Meter", desc = "") @Accordion public RngMeterConfig rngMeter = new RngMeterConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt new file mode 100644 index 000000000..c02f29933 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/FocusMode.kt @@ -0,0 +1,35 @@ +package at.hannibal2.skyhanni.features.inventory + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object FocusMode { + + private val config get() = SkyHanniMod.feature.inventory.focusMode + + private var toggle = true + + @SubscribeEvent(priority = EventPriority.LOWEST) + fun onLorenzToolTip(event: LorenzToolTipEvent) { + if (!isEnabled() || !toggle) return + if(event.toolTip.isEmpty()) return + event.toolTip = mutableListOf(event.toolTip.first()) + } + + @SubscribeEvent + fun onLorenzTick(event: LorenzTickEvent) { + if (!isEnabled()) return + if (!config.toggleKey.isKeyClicked()) return + toggle = !toggle + } + + fun isEnabled() = LorenzUtils.inSkyBlock && InventoryUtils.inContainer() && config.enabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index 7ff17f965..0f025e50b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -41,6 +41,8 @@ object InventoryUtils { fun inInventory() = Minecraft.getMinecraft().currentScreen is GuiChest + fun inContainer() = Minecraft.getMinecraft().currentScreen is GuiContainer + fun ContainerChest.getInventoryName() = this.lowerChestInventory.displayName.unformattedText.trim() fun getWindowId(): Int? = (Minecraft.getMinecraft().currentScreen as? GuiChest)?.inventorySlots?.windowId |