aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/misc
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-01 18:58:23 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-01 18:58:23 +0200
commit70e1bcea4718a325fc23b8e926e4ec998482b396 (patch)
tree1e086473c096c9b567bb63bc7d8817cb14f5c2c4 /src/main/java/at/hannibal2/skyhanni/features/misc
parent18245e2630bfb8242d4519d2b17bf6243808e081 (diff)
downloadskyhanni-70e1bcea4718a325fc23b8e926e4ec998482b396.tar.gz
skyhanni-70e1bcea4718a325fc23b8e926e4ec998482b396.tar.bz2
skyhanni-70e1bcea4718a325fc23b8e926e4ec998482b396.zip
Added chum bucket hider
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/ChumBucketHider.kt88
1 files changed, 88 insertions, 0 deletions
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()
+ }
+}