From 2eab6cb3fe89304ecad663c6c010bab38cda01d3 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Tue, 12 Dec 2023 23:00:29 +0100 Subject: [PATCH 01/19] Added overlay --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../features/fishing/FishingConfig.java | 5 ++ .../fishing/TotemOfCorruptionConfig.java | 19 +++++ .../features/misc/TotemOfCorruption.kt | 79 +++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 6c27a0be100b..b061a494a010 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -246,6 +246,7 @@ import at.hannibal2.skyhanni.features.misc.ServerRestartTitle import at.hannibal2.skyhanni.features.misc.SkyBlockKickDuration import at.hannibal2.skyhanni.features.misc.SuperpairsClicksAlert import at.hannibal2.skyhanni.features.misc.TimeFeatures +import at.hannibal2.skyhanni.features.misc.TotemOfCorruption import at.hannibal2.skyhanni.features.misc.TpsCounter import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList import at.hannibal2.skyhanni.features.misc.compacttablist.TabListReader @@ -676,6 +677,7 @@ class SkyHanniMod { loadModule(HighlightPlaceableNpcs()) loadModule(PresentWaypoints()) loadModule(JyrreTimer()) + loadModule(TotemOfCorruption()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java index 349f4882eb12..a991b13ffbc8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java @@ -55,6 +55,11 @@ public class FishingConfig { @Accordion public FishingProfitTrackerConfig fishingProfitTracker = new FishingProfitTrackerConfig(); + @Expose + @ConfigOption(name = "Totem of Corruption", desc = "") + @Accordion + public TotemOfCorruptionConfig totemOfCorruption = new TotemOfCorruptionConfig(); + @Expose @ConfigOption( name = "Shark Fish Counter", diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java new file mode 100644 index 000000000000..5830e4916aa0 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -0,0 +1,19 @@ +package at.hannibal2.skyhanni.config.features.fishing; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class TotemOfCorruptionConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show the Totem of Corruption overlay.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + public Position position = new Position(50, 20, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt new file mode 100644 index 000000000000..c4f738966fba --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt @@ -0,0 +1,79 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class TotemOfCorruption { + private var totemEntity: EntityArmorStand? = null + private var timeRemainingEntity: EntityArmorStand? = null + private var ownerEntity: EntityArmorStand? = null + private var timeRemainingSeconds: Int? = null + private var ownerName: String? = null + + private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption + private var display = emptyList() + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!enabled()) return + + totemEntity = EntityUtils.getEntitiesNextToPlayer(40.0) + .firstOrNull { it.inventory?.get(4)?.name == "§aTotem of Corruption" } ?: return clearData() + timeRemainingEntity = EntityUtils.getEntitiesNearby(totemEntity!!.getLorenzVec(), 2.0) + .firstOrNull { it.name.startsWith("§7Remaining: §e") } ?: return clearData() + ownerEntity = EntityUtils.getEntitiesNearby(totemEntity!!.getLorenzVec(), 2.0) + .firstOrNull { it.name.startsWith("§7Owner: §e") } ?: return clearData() + + // time format: 1min 23s AND 24s, returns seconds + timeRemainingSeconds = + timeRemainingEntity!!.name.substring(15).replace("m", "").replace("s", "").split(" ").let { + if (it.size == 2) { + it[0].toInt() * 60 + it[1].substring(0, it[1].length).toInt() + } else { + it[0].substring(0, it[0].length).toInt() + } + } + + ownerName = ownerEntity!!.name.substring(11) + + display = createLines() + } + + @SubscribeEvent + fun onRender(event: GuiRenderEvent.GuiOverlayRenderEvent) { + if (!enabled()) return + if (display.isEmpty()) return + + config.position.renderStrings(display, posLabel = "Totem of Corruption") + } + + private fun createLines(): List { + val lines = mutableListOf() + lines.add("§5§lTotem of Corruption") + if (timeRemainingSeconds!! < 60) { + lines.add("§7Remaining: §e${timeRemainingSeconds!! % 60}s") + } else { + lines.add("§7Remaining: §e${timeRemainingSeconds!! / 60}min ${timeRemainingSeconds!! % 60}s") + } + lines.add("§7Owner: §e$ownerName") + return lines + } + + private fun enabled() = config.enabled && LorenzUtils.inSkyBlock + + private fun clearData() { + totemEntity = null + timeRemainingEntity = null + ownerEntity = null + timeRemainingSeconds = null + display = emptyList() + } +} From 0620781393217c1b7518a7a655d349d140f66361 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:09:07 +0100 Subject: [PATCH 02/19] display does not work right now --- .../features/misc/TotemOfCorruption.kt | 116 +++++++++++------- 1 file changed, 75 insertions(+), 41 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt index c4f738966fba..5403b148a6c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt @@ -1,3 +1,7 @@ +// +// https://discord.com/channels/997079228510117908/1167847565564334090 +// + package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod @@ -8,72 +12,102 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityArmorStand import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class TotemOfCorruption { - private var totemEntity: EntityArmorStand? = null - private var timeRemainingEntity: EntityArmorStand? = null - private var ownerEntity: EntityArmorStand? = null - private var timeRemainingSeconds: Int? = null - private var ownerName: String? = null - - private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption - private var display = emptyList() +private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption +private var display = emptyList() +private var totems: List = emptyList() +class TotemOfCorruption { @SubscribeEvent - fun onTick(event: LorenzTickEvent) { + fun onRender(event: GuiRenderEvent.GuiOverlayRenderEvent) { if (!enabled()) return + if (display.isEmpty()) return - totemEntity = EntityUtils.getEntitiesNextToPlayer(40.0) - .firstOrNull { it.inventory?.get(4)?.name == "§aTotem of Corruption" } ?: return clearData() - timeRemainingEntity = EntityUtils.getEntitiesNearby(totemEntity!!.getLorenzVec(), 2.0) - .firstOrNull { it.name.startsWith("§7Remaining: §e") } ?: return clearData() - ownerEntity = EntityUtils.getEntitiesNearby(totemEntity!!.getLorenzVec(), 2.0) - .firstOrNull { it.name.startsWith("§7Owner: §e") } ?: return clearData() - - // time format: 1min 23s AND 24s, returns seconds - timeRemainingSeconds = - timeRemainingEntity!!.name.substring(15).replace("m", "").replace("s", "").split(" ").let { - if (it.size == 2) { - it[0].toInt() * 60 + it[1].substring(0, it[1].length).toInt() - } else { - it[0].substring(0, it[0].length).toInt() - } - } - - ownerName = ownerEntity!!.name.substring(11) + LorenzUtils.chat("totems: ${totems.size}") + LorenzUtils.chat("display: ${display.size}") - display = createLines() + config.position.renderStrings(display, posLabel = "Totem of Corruption") } @SubscribeEvent - fun onRender(event: GuiRenderEvent.GuiOverlayRenderEvent) { + fun onTick(event: LorenzTickEvent) { if (!enabled()) return - if (display.isEmpty()) return - config.position.renderStrings(display, posLabel = "Totem of Corruption") + if (getTotems().isEmpty()) { + clearData() + return + } + + LorenzUtils.chat("amount: ${getTotems().size}") + + for (totem in getTotems()) { + if (totem == null) continue + val timeRemainingEntity = EntityUtils.getEntitiesNearby( + totem.getLorenzVec(), + 2.0 + ).filter { it.name.startsWith("§7Time Remaining: §e") }.firstOrNull() + val ownerEntity = EntityUtils.getEntitiesNearby( + totem.getLorenzVec(), + 2.0 + ).filter { it.name.startsWith("§7Owner: §e") }.firstOrNull() + if (timeRemainingEntity != null && ownerEntity != null) { + totems += Totem( + totem, + timeRemainingEntity.nameToSeconds(), + ownerEntity.name.substring(11) + ) + } + } + + display = createLines() } private fun createLines(): List { + val totem = getTotemToShow() ?: return emptyList() + LorenzUtils.chat("building string") val lines = mutableListOf() lines.add("§5§lTotem of Corruption") - if (timeRemainingSeconds!! < 60) { - lines.add("§7Remaining: §e${timeRemainingSeconds!! % 60}s") + if (totem.timeRemainingSeconds < 60) { + lines.add("§7Remaining: §e${totem.timeRemainingSeconds % 60}s") } else { - lines.add("§7Remaining: §e${timeRemainingSeconds!! / 60}min ${timeRemainingSeconds!! % 60}s") + lines.add("§7Remaining: §e${totem.timeRemainingSeconds / 60}min ${totem.timeRemainingSeconds % 60}s") } - lines.add("§7Owner: §e$ownerName") + lines.add("§7Owner: §e${totem.ownerName}") return lines } - private fun enabled() = config.enabled && LorenzUtils.inSkyBlock + private fun getTotemToShow(): Totem? { + return totems.maxByOrNull { it.timeRemainingSeconds } + } + + private fun getTotems(): List { + return EntityUtils.getEntitiesNextToPlayer(20.0) + .filter { it.inventory?.get(4)?.name == "§aTotem of Corruption" }.toList() + } private fun clearData() { - totemEntity = null - timeRemainingEntity = null - ownerEntity = null - timeRemainingSeconds = null + totems = emptyList() display = emptyList() } + + private fun Entity.nameToSeconds(): Int { + return name.substring(15).replace("m", "").replace("s", "").split(" ").let { + if (it.size == 2) { + it[0].toInt() * 60 + it[1].substring(0, it[1].length).toInt() + } else { + it[0].substring(0, it[0].length).toInt() + } + } + } + + private fun enabled() = config.enabled && LorenzUtils.inSkyBlock } + +class Totem( + val totemEntity: EntityArmorStand, + val timeRemainingSeconds: Int, + val ownerName: String +) From 152d96742b43778e260bed9b960488dc27f8a66c Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:51:36 +0100 Subject: [PATCH 03/19] works again (a lot better) --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- .../features/fishing/TotemOfCorruption.kt | 112 +++++++++++++++++ .../features/misc/TotemOfCorruption.kt | 113 ------------------ 3 files changed, 113 insertions(+), 114 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c0069ed3e143..0305feba317f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -277,7 +277,7 @@ import at.hannibal2.skyhanni.features.misc.ServerRestartTitle import at.hannibal2.skyhanni.features.misc.SkyBlockKickDuration import at.hannibal2.skyhanni.features.misc.SuperpairsClicksAlert import at.hannibal2.skyhanni.features.misc.TimeFeatures -import at.hannibal2.skyhanni.features.misc.TotemOfCorruption +import at.hannibal2.skyhanni.features.fishing.TotemOfCorruption import at.hannibal2.skyhanni.features.misc.TpsCounter import at.hannibal2.skyhanni.features.misc.compacttablist.AdvancedPlayerList import at.hannibal2.skyhanni.features.misc.compacttablist.TabListReader diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt new file mode 100644 index 000000000000..073c5d71017e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -0,0 +1,112 @@ +package at.hannibal2.skyhanni.features.fishing + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.getLorenzVec +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption + +private var display = emptyList() +private var totems: List = emptyList() + +class TotemOfCorruption { + private val group = RepoPattern.group("features.fishing.totemofcorruption") + private val totemNamePattern by group.pattern( + "totemname", + "§5§lTotem of Corruption" + ) + private val timeRemainingPattern by group.pattern( + "timeremaining", + "§7Remaining: §e(?:(?\\d+)m )?(?\\d+)s" + ) + private val ownerPattern by group.pattern( + "owner", + "§7Owner: §e(?.+)" + ) + + @SubscribeEvent + fun onRender(event: GuiRenderEvent.GuiOverlayRenderEvent) { + if (!enabled() || display.isEmpty()) return + config.position.renderStrings(display, posLabel = "Totem of Corruption") + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!enabled()) return + totems = getTotems() + .filterNotNull() + .mapNotNull { totem -> + val timeRemaining = getTimeRemaining(totem) + val owner = getOwner(totem) + if (timeRemaining != null && owner != null) { + Totem(totem, timeRemaining, owner) + } else { + null + } + } + + display = createLines() + } + + private fun getTimeRemaining(totem: EntityArmorStand): Int? { + return EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) + .firstOrNull { timeRemainingPattern.matches(it.name) } + ?.let { + timeRemainingPattern.matchMatcher(it.name) { + group("min")?.toInt()?.let { min -> min * 60 + group("sec").toInt() } + ?: group("sec").toInt() + } + } + } + + private fun getOwner(totem: EntityArmorStand): String? { + return EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) + .firstOrNull { ownerPattern.matches(it.name) } + ?.let { + ownerPattern.matchMatcher(it.name) { + group("owner") + } + } + } + + private fun createLines() = buildList { + val totem = getTotemToShow() ?: return@buildList + add("§5§lTotem of Corruption") + add("§7Remaining: §e${totem.timeRemainingFormatted()}") + add("§7Owner: §e${totem.ownerName}") + } + + private fun Totem.timeRemainingFormatted(): String { + return if (timeRemainingSeconds < 60) { + "§e${timeRemainingSeconds % 60}s" + } else { + "§e${timeRemainingSeconds / 60}min ${timeRemainingSeconds % 60}s" + } + } + + private fun getTotemToShow(): Totem? { + return totems.maxByOrNull { it.timeRemainingSeconds } + } + + private fun getTotems(): List { + return EntityUtils.getEntitiesNextToPlayer(20.0) + .filter { totemNamePattern.matches(it.name) }.toList() + } + + private fun enabled() = config.enabled && LorenzUtils.inSkyBlock +} + +class Totem( + val totemEntity: EntityArmorStand, + val timeRemainingSeconds: Int, + val ownerName: String +) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt deleted file mode 100644 index 5403b148a6c7..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/TotemOfCorruption.kt +++ /dev/null @@ -1,113 +0,0 @@ -// -// https://discord.com/channels/997079228510117908/1167847565564334090 -// - -package at.hannibal2.skyhanni.features.misc - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings -import at.hannibal2.skyhanni.utils.getLorenzVec -import net.minecraft.entity.Entity -import net.minecraft.entity.item.EntityArmorStand -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption -private var display = emptyList() -private var totems: List = emptyList() - -class TotemOfCorruption { - @SubscribeEvent - fun onRender(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!enabled()) return - if (display.isEmpty()) return - - LorenzUtils.chat("totems: ${totems.size}") - LorenzUtils.chat("display: ${display.size}") - - config.position.renderStrings(display, posLabel = "Totem of Corruption") - } - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - if (!enabled()) return - - if (getTotems().isEmpty()) { - clearData() - return - } - - LorenzUtils.chat("amount: ${getTotems().size}") - - for (totem in getTotems()) { - if (totem == null) continue - val timeRemainingEntity = EntityUtils.getEntitiesNearby( - totem.getLorenzVec(), - 2.0 - ).filter { it.name.startsWith("§7Time Remaining: §e") }.firstOrNull() - val ownerEntity = EntityUtils.getEntitiesNearby( - totem.getLorenzVec(), - 2.0 - ).filter { it.name.startsWith("§7Owner: §e") }.firstOrNull() - if (timeRemainingEntity != null && ownerEntity != null) { - totems += Totem( - totem, - timeRemainingEntity.nameToSeconds(), - ownerEntity.name.substring(11) - ) - } - } - - display = createLines() - } - - private fun createLines(): List { - val totem = getTotemToShow() ?: return emptyList() - LorenzUtils.chat("building string") - val lines = mutableListOf() - lines.add("§5§lTotem of Corruption") - if (totem.timeRemainingSeconds < 60) { - lines.add("§7Remaining: §e${totem.timeRemainingSeconds % 60}s") - } else { - lines.add("§7Remaining: §e${totem.timeRemainingSeconds / 60}min ${totem.timeRemainingSeconds % 60}s") - } - lines.add("§7Owner: §e${totem.ownerName}") - return lines - } - - private fun getTotemToShow(): Totem? { - return totems.maxByOrNull { it.timeRemainingSeconds } - } - - private fun getTotems(): List { - return EntityUtils.getEntitiesNextToPlayer(20.0) - .filter { it.inventory?.get(4)?.name == "§aTotem of Corruption" }.toList() - } - - private fun clearData() { - totems = emptyList() - display = emptyList() - } - - private fun Entity.nameToSeconds(): Int { - return name.substring(15).replace("m", "").replace("s", "").split(" ").let { - if (it.size == 2) { - it[0].toInt() * 60 + it[1].substring(0, it[1].length).toInt() - } else { - it[0].substring(0, it[0].length).toInt() - } - } - } - - private fun enabled() = config.enabled && LorenzUtils.inSkyBlock -} - -class Totem( - val totemEntity: EntityArmorStand, - val timeRemainingSeconds: Int, - val ownerName: String -) From 5869cff05783db5c8219910d3a692f87530e7f02 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 9 Mar 2024 18:08:37 +0100 Subject: [PATCH 04/19] Option to hide particles --- .../fishing/TotemOfCorruptionConfig.java | 8 ++++++- .../features/fishing/TotemOfCorruption.kt | 22 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index 5830e4916aa0..a4a380c7412b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -12,7 +12,13 @@ public class TotemOfCorruptionConfig { @ConfigOption(name = "Enabled", desc = "Show the Totem of Corruption overlay.") @ConfigEditorBoolean @FeatureToggle - public boolean enabled = true; + public boolean showOverlay = true; + + @Expose + @ConfigOption(name = "Hide Particles", desc = "Hide the particles of the Totem of Corruption.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hideParticles = true; @Expose public Position position = new Position(50, 20, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 073c5d71017e..0a82432f11dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings @@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.getLorenzVec import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption @@ -35,13 +37,13 @@ class TotemOfCorruption { @SubscribeEvent fun onRender(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!enabled() || display.isEmpty()) return + if (!isOverlayEnabled() || display.isEmpty()) return config.position.renderStrings(display, posLabel = "Totem of Corruption") } @SubscribeEvent fun onTick(event: LorenzTickEvent) { - if (!enabled()) return + if (!isOverlayEnabled()) return totems = getTotems() .filterNotNull() .mapNotNull { totem -> @@ -57,6 +59,19 @@ class TotemOfCorruption { display = createLines() } + @SubscribeEvent + fun onChatPacket(event: ReceiveParticleEvent) { + if (!isHideParticlesEnabled()) return + + for (totem in totems) { + if (event.type == EnumParticleTypes.SPELL_WITCH && event.speed == 0.0f) { + if (totem.totemEntity.getLorenzVec().distance(event.location) < 4.0) { + event.isCanceled = true + } + } + } + } + private fun getTimeRemaining(totem: EntityArmorStand): Int? { return EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) .firstOrNull { timeRemainingPattern.matches(it.name) } @@ -102,7 +117,8 @@ class TotemOfCorruption { .filter { totemNamePattern.matches(it.name) }.toList() } - private fun enabled() = config.enabled && LorenzUtils.inSkyBlock + private fun isOverlayEnabled() = config.showOverlay && LorenzUtils.inSkyBlock + private fun isHideParticlesEnabled() = config.hideParticles && LorenzUtils.inSkyBlock } class Totem( From 74499971dd6f8ea794181c891ee303ff08f0fb2a Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sun, 10 Mar 2024 19:30:10 +0100 Subject: [PATCH 05/19] tried adding circle renderer --- .../fishing/TotemOfCorruptionConfig.java | 6 +++ .../features/fishing/TotemOfCorruption.kt | 20 +++++++- .../hannibal2/skyhanni/utils/RenderUtils.kt | 51 +++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index a4a380c7412b..0041699406a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; import io.github.moulberry.moulconfig.annotations.ConfigOption; public class TotemOfCorruptionConfig { @@ -20,6 +21,11 @@ public class TotemOfCorruptionConfig { @FeatureToggle public boolean hideParticles = true; + @Expose + @ConfigOption(name = "Color", desc = "color") + @ConfigEditorColour + public String color = "0:120:255:85:85"; + @Expose public Position position = new Position(50, 20, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 0a82432f11dd..2abd98ad25e6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -2,11 +2,14 @@ package at.hannibal2.skyhanni.features.fishing import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.SpecialColour import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.getLorenzVec @@ -14,12 +17,16 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption private var display = emptyList() private var totems: List = emptyList() +private var EFFECTIVE_TOTEM_RADIUS = 16.0 // Center is upper half of banner +private var TOTEM_UI_OVERLAY_RADIUS = 20.0 + class TotemOfCorruption { private val group = RepoPattern.group("features.fishing.totemofcorruption") private val totemNamePattern by group.pattern( @@ -72,6 +79,17 @@ class TotemOfCorruption { } } + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + val color = Color(SpecialColour.specialToChromaRGB(config.color), true) + getTotemToShow()?.let { totem -> + val x = totem.totemEntity.posX + val y = totem.totemEntity.posY + 1.0 + val z = totem.totemEntity.posZ + RenderUtils.drawSphereInWorld(color, x, y, z, 3.5f, 4.5f, event.partialTicks) + } + } + private fun getTimeRemaining(totem: EntityArmorStand): Int? { return EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) .firstOrNull { timeRemainingPattern.matches(it.name) } @@ -113,7 +131,7 @@ class TotemOfCorruption { } private fun getTotems(): List { - return EntityUtils.getEntitiesNextToPlayer(20.0) + return EntityUtils.getEntitiesNextToPlayer(TOTEM_UI_OVERLAY_RADIUS) .filter { totemNamePattern.matches(it.name) }.toList() } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 32ea323298fd..37cd9a450d4d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -19,6 +19,7 @@ import net.minecraft.client.gui.Gui import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator +import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.enchantment.Enchantment import net.minecraft.entity.Entity @@ -622,6 +623,56 @@ object RenderUtils { GlStateManager.popMatrix() } + fun drawSphereInWorld( + color: Color, + x: Double, + y: Double, + z: Double, + radius: Float, + height: Float, + partialTicks: Float, + ) { + val minecraft = Minecraft.getMinecraft() + + GlStateManager.pushMatrix() + GlStateManager.translate(x - minecraft.renderManager.viewerPosX, y - minecraft.renderManager.viewerPosY, z - minecraft.renderManager.viewerPosZ) + GlStateManager.disableTexture2D() + GlStateManager.enableBlend() + GlStateManager.disableAlpha() + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO) + GlStateManager.shadeModel(GL11.GL_SMOOTH) + + val tessellator = Tessellator.getInstance() + val worldRenderer = tessellator.worldRenderer + worldRenderer.begin(GL11.GL_TRIANGLE_FAN, WorldRenderer.POSITION_COLOR) + + val red = color.red.toFloat() / 255.0f + val green = color.green.toFloat() / 255.0f + val blue = color.blue.toFloat() / 255.0f + + val segments = 32 + val increment = 360.0 / segments + + worldRenderer.pos(0.0, height, 0.0).color(red, green, blue, 1.0f).endVertex() + + for (angle in 0 until 360 step increment.toInt()) { + val radians = Math.toRadians(angle.toDouble()) + val xPos = radius * Math.cos(radians) + val zPos = radius * Math.sin(radians) + + worldRenderer.pos(xPos, height, zPos).color(red, green, blue, 1.0f).endVertex() + } + + tessellator.draw() + + GlStateManager.shadeModel(GL11.GL_FLAT) + GlStateManager.disableBlend() + GlStateManager.enableAlpha() + GlStateManager.enableTexture2D() + GlStateManager.popMatrix() + } + + private fun Color.bindColor() = GlStateManager.color(this.red / 255f, this.green / 255f, this.blue / 255f, this.alpha / 255f) From 0f5abdda11472bc9c6c2a5d702961f9376413f0d Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sun, 10 Mar 2024 23:53:11 +0100 Subject: [PATCH 06/19] Added effective area highlight --- .../features/fishing/FishingConfig.java | 5 +- .../fishing/TotemOfCorruptionConfig.java | 20 ++++- .../features/fishing/TotemOfCorruption.kt | 42 +++++----- .../hannibal2/skyhanni/utils/RenderUtils.kt | 77 ++++++++++++------- 4 files changed, 93 insertions(+), 51 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java index 0f389ff968b9..0814f3a40bf2 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/FishingConfig.java @@ -66,7 +66,10 @@ public class FishingConfig { public SeaCreatureTrackerConfig seaCreatureTracker = new SeaCreatureTrackerConfig(); @Expose - @ConfigOption(name = "Shark Fish Counter", desc = "Counts how many Sharks have been caught.") + @ConfigOption( + name = "Shark Fish Counter", + desc = "Counts how many Sharks have been caught." + ) @ConfigEditorBoolean @FeatureToggle public boolean sharkFishCounter = false; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index 0041699406a1..bed3ce7035dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -5,16 +5,24 @@ import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; public class TotemOfCorruptionConfig { @Expose - @ConfigOption(name = "Enabled", desc = "Show the Totem of Corruption overlay.") + @ConfigOption(name = "Show Overlay", desc = "Show the Totem of Corruption overlay.") @ConfigEditorBoolean @FeatureToggle public boolean showOverlay = true; + @Expose + @ConfigOption(name = "Distance Threshold", desc = "The distance from the player to the Totem of Corruption for the overlay to be shown. " + + "\nThe effective distance of the totem is 16." + + "\n§cLimited by the far you can see the nametags.") + @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) + public int distanceThreshold = 16; + @Expose @ConfigOption(name = "Hide Particles", desc = "Hide the particles of the Totem of Corruption.") @ConfigEditorBoolean @@ -22,9 +30,15 @@ public class TotemOfCorruptionConfig { public boolean hideParticles = true; @Expose - @ConfigOption(name = "Color", desc = "color") + @ConfigOption(name = "Show Effective Area", desc = "Show the effective area (16 blocks) of the Totem of Corruption.") + @ConfigEditorBoolean + @FeatureToggle + public boolean showEffectiveArea = true; + + @Expose + @ConfigOption(name = "Color of the area", desc = "The color of the area of the Totem of Corruption.") @ConfigEditorColour - public String color = "0:120:255:85:85"; + public String color = "0:153:18:159:85"; @Expose public Position position = new Position(50, 20, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 2abd98ad25e6..2a794bdcc9c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings @@ -24,9 +25,6 @@ private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption private var display = emptyList() private var totems: List = emptyList() -private var EFFECTIVE_TOTEM_RADIUS = 16.0 // Center is upper half of banner -private var TOTEM_UI_OVERLAY_RADIUS = 20.0 - class TotemOfCorruption { private val group = RepoPattern.group("features.fishing.totemofcorruption") private val totemNamePattern by group.pattern( @@ -81,17 +79,19 @@ class TotemOfCorruption { @SubscribeEvent fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!isEffectiveAreaEnabled()) return + val color = Color(SpecialColour.specialToChromaRGB(config.color), true) - getTotemToShow()?.let { totem -> + for (totem in totems) { val x = totem.totemEntity.posX - val y = totem.totemEntity.posY + 1.0 + val y = totem.totemEntity.posY + 1.0 // The center of the totem is the upper part val z = totem.totemEntity.posZ - RenderUtils.drawSphereInWorld(color, x, y, z, 3.5f, 4.5f, event.partialTicks) + RenderUtils.drawSphereInWorld(color, x, y, z, 16f, event.partialTicks) } } - private fun getTimeRemaining(totem: EntityArmorStand): Int? { - return EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) + private fun getTimeRemaining(totem: EntityArmorStand) = + EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) .firstOrNull { timeRemainingPattern.matches(it.name) } ?.let { timeRemainingPattern.matchMatcher(it.name) { @@ -99,17 +99,15 @@ class TotemOfCorruption { ?: group("sec").toInt() } } - } - private fun getOwner(totem: EntityArmorStand): String? { - return EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) + private fun getOwner(totem: EntityArmorStand) = + EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) .firstOrNull { ownerPattern.matches(it.name) } ?.let { ownerPattern.matchMatcher(it.name) { group("owner") } } - } private fun createLines() = buildList { val totem = getTotemToShow() ?: return@buildList @@ -118,29 +116,31 @@ class TotemOfCorruption { add("§7Owner: §e${totem.ownerName}") } - private fun Totem.timeRemainingFormatted(): String { - return if (timeRemainingSeconds < 60) { - "§e${timeRemainingSeconds % 60}s" - } else { - "§e${timeRemainingSeconds / 60}min ${timeRemainingSeconds % 60}s" - } + private fun Totem.timeRemainingFormatted() = if (timeRemainingSeconds < 60) { + "§e${timeRemainingSeconds % 60}s" + } else { + "§e${timeRemainingSeconds / 60}min ${timeRemainingSeconds % 60}s" } private fun getTotemToShow(): Totem? { - return totems.maxByOrNull { it.timeRemainingSeconds } + return totems + .filter { it.distance < config.distanceThreshold } + .maxByOrNull { it.timeRemainingSeconds } } private fun getTotems(): List { - return EntityUtils.getEntitiesNextToPlayer(TOTEM_UI_OVERLAY_RADIUS) + return EntityUtils.getEntitiesNextToPlayer(100.0) .filter { totemNamePattern.matches(it.name) }.toList() } private fun isOverlayEnabled() = config.showOverlay && LorenzUtils.inSkyBlock private fun isHideParticlesEnabled() = config.hideParticles && LorenzUtils.inSkyBlock + private fun isEffectiveAreaEnabled() = config.showEffectiveArea && LorenzUtils.inSkyBlock } class Totem( val totemEntity: EntityArmorStand, val timeRemainingSeconds: Int, - val ownerName: String + val ownerName: String, + val distance: Double = totemEntity.getLorenzVec().distanceToPlayer() ) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 37cd9a450d4d..2f609a95a519 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -19,7 +19,6 @@ import net.minecraft.client.gui.Gui import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator -import net.minecraft.client.renderer.WorldRenderer import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.enchantment.Enchantment import net.minecraft.entity.Entity @@ -629,50 +628,76 @@ object RenderUtils { y: Double, z: Double, radius: Float, - height: Float, partialTicks: Float, ) { - val minecraft = Minecraft.getMinecraft() - GlStateManager.pushMatrix() - GlStateManager.translate(x - minecraft.renderManager.viewerPosX, y - minecraft.renderManager.viewerPosY, z - minecraft.renderManager.viewerPosZ) - GlStateManager.disableTexture2D() + GL11.glNormal3f(0.0f, 1.0f, 0.0f) + + GlStateManager.enableDepth() GlStateManager.enableBlend() - GlStateManager.disableAlpha() - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO) - GlStateManager.shadeModel(GL11.GL_SMOOTH) + GlStateManager.depthFunc(GL11.GL_LEQUAL) + GlStateManager.disableCull() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.enableAlpha() + GlStateManager.disableTexture2D() + color.bindColor() - val tessellator = Tessellator.getInstance() - val worldRenderer = tessellator.worldRenderer - worldRenderer.begin(GL11.GL_TRIANGLE_FAN, WorldRenderer.POSITION_COLOR) + var x1 = x + var y1 = y + var z1 = z + val renderViewEntity = Minecraft.getMinecraft().renderViewEntity + val viewX = + renderViewEntity.prevPosX + (renderViewEntity.posX - renderViewEntity.prevPosX) * partialTicks.toDouble() + val viewY = + renderViewEntity.prevPosY + (renderViewEntity.posY - renderViewEntity.prevPosY) * partialTicks.toDouble() + val viewZ = + renderViewEntity.prevPosZ + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * partialTicks.toDouble() + x1 -= viewX + y1 -= viewY + z1 -= viewZ - val red = color.red.toFloat() / 255.0f - val green = color.green.toFloat() / 255.0f - val blue = color.blue.toFloat() / 255.0f + val tessellator = Tessellator.getInstance() + val worldrenderer = tessellator.worldRenderer + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION) val segments = 32 - val increment = 360.0 / segments - worldRenderer.pos(0.0, height, 0.0).color(red, green, blue, 1.0f).endVertex() + for (phi in 0 until segments) { + for (theta in 0 until segments * 2) { + val x2 = x1 + radius * sin(Math.PI * phi / segments) * cos(2.0 * Math.PI * theta / (segments * 2)) + val y2 = y1 + radius * cos(Math.PI * phi / segments) + val z2 = z1 + radius * sin(Math.PI * phi / segments) * sin(2.0 * Math.PI * theta / (segments * 2)) + + val x3 = x1 + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * theta / (segments * 2)) + val y3 = y1 + radius * cos(Math.PI * (phi + 1) / segments) + val z3 = z1 + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * theta / (segments * 2)) - for (angle in 0 until 360 step increment.toInt()) { - val radians = Math.toRadians(angle.toDouble()) - val xPos = radius * Math.cos(radians) - val zPos = radius * Math.sin(radians) + worldrenderer.pos(x2, y2, z2).endVertex() + worldrenderer.pos(x3, y3, z3).endVertex() - worldRenderer.pos(xPos, height, zPos).color(red, green, blue, 1.0f).endVertex() + val x4 = x1 + radius * sin(Math.PI * (phi + 1) / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) + val y4 = y1 + radius * cos(Math.PI * (phi + 1) / segments) + val z4 = z1 + radius * sin(Math.PI * (phi + 1) / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2)) + + val x5 = x1 + radius * sin(Math.PI * phi / segments) * cos(2.0 * Math.PI * (theta + 1) / (segments * 2)) + val y5 = y1 + radius * cos(Math.PI * phi / segments) + val z5 = z1 + radius * sin(Math.PI * phi / segments) * sin(2.0 * Math.PI * (theta + 1) / (segments * 2)) + + worldrenderer.pos(x4, y4, z4).endVertex() + worldrenderer.pos(x5, y5, z5).endVertex() + } } tessellator.draw() - GlStateManager.shadeModel(GL11.GL_FLAT) - GlStateManager.disableBlend() - GlStateManager.enableAlpha() + GlStateManager.enableCull() GlStateManager.enableTexture2D() + GlStateManager.enableDepth() + GlStateManager.disableBlend() + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f) GlStateManager.popMatrix() } - private fun Color.bindColor() = GlStateManager.color(this.red / 255f, this.green / 255f, this.blue / 255f, this.alpha / 255f) From 47abddb998d7d1052fcc4ce8f35c13acf8f26fb4 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sun, 10 Mar 2024 23:59:34 +0100 Subject: [PATCH 07/19] tried to explain the overlay --- .../config/features/fishing/TotemOfCorruptionConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index bed3ce7035dd..276cc02b3861 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -11,7 +11,8 @@ public class TotemOfCorruptionConfig { @Expose - @ConfigOption(name = "Show Overlay", desc = "Show the Totem of Corruption overlay.") + @ConfigOption(name = "Show Overlay", desc = "Show the Totem of Corruption overlay." + + "\nShows the totem, in which effective area you are in, with the longest time left.") @ConfigEditorBoolean @FeatureToggle public boolean showOverlay = true; From b75419ce6799778026f66cbc4cc1cd192e4d78ce Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:15:39 +0100 Subject: [PATCH 08/19] fix typo --- .../config/features/fishing/TotemOfCorruptionConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index 276cc02b3861..75403ca47b82 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -20,7 +20,7 @@ public class TotemOfCorruptionConfig { @Expose @ConfigOption(name = "Distance Threshold", desc = "The distance from the player to the Totem of Corruption for the overlay to be shown. " + "\nThe effective distance of the totem is 16." + - "\n§cLimited by the far you can see the nametags.") + "\n§cLimited by how far you can see the nametags.") @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) public int distanceThreshold = 16; From 7fda38347896ada814f9f987df2b06f7f67163e6 Mon Sep 17 00:00:00 2001 From: j10a1n15 Date: Mon, 11 Mar 2024 13:44:01 +0100 Subject: [PATCH 09/19] Added kinda broken replace totem reminder --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- .../features/fishing/TotemOfCorruptionConfig.java | 6 ++++++ .../skyhanni/features/fishing/TotemOfCorruption.kt | 13 +++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 8068d5061200..d0c3ee8f7048 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -837,7 +837,7 @@ class SkyHanniMod { @JvmStatic val feature: Features get() = configManager.features - val sackData: SackData get() = configManager.sackData + val sackData: SackData get() = configManager.sackData val friendsData: FriendsJson get() = configManager.friendsData val knownFeaturesData: KnownFeaturesJson get() = configManager.knownFeaturesData val jacobContestsData: JacobContestsJson get() = configManager.jacobContestData diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index 75403ca47b82..7e124a0ccc40 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -41,6 +41,12 @@ public class TotemOfCorruptionConfig { @ConfigEditorColour public String color = "0:153:18:159:85"; + @Expose + @ConfigOption(name = "Warn when about to expire", desc = "Select the time in seconds when the totem is about to expire to warn you." + + "\nSelect 0 to disable.") + @ConfigEditorSlider(minValue = 0, maxValue = 60, minStep = 1) + public int warnWhenAboutToExpire = 5; + @Expose public Position position = new Position(50, 20, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 2a794bdcc9c2..e22601dacad3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -8,8 +8,10 @@ import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.sendTitle import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.SoundUtils.playPlingSound import at.hannibal2.skyhanni.utils.SpecialColour import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -19,6 +21,7 @@ import net.minecraft.entity.item.EntityArmorStand import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color +import kotlin.time.Duration.Companion.seconds private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption @@ -48,13 +51,19 @@ class TotemOfCorruption { @SubscribeEvent fun onTick(event: LorenzTickEvent) { + if (event.repeatSeconds(1)) return if (!isOverlayEnabled()) return + totems = getTotems() .filterNotNull() .mapNotNull { totem -> val timeRemaining = getTimeRemaining(totem) val owner = getOwner(totem) if (timeRemaining != null && owner != null) { + if (timeRemaining <= config.warnWhenAboutToExpire && config.warnWhenAboutToExpire > 0) { + playPlingSound() + sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) + } Totem(totem, timeRemaining, owner) } else { null @@ -90,7 +99,7 @@ class TotemOfCorruption { } } - private fun getTimeRemaining(totem: EntityArmorStand) = + private fun getTimeRemaining(totem: EntityArmorStand): Int? = EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) .firstOrNull { timeRemainingPattern.matches(it.name) } ?.let { @@ -100,7 +109,7 @@ class TotemOfCorruption { } } - private fun getOwner(totem: EntityArmorStand) = + private fun getOwner(totem: EntityArmorStand): String? = EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) .firstOrNull { ownerPattern.matches(it.name) } ?.let { From dc20f3fbb0986d009e362a454ed5c1bf87ba401f Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Tue, 12 Mar 2024 08:25:01 +0100 Subject: [PATCH 10/19] Fixed totem warning --- .../hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index e22601dacad3..36ecfc4ef9a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -51,7 +51,7 @@ class TotemOfCorruption { @SubscribeEvent fun onTick(event: LorenzTickEvent) { - if (event.repeatSeconds(1)) return + if (!event.repeatSeconds(2)) return if (!isOverlayEnabled()) return totems = getTotems() @@ -60,7 +60,7 @@ class TotemOfCorruption { val timeRemaining = getTimeRemaining(totem) val owner = getOwner(totem) if (timeRemaining != null && owner != null) { - if (timeRemaining <= config.warnWhenAboutToExpire && config.warnWhenAboutToExpire > 0) { + if (timeRemaining == config.warnWhenAboutToExpire && config.warnWhenAboutToExpire > 0) { playPlingSound() sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) } From 98cf474552c5040b8c602989059c7062ce4226d1 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:55:55 +0100 Subject: [PATCH 11/19] why was there a random space --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 0ebd6173e1ae..07702b14f67f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -853,7 +853,7 @@ class SkyHanniMod { @JvmStatic val feature: Features get() = configManager.features - val sackData: SackData get() = configManager.sackData + val sackData: SackData get() = configManager.sackData val friendsData: FriendsJson get() = configManager.friendsData val knownFeaturesData: KnownFeaturesJson get() = configManager.knownFeaturesData val jacobContestsData: JacobContestsJson get() = configManager.jacobContestData From fc68d05f7842d0d7e260add90d3bfb39a91e29d9 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 18:50:11 +0100 Subject: [PATCH 12/19] Resolved hannis things --- .../fishing/TotemOfCorruptionConfig.java | 4 +- .../features/fishing/TotemOfCorruption.kt | 72 +++++++++---------- .../hannibal2/skyhanni/utils/RenderUtils.kt | 9 +++ 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index 7e124a0ccc40..cb967da3dfbd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -18,7 +18,7 @@ public class TotemOfCorruptionConfig { public boolean showOverlay = true; @Expose - @ConfigOption(name = "Distance Threshold", desc = "The distance from the player to the Totem of Corruption for the overlay to be shown. " + + @ConfigOption(name = "Distance Threshold", desc = "The minimum distance to the Totem of Corruption for the overlay." + "\nThe effective distance of the totem is 16." + "\n§cLimited by how far you can see the nametags.") @ConfigEditorSlider(minValue = 0, maxValue = 100, minStep = 1) @@ -27,13 +27,11 @@ public class TotemOfCorruptionConfig { @Expose @ConfigOption(name = "Hide Particles", desc = "Hide the particles of the Totem of Corruption.") @ConfigEditorBoolean - @FeatureToggle public boolean hideParticles = true; @Expose @ConfigOption(name = "Show Effective Area", desc = "Show the effective area (16 blocks) of the Totem of Corruption.") @ConfigEditorBoolean - @FeatureToggle public boolean showEffectiveArea = true; @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 36ecfc4ef9a8..3356dd6ccd93 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -9,19 +9,25 @@ import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sendTitle +import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SoundUtils.playPlingSound import at.hannibal2.skyhanni.utils.SpecialColour import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.TimeUnit +import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.getLorenzVec import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.awt.Color +import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds +import kotlin.time.DurationUnit +import kotlin.time.toDuration private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption @@ -29,6 +35,7 @@ private var display = emptyList() private var totems: List = emptyList() class TotemOfCorruption { + private val group = RepoPattern.group("features.fishing.totemofcorruption") private val totemNamePattern by group.pattern( "totemname", @@ -60,17 +67,20 @@ class TotemOfCorruption { val timeRemaining = getTimeRemaining(totem) val owner = getOwner(totem) if (timeRemaining != null && owner != null) { - if (timeRemaining == config.warnWhenAboutToExpire && config.warnWhenAboutToExpire > 0) { + if ( + timeRemaining == config.warnWhenAboutToExpire.toDuration(DurationUnit.SECONDS) + && config.warnWhenAboutToExpire.toDuration(DurationUnit.SECONDS) > 0.seconds + ) { playPlingSound() sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) } - Totem(totem, timeRemaining, owner) + Totem(totem.getLorenzVec(), timeRemaining, owner) } else { null } } - display = createLines() + display = createDisplay() } @SubscribeEvent @@ -79,7 +89,7 @@ class TotemOfCorruption { for (totem in totems) { if (event.type == EnumParticleTypes.SPELL_WITCH && event.speed == 0.0f) { - if (totem.totemEntity.getLorenzVec().distance(event.location) < 4.0) { + if (totem.location.distance(event.location) < 4.0) { event.isCanceled = true } } @@ -92,64 +102,54 @@ class TotemOfCorruption { val color = Color(SpecialColour.specialToChromaRGB(config.color), true) for (totem in totems) { - val x = totem.totemEntity.posX - val y = totem.totemEntity.posY + 1.0 // The center of the totem is the upper part - val z = totem.totemEntity.posZ - RenderUtils.drawSphereInWorld(color, x, y, z, 16f, event.partialTicks) + // The center of the totem is the upper part + RenderUtils.drawSphereInWorld(color, totem.location.add(y = 1), 16f, event.partialTicks) } } - private fun getTimeRemaining(totem: EntityArmorStand): Int? = + private fun getTimeRemaining(totem: EntityArmorStand): Duration? = EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) - .firstOrNull { timeRemainingPattern.matches(it.name) } - ?.let { - timeRemainingPattern.matchMatcher(it.name) { - group("min")?.toInt()?.let { min -> min * 60 + group("sec").toInt() } - ?: group("sec").toInt() + .firstNotNullOfOrNull { entity -> + timeRemainingPattern.matchMatcher(entity.name) { + val minutes = group("min")?.toIntOrNull() ?: 0 + val seconds = group("sec")?.toInt() ?: 0 + (minutes * 60 + seconds).seconds } } private fun getOwner(totem: EntityArmorStand): String? = EntityUtils.getEntitiesNearby(totem.getLorenzVec(), 2.0) - .firstOrNull { ownerPattern.matches(it.name) } - ?.let { - ownerPattern.matchMatcher(it.name) { + .firstNotNullOfOrNull { entity -> + ownerPattern.matchMatcher(entity.name) { group("owner") } } - private fun createLines() = buildList { + + private fun createDisplay() = buildList { val totem = getTotemToShow() ?: return@buildList add("§5§lTotem of Corruption") - add("§7Remaining: §e${totem.timeRemainingFormatted()}") + add("§7Remaining: §e${totem.timeRemaining.format(TimeUnit.MINUTE)}") add("§7Owner: §e${totem.ownerName}") } - private fun Totem.timeRemainingFormatted() = if (timeRemainingSeconds < 60) { - "§e${timeRemainingSeconds % 60}s" - } else { - "§e${timeRemainingSeconds / 60}min ${timeRemainingSeconds % 60}s" - } - - private fun getTotemToShow(): Totem? { - return totems - .filter { it.distance < config.distanceThreshold } - .maxByOrNull { it.timeRemainingSeconds } - } + private fun getTotemToShow(): Totem? = totems + .filter { it.distance < config.distanceThreshold } + .maxByOrNull { it.timeRemaining } private fun getTotems(): List { return EntityUtils.getEntitiesNextToPlayer(100.0) .filter { totemNamePattern.matches(it.name) }.toList() } - private fun isOverlayEnabled() = config.showOverlay && LorenzUtils.inSkyBlock - private fun isHideParticlesEnabled() = config.hideParticles && LorenzUtils.inSkyBlock - private fun isEffectiveAreaEnabled() = config.showEffectiveArea && LorenzUtils.inSkyBlock + private fun isOverlayEnabled() = LorenzUtils.inSkyBlock && config.showOverlay + private fun isHideParticlesEnabled() = LorenzUtils.inSkyBlock && config.hideParticles + private fun isEffectiveAreaEnabled() = LorenzUtils.inSkyBlock && config.showEffectiveArea } class Totem( - val totemEntity: EntityArmorStand, - val timeRemainingSeconds: Int, + val location: LorenzVec, + val timeRemaining: Duration, val ownerName: String, - val distance: Double = totemEntity.getLorenzVec().distanceToPlayer() + val distance: Double = location.distanceToPlayer() ) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 4c5a0f315c3b..b7b60da0c451 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -681,6 +681,15 @@ object RenderUtils { GlStateManager.popMatrix() } + fun drawSphereInWorld( + color: Color, + location: LorenzVec, + radius: Float, + partialTicks: Float, + ) { + drawSphereInWorld(color, location.x, location.y, location.z, radius, partialTicks) + } + fun drawSphereInWorld( color: Color, x: Double, From 54c7da70d0e8b962d2c62858082654c66b9aa21e Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:57:49 +0100 Subject: [PATCH 13/19] Resolved funny elephant person things --- .../skyhanni/features/fishing/TotemOfCorruption.kt | 4 ++-- src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 3356dd6ccd93..1d6f79f75d09 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -10,7 +10,7 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.sendTitle import at.hannibal2.skyhanni.utils.LorenzVec -import at.hannibal2.skyhanni.utils.RenderUtils +import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereInWorld import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SoundUtils.playPlingSound import at.hannibal2.skyhanni.utils.SpecialColour @@ -103,7 +103,7 @@ class TotemOfCorruption { val color = Color(SpecialColour.specialToChromaRGB(config.color), true) for (totem in totems) { // The center of the totem is the upper part - RenderUtils.drawSphereInWorld(color, totem.location.add(y = 1), 16f, event.partialTicks) + event.drawSphereInWorld(color, totem.location.add(y = 1), 16f) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index b7b60da0c451..0c19c2627d6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -681,22 +681,20 @@ object RenderUtils { GlStateManager.popMatrix() } - fun drawSphereInWorld( + fun LorenzRenderWorldEvent.drawSphereInWorld( color: Color, location: LorenzVec, radius: Float, - partialTicks: Float, ) { - drawSphereInWorld(color, location.x, location.y, location.z, radius, partialTicks) + drawSphereInWorld(color, location.x, location.y, location.z, radius) } - fun drawSphereInWorld( + fun LorenzRenderWorldEvent.drawSphereInWorld( color: Color, x: Double, y: Double, z: Double, radius: Float, - partialTicks: Float, ) { GlStateManager.pushMatrix() GL11.glNormal3f(0.0f, 1.0f, 0.0f) From 2208d0f984164fc036daec9d205c8aaca2f1be92 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:05:04 +0100 Subject: [PATCH 14/19] Update src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt Co-authored-by: hannibal2 <24389977+hannibal002@users.noreply.github.com> --- .../at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 1d6f79f75d09..cd75ebd033dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -100,7 +100,7 @@ class TotemOfCorruption { fun onRenderWorld(event: LorenzRenderWorldEvent) { if (!isEffectiveAreaEnabled()) return - val color = Color(SpecialColour.specialToChromaRGB(config.color), true) + val color = config.color.toChromaColor() for (totem in totems) { // The center of the totem is the upper part event.drawSphereInWorld(color, totem.location.add(y = 1), 16f) From 02b08591b61db5337d17e809d24b2372339cc7cb Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:05:12 +0100 Subject: [PATCH 15/19] Update src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt Co-authored-by: hannibal2 <24389977+hannibal002@users.noreply.github.com> --- .../at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index cd75ebd033dd..490bfe00c977 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -68,7 +68,7 @@ class TotemOfCorruption { val owner = getOwner(totem) if (timeRemaining != null && owner != null) { if ( - timeRemaining == config.warnWhenAboutToExpire.toDuration(DurationUnit.SECONDS) + timeRemaining == config.warnWhenAboutToExpire.seconds && config.warnWhenAboutToExpire.toDuration(DurationUnit.SECONDS) > 0.seconds ) { playPlingSound() From 153ed80fb9b4b51a88a40569e74df6ca49d4f01b Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:05:59 +0100 Subject: [PATCH 16/19] fix build --- .../hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 490bfe00c977..5eb71ea5e67d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer import at.hannibal2.skyhanni.utils.LorenzUtils @@ -13,7 +14,6 @@ import at.hannibal2.skyhanni.utils.LorenzVec import at.hannibal2.skyhanni.utils.RenderUtils.drawSphereInWorld import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SoundUtils.playPlingSound -import at.hannibal2.skyhanni.utils.SpecialColour import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.TimeUnit @@ -23,7 +23,6 @@ import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.entity.item.EntityArmorStand import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit From c00278ab42ad5dea6e8a176ec171fd9c420142d6 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:17:44 +0100 Subject: [PATCH 17/19] Resolved more --- .../fishing/TotemOfCorruptionConfig.java | 3 +- .../features/fishing/TotemOfCorruption.kt | 45 ++++++++----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java index cb967da3dfbd..67dbf364f7a9 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/TotemOfCorruptionConfig.java @@ -12,7 +12,8 @@ public class TotemOfCorruptionConfig { @Expose @ConfigOption(name = "Show Overlay", desc = "Show the Totem of Corruption overlay." + - "\nShows the totem, in which effective area you are in, with the longest time left.") + "\nShows the totem, in which effective area you are in, with the longest time left." + + "\n§cThis needs to be enabled for the other options to work.") @ConfigEditorBoolean @FeatureToggle public boolean showOverlay = true; diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 5eb71ea5e67d..05f7f14c4b28 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -25,17 +25,15 @@ import net.minecraft.util.EnumParticleTypes import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds -import kotlin.time.DurationUnit -import kotlin.time.toDuration -private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption +class TotemOfCorruption { -private var display = emptyList() -private var totems: List = emptyList() + private val config get() = SkyHanniMod.feature.fishing.totemOfCorruption -class TotemOfCorruption { + private var display = emptyList() + private var totems: List = emptyList() - private val group = RepoPattern.group("features.fishing.totemofcorruption") + private val group = RepoPattern.group("fishing.totemofcorruption") private val totemNamePattern by group.pattern( "totemname", "§5§lTotem of Corruption" @@ -61,24 +59,6 @@ class TotemOfCorruption { if (!isOverlayEnabled()) return totems = getTotems() - .filterNotNull() - .mapNotNull { totem -> - val timeRemaining = getTimeRemaining(totem) - val owner = getOwner(totem) - if (timeRemaining != null && owner != null) { - if ( - timeRemaining == config.warnWhenAboutToExpire.seconds - && config.warnWhenAboutToExpire.toDuration(DurationUnit.SECONDS) > 0.seconds - ) { - playPlingSound() - sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) - } - Totem(totem.getLorenzVec(), timeRemaining, owner) - } else { - null - } - } - display = createDisplay() } @@ -136,9 +116,22 @@ class TotemOfCorruption { .filter { it.distance < config.distanceThreshold } .maxByOrNull { it.timeRemaining } - private fun getTotems(): List { + private fun getTotems(): List { return EntityUtils.getEntitiesNextToPlayer(100.0) .filter { totemNamePattern.matches(it.name) }.toList() + .mapNotNull { totem -> + val timeRemaining = getTimeRemaining(totem) ?: return@mapNotNull null + val owner = getOwner(totem) ?: return@mapNotNull null + + if ( + timeRemaining == config.warnWhenAboutToExpire.seconds + && config.warnWhenAboutToExpire.seconds > 0.seconds + ) { + playPlingSound() + sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) + } + Totem(totem.getLorenzVec(), timeRemaining, owner) + } } private fun isOverlayEnabled() = LorenzUtils.inSkyBlock && config.showOverlay From 7e3e040c2179912586979ae19c0396ffbab26e1f Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:27:21 +0100 Subject: [PATCH 18/19] small cleanup --- .../skyhanni/features/fishing/TotemOfCorruption.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 05f7f14c4b28..8c28575dee41 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -123,10 +123,8 @@ class TotemOfCorruption { val timeRemaining = getTimeRemaining(totem) ?: return@mapNotNull null val owner = getOwner(totem) ?: return@mapNotNull null - if ( - timeRemaining == config.warnWhenAboutToExpire.seconds - && config.warnWhenAboutToExpire.seconds > 0.seconds - ) { + val timeToWarn = config.warnWhenAboutToExpire.seconds + if (timeToWarn > 0.seconds && timeRemaining == timeToWarn) { playPlingSound() sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) } From 3c27d7439e1fa605ea081f14d7674f9689751de3 Mon Sep 17 00:00:00 2001 From: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:28:02 +0100 Subject: [PATCH 19/19] small cleanup 2 --- .../features/fishing/TotemOfCorruption.kt | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt index 8c28575dee41..2deb676af114 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/TotemOfCorruption.kt @@ -116,21 +116,19 @@ class TotemOfCorruption { .filter { it.distance < config.distanceThreshold } .maxByOrNull { it.timeRemaining } - private fun getTotems(): List { - return EntityUtils.getEntitiesNextToPlayer(100.0) - .filter { totemNamePattern.matches(it.name) }.toList() - .mapNotNull { totem -> - val timeRemaining = getTimeRemaining(totem) ?: return@mapNotNull null - val owner = getOwner(totem) ?: return@mapNotNull null - - val timeToWarn = config.warnWhenAboutToExpire.seconds - if (timeToWarn > 0.seconds && timeRemaining == timeToWarn) { - playPlingSound() - sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) - } - Totem(totem.getLorenzVec(), timeRemaining, owner) + private fun getTotems(): List = EntityUtils.getEntitiesNextToPlayer(100.0) + .filter { totemNamePattern.matches(it.name) }.toList() + .mapNotNull { totem -> + val timeRemaining = getTimeRemaining(totem) ?: return@mapNotNull null + val owner = getOwner(totem) ?: return@mapNotNull null + + val timeToWarn = config.warnWhenAboutToExpire.seconds + if (timeToWarn > 0.seconds && timeRemaining == timeToWarn) { + playPlingSound() + sendTitle("§c§lTotem of Corruption §eabout to expire!", 5.seconds) } - } + Totem(totem.getLorenzVec(), timeRemaining, owner) + } private fun isOverlayEnabled() = LorenzUtils.inSkyBlock && config.showOverlay private fun isHideParticlesEnabled() = LorenzUtils.inSkyBlock && config.hideParticles