From 7f76e8ae059a8689085fcfd072195a5b80258c42 Mon Sep 17 00:00:00 2001 From: inglettronald Date: Fri, 28 Apr 2023 05:12:55 -0500 Subject: helpful p5 waypoints added --- src/main/kotlin/dulkirmod/DulkirMod.kt | 4 +- src/main/kotlin/dulkirmod/config/DulkirConfig.kt | 43 ++++- .../kotlin/dulkirmod/features/DragonFeatures.kt | 190 +++++++++++++++++++++ src/main/kotlin/dulkirmod/features/DragonTimer.kt | 146 ---------------- 4 files changed, 230 insertions(+), 153 deletions(-) create mode 100644 src/main/kotlin/dulkirmod/features/DragonFeatures.kt delete mode 100644 src/main/kotlin/dulkirmod/features/DragonTimer.kt diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt index 8295108..6fbc948 100644 --- a/src/main/kotlin/dulkirmod/DulkirMod.kt +++ b/src/main/kotlin/dulkirmod/DulkirMod.kt @@ -5,7 +5,6 @@ import dulkirmod.config.DulkirConfig import dulkirmod.events.ChatEvent import dulkirmod.features.* import dulkirmod.features.chat.AbiphoneDND -import dulkirmod.huds.KeyHud import dulkirmod.utils.ContainerNameUtil import dulkirmod.utils.TabListUtils import dulkirmod.utils.TextUtils @@ -78,7 +77,7 @@ class DulkirMod { mcBus.register(KeeperWaypoints) mcBus.register(ScalableTooltips) mcBus.register(GardenVisitorAlert) - mcBus.register(DragonTimer) + mcBus.register(DragonFeatures) mcBus.register(HideHealerFairy) mcBus.register(SecretSounds) @@ -133,7 +132,6 @@ class DulkirMod { val mc: Minecraft = Minecraft.getMinecraft() var config = DulkirConfig - var hud = KeyHud() var display: GuiScreen? = null val scope = CoroutineScope(EmptyCoroutineContext) diff --git a/src/main/kotlin/dulkirmod/config/DulkirConfig.kt b/src/main/kotlin/dulkirmod/config/DulkirConfig.kt index 24d69b7..ecec289 100644 --- a/src/main/kotlin/dulkirmod/config/DulkirConfig.kt +++ b/src/main/kotlin/dulkirmod/config/DulkirConfig.kt @@ -5,10 +5,11 @@ import cc.polyfrost.oneconfig.config.annotations.* import cc.polyfrost.oneconfig.config.data.Mod import cc.polyfrost.oneconfig.config.data.ModType import dulkirmod.DulkirMod -import dulkirmod.huds.GardenInfoHud -import dulkirmod.huds.KeyHud -import dulkirmod.huds.YawDisplayHud +import dulkirmod.overlays.GardenInfoHud +import dulkirmod.overlays.KeyHud +import dulkirmod.overlays.YawDisplayHud import dulkirmod.utils.Utils +import net.minecraft.client.audio.SoundCategory object DulkirConfig : Config(Mod("DulkirMod", ModType.SKYBLOCK), "dulkirmod-config.json") { @@ -157,6 +158,30 @@ object DulkirConfig : Config(Mod("DulkirMod", ModType.SKYBLOCK), "dulkirmod-conf ) var dragonKillBox = true + @Switch( + name = "Gyro Waypoints", + description = "Only renders in p5", + category = "Dungeons", + subcategory = "Dungeons" + ) + var gyroWaypoints = true + + @Switch( + name = "Decoy Waypoints", + description = "Only renders in p5", + category = "Dungeons", + subcategory = "Dungeons" + ) + var decoyWaypoints = true + + @Switch( + name = "LB Waypoints", + description = "Only renders in p5", + category = "Dungeons", + subcategory = "Dungeons" + ) + var lbWaypoints = true + @Switch( name = "Hide Extra Nametags", description = "Prevents some nametags not covered by skytils \"Hide non-starred nametags\" from rendering.", @@ -389,7 +414,17 @@ object DulkirConfig : Config(Mod("DulkirMod", ModType.SKYBLOCK), "dulkirmod-conf text = "Test" ) fun demoSecretVolume() { - DulkirMod.mc.thePlayer.playSound("random.break", 1f * secretSoundVolume, 1f) + val prevMaster = DulkirMod.mc.gameSettings.getSoundLevel(SoundCategory.MASTER) + DulkirMod.mc.gameSettings.setSoundLevel(SoundCategory.MASTER, 1f) + val prevNote = DulkirMod.mc.gameSettings.getSoundLevel(SoundCategory.MASTER) + DulkirMod.mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, 1f) + DulkirMod.mc.thePlayer.playSound( + "note.pling", + 1f * DulkirConfig.secretSoundVolume, + 1f + ) + DulkirMod.mc.gameSettings.setSoundLevel(SoundCategory.MASTER, prevMaster) + DulkirMod.mc.gameSettings.setSoundLevel(SoundCategory.RECORDS, prevNote) } @Switch( diff --git a/src/main/kotlin/dulkirmod/features/DragonFeatures.kt b/src/main/kotlin/dulkirmod/features/DragonFeatures.kt new file mode 100644 index 0000000..42f8780 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/DragonFeatures.kt @@ -0,0 +1,190 @@ +package dulkirmod.features + +import dulkirmod.DulkirMod.Companion.mc +import dulkirmod.config.DulkirConfig +import dulkirmod.utils.ScoreBoardUtils +import dulkirmod.utils.WorldRenderUtils +import net.minecraft.util.BlockPos +import net.minecraft.util.Vec3 +import net.minecraft.world.World +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import kotlin.math.max + +object DragonFeatures { + data class Dragon(val color: String, val pos: Vec3, var spawnTime: Long) + + private val dragons = arrayOf( + Dragon("orange", Vec3(84.0, 18.0, 56.0), 0), + Dragon("red", Vec3(27.0, 18.0, 56.0), 0), + Dragon("green", Vec3(26.0, 18.0, 95.0), 0), + Dragon("purple", Vec3(57.0, 18.0, 125.0), 0), + 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 + ) + 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 + ) + 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 + ) + + /** + * Called from within the MixinWorld Class + */ + fun handleNewParticle(pID: Int, x: Double, y: Double, z: Double) { + if (!DulkirConfig.dragonTimer) return + if (!ScoreBoardUtils.isInM7) return + + if (pID != 26) return + + val particleVec = Vec3(x, y, z) + dragons.forEach { + if (System.currentTimeMillis() - it.spawnTime < 10000 || !inRangeOf(it.color, particleVec)) return@forEach + it.spawnTime = System.currentTimeMillis() + } + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + renderDragonBoxes() + + if (!DulkirConfig.dragonTimer) return + if (!ScoreBoardUtils.isInM7) return + + val curTime = System.currentTimeMillis() + dragons.forEach { + if (it.spawnTime + 5000 < curTime || isDead(it.color)) return@forEach + val timeUntilSpawn = (it.spawnTime + 5000 - curTime) / 1000f + val color = when { + timeUntilSpawn <= 1 -> "§c" + timeUntilSpawn <= 3 -> "§e" + else -> "§a" + } + + val scale = max(1.0, mc.thePlayer.positionVector.distanceTo(it.pos) / 5.0).toFloat() + + WorldRenderUtils.renderString( + it.pos, "${color}${String.format("%.2f", timeUntilSpawn)}", false, scale, true + ) + } + } + + /** + * 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) + } + return world.isAirBlock(pos) + } + + private fun inRangeOf(color: String, pos: Vec3): Boolean { + val x = pos.xCoord.toInt() + val y = pos.yCoord.toInt() + val z = pos.zCoord.toInt() + + return when (color) { + "orange" -> { + x in 82..88 && y in 15..22 && z in 53..59 + } + + "red" -> { + x in 24..30 && y in 15..22 && z in 56..62 + } + + "green" -> { + x in 23..29 && y in 15..22 && z in 91..97 + } + + "purple" -> { + x in 53..59 && y in 15..22 && z in 122..128 + } + + "blue" -> { + x in 82..88 && y in 15..22 && z in 91..97 + } + + else -> { + false + } + } + } + + private fun renderDragonBoxes() { + if (!DulkirConfig.dragonKillBox) return + if (!ScoreBoardUtils.isInM7) return + if (mc.thePlayer.positionVector.yCoord > 45) return + // Blue + if (!isDead("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")) + 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")) + 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")) + 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")) + WorldRenderUtils.drawCustomBox(72.0, 30.0, 8.0, 20.0, 47.0, 29.0, Color(255, 170, 0, 255), 3f, phase = false) + } + + @SubscribeEvent + fun updateM7Check(event: WorldEvent.Load) { + val executor = Executors.newSingleThreadScheduledExecutor() + executor.schedule({ + ScoreBoardUtils.inM7() + }, 10, TimeUnit.SECONDS) + } + + @SubscribeEvent + fun renderP5Waypoints(event: RenderWorldLastEvent) { + if (!(DulkirConfig.gyroWaypoints || DulkirConfig.lbWaypoints || DulkirConfig.decoyWaypoints)) 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 (DulkirConfig.lbWaypoints) { + val color = "§a" + for (s in shoot) { + WorldRenderUtils.renderString(s, "${color}Target", false, max(1f, playerVec.distanceTo(s).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) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/DragonTimer.kt b/src/main/kotlin/dulkirmod/features/DragonTimer.kt deleted file mode 100644 index 4f20430..0000000 --- a/src/main/kotlin/dulkirmod/features/DragonTimer.kt +++ /dev/null @@ -1,146 +0,0 @@ -package dulkirmod.features - -import dulkirmod.DulkirMod.Companion.mc -import dulkirmod.config.DulkirConfig -import dulkirmod.utils.ScoreBoardUtils -import dulkirmod.utils.WorldRenderUtils -import net.minecraft.util.BlockPos -import net.minecraft.util.Vec3 -import net.minecraft.world.World -import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import kotlin.math.max - -object DragonTimer { - data class Dragon(val color: String, val pos: Vec3, var spawnTime: Long) - - private val dragons = arrayOf( - Dragon("orange", Vec3(84.0, 18.0, 56.0), 0), - Dragon("red", Vec3(27.0, 18.0, 56.0), 0), - Dragon("green", Vec3(26.0, 18.0, 95.0), 0), - Dragon("purple", Vec3(57.0, 18.0, 125.0), 0), - Dragon("blue", Vec3(84.0, 18.0, 95.0), 0) - ) - - /** - * Called from within the MixinWorld Class - */ - fun handleNewParticle(pID: Int, x: Double, y: Double, z: Double) { - if (!DulkirConfig.dragonTimer) return - if (!ScoreBoardUtils.isInM7) return - - if (pID != 26) return - - val particleVec = Vec3(x, y, z) - dragons.forEach { - if (System.currentTimeMillis() - it.spawnTime < 10000 || !inRangeOf(it.color, particleVec)) return@forEach - it.spawnTime = System.currentTimeMillis() - } - } - - @SubscribeEvent - fun onRenderWorld(event: RenderWorldLastEvent) { - renderDragonBoxes() - - if (!DulkirConfig.dragonTimer) return - if (!ScoreBoardUtils.isInM7) return - - val curTime = System.currentTimeMillis() - dragons.forEach { - if (it.spawnTime + 5000 < curTime || isDead(it.color)) return@forEach - val timeUntilSpawn = (it.spawnTime + 5000 - curTime) / 1000f - val color = when { - timeUntilSpawn <= 1 -> "§c" - timeUntilSpawn <= 3 -> "§e" - else -> "§a" - } - - val scale = max(1.0, mc.thePlayer.positionVector.distanceTo(it.pos) / 5.0).toFloat() - - WorldRenderUtils.renderString( - it.pos, "${color}${String.format("%.2f", timeUntilSpawn)}", false, scale, true - ) - } - } - - /** - * 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) - } - return world.isAirBlock(pos) - } - - private fun inRangeOf(color: String, pos: Vec3): Boolean { - val x = pos.xCoord.toInt() - val y = pos.yCoord.toInt() - val z = pos.zCoord.toInt() - - return when (color) { - "orange" -> { - x in 82..88 && y in 15..22 && z in 53..59 - } - - "red" -> { - x in 24..30 && y in 15..22 && z in 56..62 - } - - "green" -> { - x in 23..29 && y in 15..22 && z in 91..97 - } - - "purple" -> { - x in 53..59 && y in 15..22 && z in 122..128 - } - - "blue" -> { - x in 82..88 && y in 15..22 && z in 91..97 - } - - else -> { - false - } - } - } - - private fun renderDragonBoxes() { - if (!DulkirConfig.dragonKillBox) return - if (!ScoreBoardUtils.isInM7) return - if (mc.thePlayer.positionVector.yCoord > 45) return - // Blue - if (!isDead("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")) - 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")) - 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")) - 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")) - WorldRenderUtils.drawCustomBox(72.0, 30.0, 8.0, 20.0, 47.0, 29.0, Color(255, 170, 0, 255), 3f, phase = false) - } - - @SubscribeEvent - fun updateM7Check(event: WorldEvent.Load) { - val executor = Executors.newSingleThreadScheduledExecutor() - executor.schedule({ - ScoreBoardUtils.inM7() - }, 10, TimeUnit.SECONDS) - } -} \ No newline at end of file -- cgit