aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/HideFarEntitiesConfig.java30
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt39
4 files changed, 76 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index fa375862e..c225c768d 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -309,6 +309,7 @@ import at.hannibal2.skyhanni.features.misc.ExpOrbsOnGroundHider
import at.hannibal2.skyhanni.features.misc.FixGhostEntities
import at.hannibal2.skyhanni.features.misc.FixNEUHeavyPearls
import at.hannibal2.skyhanni.features.misc.HideArmor
+import at.hannibal2.skyhanni.features.misc.HideFarEntities
import at.hannibal2.skyhanni.features.misc.InGameDateDisplay
import at.hannibal2.skyhanni.features.misc.JoinCrystalHollows
import at.hannibal2.skyhanni.features.misc.LesserOrbHider
@@ -575,6 +576,7 @@ class SkyHanniMod {
loadModule(HideNotClickableItems())
loadModule(ItemDisplayOverlayFeatures)
loadModule(CurrentPetDisplay())
+ loadModule(HideFarEntities())
loadModule(ExpOrbsOnGroundHider())
loadModule(BetterWikiFromMenus())
loadModule(DamageIndicatorManager())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/HideFarEntitiesConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/HideFarEntitiesConfig.java
new file mode 100644
index 000000000..2ac5ad4ed
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/HideFarEntitiesConfig.java
@@ -0,0 +1,30 @@
+package at.hannibal2.skyhanni.config.features.misc;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+public class HideFarEntitiesConfig {
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Hide all entities from rendering except the nearest ones.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Min Distance", desc = "Always shows mobs that are at least that close to the player.")
+ @ConfigEditorSlider(minValue = 3, maxValue = 30, minStep = 1)
+ public int minDistance = 10;
+
+ @Expose
+ @ConfigOption(name = "Max Amount", desc = "Not showing more than this amount of nearest entities.")
+ @ConfigEditorSlider(minValue = 1, maxValue = 150, minStep = 1)
+ public int maxAmount = 30;
+
+ @Expose
+ @ConfigOption(name = "Exclude Garden", desc = "Disable this feature while in the Garden.")
+ @ConfigEditorBoolean
+ public boolean excludeGarden = false;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
index d1fa39a86..a49dc2607 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
@@ -251,4 +251,9 @@ public class MiscConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean fixGhostEntities = true;
+
+ @ConfigOption(name = "Hide Far Entities", desc = "")
+ @Accordion
+ @Expose
+ public HideFarEntitiesConfig hideFarEntities = new HideFarEntitiesConfig();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt
new file mode 100644
index 000000000..cde4acdf4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideFarEntities.kt
@@ -0,0 +1,39 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.CheckRenderEntityEvent
+import at.hannibal2.skyhanni.events.LorenzTickEvent
+import at.hannibal2.skyhanni.features.garden.GardenAPI
+import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class HideFarEntities {
+ private val config get() = SkyHanniMod.feature.misc.hideFarEntities
+
+ private var ignored = emptySet<Int>()
+
+ @SubscribeEvent
+ fun onTick(event: LorenzTickEvent) {
+ if (!isEnabled()) return
+
+ val maxAmount = config.maxAmount.coerceAtLeast(1)
+ val minDistance = config.minDistance.coerceAtLeast(3)
+
+ ignored = EntityUtils.getAllEntities()
+ .map { it.entityId to it.distanceToPlayer() }
+ .filter { it.second > minDistance }
+ .sortedBy { it.second }.drop(maxAmount)
+ .map { it.first }.toSet()
+ }
+
+ @SubscribeEvent
+ fun onCheckRender(event: CheckRenderEntityEvent<*>) {
+ if (isEnabled() && event.entity.entityId in ignored) {
+ event.cancel()
+ }
+ }
+
+ fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && !(GardenAPI.inGarden() && config.excludeGarden)
+}