Skip to content

Commit

Permalink
Fix: All Names Party Tab (hannibal002#1340)
Browse files Browse the repository at this point in the history
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
  • Loading branch information
2 people authored and superhize committed Apr 8, 2024
1 parent 19a7361 commit 1dbc9fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.PartyAPI
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.EntityUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object PartyCommands {
Expand Down Expand Up @@ -93,7 +94,8 @@ object PartyCommands {
} else {
emptyList<String>()
}
return friends + getPartyCommands()
val allOnLobby = EntityUtils.getPlayerEntities().map { it.name }
return friends + getPartyCommands() + allOnLobby
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import at.hannibal2.skyhanni.data.FriendAPI
import at.hannibal2.skyhanni.data.PartyAPI
import at.hannibal2.skyhanni.data.jsonobjects.repo.VipVisitsJson
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import at.hannibal2.skyhanni.utils.EntityUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object PlayerTabComplete {
Expand Down Expand Up @@ -59,10 +57,8 @@ object PlayerTabComplete {
}

if (config.islandPlayers && PlayerCategory.ISLAND_PLAYERS !in ignored) {
for (entity in Minecraft.getMinecraft().theWorld.playerEntities) {
if (!entity.isNPC() && entity is EntityOtherPlayerMP) {
add(entity.name)
}
for (entity in EntityUtils.getPlayerEntities()) {
add(entity.name)
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import net.minecraft.block.state.IBlockState
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
Expand Down Expand Up @@ -58,6 +59,16 @@ object EntityUtils {
}
}

fun getPlayerEntities(): MutableList<EntityOtherPlayerMP> {
val list = mutableListOf<EntityOtherPlayerMP>()
for (entity in Minecraft.getMinecraft().theWorld.playerEntities) {
if (!entity.isNPC() && entity is EntityOtherPlayerMP) {
list.add(entity)
}
}
return list
}

fun EntityLivingBase.getAllNameTagsInRadiusWith(
contains: String,
radius: Double = 3.0,
Expand Down

0 comments on commit 1dbc9fb

Please sign in to comment.