diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-01 18:58:23 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-01 18:58:23 +0200 |
commit | 70e1bcea4718a325fc23b8e926e4ec998482b396 (patch) | |
tree | 1e086473c096c9b567bb63bc7d8817cb14f5c2c4 /src/main/java/at | |
parent | 18245e2630bfb8242d4519d2b17bf6243808e081 (diff) | |
download | skyhanni-70e1bcea4718a325fc23b8e926e4ec998482b396.tar.gz skyhanni-70e1bcea4718a325fc23b8e926e4ec998482b396.tar.bz2 skyhanni-70e1bcea4718a325fc23b8e926e4ec998482b396.zip |
Added chum bucket hider
Diffstat (limited to 'src/main/java/at')
4 files changed, 115 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 00da1d347..17a6a414e 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -265,6 +265,7 @@ class SkyHanniMod { loadModule(JacobContestFFNeededDisplay()) loadModule(GardenYawAndPitch()) loadModule(MovementSpeedDisplay()) + loadModule(ChumBucketHider()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java index 096c03f39..58fa58a84 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Fishing.java @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.features; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.*; +import io.github.moulberry.moulconfig.observer.Property; public class Fishing { @@ -97,6 +98,29 @@ public class Fishing { public int barnTimerAlertTime = 330; @Expose + @ConfigOption(name = "Chum Bucket Hider", desc = "") + @Accordion + public ChumBucketHider chumBucketHider = new ChumBucketHider(); + + public static class ChumBucketHider { + + @Expose + @ConfigOption(name = "Enable", desc = "Hide the Chum Bucket name tags for other players.") + @ConfigEditorBoolean + public Property<Boolean> enabled = Property.of(true); + + @Expose + @ConfigOption(name = "Hide Bucket", desc = "Hide the Chum Bucket.") + @ConfigEditorBoolean + public Property<Boolean> hideBucket = Property.of(false); + + @Expose + @ConfigOption(name = "Hide Own", desc = "Hides your own Chum Bucket.") + @ConfigEditorBoolean + public Property<Boolean> hideOwn = Property.of(false); + } + + @Expose @ConfigOption( name = "Shark Fish Counter", desc = "Counts how many sharks have been caught." diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt new file mode 100644 index 000000000..73281cddf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt @@ -0,0 +1,88 @@ +package at.hannibal2.skyhanni.features.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.Entity +import net.minecraft.entity.item.EntityArmorStand +import net.minecraftforge.event.world.WorldEvent +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 onWorldLoad(event: WorldEvent.Load) { + 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")) { + 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())) { + println("found lower chum entity") + hiddenEntities.add(entity) + event.isCanceled = true + return + } + } + } + + // Chum Bucket + if (config.hideBucket.get()) { + if (entity.inventory.any { it != null && it.name == "§fEmpty Chum 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) { + val function: (oldValue: Boolean, newValue: Boolean) -> Unit = { _, _ -> reset() } + config.enabled.whenChanged(function) + config.hideBucket.whenChanged(function) + config.hideOwn.whenChanged(function) + } + + private fun reset() { + titleEntity.clear() + hiddenEntities.clear() + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt index f973a4e6a..4c110cb6c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt @@ -90,6 +90,8 @@ data class LorenzVec( return arrayOf(x, y, z) } + fun equalsIgnoreY(other: LorenzVec) = x == other.x && z == other.z + companion object { fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec { val yaw: Double = (yaw + 90) * Math.PI / 180 |