diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
7 files changed, 99 insertions, 30 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 916cb896b..75674ca78 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -66,6 +66,11 @@ public class Features { editOverlay(activeConfigCategory, 200, 16, misc.realTimePos); return; } + + if (runnableId.equals("hopperProfitDisplay")) { + editOverlay(activeConfigCategory, 200, 16, minions.hopperProfitPos); + return; + } } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java b/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java index 016d5f6d2..318b16555 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Minions.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features; +import at.hannibal2.skyhanni.config.gui.core.config.Position; import at.hannibal2.skyhanni.config.gui.core.config.annotations.*; import com.google.gson.annotations.Expose; @@ -64,4 +65,20 @@ public class Minions { @ConfigOption(name = "Hide Mob Nametag", desc = "Hiding the nametag of mobs close to minions") @ConfigEditorBoolean public boolean hideMobsNametagNearby = false; + + @ConfigOption(name = "Hopper Profit", desc = "") + @ConfigEditorAccordion(id = 2) + public boolean hopperProfit = false; + + @Expose + @ConfigOption(name = "Hopper Profit Display", desc = "Using the held coins and the last empty time to calculate the coins a hopper collects in a day") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean hopperProfitDisplay = false; + + @Expose + @ConfigOption(name = "Best Sell Method Position", desc = "") + @ConfigEditorButton(runnableId = "hopperProfitDisplay", buttonText = "Edit") + @ConfigAccordionId(id = 2) + public Position hopperProfitPos = new Position(10, 10, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt index cee707155..95d9517d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/items/HideNotClickableItems.kt @@ -94,7 +94,7 @@ class HideNotClickableItems { val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() val stack = event.itemStack - if (ItemUtils.getItemsInOpenChest().map { it.stack }.contains(stack)) return + if (InventoryUtils.getItemsInOpenChest().map { it.stack }.contains(stack)) return if (!ItemUtils.getItemsInInventory().contains(stack)) return if (hide(chestName, stack)) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt index 1c0c4cfb5..13ba0a34f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/items/RngMeterInventory.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.features.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.GuiRenderItemEvent -import at.hannibal2.skyhanni.utils.ItemUtils +import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzColor @@ -68,7 +68,7 @@ class RngMeterInventory { if (SkyHanniMod.feature.inventory.rngMeterNoDrop) { if (chestName == "Catacombs RNG Meter") { - for (slot in ItemUtils.getItemsInOpenChest()) { + for (slot in InventoryUtils.getItemsInOpenChest()) { val stack = slot.stack if (stack.getLore().any { it.contains("You don't have an RNG drop") }) { slot highlight LorenzColor.RED @@ -82,7 +82,7 @@ class RngMeterInventory { if (SkyHanniMod.feature.inventory.rngMeterSelectedDrop) { if (chestName.endsWith(" RNG Meter")) { - for (slot in ItemUtils.getItemsInOpenChest()) { + for (slot in InventoryUtils.getItemsInOpenChest()) { val stack = slot.stack if (stack.getLore().any { it.contains("§aSELECTED") }) { slot highlight LorenzColor.YELLOW diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index 1d3667e2e..697c8bbb2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -5,11 +5,16 @@ import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils.formatInteger import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex import at.hannibal2.skyhanni.utils.RenderUtils.drawString +import at.hannibal2.skyhanni.utils.RenderUtils.renderString import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.client.event.GuiScreenEvent import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.event.world.WorldEvent @@ -30,6 +35,7 @@ class MinionFeatures { var lastCoinsRecived = 0L var lastMinionPickedUp = 0L val minions = mutableMapOf<LorenzVec, Long>() + var coinsPerDay = "" @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { @@ -103,6 +109,45 @@ class MinionFeatures { } } } + + if (SkyHanniMod.feature.minions.hopperProfitDisplay) { + coinsPerDay = if (minionInventoryOpen) { + updateCoinsPerDay() + } else { + "" + } + } + } + + private fun updateCoinsPerDay(): String { + val loc = lastMinion!! + val slot = InventoryUtils.getItemsInOpenChest().find { it.slotNumber == 28 } ?: return "" + + val stack = slot.stack + val line = stack.getLore().find { it.contains("Held Coins") } ?: return "" + + if (coinsPerDay != "") return coinsPerDay + + val lastClicked = minions.getOrDefault(loc, -1) + if (lastClicked == -1L) { + return "Can't calculate coins/day: No time data available!" + } + val duration = System.currentTimeMillis() - lastClicked + +// println("line: '$line'") + //§7Held Coins: §b151,389 + val coins = line.split(": §b")[1].replace(",", "").toDouble() + + println(" ") + println("coins: $coins") + println("duration: $duration") + + val coinsPerDay = (coins / (duration.toDouble())) * 1000 * 60 * 60 * 24 + println("coinsPerDay: $coinsPerDay") + + val format = formatInteger(coinsPerDay.toInt()) + val hopperName = stack.name + return "§7Coins/day with $hopperName§7: §6$format coins" } private fun saveConfig() { @@ -144,7 +189,7 @@ class MinionFeatures { if (LorenzUtils.skyBlockIsland != "Private Island") return val playerLocation = LocationUtils.playerLocation() - var playerEyeLocation = LocationUtils.playerEyeLocation() + val playerEyeLocation = LocationUtils.playerEyeLocation() for (minion in minions) { val location = minion.key if (playerLocation.distance(location) < SkyHanniMod.feature.minions.emptiedTimeDistance) { @@ -170,10 +215,17 @@ class MinionFeatures { if (entity.isDead) return if (entity.customNameTag.contains("§c❤")) { - var loc = entity.getLorenzVec() + val loc = entity.getLorenzVec() if (minions.any { it.key.distance(loc) < 5 }) { event.isCanceled = true } } } + + @SubscribeEvent(priority = EventPriority.LOWEST) + fun renderOverlay(event: GuiScreenEvent.BackgroundDrawnEvent) { + if (SkyHanniMod.feature.minions.hopperProfitDisplay) { + SkyHanniMod.feature.minions.hopperProfitPos.renderString(coinsPerDay) + } + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index 18a4ce635..1d51d1be9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.inventory.ContainerChest +import net.minecraft.inventory.Slot object InventoryUtils { @@ -15,4 +16,20 @@ object InventoryUtils { return chest.lowerChestInventory.displayName.unformattedText.trim() } + fun getItemsInOpenChest(): List<Slot> { + val list = mutableListOf<Slot>() + val guiChest = Minecraft.getMinecraft().currentScreen as GuiChest + val inventorySlots = guiChest.inventorySlots.inventorySlots + val skipAt = inventorySlots.size - 9 * 4 + var i = 0 + for (slot in inventorySlots) { + val stack = slot.stack + if (stack != null) { + list.add(slot) + } + i++ + if (i == skipAt) break + } + return list + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index 24c3d822a..b1d3ef7a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -5,9 +5,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.gson.GsonBuilder import com.google.gson.JsonObject import net.minecraft.client.Minecraft -import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.init.Items -import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack import net.minecraftforge.common.util.Constants import java.util.* @@ -17,30 +15,10 @@ object ItemUtils { fun ItemStack.cleanName() = this.displayName.removeColor() - fun getItemsInOpenChest(): List<Slot> { - val list = mutableListOf<Slot>() - val guiChest = Minecraft.getMinecraft().currentScreen as GuiChest - val inventorySlots = guiChest.inventorySlots.inventorySlots - val skipAt = inventorySlots.size - 9 * 4 - var i = 0 - for (slot in inventorySlots) { - val stack = slot.stack - if (stack != null) { - list.add(slot) - } - i++ - if (i == skipAt) break - } - return list - } - fun isSack(name: String): Boolean = name.endsWith(" Sack")//TODO change - fun ItemStack.getLore() = getLoree(this) - - - fun getLoree(`is`: ItemStack): List<String> { - val tagCompound = `is`.tagCompound ?: return emptyList() + fun ItemStack.getLore(): List<String> { + val tagCompound = this.tagCompound ?: return emptyList() val tagList = tagCompound.getCompoundTag("display").getTagList("Lore", 8) val list: MutableList<String> = ArrayList() for (i in 0 until tagList.tagCount()) { |