aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test/command
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-04-03 20:50:31 +0200
committerGitHub <noreply@github.com>2024-04-03 20:50:31 +0200
commit2f85351bacddb9ab3704a53c778d558a755bcc06 (patch)
treef479045f271f04a66a1ba69a61cb1b9893261eb5 /src/main/java/at/hannibal2/skyhanni/test/command
parent76be6ad6de39c7078550394e8ec24a494ddb3bcc (diff)
downloadskyhanni-2f85351bacddb9ab3704a53c778d558a755bcc06.tar.gz
skyhanni-2f85351bacddb9ab3704a53c778d558a755bcc06.tar.bz2
skyhanni-2f85351bacddb9ab3704a53c778d558a755bcc06.zip
Backend: Mob Detection (#712)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test/command')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt97
1 files changed, 95 insertions, 2 deletions
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 5ba4447f2..276e5477a 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyNearbyEntitiesCommand.kt
@@ -1,21 +1,32 @@
package at.hannibal2.skyhanni.test.command
+import at.hannibal2.skyhanni.data.mob.Mob
+import at.hannibal2.skyhanni.data.mob.MobData
+import at.hannibal2.skyhanni.data.mob.MobFilter.isDisplayNPC
+import at.hannibal2.skyhanni.data.mob.MobFilter.isRealPlayer
+import at.hannibal2.skyhanni.data.mob.MobFilter.isSkyBlockMob
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.EntityUtils.cleanName
import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand
import at.hannibal2.skyhanni.utils.EntityUtils.getSkinTexture
+import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.ItemUtils.isEnchanted
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.client.entity.EntityOtherPlayerMP
+import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
+import net.minecraft.entity.boss.EntityWither
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.item.EntityItem
+import net.minecraft.entity.monster.EntityCreeper
import net.minecraft.entity.monster.EntityEnderman
import net.minecraft.entity.monster.EntityMagmaCube
import net.minecraft.entity.player.EntityPlayer
@@ -34,18 +45,21 @@ object CopyNearbyEntitiesCommand {
val resultList = mutableListOf<String>()
var counter = 0
- for (entity in EntityUtils.getAllEntities()) {
+ for (entity in EntityUtils.getAllEntities().sortedBy { it.entityId }) {
val position = entity.position
val vec = position.toLorenzVec()
val distance = start.distance(vec)
+ val mob = MobData.entityToMob[entity]
if (distance < searchRadius) {
val simpleName = entity.javaClass.simpleName
resultList.add("entity: $simpleName")
val displayName = entity.displayName
resultList.add("name: '" + entity.name + "'")
+ if (entity is EntityArmorStand) resultList.add("cleanName: '" + entity.cleanName() + "'")
resultList.add("displayName: '${displayName.formattedText}'")
resultList.add("entityId: ${entity.entityId}")
- resultList.add("uuid version: ${entity.uniqueID.version()} ${if (entity.uniqueID.version() != 4) "NPC " else ""}(${entity.uniqueID})")
+ resultList.add("Type of Mob: ${getType(entity, mob)}")
+ resultList.add("uuid version: ${entity.uniqueID.version()} (${entity.uniqueID})")
resultList.add("location data:")
resultList.add("- vec: $vec")
resultList.add("- distance: $distance")
@@ -137,6 +151,26 @@ object CopyNearbyEntitiesCommand {
val skinTexture = entity.getSkinTexture()
resultList.add("- skin texture: $skinTexture")
}
+
+ is EntityCreeper -> {
+ resultList.add("EntityCreeper:")
+ val creeperState = entity.creeperState
+ val ignite = entity.hasIgnited()
+ val powered = entity.powered
+ resultList.add("- creeperState: '$creeperState'")
+ resultList.add("- ignite: '$ignite'")
+ resultList.add("- powered: '$powered'")
+ }
+
+ is EntityWither -> {
+ resultList.add("EntityWither:")
+ val invulTime = entity.invulTime
+ resultList.add("- invulTime: '$invulTime'")
+ }
+ }
+ if (mob != null && mob.mobType != Mob.Type.PLAYER) {
+ resultList.add("MobInfo: ")
+ resultList.addAll(getMobInfo(mob).map { "- $it" })
}
resultList.add("")
resultList.add("")
@@ -168,4 +202,63 @@ object CopyNearbyEntitiesCommand {
resultList.add("- type: $type")
}
}
+
+ private fun getType(entity: Entity, mob: Mob?) = buildString {
+ if (entity is EntityLivingBase && entity.isDisplayNPC()) append("DisplayNPC, ")
+ if (entity is EntityPlayer && entity.isNPC()) append("NPC, ")
+ if (entity is EntityPlayer && entity.isRealPlayer()) append("RealPlayer, ")
+ if (mob?.mobType == Mob.Type.SUMMON) append("Summon, ")
+ if (entity.isSkyBlockMob()) {
+ append("SkyblockMob(")
+
+ if (mob == null) {
+ append(if (entity.distanceToPlayer() > MobData.DETECTION_RANGE) "Not in Range" else "None")
+ append(")")
+ } else {
+ append(mob.mobType.name)
+ if (mob.baseEntity == entity) append("/Base")
+ append(")\"")
+ append(mob.name)
+ append("\"")
+ }
+ append(", ")
+ }
+
+ if (isNotEmpty()) {
+ delete(length - 2, length) // Remove the last ", "
+ } else {
+ append("NONE")
+ }
+ }
+
+ fun getMobInfo(mob: Mob) = buildList<String> {
+ add("Name: ${mob.name}")
+ add("Type: ${mob.mobType}")
+ add("Base Entity: ${mob.baseEntity.asString()}")
+ add("Armorstand: ${mob.armorStand?.asString()}")
+ if (mob.extraEntities.isNotEmpty()) {
+ add("Extra Entities")
+ addAll(mob.extraEntities.map { " " + it.asString() })
+ }
+ if (mob.hologram1Delegate.isInitialized()) {
+ add("Hologram1: ${mob.hologram1?.asString()}")
+ }
+ if (mob.hologram2Delegate.isInitialized()) {
+ add("Hologram2: ${mob.hologram2?.asString()}")
+ }
+ if (mob.owner != null) {
+ add("Owner: ${mob.owner.ownerName}")
+ }
+ add("Level or Tier: ${mob.levelOrTier.takeIf { it != -1 }}")
+ if (mob.mobType == Mob.Type.DUNGEON) {
+ add("Is Starred: ${mob.hasStar}")
+ add("Attribute: ${mob.attribute ?: "NONE"}")
+ }
+ if (mob.boundingBox != mob.baseEntity.entityBoundingBox) {
+ add("Bounding Box: ${mob.boundingBox}")
+ }
+ }
+
+ private fun EntityLivingBase.asString() =
+ this.entityId.toString() + " - " + this.javaClass.simpleName + " \"" + this.name + "\""
}