aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-05-20 15:29:26 +0200
committerGitHub <noreply@github.com>2024-05-20 15:29:26 +0200
commit57ba5e53577d0e4a1c244ff3ea86ee188e4b98b5 (patch)
tree95e128a48e11bcf1eedc6b6bd0a62abe918af1e0
parent9d82aa34aab011a538c96418ca7317c2554427d9 (diff)
downloadskyhanni-57ba5e53577d0e4a1c244ff3ea86ee188e4b98b5.tar.gz
skyhanni-57ba5e53577d0e4a1c244ff3ea86ee188e4b98b5.tar.bz2
skyhanni-57ba5e53577d0e4a1c244ff3ea86ee188e4b98b5.zip
Fix: MobDetection Memory Leak (#1844)
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
index 4a9323ae2..3d8b00b70 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
@@ -19,6 +19,7 @@ import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityZombie
import net.minecraft.util.AxisAlignedBB
import java.awt.Color
+import java.util.UUID
/**
* Represents a Mob in Hypixel Skyblock.
@@ -56,6 +57,7 @@ import java.awt.Color
* Gives back the second additional armor stand.
*
* (should be called in the [MobEvent.Spawn] since it is a lazy)
+ * @property id Unique identifier for each Mob instance
*/
class Mob(
var baseEntity: EntityLivingBase,
@@ -69,6 +71,8 @@ class Mob(
val levelOrTier: Int = -1,
) {
+ private val id: UUID = UUID.randomUUID()
+
val owner: MobUtils.OwnerShip?
val hologram1Delegate = lazy { MobUtils.getArmorStand(armorStand ?: baseEntity, 1) }
@@ -200,16 +204,14 @@ class Mob(
}
}
- override fun hashCode() = baseEntity.hashCode()
+ override fun hashCode() = id.hashCode()
override fun toString(): String = "$name - ${baseEntity.entityId}"
override fun equals(other: Any?): Boolean {
if (this === other) return true
- if (javaClass != other?.javaClass) return false
-
- other as Mob
+ if (other !is Mob) return false
- return baseEntity == other.baseEntity
+ return id == other.id
}
}