From 71986bac22e7458afb9cb106ec8327100f55cdf0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 17 Sep 2022 10:20:41 +0200 Subject: add skin texture to copyentities --- .../test/command/CopyNearbyEntitiesCommand.kt | 44 ++++++++++++++++++---- .../at/hannibal2/skyhanni/utils/EntityUtils.kt | 11 ++++++ 2 files changed, 48 insertions(+), 7 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt index 1467f2b85..a5e7a0b79 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.test.command +import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -9,6 +10,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.toLorenzVec import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.item.EntityItem @@ -55,6 +57,13 @@ object CopyNearbyEntitiesCommand { val ridingEntity = entity.ridingEntity resultList.add("ridingEntity: $ridingEntity") + if (entity is EntityLivingBase) { + resultList.add("EntityLivingBase:") + val baseMaxHealth = entity.baseMaxHealth.toInt() + val health = entity.health.toInt() + resultList.add("- baseMaxHealth: $baseMaxHealth") + resultList.add("- health: $health") + } when (entity) { is EntityArmorStand -> { @@ -106,16 +115,37 @@ object CopyNearbyEntitiesCommand { resultList.add("- itemDamage: '$itemDamage'") resultList.add("- stackSize: '$stackSize'") resultList.add("- maxStackSize: '$maxStackSize'") + } + is EntityOtherPlayerMP -> { + resultList.add("EntityOtherPlayerMP:") + + val skinTexture = entity.getSkinTexture() + resultList.add("- skin texture: $skinTexture") + +// val gameProfile = entity.gameProfile +// if (gameProfile == null) { +// resultList.add("- gameProfile is null!") +// } else { +// val id = gameProfile.id +// val name = gameProfile.name +// +// resultList.add("- gameProfile id: $id") +// resultList.add("- gameProfile name: $name") +// val properties = gameProfile.properties +// resultList.add("- gameProfile properties: (${properties.size()})") +// for (entry in properties.entries()) { +// val key = entry.key +// val property = entry.value +// resultList.add("- key: '$key'") +// val name1 = property.name +// val value = property.value +// resultList.add("- property name: '$name1'") +// resultList.add("- property value: '$value'") +// } +// } } } - if (entity is EntityLivingBase) { - resultList.add("EntityLivingBase:") - val baseMaxHealth = entity.baseMaxHealth.toInt() - val health = entity.health.toInt() - resultList.add("- baseMaxHealth: $baseMaxHealth") - resultList.add("- health: $health") - } resultList.add("") resultList.add("") counter++ diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index d057abd90..e9621b319 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth import net.minecraft.entity.EntityLiving import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.player.EntityPlayer import net.minecraft.util.AxisAlignedBB object EntityUtils { @@ -88,4 +89,14 @@ object EntityUtils { else -> false } } + + fun EntityPlayer.getSkinTexture(): String? { + val gameProfile = gameProfile ?: return null + + return gameProfile.properties.entries() + .filter { it.key == "textures" } + .map { it.value } + .firstOrNull { it.name == "textures" } + ?.value + } } \ No newline at end of file -- cgit