aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-28 00:15:55 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-10-28 00:15:55 +0200
commit20b1d741db61194c8dd43edb59d82e0c8a9cd3d1 (patch)
tree003e046602202411daedea3dcf56dbcb1f77c4be /src/main/java
parent28918c18394210daa121d929d3bfbb48e22a2536 (diff)
downloadskyhanni-20b1d741db61194c8dd43edb59d82e0c8a9cd3d1.tar.gz
skyhanni-20b1d741db61194c8dd43edb59d82e0c8a9cd3d1.tar.bz2
skyhanni-20b1d741db61194c8dd43edb59d82e0c8a9cd3d1.zip
created and used Entity.canBeSeen and LorenzVec.canBeSeen
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt11
7 files changed, 39 insertions, 37 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
index a3dcdced7..f4853961c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy
import at.hannibal2.skyhanni.utils.LorenzUtils.formatInteger
@@ -232,7 +233,7 @@ class MinionFeatures {
val message = event.message
if (message.matchRegex("§aYou received §r§6(.*) coins§r§a!") && System.currentTimeMillis() - lastInventoryClosed < 2_000) {
- minions?.get(lastMinion)?.let {
+ minions?.get(lastMinion)?.let {
it.lastClicked = System.currentTimeMillis()
}
@@ -244,14 +245,14 @@ class MinionFeatures {
lastMinionOpened = 0L
}
if (message.startsWith("§bYou placed a minion!") && newMinion != null) {
- minions = minions?.editCopy {
- this[newMinion!!] = Storage.ProfileSpecific.MinionConfig().apply {
- displayName = newMinionName
- lastClicked = 0
- }
+ minions = minions?.editCopy {
+ this[newMinion!!] = Storage.ProfileSpecific.MinionConfig().apply {
+ displayName = newMinionName
+ lastClicked = 0
}
- newMinion = null
- newMinionName = null
+ }
+ newMinion = null
+ newMinionName = null
}
minionUpgradePattern.matchMatcher(message) {
@@ -269,11 +270,10 @@ class MinionFeatures {
if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
val playerLocation = LocationUtils.playerLocation()
- val playerEyeLocation = LocationUtils.playerEyeLocation()
val minions = minions ?: return
for (minion in minions) {
val location = minion.key.add(0.0, 1.0, 0.0)
- if (!LocationUtils.canSee(playerEyeLocation, location)) continue
+ if (!location.canBeSeen()) continue
val lastEmptied = minion.value.lastClicked
if (playerLocation.distance(location) >= config.emptiedTime.distance) continue
@@ -348,4 +348,4 @@ class MinionFeatures {
event.move(3, "minions.emptiedTimeDisplay", "minions.emptiedTime.display")
event.move(3, "minions.distance", "minions.emptiedTime.distance")
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt
index 0dd7ba5e8..3d387cebd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.misc.trevor
import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -58,10 +59,7 @@ object TrevorSolver {
val dist = entity.position.toLorenzVec().distanceToPlayer()
if ((currentMob == TrevorMobs.RABBIT || currentMob == TrevorMobs.SHEEP) && mobLocation == CurrentMobArea.OASIS) {
println("This is unfortunate")
- } else canSee = LocationUtils.canSee(
- LocationUtils.playerEyeLocation(),
- entity.position.toLorenzVec().add(0.0, 0.5, 0.0)
- ) && dist < currentMob!!.renderDistance
+ } else canSee = entity.canBeSeen() && dist < currentMob!!.renderDistance
if (!canSee) {
val nameTagEntity = Minecraft.getMinecraft().theWorld.getEntityByID(foundID + 1)
@@ -95,3 +93,4 @@ object TrevorSolver {
mobCoordinates = LorenzVec(0.0, 0.0, 0.0)
}
}
+
diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
index 55327ccb1..aca97f9e0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/motes/RiftMotesOrb.kt
@@ -80,7 +80,7 @@ class RiftMotesOrb {
orb.pickedUp = true
}
- val location = orb.location.add(0.0, 0.5, 0.0)
+ val location = orb.location.add(y = 0.5)
val sizeOffset = (5 - config.size) * -0.1
val color = if (orb.pickedUp) LorenzColor.GRAY else LorenzColor.LIGHT_PURPLE
val text = color.getChatColor() + "Motes Orb"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
index 87bccc642..a60d1e51a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
import at.hannibal2.skyhanni.utils.EntityUtils
+import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsInRadiusWith
import at.hannibal2.skyhanni.utils.EntityUtils.hasSkullTexture
import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
@@ -29,7 +30,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.exactLocation
import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation
import at.hannibal2.skyhanni.utils.SoundUtils
import at.hannibal2.skyhanni.utils.SoundUtils.playSound
-import at.hannibal2.skyhanni.utils.getLorenzVec
import at.hannibal2.skyhanni.utils.toLorenzVec
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -267,11 +267,7 @@ object VampireSlayerFeatures {
fun pre(event: RenderLivingEvent.Pre<EntityOtherPlayerMP>) {
if (!isEnabled()) return
if (!config.seeThrough) return
- if (entityList.contains(event.entity) && LocationUtils.canSee(
- LocationUtils.playerEyeLocation(),
- event.entity.getLorenzVec()
- )
- ) {
+ if (entityList.contains(event.entity) && event.entity.canBeSeen()) {
GlStateManager.disableDepth()
}
}
@@ -280,11 +276,7 @@ object VampireSlayerFeatures {
fun pre(event: RenderLivingEvent.Post<EntityOtherPlayerMP>) {
if (!isEnabled()) return
if (!config.seeThrough) return
- if (entityList.contains(event.entity) && LocationUtils.canSee(
- LocationUtils.playerEyeLocation(),
- event.entity.getLorenzVec()
- )
- ) {
+ if (entityList.contains(event.entity) && event.entity.canBeSeen()) {
GlStateManager.enableDepth()
}
}
@@ -364,7 +356,6 @@ object VampireSlayerFeatures {
}
}
-
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
entityList.clear()
@@ -372,7 +363,6 @@ object VampireSlayerFeatures {
standList = mutableMapOf()
}
-
@SubscribeEvent
fun onParticle(event: ReceiveParticleEvent) {
if (!isEnabled()) return
@@ -389,4 +379,4 @@ object VampireSlayerFeatures {
}
fun isEnabled() = RiftAPI.inRift() && RiftAPI.inStillgoreChateau()
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt
index d36a7be57..ae76d4c9b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt
@@ -11,10 +11,11 @@ import at.hannibal2.skyhanni.events.RenderMobColoredEvent
import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled
+import at.hannibal2.skyhanni.utils.EntityUtils.canBeSeen
import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.LocationUtils
+import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.LorenzLogger
@@ -54,7 +55,7 @@ class EndermanSlayerFeatures {
val entity = event.entity
if (entity in endermenWithBeacons || entity in flyingBeacons) return
- if (entity is EntityEnderman && showBeacon() && hasBeaconInHand(entity) && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) {
+ if (entity is EntityEnderman && showBeacon() && hasBeaconInHand(entity) && entity.canBeSeen(15.0)) {
endermenWithBeacons.add(entity)
logger.log("Added enderman with beacon at ${entity.getLorenzVec()}")
}
@@ -62,7 +63,7 @@ class EndermanSlayerFeatures {
if (entity is EntityArmorStand) {
if (showBeacon()) {
val stack = entity.inventory[4] ?: return
- if (stack.name == "Beacon" && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) {
+ if (stack.name == "Beacon" && entity.canBeSeen(15.0)) {
flyingBeacons = flyingBeacons.editCopy {
add(entity)
}
@@ -82,7 +83,7 @@ class EndermanSlayerFeatures {
private fun hasBeaconInHand(enderman: EntityEnderman) = enderman.getBlockInHand()?.block == Blocks.beacon
- private fun canSee(a: LorenzVec, b: LorenzVec) = LocationUtils.canSee(a, b) || a.distance(b) < 15
+ private fun canSee(b: LorenzVec) = b.canBeSeen(15.0)
private fun showBeacon() = beaconConfig.highlightBeacon || beaconConfig.showWarning || beaconConfig.showLine
@@ -227,4 +228,4 @@ class EndermanSlayerFeatures {
event.move(3, "slayer.endermanBeaconConfig.lineWidth", "slayer.endermen.endermanBeaconConfig.lineWidth")
event.move(3, "slayer.endermanHighlightNukekebi", "slayer.endermen.highlightNukekebi")
}
-} \ 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
index f9e8ddb86..0e31c45bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.LocationUtils.canBeSeen
import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import net.minecraft.block.state.IBlockState
@@ -152,4 +153,6 @@ object EntityUtils {
fun getAllEntities(): Sequence<Entity> = Minecraft.getMinecraft()?.theWorld?.loadedEntityList?.let {
if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList()
}?.asSequence() ?: emptySequence()
-} \ No newline at end of file
+
+ fun Entity.canBeSeen(radius: Double = 150.0) = getLorenzVec().add(0.0, 0.5, 0.0).canBeSeen(radius)
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
index 99b95f734..fafb41c96 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt
@@ -31,4 +31,13 @@ object LocationUtils {
fun AxisAlignedBB.isVecInside(vec: LorenzVec) = isVecInside(vec.toVec3())
fun AxisAlignedBB.isPlayerInside() = isVecInside(playerLocation())
-} \ No newline at end of file
+
+ fun LorenzVec.canBeSeen(radius: Double = 150.0): Boolean {
+ val a = playerEyeLocation()
+ val b = this
+ val noBlocks = canSee(a, b)
+ val notTooFar = a.distance(b) < radius
+ val inFov = true // TODO add Frustum "Frustum().isBoundingBoxInFrustum(entity.entityBoundingBox)"
+ return noBlocks && notTooFar && inFov
+ }
+}