Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Hide Far Entities #1064

Merged
merged 20 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,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
Expand Down Expand Up @@ -754,6 +755,7 @@ class SkyHanniMod {
loadModule(SkillProgress)
loadModule(SkillTooltip())
loadModule(QuiverNotification)
loadModule(HideFarEntities())

init()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public class DevConfig {
@Category(name = "Minecraft Console", desc = "Minecraft Console Settings")
public MinecraftConsoleConfig minecraftConsoles = new MinecraftConsoleConfig();

@ConfigOption(name = "Hide Far Entities", desc = "")
@Accordion
@Expose
public HideFarEntitiesConfig hideFarEntities = new HideFarEntitiesConfig();

}
hannibal002 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package at.hannibal2.skyhanni.config.features.dev;

import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider;
import io.github.moulberry.moulconfig.annotations.ConfigOption;

public class HideFarEntitiesConfig {
@Expose
@ConfigOption(name = "Enabled", desc = "Hide all entities from rendering except the nearest ones.")
@ConfigEditorBoolean
public boolean enabled = false;

@Expose
@ConfigOption(name = "Amount", desc = "Keep showing this amount of nearest entities.")
@ConfigEditorSlider(minValue = 5f, maxValue = 150f, minStep = 5f)
public float amount = 50f;
hannibal002 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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.utils.CollectionUtils.sorted
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.dev.hideFarEntities

private var ignored = emptyList<Int>()
hannibal002 marked this conversation as resolved.
Show resolved Hide resolved

@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (isEnabled()) {
val min = config.amount.toInt().coerceAtLeast(1)
ignored = EntityUtils.getAllEntities()
.map { it to it.distanceToPlayer() }
.toMap()
.sorted().keys.drop(min)
.map { it.entityId }

}
}

@SubscribeEvent
fun onCheckRender(event: CheckRenderEntityEvent<*>) {
if (isEnabled() && event.entity.entityId in ignored) {
event.cancel()
}
}

fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
}
Loading