-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Crown of Avarice Counter (#2229)
- Loading branch information
1 parent
fb73845
commit 81358be
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/at/hannibal2/skyhanni/config/features/itemability/CrownOfAvariceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package at.hannibal2.skyhanni.config.features.itemability; | ||
|
||
import at.hannibal2.skyhanni.config.FeatureToggle; | ||
import at.hannibal2.skyhanni.config.core.config.Position; | ||
import com.google.gson.annotations.Expose; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; | ||
|
||
public class CrownOfAvariceConfig { | ||
|
||
@Expose | ||
@ConfigOption(name = "Counter", | ||
desc = "Shows the current coins of your crown of avarice (if worn).") | ||
@ConfigEditorBoolean | ||
@FeatureToggle | ||
public boolean enable = false; | ||
|
||
@Expose | ||
@ConfigOption(name = "Counter format", | ||
desc = "Have the crown of avarice counter as short format instead of every digit.") | ||
@ConfigEditorBoolean | ||
public boolean shortFormat = true; | ||
|
||
@Expose | ||
@ConfigLink(owner = CrownOfAvariceConfig.class,field = "enable") | ||
public Position position = new Position(20,20); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/at/hannibal2/skyhanni/features/itemabilities/CrownOfAvariceCounter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package at.hannibal2.skyhanni.features.itemabilities | ||
|
||
import at.hannibal2.skyhanni.SkyHanniMod | ||
import at.hannibal2.skyhanni.events.GuiRenderEvent | ||
import at.hannibal2.skyhanni.events.LorenzTickEvent | ||
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | ||
import at.hannibal2.skyhanni.utils.InventoryUtils | ||
import at.hannibal2.skyhanni.utils.ItemUtils.extraAttributes | ||
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName | ||
import at.hannibal2.skyhanni.utils.NEUItems.getItemStack | ||
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators | ||
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat | ||
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable | ||
import at.hannibal2.skyhanni.utils.renderables.Renderable | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
@SkyHanniModule | ||
object CrownOfAvariceCounter { | ||
|
||
private val config get() = SkyHanniMod.feature.inventory.itemAbilities.crownOfAvarice | ||
|
||
private val internalName = "CROWN_OF_AVARICE".asInternalName() | ||
|
||
private var render: Renderable? = null | ||
|
||
@SubscribeEvent | ||
fun onOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { | ||
render?.let { config.position.renderRenderable(it, posLabel = "Crown of Avarice Counter") } | ||
} | ||
|
||
@SubscribeEvent | ||
fun onTick(event: LorenzTickEvent) { | ||
render = check() | ||
} | ||
|
||
fun check(): Renderable? { | ||
if (!LorenzUtils.inSkyBlock) return null | ||
if (!config.enable) return null | ||
val item = InventoryUtils.getHelmet() | ||
if (item?.getInternalNameOrNull() != internalName) return null | ||
val count = item.extraAttributes.getLong("collected_coins"); | ||
return Renderable.horizontalContainer( | ||
listOf( | ||
Renderable.itemStack(internalName.getItemStack()), | ||
Renderable.string("§6" + if (config.shortFormat) count.shortFormat() else count.addSeparators()), | ||
), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters