diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-05-16 00:05:46 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-15 16:05:46 +0200 |
commit | a563f32d0564b3187b4db7098f6e39173d9b2f64 (patch) | |
tree | eaf8a7d5ea649f57d49ead92bb37e2657312fcc7 /src/main/java | |
parent | db07bd4a22c4feace8cefa9cfc39dd953999c5e9 (diff) | |
download | skyhanni-a563f32d0564b3187b4db7098f6e39173d9b2f64.tar.gz skyhanni-a563f32d0564b3187b4db7098f6e39173d9b2f64.tar.bz2 skyhanni-a563f32d0564b3187b4db7098f6e39173d9b2f64.zip |
Trevor fixes (#106)
Diffstat (limited to 'src/main/java')
5 files changed, 48 insertions, 34 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index afb351c9f..07e2a92c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -316,7 +316,8 @@ public class Misc { public static class TrevorTheTrapper { @Expose - @ConfigOption(name = "Trapper Solver", desc = "Assists you in finding Trevor's mobs. §cMay not always work as expected.") + @ConfigOption(name = "Trapper Solver", desc = "Assists you in finding Trevor's mobs. §eNote: May not always work as expected. " + + "§cWill not help you to find rabbits or sheep in the Oasis!") @ConfigEditorBoolean public boolean trapperSolver = true; 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 9a2209ab3..05a4cd017 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 @@ -83,8 +83,9 @@ class TrevorFeatures { currentLabel = "§2Ready" } else { currentStatus = TrapperStatus.WAITING - currentLabel = "§3$timeUntilNextReady seconds left" + currentLabel = if (timeUntilNextReady == 1) "§31 second left" else "§3$timeUntilNextReady seconds left" } + TrevorSolver.mobLocation = CurrentMobArea.NONE } var matcher = trapperPattern.matcher(event.message.removeColor()) @@ -112,12 +113,12 @@ class TrevorFeatures { timeUntilNextReady -= 1 if (trapperReady && timeUntilNextReady > 0) { currentStatus = TrapperStatus.WAITING - currentLabel = "§3$timeUntilNextReady seconds left" + currentLabel = if (timeUntilNextReady == 1) "§31 second left" else "§3$timeUntilNextReady seconds left" } if (timeUntilNextReady <= 0 && trapperReady) { if (timeUntilNextReady == 0) { - TitleUtils.sendTitle("§2Trapper Ready ", 3_000) + TitleUtils.sendTitle("§2Trapper Ready", 3_000) SoundUtils.playBeepSound() } currentStatus = TrapperStatus.READY @@ -185,7 +186,7 @@ class TrevorFeatures { if (TrevorSolver.mobLocation == CurrentMobArea.FOUND) { location = TrevorSolver.mobCoordinates event.drawWaypointFilled(location.add(0, -2, 0), LorenzColor.GREEN.toColor(), true, true) - event.drawDynamicText(location.add(0, 2, 0), TrevorSolver.mobLocation.location, 1.5) + event.drawDynamicText(location.add(0, 1, 0), TrevorSolver.mobLocation.location, 1.5) } else { event.drawWaypointFilled(location, LorenzColor.GOLD.toColor(), true, true) event.drawDynamicText(location.add(0, 1, 0), TrevorSolver.mobLocation.location, 1.5) @@ -201,8 +202,6 @@ class TrevorFeatures { val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey() if (config.keyBindWarpTrapper != key) return - if (!LorenzUtils.inSkyBlock || LorenzUtils.inDungeons || LorenzUtils.inKuudraFight) return - Minecraft.getMinecraft().currentScreen?.let { if (it !is GuiInventory && it !is GuiChest && it !is GuiEditSign) return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMobs.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMobs.kt new file mode 100644 index 000000000..d04f6f285 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMobs.kt @@ -0,0 +1,10 @@ +package at.hannibal2.skyhanni.features.misc.trevor + +enum class TrevorMobs(val mobName: String, val renderDistance: Double) { + COW("Cow", 68.0), + HORSE("Horse", 90.0), + SHEEP("Sheep", 68.0), + PIG("Pig", 68.0), + RABBIT("Rabbit", 43.0), + CHICKEN("Chicken", 33.0), +} 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 46b367e7d..1588d2c22 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,8 @@ package at.hannibal2.skyhanni.features.misc.trevor +import at.hannibal2.skyhanni.data.TitleUtils 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.LorenzVec import at.hannibal2.skyhanni.utils.toLorenzVec @@ -10,8 +12,9 @@ import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand object TrevorSolver { - private val animalNames = arrayOf("Cow", "Horse", "Sheep", "Pig", "Rabbit", "Chicken") + private val animalHealths = intArrayOf(100, 200, 400, 500, 1000, 2000, 5000, 10000, 20000) //future proofing for Derpy :) + private var currentMob: TrevorMobs? = null private var maxHeight: Double = 0.0 private var minHeight: Double = 0.0 private var foundID = -1 @@ -40,42 +43,44 @@ object TrevorSolver { } fun findMob() { + var canSee = false val world = Minecraft.getMinecraft().theWorld ?: return for (entity in world.getLoadedEntityList()) { - val name = entity.name if (entity is EntityOtherPlayerMP) continue - // looking at 2 diff entities rn - Mostly fixed I think as it returns + val name = entity.name val entityHealth = if (entity is EntityLivingBase) entity.baseMaxHealth else 0 - if (intArrayOf(100, 500, 1000, 5000, 10000).any { it == entityHealth }) { - if (animalNames.any { it == name }) { - if (LocationUtils.canSee(LocationUtils.playerLocation(), entity.position.toLorenzVec())) { - if (!entity.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { - if (foundID == entity.entityId) { - mobLocation = CurrentMobArea.FOUND - mobCoordinates = entity.position.toLorenzVec() - } else { - foundID = entity.entityId - } - return - } - } - } - } + currentMob = TrevorMobs.values().firstOrNull {it.mobName.contains(name)} + if (animalHealths.any { it == entityHealth } ) { + if (currentMob != null) { + if (foundID == entity.entityId) { + 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 - if (entity is EntityArmorStand) { - for (animal in animalNames) { - if (name.contains(animal) && name.contains("§c❤")) { - if (foundID == entity.entityId) { + if (!canSee) { + val nameTagEntity = Minecraft.getMinecraft().theWorld.getEntityByID(foundID + 1) + if (nameTagEntity is EntityArmorStand) canSee = true + } + if (canSee) { + if (mobLocation != CurrentMobArea.FOUND) { + TitleUtils.sendTitle("§2Saw Mob!", 3_000) + } mobLocation = CurrentMobArea.FOUND mobCoordinates = entity.position.toLorenzVec() - } else { - foundID = entity.entityId } - return + } else { + foundID = entity.entityId } + return } } } + if (foundID != -1) { + println("Cannot find mob anymore") + mobCoordinates = LorenzVec(0.0, 0.0, 0.0) + foundID = -1 + } } fun resetLocation() { @@ -85,5 +90,4 @@ object TrevorSolver { foundID = -1 mobCoordinates = LorenzVec(0.0, 0.0, 0.0) } - } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt index 34cdc4d6c..efcc8e493 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt @@ -5,7 +5,7 @@ import net.minecraft.client.Minecraft object LocationUtils { fun canSee(a: LorenzVec, b: LorenzVec): Boolean { - return Minecraft.getMinecraft().theWorld.rayTraceBlocks(a.toVec3(), b.toVec3()) == null + return Minecraft.getMinecraft().theWorld.rayTraceBlocks(a.toVec3(), b.toVec3(), false, true, false) == null } fun playerLocation() = Minecraft.getMinecraft().thePlayer.getLorenzVec() |