diff options
author | inglettronald <inglettronald@gmail.com> | 2023-04-28 17:01:03 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-04-28 17:01:03 -0500 |
commit | f64775d1e49c621141e29e4d2e3d0dfe55e085c7 (patch) | |
tree | 30f96dffe23f1b0f4701272b8ac53db7b486e9dd | |
parent | 698193d1a9c7dbb5f44974f388b1cae3e25acbef (diff) | |
download | DulkirMod-f64775d1e49c621141e29e4d2e3d0dfe55e085c7.tar.gz DulkirMod-f64775d1e49c621141e29e4d2e3d0dfe55e085c7.tar.bz2 DulkirMod-f64775d1e49c621141e29e4d2e3d0dfe55e085c7.zip |
refactor and waypoint improvement
-rw-r--r-- | src/main/kotlin/dulkirmod/DulkirMod.kt | 1 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/DragonFeatures.kt | 97 |
2 files changed, 63 insertions, 35 deletions
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt index af29ea4..d9aaf53 100644 --- a/src/main/kotlin/dulkirmod/DulkirMod.kt +++ b/src/main/kotlin/dulkirmod/DulkirMod.kt @@ -108,6 +108,7 @@ class DulkirMod { // Now I don't have to fetch the entries for multiple things, this just updates and caches // the data structure on 1s cooldown TabListUtils.parseTabEntries() + DragonFeatures.updateDragonDead() lastLongUpdate = currTime } } diff --git a/src/main/kotlin/dulkirmod/features/DragonFeatures.kt b/src/main/kotlin/dulkirmod/features/DragonFeatures.kt index 42f8780..2957c00 100644 --- a/src/main/kotlin/dulkirmod/features/DragonFeatures.kt +++ b/src/main/kotlin/dulkirmod/features/DragonFeatures.kt @@ -17,6 +17,7 @@ import kotlin.math.max object DragonFeatures { data class Dragon(val color: String, val pos: Vec3, var spawnTime: Long) + data class Waypoint(val pos: Vec3, val color: String) private val dragons = arrayOf( Dragon("orange", Vec3(84.0, 18.0, 56.0), 0), @@ -26,24 +27,30 @@ object DragonFeatures { Dragon("blue", Vec3(84.0, 18.0, 95.0), 0) ) - val gyros = arrayOf( - Vec3(83.5,5.5,104.5), // blue - Vec3(25.5, 5.5, 81.5) // green + private val gyros = arrayOf( + Waypoint(Vec3(83.5,5.5,104.5), "blue"), // blue + Waypoint(Vec3(25.5, 5.5, 81.5), "green") // green ) - val decoys = arrayOf( - Vec3(32.5, 19.5, 59.9), // red - Vec3(56.5, 7.5, 124.5), // purple - Vec3(90.5, 11.5, 100.5), // blue - Vec3(21.5, 11.5, 88.5) // green + private val decoys = arrayOf( + Waypoint(Vec3(37.5, 14.5, 44.5), "red"), // red + Waypoint(Vec3(56.5, 7.5, 124.5), "purple"), // purple + Waypoint(Vec3(90.5, 11.5, 100.5), "blue"), // blue + Waypoint(Vec3(21.5, 11.5, 88.5), "green") // green ) - val shoot = arrayOf( - Vec3(56.5, 20.5, 124.5), // purple - Vec3(84.5, 20.5, 59.5), // orange - Vec3(23.5,21.5, 54.5), // red - Vec3(27.5, 16.5, 94.5), // green - Vec3(85.5, 20.5, 98.5) // blue + private val shoot = arrayOf( + Waypoint(Vec3(56.5, 20.5, 124.5), "purple"), // purple + Waypoint(Vec3(84.5, 20.5, 59.5), "orange"), // orange + Waypoint(Vec3(23.5,21.5, 54.5), "red"), // red + Waypoint(Vec3(27.5, 16.5, 94.5), "green"), // green + Waypoint(Vec3(85.5, 20.5, 98.5), "blue") // blue ) + private var greenAlive = true + private var blueAlive = true + private var redAlive = true + private var orangeAlive = true + private var purpleAlive = true + /** * Called from within the MixinWorld Class */ @@ -69,7 +76,7 @@ object DragonFeatures { val curTime = System.currentTimeMillis() dragons.forEach { - if (it.spawnTime + 5000 < curTime || isDead(it.color)) return@forEach + if (it.spawnTime + 5000 < curTime || isAlive(it.color)) return@forEach val timeUntilSpawn = (it.spawnTime + 5000 - curTime) / 1000f val color = when { timeUntilSpawn <= 1 -> "§c" @@ -85,20 +92,34 @@ object DragonFeatures { } } + + fun updateDragonDead() { + if (!(DulkirConfig.dragonKillBox || DulkirConfig.lbWaypoints || DulkirConfig.decoyWaypoints || DulkirConfig.gyroWaypoints)) return + //if (!ScoreBoardUtils.isInM7) return + if (mc.theWorld == null) return + if (mc.thePlayer.positionVector.yCoord > 45) return + + val world: World = mc.theWorld + + orangeAlive = !world.isAirBlock(BlockPos(90, 21, 56)) + redAlive = !world.isAirBlock(BlockPos(22, 20 , 59)) + greenAlive = !world.isAirBlock(BlockPos(22, 21, 94)) + purpleAlive = !world.isAirBlock(BlockPos(56, 20, 130)) + blueAlive = !world.isAirBlock(BlockPos(89, 21, 94)) + } + /** * true = dead */ - private fun isDead(color: String): Boolean { - val world: World = mc.theWorld - val pos = when (color) { - "orange" -> BlockPos(90, 21, 56) - "red" -> BlockPos(20, 22, 59) - "green" -> BlockPos(22, 21, 94) - "purple" -> BlockPos(56, 20, 130) - "blue" -> BlockPos(89, 21, 94) - else -> BlockPos(0, 0, 0) + private fun isAlive(color: String): Boolean { + return when (color) { + "orange" -> orangeAlive + "red" -> redAlive + "green" -> greenAlive + "purple" -> purpleAlive + "blue" -> blueAlive + else -> false } - return world.isAirBlock(pos) } private fun inRangeOf(color: String, pos: Vec3): Boolean { @@ -135,22 +156,22 @@ object DragonFeatures { private fun renderDragonBoxes() { if (!DulkirConfig.dragonKillBox) return - if (!ScoreBoardUtils.isInM7) return + //if (!ScoreBoardUtils.isInM7) return if (mc.thePlayer.positionVector.yCoord > 45) return // Blue - if (!isDead("blue")) + if (isAlive("blue")) WorldRenderUtils.drawCustomBox(71.5, 25.0, 16.0, 10.0, 82.5, 25.0, Color(0, 170, 170, 255), 3f, phase = false) // Purple - if (!isDead("purple")) + if (isAlive("purple")) WorldRenderUtils.drawCustomBox(45.5, 23.0, 13.0, 10.0, 113.5, 23.0, Color(170, 0, 170, 255), 3f, phase = false) // Green - if (!isDead("green")) + if (isAlive("green")) WorldRenderUtils.drawCustomBox(7.0, 30.0, 8.0, 20.0, 80.0, 30.0, Color(85, 255, 85, 255), 3f, phase = false) // Red - if (!isDead("red")) + if (isAlive("red")) WorldRenderUtils.drawCustomBox(14.5, 25.0, 13.0, 15.0, 45.5, 25.0, Color(255, 85, 85, 255), 3f, phase = false) // Orange - if (!isDead("orange")) + if (isAlive("orange")) WorldRenderUtils.drawCustomBox(72.0, 30.0, 8.0, 20.0, 47.0, 29.0, Color(255, 170, 0, 255), 3f, phase = false) } @@ -165,25 +186,31 @@ object DragonFeatures { @SubscribeEvent fun renderP5Waypoints(event: RenderWorldLastEvent) { if (!(DulkirConfig.gyroWaypoints || DulkirConfig.lbWaypoints || DulkirConfig.decoyWaypoints)) return - if (!ScoreBoardUtils.isInM7) return + //if (!ScoreBoardUtils.isInM7) return val playerVec = mc.thePlayer.positionVector if (playerVec.yCoord > 45) return if (DulkirConfig.gyroWaypoints) { val color = "§6" for (g in gyros) { - WorldRenderUtils.renderString(g, "${color}Gyro", false, max(1f, playerVec.distanceTo(g).toFloat()/10f), false) + if (!isAlive(g.color)) continue + WorldRenderUtils.drawCustomBox(g.pos.xCoord - .5, 1.0, g.pos.yCoord -.5, 1.0, g.pos.zCoord -.5, 1.0, Color(125, 87, 10, 255), 3f, phase = true) + WorldRenderUtils.renderString(g.pos.add(Vec3(0.0, 1.0,0.0)), "${color}Gyro", false, max(1f, playerVec.distanceTo(g.pos).toFloat()/10f), false) } } if (DulkirConfig.lbWaypoints) { val color = "§a" for (s in shoot) { - WorldRenderUtils.renderString(s, "${color}Target", false, max(1f, playerVec.distanceTo(s).toFloat()/10f), false) + if (!isAlive(s.color)) continue + WorldRenderUtils.drawCustomBox(s.pos.xCoord - .5, 1.0, s.pos.yCoord -.5, 1.0, s.pos.zCoord -.5, 1.0, Color(27, 99, 18, 255), 3f, phase = true) + WorldRenderUtils.renderString(s.pos, "${color}Target", false, max(1f, playerVec.distanceTo(s.pos).toFloat()/10f), false) } } if (DulkirConfig.decoyWaypoints) { val color = "§3" for (d in decoys) { - WorldRenderUtils.renderString(d, "${color}Decoy", false, max(1f, playerVec.distanceTo(d).toFloat()/10f), false) + if (!isAlive(d.color)) continue + WorldRenderUtils.drawCustomBox(d.pos.xCoord - .5, 1.0, d.pos.yCoord -.5, 1.0, d.pos.zCoord -.5, 1.0, Color(33, 62, 209), 3f, phase = true) + WorldRenderUtils.renderString(d.pos, "${color}Decoy", false, max(1f, playerVec.distanceTo(d.pos).toFloat()/10f), false) } } } |