aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-30 20:03:45 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-30 20:03:45 +0100
commit8b4639f923185f3bbe693805303047ce24eaa238 (patch)
tree8d599603a9e078483c008dd17f19ab5878b565bb /src/main/java
parent572e159de71827c5c8a6433de90adba2ebec5c4a (diff)
downloadskyhanni-8b4639f923185f3bbe693805303047ce24eaa238.tar.gz
skyhanni-8b4639f923185f3bbe693805303047ce24eaa238.tar.bz2
skyhanni-8b4639f923185f3bbe693805303047ce24eaa238.zip
code cleanup
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/EntityData.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt7
7 files changed, 14 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
index 1ffa5a70b..8d1b836df 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/EntityData.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PacketEvent
import at.hannibal2.skyhanni.utils.EntityUtils
-import at.hannibal2.skyhanni.utils.EntityUtils.getEntityByID
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.LorenzUtils.derpy
import net.minecraft.client.entity.EntityOtherPlayerMP
@@ -50,7 +49,7 @@ class EntityData {
val watchableObjects = packet.func_149376_c() ?: return
val entityId = packet.entityId
- val entity = getEntityByID(entityId) ?: return
+ val entity = EntityUtils.getEntityByID(entityId) ?: return
if (entity is EntityArmorStand) return
if (entity is EntityXPOrb) return
if (entity is EntityItem) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
index 7485d38ae..0c4e031f9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt
@@ -8,7 +8,7 @@ import at.hannibal2.skyhanni.events.LorenzKeyPressEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PacketEvent
-import at.hannibal2.skyhanni.utils.EntityUtils.getEntityByID
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzLogger
@@ -191,7 +191,7 @@ object InquisitorWaypointShare {
return
}
- val inquisitor = getEntityByID(inquisitor)
+ val inquisitor = EntityUtils.getEntityByID(inquisitor)
if (inquisitor == null) {
LorenzUtils.chat("§cInquisitor out of range!")
return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
index d45088171..66b0ce39c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorAPI.kt
@@ -7,13 +7,12 @@ import at.hannibal2.skyhanni.events.garden.visitor.VisitorLeftEvent
import at.hannibal2.skyhanni.events.garden.visitor.VisitorRefusedEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.test.command.ErrorManager
-import at.hannibal2.skyhanni.utils.EntityUtils.getEntityByID
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import at.hannibal2.skyhanni.utils.NEUInternalName
-import net.minecraft.entity.Entity
import net.minecraft.item.ItemStack
object VisitorAPI {
@@ -116,8 +115,8 @@ object VisitorAPI {
var allRewards = listOf<NEUInternalName>()
var lastLore = listOf<String>()
- fun getEntity(): Entity? = getEntityByID(entityId)
- fun getNameTagEntity(): Entity? = getEntityByID(nameTagEntityId)
+ fun getEntity() = EntityUtils.getEntityByID(entityId)
+ fun getNameTagEntity() = EntityUtils.getEntityByID(nameTagEntityId)
fun hasReward(): VisitorReward? {
for (internalName in allRewards) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
index 3475802dd..c6b6e3749 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt
@@ -14,7 +14,7 @@ import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.test.command.ErrorManager
-import at.hannibal2.skyhanni.utils.EntityUtils.getEntityByID
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -212,9 +212,8 @@ object TrevorFeatures {
@SubscribeEvent
fun onRenderWorld(event: LorenzRenderWorldEvent) {
if (!onFarmingIsland()) return
- var entityTrapper = getEntityByID(trapperID)
- if (entityTrapper !is EntityLivingBase) entityTrapper =
- getEntityByID(backupTrapperID)
+ var entityTrapper = EntityUtils.getEntityByID(trapperID)
+ if (entityTrapper !is EntityLivingBase) entityTrapper = EntityUtils.getEntityByID(backupTrapperID)
if (entityTrapper is EntityLivingBase && config.trapperTalkCooldown) {
RenderLivingEntityHelper.setEntityColor(entityTrapper, currentStatus.color)
{ config.trapperTalkCooldown }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
index aec856797..2aebe7e57 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt
@@ -14,7 +14,7 @@ import at.hannibal2.skyhanni.events.SlayerChangeEvent
import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent
import at.hannibal2.skyhanni.features.bazaar.BazaarApi.Companion.getBazaarData
import at.hannibal2.skyhanni.test.PriceSource
-import at.hannibal2.skyhanni.utils.EntityUtils.getEntityByID
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.KeyboardManager
@@ -162,7 +162,7 @@ object SlayerItemProfitTracker {
if (packet !is S0DPacketCollectItem) return
val entityID = packet.collectedItemEntityID
- val item = getEntityByID(entityID) ?: return
+ val item = EntityUtils.getEntityByID(entityID) ?: return
if (item !is EntityItem) return
if (collectedCache.getIfPresent(entityID) != null) return
diff --git a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
index e9a683dae..454ce6afa 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.events.PacketEvent
-import at.hannibal2.skyhanni.utils.EntityUtils.getEntityByID
+import at.hannibal2.skyhanni.utils.EntityUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
@@ -190,7 +190,7 @@ class PacketTest {
return packet.getEntity(world)
}
if (id != null) {
- return getEntityByID(id)
+ return EntityUtils.getEntityByID(id)
}
return null
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index f1d0544a2..7fe6e8efb 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -156,10 +156,5 @@ object EntityUtils {
fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().add(y = 0.5).canBeSeen(radius)
- fun getEntityByID(id: Int): Entity? {
- val minecraft = Minecraft.getMinecraft() ?: return null
- val world = minecraft.theWorld ?: return null
- if (minecraft.thePlayer == null) return null
- return world.getEntityByID(id)
- }
+ fun getEntityByID(entityId: Int) = Minecraft.getMinecraft()?.thePlayer?.entityWorld?.getEntityByID(entityId)
}