Skip to content

Commit

Permalink
Fix: Fel Highlight in Edge Case (#2746)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <[email protected]>
  • Loading branch information
Thunderblade73 and hannibal002 authored Oct 18, 2024
1 parent 5dae347 commit df28fc4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Mob(

fun isInRender() = baseEntity.distanceToPlayer() < MobData.ENTITY_RENDER_RANGE_IN_BLOCKS

fun canBeSeen() = baseEntity.canBeSeen()
fun canBeSeen(viewDistance: Number = 150) = baseEntity.canBeSeen(viewDistance)

fun isInvisible() = baseEntity !is EntityZombie && baseEntity.isInvisible && baseEntity.inventory.isNullOrEmpty()

Expand All @@ -131,9 +131,9 @@ class Mob(

private fun internalHighlight() {
highlightColor?.let { color ->
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(baseEntity, color.rgb) { true }
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(baseEntity, color.rgb) { !this.isInvisible() }
extraEntities.forEach {
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(it, color.rgb) { true }
RenderLivingEntityHelper.setEntityColorWithNoHurtTime(it, color.rgb) { !this.isInvisible() }
}
}
}
Expand Down Expand Up @@ -242,4 +242,5 @@ class Mob(

// TODO add max distance
fun lineToPlayer(color: Color, lineWidth: Int = 2, depth: Boolean = true) = LineToMobHandler.register(this, color, lineWidth, depth)
fun distanceToPlayer(): Double = baseEntity.distanceToPlayer()
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ object DungeonMobManager {
fun onRenderWorld(event: LorenzRenderWorldEvent) {
if (!fel.highlight.get()) return
if (fel.line) {
felOnTheGround.filter { it.canBeSeen() }.forEach {
felOnTheGround.filter { it.canBeSeen(30) }.forEach {
event.draw3DLine(
it.baseEntity.getLorenzVec().add(y = 0.15),
event.exactPlayerEyeLocation(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ object CopyNearbyEntitiesCommand {
val ridingEntity = entity.ridingEntity
resultList.add("ridingEntity: $ridingEntity")

if(entity.isInvisible) {
resultList.add("Invisible: true")
}

if (entity is EntityLivingBase) {
resultList.add("EntityLivingBase:")
val baseMaxHealth = entity.baseMaxHealth
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ object EntityUtils {
if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList()
}?.asSequence()?.filterNotNull() ?: emptySequence()

fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().up(0.5).canBeSeen(radius)
fun Entity.canBeSeen(viewDistance: Number = 150.0) = getLorenzVec().up(0.5).canBeSeen(viewDistance)

fun getEntityByID(entityId: Int) = Minecraft.getMinecraft()?.thePlayer?.entityWorld?.getEntityByID(entityId)

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ object LocationUtils {

fun AxisAlignedBB.isPlayerInside() = isInside(playerLocation())

fun LorenzVec.canBeSeen(radius: Double = 150.0, offset: Double? = null): Boolean {
fun LorenzVec.canBeSeen(viewDistance: Number = 150.0, offset: Double? = null): Boolean {
val a = playerEyeLocation()
val b = this
val noBlocks = canSee(a, b, offset)
val notTooFar = a.distance(b) < radius
val notTooFar = a.distance(b) < viewDistance.toDouble()
val inFov = true // TODO add Frustum "Frustum().isBoundingBoxInFrustum(entity.entityBoundingBox)"
return noBlocks && notTooFar && inFov
}
Expand Down

0 comments on commit df28fc4

Please sign in to comment.