diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-03-07 01:20:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 01:20:43 +0100 |
commit | 84589e27e919acd6f8972bb053e209b175950cfc (patch) | |
tree | 33e168a478c85ff5170e67c88594ada2538370aa /src/main/java/at | |
parent | 0dd5963b30522610991bc1f75b188d7c4f8266d5 (diff) | |
download | skyhanni-84589e27e919acd6f8972bb053e209b175950cfc.tar.gz skyhanni-84589e27e919acd6f8972bb053e209b175950cfc.tar.bz2 skyhanni-84589e27e919acd6f8972bb053e209b175950cfc.zip |
Interlal Change: Code cleanup (#1113)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
10 files changed, 26 insertions, 53 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java index 7ee18deb9..0c72e2b32 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java @@ -44,7 +44,8 @@ public class MiningEventConfig { public enum ShowType { BOTH("Both Mining Islands"), CRYSTAL("Crystal Hollows Only"), - DWARVEN("Dwarven Mines Only"); + DWARVEN("Dwarven Mines Only"), + ; private final String str; diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt index 51a3def55..2b7e33e66 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/HighlightInquisitors.kt @@ -21,10 +21,8 @@ class HighlightInquisitors { val entity = event.entity if (entity is EntityPlayer && entity.name == "Minos Inquisitor") { - RenderLivingEntityHelper.setEntityColor( - entity, - LorenzColor.AQUA.toColor().withAlpha(127) - ) { config.highlightInquisitors } + val color = LorenzColor.AQUA.toColor().withAlpha(127) + RenderLivingEntityHelper.setEntityColor(entity, color) { config.highlightInquisitors } RenderLivingEntityHelper.setNoHurtTime(entity) { config.highlightInquisitors } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt index deb699327..f17ec4587 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/GeyserFishing.kt @@ -22,19 +22,17 @@ import java.awt.Color class GeyserFishing { private val config get() = SkyHanniMod.feature.fishing.trophyFishing.geyserOptions + private val geyserOffset = LorenzVec(0.1f, 0.6f, 0.1f) + private var geyser: LorenzVec? = null private var geyserBox: AxisAlignedBB? = null @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onReceiveParticle(event: ReceiveParticleEvent) { if (!shouldProcessParticles()) return - if (event.type != EnumParticleTypes.CLOUD || event.count != 15 || event.speed != 0.05f || event.offset != LorenzVec( - 0.1f, - 0.6f, - 0.1f - ) - ) return - + with(event) { + if (type != EnumParticleTypes.CLOUD || count != 15 || speed != 0.05f || offset != geyserOffset) return + } geyser = event.location val potentialGeyser = geyser ?: return diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt index 086f4816d..ff27bd43f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt @@ -89,10 +89,13 @@ class MinionXp { } } + // TODO find the correct name of the list + private val listWithMissingName = listOf(21..26, 30..35, 39..44) + private fun handleItems(inventoryItems: Map<Int, ItemStack>, isMinion: Boolean): EnumMap<SkillType, Double> { val xpTotal = EnumMap<SkillType, Double>(SkillType::class.java) inventoryItems.filter { - it.value.getLore().isNotEmpty() && (!isMinion || it.key in listOf(21..26, 30..35, 39..44).flatten()) + it.value.getLore().isNotEmpty() && (!isMinion || it.key in listWithMissingName.flatten()) }.forEach { (_, itemStack) -> val item = toPrimitiveItemStack(itemStack) val name = item.internalName diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt index c5dde5ffb..b2530af37 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt @@ -43,7 +43,7 @@ class CustomTextBox { } private fun isEnabled() = - config.enabled && (LorenzUtils.inSkyBlock || OutsideSbFeature.CUSTOM_TEXT_BOX.isSelected()) + (LorenzUtils.inSkyBlock || OutsideSbFeature.CUSTOM_TEXT_BOX.isSelected()) && config.enabled @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt index b8a57856c..6997da51b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt @@ -106,8 +106,8 @@ class MarkedPlayerManager { } } - private fun isEnabled() = - config.highlightInWorld && (LorenzUtils.inSkyBlock || OutsideSbFeature.MARKED_PLAYERS.isSelected()) + private fun isEnabled() = (LorenzUtils.inSkyBlock || OutsideSbFeature.MARKED_PLAYERS.isSelected()) + && config.highlightInWorld @SubscribeEvent fun onWorldChange(event: LorenzWorldChangeEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt index 9efac5974..7199a1d56 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -95,17 +95,9 @@ object SkillProgress { SkillProgressConfig.TextAlignment.LEFT, SkillProgressConfig.TextAlignment.RIGHT, -> { - config.displayPosition.renderRenderables( - listOf( - Renderable.fixedSizeLine( - horizontalContainer( - display, - horizontalAlign = textAlignment.alignment - ), maxWidth - ) - ), - posLabel = "Skill Progress" - ) + val content = horizontalContainer(display, horizontalAlign = textAlignment.alignment) + val renderables = listOf(Renderable.fixedSizeLine(content, maxWidth)) + config.displayPosition.renderRenderables(renderables, posLabel = "Skill Progress") } else -> {} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt index 8c8ed5ab8..3304534a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiContainerHook.kt @@ -40,15 +40,8 @@ class GuiContainerHook(guiAny: Any) { } fun onMouseClick(slot: Slot?, slotId: Int, clickedButton: Int, clickType: Int, ci: CallbackInfo) { - if (SlotClickEvent( - gui, - gui.inventorySlots, - gui.inventorySlots?.inventory?.takeIf { it.size > slotId && slotId >= 0 }?.get(slotId), - slot, - slotId, - clickedButton, - clickType - ).postAndCatch() + val item = gui.inventorySlots?.inventory?.takeIf { it.size > slotId && slotId >= 0 }?.get(slotId) + if (SlotClickEvent(gui, gui.inventorySlots, item, slot, slotId, clickedButton, clickType).postAndCatch() ) ci.cancel() } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt index 41bed3290..aab61ab10 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/GuiRenderUtils.kt @@ -355,17 +355,9 @@ object GuiRenderUtils { } if (k > 0) { - Utils.drawTexturedRect( - x, - y, - w_2.coerceAtMost(k).toFloat(), - height, - 0f, - w_2.toDouble().coerceAtMost(k.toDouble() / xSize).toFloat(), - vMinFilled, - vMaxFilled, - GL11.GL_NEAREST - ) + val uMax = w_2.toDouble().coerceAtMost(k.toDouble() / xSize).toFloat() + val width = w_2.coerceAtMost(k).toFloat() + Utils.drawTexturedRect(x, y, width, height, 0f, uMax, vMinFilled, vMaxFilled, GL11.GL_NEAREST) if (completed > 0.5f) { Utils.drawTexturedRect( x + w_2, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index 535298543..e8045d70a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -148,12 +148,8 @@ class SkyHanniItemTracker<Data : ItemTrackerData>( lists.addAsSingletonList(renderable) } if (hiddenItemTexts.size > 0) { - lists.addAsSingletonList( - Renderable.hoverTips( - " §7${hiddenItemTexts.size} cheap items are hidden.", - hiddenItemTexts - ) - ) + val text = Renderable.hoverTips(" §7${hiddenItemTexts.size} cheap items are hidden.", hiddenItemTexts) + lists.addAsSingletonList(text) } return profit |