aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index 5e85bb64f..5f52508f2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -27,12 +27,15 @@ import net.minecraft.entity.monster.EntityEnderman
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.potion.Potion
+import net.minecraft.scoreboard.ScorePlayerTeam
+import net.minecraft.tileentity.TileEntity
import net.minecraft.util.AxisAlignedBB
import net.minecraftforge.client.event.RenderLivingEvent
//#if FORGE
import net.minecraftforge.fml.common.eventhandler.Event
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
//#endif
@SkyHanniModule
@@ -131,8 +134,7 @@ object EntityUtils {
return gameProfile.properties.entries()
.filter { it.key == "textures" }
.map { it.value }
- .firstOrNull { it.name == "textures" }
- ?.value
+ .firstOrNull { it.name == "textures" }?.value
}
inline fun <reified T : Entity> getEntitiesNextToPlayer(radius: Double): Sequence<T> =
@@ -182,6 +184,10 @@ object EntityUtils {
) it else it.toMutableList() // TODO: while i am here, i want to point out that copying the entity list does not constitute proper synchronization, but *does* make crashes because of it rarer.
}?.asSequence()?.filterNotNull() ?: emptySequence()
+ fun getAllTileEntities(): Sequence<TileEntity> = Minecraft.getMinecraft()?.theWorld?.loadedTileEntityList?.let {
+ if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList()
+ }?.asSequence()?.filterNotNull() ?: emptySequence()
+
fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().add(y = 0.5).canBeSeen(radius)
fun getEntityByID(entityId: Int) = Minecraft.getMinecraft()?.thePlayer?.entityWorld?.getEntityByID(entityId)
@@ -217,11 +223,10 @@ object EntityUtils {
SkyHanniRenderEntityEvent.Post(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch()
}
-//#if MC < 11400
+ //#if MC < 11400
@SubscribeEvent
fun onEntityRenderSpecialsPre(
- event:
- RenderLivingEvent.Specials.Pre<*>,
+ event: RenderLivingEvent.Specials.Pre<*>,
) {
val shEvent = SkyHanniRenderEntityEvent.Specials.Pre(event.entity, event.renderer, event.x, event.y, event.z)
if (shEvent.postAndCatch()) {
@@ -231,8 +236,7 @@ object EntityUtils {
@SubscribeEvent
fun onEntityRenderSpecialsPost(
- event:
- RenderLivingEvent.Specials.Post<*>,
+ event: RenderLivingEvent.Specials.Post<*>,
) {
SkyHanniRenderEntityEvent.Specials.Post(event.entity, event.renderer, event.x, event.y, event.z).postAndCatch()
}