aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-17 04:56:25 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-17 04:56:25 +0200
commitfb5e963b915f192048f3939c58fb5bac404dae8e (patch)
treed466db05f620241fee783fcb51b45e8662910f1d /src
parentddb2124a98dde079732e7d4cf1f7cae83076ebc4 (diff)
downloadskyhanni-fb5e963b915f192048f3939c58fb5bac404dae8e.tar.gz
skyhanni-fb5e963b915f192048f3939c58fb5bac404dae8e.tar.bz2
skyhanni-fb5e963b915f192048f3939c58fb5bac404dae8e.zip
moving hasNameTagWith in separate utils class
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossFinder.kt42
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt46
3 files changed, 48 insertions, 46 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt b/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt
index 0ca601a54..13900555e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/SummoningSoulsName.kt
@@ -1,14 +1,10 @@
package at.hannibal2.skyhanni.features
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.features.damageindicator.getNameTagWith
import at.hannibal2.skyhanni.test.GriffinJavaUtils
+import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
-import at.hannibal2.skyhanni.utils.LocationUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.RenderUtils.drawString
-import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.item.EntityArmorStand
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossFinder.kt
index 421394d7e..9a91c7680 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/BossFinder.kt
@@ -6,18 +6,16 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.getLorenzVec
+import at.hannibal2.skyhanni.utils.hasNameTagWith
import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityOtherPlayerMP
import net.minecraft.entity.Entity
-import net.minecraft.entity.EntityLiving
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.boss.EntityDragon
import net.minecraft.entity.boss.EntityWither
-import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.*
import net.minecraft.entity.passive.EntityHorse
import net.minecraft.entity.passive.EntityWolf
-import net.minecraft.util.AxisAlignedBB
import java.util.*
class BossFinder {
@@ -536,42 +534,4 @@ class BossFinder {
return null
}
-}
-
-//TODO move into utils method
-fun EntityLiving.hasNameTagWith(
- y: Int,
- contains: String,
- debugRightEntity: Boolean = false,
- inaccuracy: Double = 1.6,
- debugWrongEntity: Boolean = false,
-): Boolean {
- return getNameTagWith(y, contains, debugRightEntity, inaccuracy, debugWrongEntity) != null
-}
-
-fun EntityLiving.getNameTagWith(
- y: Int,
- contains: String,
- debugRightEntity: Boolean = false,
- inaccuracy: Double = 1.6,
- debugWrongEntity: Boolean = false,
-): EntityArmorStand? {
- val center = getLorenzVec().add(0, y, 0)
- val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
- val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()
- val alignedBB = AxisAlignedBB(a, b)
- val clazz = EntityArmorStand::class.java
- val found = worldObj.getEntitiesWithinAABB(clazz, alignedBB)
- return found.find {
- val result = it.name.contains(contains)
- if (debugWrongEntity && !result) {
- println("wrong entity in aabb: '" + it.name + "'")
- }
- if (debugRightEntity && result) {
- println("mob: " + center.printWithAccuracy(2))
- println("nametag: " + it.getLorenzVec().printWithAccuracy(2))
- println("accuracy: " + it.getLorenzVec().subtract(center).printWithAccuracy(3))
- }
- result
- }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
new file mode 100644
index 000000000..acfcd86d4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -0,0 +1,46 @@
+package at.hannibal2.skyhanni.utils
+
+import net.minecraft.entity.EntityLiving
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.util.AxisAlignedBB
+
+class EntityUtils {
+}
+
+//TODO move into utils method
+fun EntityLiving.hasNameTagWith(
+ y: Int,
+ contains: String,
+ debugRightEntity: Boolean = false,
+ inaccuracy: Double = 1.6,
+ debugWrongEntity: Boolean = false,
+): Boolean {
+ return getNameTagWith(y, contains, debugRightEntity, inaccuracy, debugWrongEntity) != null
+}
+
+fun EntityLiving.getNameTagWith(
+ y: Int,
+ contains: String,
+ debugRightEntity: Boolean = false,
+ inaccuracy: Double = 1.6,
+ debugWrongEntity: Boolean = false,
+): EntityArmorStand? {
+ val center = getLorenzVec().add(0, y, 0)
+ val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
+ val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()
+ val alignedBB = AxisAlignedBB(a, b)
+ val clazz = EntityArmorStand::class.java
+ val found = worldObj.getEntitiesWithinAABB(clazz, alignedBB)
+ return found.find {
+ val result = it.name.contains(contains)
+ if (debugWrongEntity && !result) {
+ println("wrong entity in aabb: '" + it.name + "'")
+ }
+ if (debugRightEntity && result) {
+ println("mob: " + center.printWithAccuracy(2))
+ println("nametag: " + it.getLorenzVec().printWithAccuracy(2))
+ println("accuracy: " + it.getLorenzVec().subtract(center).printWithAccuracy(3))
+ }
+ result
+ }
+} \ No newline at end of file