@@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.InventoryUtils
1616import at.hannibal2.skyhanni.utils.ItemUtils.getLore
1717import at.hannibal2.skyhanni.utils.ItemUtils.getSingleLineLore
1818import at.hannibal2.skyhanni.utils.KeyboardManager
19+ import at.hannibal2.skyhanni.utils.MobUtils.mob
1920import at.hannibal2.skyhanni.utils.NumberUtil.formatLongOrNull
2021import at.hannibal2.skyhanni.utils.PrimitiveItemStack
2122import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.toPrimitiveStackOrNull
@@ -25,6 +26,7 @@ import at.hannibal2.skyhanni.utils.RegexUtils.matches
2526import at.hannibal2.skyhanni.utils.SoundUtils
2627import at.hannibal2.skyhanni.utils.StringUtils.removeColor
2728import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGroup
29+ import net.minecraft.client.Minecraft
2830import net.minecraft.world.inventory.Slot
2931import kotlin.time.Duration.Companion.seconds
3032
@@ -89,8 +91,9 @@ object SuperCraftingInventory {
8991 if (event.slotId != PICKAXE_SLOT ) return
9092 val slots = InventoryUtils .getItemsInOpenChestWithNull()
9193 val craftingAmount = getSuperCraftingCount(slots) ? : return
92- val profit = getProfit(slots, craftingAmount) ? : return
93- val maxCraftingAmount = getSuperCraftingMaxCount(slots, craftingAmount)
94+ val craftMultiplier = getResultItem(slots).amount
95+ val profit = getProfit(slots, craftingAmount, craftMultiplier) ? : return
96+ val maxCraftingAmount = getSuperCraftingMaxCount(slots, craftingAmount, craftMultiplier)
9497 if (! blockWasteClick(profit, craftingAmount, maxCraftingAmount)) return
9598 SoundUtils .playErrorSound()
9699 val diff = (- profit).formatChatCoins()
@@ -108,27 +111,28 @@ object SuperCraftingInventory {
108111 event.cancel()
109112 }
110113
111- private fun getSuperCraftingMaxCount (slots : List <Slot >, craftingAmount : Long ) = slots[PICKAXE_SLOT ].item.getLore()
112- .mapNotNull { calculateMaxPossible(it, craftingAmount) }
114+ private fun getSuperCraftingMaxCount (slots : List <Slot >, craftingAmount : Long , craftMultiplier : Int ) = slots[PICKAXE_SLOT ].item.getLore()
115+ .mapNotNull { calculateMaxPossible(it, craftingAmount, craftMultiplier ) }
113116 .minOrNull() ? : ErrorManager .skyHanniError(
114117 " Super Crafting resource line not found" ,
115118 " lore" to slots.map { slot -> slot.item.getLore().map { line -> line.removeColor() } },
116119 )
117120
118- private fun calculateMaxPossible (string : String , craftingAmount : Long ) = craftingResourcePattern.matchMatcher(string.removeColor()) {
119- val owned = groupOrNull(" owned" )?.formatLongOrNull() ? : return null
120- val used = groupOrNull(" used" )?.formatLongOrNull() ? : return null
121- if (used == 0L || owned == 0L ) return null
122- val matsPerCraft = used / craftingAmount
123- if (matsPerCraft == 0L ) return null
124- owned / matsPerCraft
125- }
121+ private fun calculateMaxPossible (string : String , craftingAmount : Long , craftMultiplier : Int ) =
122+ craftingResourcePattern.matchMatcher(string.removeColor()) {
123+ val owned = groupOrNull(" owned" )?.formatLongOrNull() ? : return null
124+ val used = groupOrNull(" used" )?.formatLongOrNull() ? : return null
125+ if (used == 0L || owned == 0L ) return null
126+ val matsPerCraft = used / (craftingAmount / craftMultiplier)
127+ if (matsPerCraft == 0L ) return null
128+ owned / matsPerCraft
129+ }
126130
127- private fun getProfit (slots : List <Slot >, craftingAmount : Long ): Double? {
131+ private fun getProfit (slots : List <Slot >, craftingAmount : Long , craftMultiplier : Int ): Double? {
128132 val materials = getRecipeMaterials(slots)
129- val resultItem = getResultItem(slots)
130133
131- val recipeMultiplier = resultItem.amount
134+ val recipeMultiplier = craftMultiplier
135+ val resultItem = getResultItem(slots)
132136 if (recipeMultiplier == 0 ) ErrorManager .skyHanniError(
133137 " Result item amount is 0" ,
134138 " item" to resultItem,
0 commit comments