diff options
| author | Walker Selby <git@walkerselby.com> | 2023-10-21 07:31:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-21 08:31:19 +0200 |
| commit | 68abc8ade546de62aee76e0b786993fc59fbc3cc (patch) | |
| tree | bfc1e6fe389c7daf5cbf2ca109be70233d014590 /src/main/java/at/hannibal2/skyhanni/features/fishing | |
| parent | c5745ed4ee07759261da1dc9c0f654617276f163 (diff) | |
| download | skyhanni-68abc8ade546de62aee76e0b786993fc59fbc3cc.tar.gz skyhanni-68abc8ade546de62aee76e0b786993fc59fbc3cc.tar.bz2 skyhanni-68abc8ade546de62aee76e0b786993fc59fbc3cc.zip | |
Internal Change: Misc Refactoring (#551)
Internal Change: Misc Refactoring #551
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
3 files changed, 161 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt new file mode 100644 index 000000000..24506a22b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt @@ -0,0 +1,83 @@ +package at.hannibal2.skyhanni.features.fishing + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle +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 ChumBucketHider { + private val config get() = SkyHanniMod.feature.fishing.chumBucketHider + private val titleEntity = mutableListOf<Entity>() + private val hiddenEntities = mutableListOf<Entity>() + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + reset() + } + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!LorenzUtils.inSkyBlock) return + if (!config.enabled.get()) return + + val entity = event.entity + if (entity !is EntityArmorStand) return + + if (entity in hiddenEntities) { + event.isCanceled = true + return + } + + val name = entity.name + + // First text line + if (name.endsWith("'s Chum Bucket") || name.endsWith("'s Chumcap Bucket")) { + if (name.contains(LorenzUtils.getPlayerName()) && !config.hideOwn.get()) return + titleEntity.add(entity) + hiddenEntities.add(entity) + event.isCanceled = true + return + } + + // Second text line + if (name.contains("/10 §aChums")) { + val entityLocation = entity.getLorenzVec() + for (title in titleEntity) { + if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { + hiddenEntities.add(entity) + event.isCanceled = true + return + } + } + } + + // Chum Bucket + if (config.hideBucket.get() && entity.inventory.any { it != null && (it.name == "§fEmpty Chum Bucket" || it.name == "§aEmpty Chumcap Bucket") }) { + val entityLocation = entity.getLorenzVec() + for (title in titleEntity) { + if (entityLocation.equalsIgnoreY(title.getLorenzVec())) { + hiddenEntities.add(entity) + event.isCanceled = true + return + } + } + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + onToggle(config.enabled, config.hideBucket, config.hideOwn) { reset() } + } + + private fun reset() { + titleEntity.clear() + hiddenEntities.clear() + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt index 06e8facbf..da0d9a950 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/SeaCreatureFeatures.kt @@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.RenderEntityOutlineEvent import at.hannibal2.skyhanni.events.SeaCreatureFishEvent import at.hannibal2.skyhanni.events.withAlpha -import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.EntityUtils.hasMaxHealth import at.hannibal2.skyhanni.utils.EntityUtils.hasNameTagWith diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt new file mode 100644 index 000000000..bab0d5ae1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ThunderSparksHighlight.kt @@ -0,0 +1,77 @@ +package at.hannibal2.skyhanni.features.fishing + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture +import at.hannibal2.skyhanni.utils.LocationUtils +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.drawString +import at.hannibal2.skyhanni.utils.SpecialColour +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.init.Blocks +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color + +class ThunderSparksHighlight { + + private val config get() = SkyHanniMod.feature.fishing.thunderSpark + private val texture = + "ewogICJ0aW1lc3RhbXAiIDogMTY0MzUwNDM3MjI1NiwKICAicHJvZmlsZUlkIiA6ICI2MzMyMDgwZTY3YTI0Y2MxYjE3ZGJhNzZmM2MwMGYxZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJUZWFtSHlkcmEiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2IzMzI4ZDNlOWQ3MTA0MjAzMjI1NTViMTcyMzkzMDdmMTIyNzBhZGY4MWJmNjNhZmM1MGZhYTA0YjVjMDZlMSIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9" + private val sparks = mutableListOf<EntityArmorStand>() + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + + + EntityUtils.getEntities<EntityArmorStand>().filter { + it !in sparks && it.hasSkullTexture(texture) + }.forEach { sparks.add(it) } + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!isEnabled()) return + + val special = config.color + val color = Color(SpecialColour.specialToChromaRGB(special), true) + + val playerLocation = LocationUtils.playerLocation() + for (spark in sparks) { + if (spark.isDead) continue + val sparkLocation = spark.getLorenzVec() + val block = sparkLocation.getBlockAt() + val seeThroughBlocks = + sparkLocation.distanceToPlayer() < 6 && (block == Blocks.flowing_lava || block == Blocks.lava) + event.drawWaypointFilled( + sparkLocation.add(-0.5, 0.0, -0.5), color, extraSize = -0.25, seeThroughBlocks = seeThroughBlocks + ) + if (sparkLocation.distance(playerLocation) < 10) { + event.drawString(sparkLocation.add(0.0, 1.5, 0.0), "Thunder Spark", seeThroughBlocks = seeThroughBlocks) + } + } + } + + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + sparks.clear() + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyBlock && config.highlight + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(3, "fishing.thunderSparkHighlight", "fishing.thunderSpark.highlight") + event.move(3, "fishing.thunderSparkColor", "fishing.thunderSpark.color") + } +}
\ No newline at end of file |
