diff options
Diffstat (limited to 'src/main/java/at')
3 files changed, 58 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 807669791..b972dc6bf 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -145,6 +145,7 @@ import at.hannibal2.skyhanni.features.inventory.HideNotClickableItems import at.hannibal2.skyhanni.features.inventory.HighlightBonzoMasks import at.hannibal2.skyhanni.features.inventory.ItemDisplayOverlayFeatures import at.hannibal2.skyhanni.features.inventory.ItemStars +import at.hannibal2.skyhanni.features.inventory.QuickCraftFeatures import at.hannibal2.skyhanni.features.inventory.RngMeterInventory import at.hannibal2.skyhanni.features.inventory.SackDisplay import at.hannibal2.skyhanni.features.inventory.SkyBlockLevelGuideHelper @@ -573,6 +574,7 @@ class SkyHanniMod { loadModule(DungeonTeammateOutlines()) loadModule(DungeonRankTabListColor()) loadModule(FixNEUHeavyPearls()) + loadModule(QuickCraftFeatures()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java index b39adb8e2..db06c9a38 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/InventoryConfig.java @@ -376,6 +376,12 @@ public class InventoryConfig { public List<Integer> itemNumberAsStackSize = new ArrayList<>(Arrays.asList(3, 9, 11, 12)); @Expose + @ConfigOption(name = "Quick Craft Confirmation", desc = "Require Ctrl+Click to craft items that aren't often quick crafted (e.g. armor, weapons, accessories). Sack items can be crafted normally.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enableQuickCraftingConfirmation = false; + + @Expose @ConfigOption(name = "Sack Name", desc = "Show an abbreviation of the sack name.") @ConfigEditorBoolean @FeatureToggle diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt new file mode 100644 index 000000000..2cf9e688b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/QuickCraftFeatures.kt @@ -0,0 +1,50 @@ +package at.hannibal2.skyhanni.features.inventory
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiContainerEvent
+import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class QuickCraftFeatures {
+ private val config get() = SkyHanniMod.feature.inventory
+ private val quickCraftSlots = listOf(16, 25, 34)
+ private var quickCraftableItems = emptyList<String>()
+
+ @SubscribeEvent
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ quickCraftableItems = event.getConstant<List<String>>("QuickCraftableItems") ?: emptyList()
+ }
+
+ @SubscribeEvent
+ fun onToolTip(event: LorenzToolTipEvent) {
+ if (!isEnabled() || !quickCraftSlots.contains(event.slot.slotNumber)) return
+
+ if (needsQuickCraftConfirmation(event.itemStack)) {
+ event.toolTip.replaceAll { it.replace("Click to craft!", "§cCtrl+Click to craft!") }
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGH)
+ fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) {
+ if (!isEnabled() || !quickCraftSlots.contains(event.slot?.slotNumber)) return
+
+ val clickedItem = event.slot?.stack ?: return
+
+ if (!LorenzUtils.isControlKeyDown() && needsQuickCraftConfirmation(clickedItem)) {
+ event.isCanceled = true
+ }
+ }
+
+ private fun needsQuickCraftConfirmation(item: ItemStack): Boolean {
+ return !quickCraftableItems.contains(item.displayName.removeColor())
+ }
+
+ fun isEnabled() = LorenzUtils.inSkyBlock && config.enableQuickCraftingConfirmation && InventoryUtils.openInventoryName() == "Craft Item"
+
+}
\ No newline at end of file |