Skip to content

Commit

Permalink
fix(RenderedEntities): null on not in-game (#5214)
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 authored Jan 7, 2025
1 parent 4e5810f commit 2baf8b7
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.ccbluex.liquidbounce.utils.entity

import net.ccbluex.liquidbounce.event.EventListener
import net.ccbluex.liquidbounce.event.events.DisconnectEvent
import net.ccbluex.liquidbounce.event.events.GameTickEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.MinecraftShortcuts
import net.ccbluex.liquidbounce.utils.client.inGame
import net.ccbluex.liquidbounce.utils.combat.shouldBeShown
import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention
import net.minecraft.entity.LivingEntity
Expand All @@ -25,12 +27,22 @@ object RenderedEntities : Iterable<LivingEntity>, EventListener, MinecraftShortc
registry.remove(subscriber)
}

@Suppress("unused")
private val tickHandler = handler<GameTickEvent>(priority = EventPriorityConvention.FIRST_PRIORITY) {
if (!inGame) {
return@handler
}

@Suppress("UNCHECKED_CAST")
entities = world.entities.filter {
it is LivingEntity && it.shouldBeShown()
} as Iterable<LivingEntity>
}

@Suppress("unused")
private val disconnectHandler = handler<DisconnectEvent> {
registry.clear()
}

override fun iterator(): Iterator<LivingEntity> = entities.iterator()
}

0 comments on commit 2baf8b7

Please sign in to comment.