diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-18 11:03:01 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-18 11:03:01 +0200 |
commit | 10e548fda6d90dd03cce0ee4baa8dc35331c2460 (patch) | |
tree | d8b88a52ecb823c7c7c8e364ffdca4b1471f471c /src/main/java/at/hannibal2/skyhanni | |
parent | 66877204cf85689b57eb57d5d808949d40b0e09e (diff) | |
download | skyhanni-10e548fda6d90dd03cce0ee4baa8dc35331c2460.tar.gz skyhanni-10e548fda6d90dd03cce0ee4baa8dc35331c2460.tar.bz2 skyhanni-10e548fda6d90dd03cce0ee4baa8dc35331c2460.zip |
Fixed creating wrong minion texts flowing around on the island
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
3 files changed, 64 insertions, 55 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/MinionOpenEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/MinionOpenEvent.kt new file mode 100644 index 000000000..5d577b6ee --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/MinionOpenEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +import net.minecraft.item.ItemStack + +class MinionOpenEvent(val inventoryName: String, val inventoryItems: Map<Int, ItemStack>) : LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt index d6f971ec3..177a0016e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionCollectLogic.kt @@ -1,13 +1,10 @@ package at.hannibal2.skyhanni.features.minion import at.hannibal2.skyhanni.api.CollectionAPI -import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent +import at.hannibal2.skyhanni.events.MinionOpenEvent import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUItems import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -15,19 +12,7 @@ class MinionCollectLogic { private var oldMap = mapOf<String, Int>() @SubscribeEvent - fun onInventoryOpen(event: InventoryOpenEvent) { - if (!LorenzUtils.inSkyBlock) return - if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return - if (!event.inventoryName.contains(" Minion ")) return - - event.inventoryItems[48]?.let { - if ("§aCollect All" == it.name) { - openMinion() - } - } - } - - private fun openMinion() { + fun onMinionOpen(event: MinionOpenEvent) { if (oldMap.isNotEmpty()) return oldMap = count() } 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 b836fb315..887b17a2a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -4,7 +4,10 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.Storage import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryOpenEvent import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.MinionOpenEvent import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -83,50 +86,66 @@ class MinionFeatures { } @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { + fun onInventoryOpen(event: InventoryOpenEvent) { + if (!LorenzUtils.inSkyBlock) return if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return - val minions = minions ?: return + if (!event.inventoryName.contains(" Minion ")) return - val openInventory = InventoryUtils.currentlyOpenInventory() - if (openInventory.contains("Minion")) { - lastClickedEntity?.let { - val name = getMinionName(openInventory) - if (!minions.contains(it)) { - minions[it] = Storage.ProfileSpecific.MinionConfig().apply { - displayName = name - lastClicked = 0 - } - } else { - if (minions[it]!!.displayName != name) { - minions[it]!!.displayName = name - } - } - lastMinion = it - lastClickedEntity = null - minionInventoryOpen = true - lastMinionOpened = 0 + event.inventoryItems[48]?.let { + if ("§aCollect All" == it.name) { + MinionOpenEvent(event.inventoryName, event.inventoryItems).postAndCatch() + } + } + } + + @SubscribeEvent + fun onMinionOpen(event: MinionOpenEvent) { + val minions = minions ?: return + val entity = lastClickedEntity ?: return + + val openInventory = event.inventoryName + val name = getMinionName(openInventory) + if (!minions.contains(entity)) { + minions[entity] = Storage.ProfileSpecific.MinionConfig().apply { + displayName = name + lastClicked = 0 } } else { - if (minionInventoryOpen) { - minionInventoryOpen = false - lastMinionOpened = System.currentTimeMillis() - - val location = lastMinion - if (location != null) { - - if (System.currentTimeMillis() - lastCoinsRecived < 2_000) { - minions[location]!!.lastClicked = System.currentTimeMillis() - } - if (location !in minions) { - minions[location]!!.lastClicked = 0 - } - - if (System.currentTimeMillis() - lastMinionPickedUp < 2_000) { - minions.remove(location) - } - } + if (minions[entity]!!.displayName != name) { + minions[entity]!!.displayName = name } } + lastMinion = entity + lastClickedEntity = null + minionInventoryOpen = true + lastMinionOpened = 0 + } + + @SubscribeEvent + fun onCloseWindow(event: GuiContainerEvent.CloseWindowEvent) { + if (!minionInventoryOpen) return + val minions = minions ?: return + + minionInventoryOpen = false + lastMinionOpened = System.currentTimeMillis() + + val location = lastMinion ?: return + + if (System.currentTimeMillis() - lastCoinsRecived < 2_000) { + minions[location]!!.lastClicked = System.currentTimeMillis() + } + if (location !in minions) { + minions[location]!!.lastClicked = 0 + } + + if (System.currentTimeMillis() - lastMinionPickedUp < 2_000) { + minions.remove(location) + } + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return if (config.hopperProfitDisplay) { coinsPerDay = if (minionInventoryOpen) { |