diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-10-09 00:33:42 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-10-09 00:33:42 -0400 |
commit | 2185673d76bc639660da04b61e81601b9e0d8513 (patch) | |
tree | c73c64904991a4b9f49f2a565ec6a48f93f2ec57 /src/main | |
parent | fb7fb8156bc99b0df4e53b43972f53d6307c7be9 (diff) | |
download | SkytilsMod-2185673d76bc639660da04b61e81601b9e0d8513.tar.gz SkytilsMod-2185673d76bc639660da04b61e81601b9e0d8513.tar.bz2 SkytilsMod-2185673d76bc639660da04b61e81601b9e0d8513.zip |
spirit bear spawn timer
Diffstat (limited to 'src/main')
3 files changed, 86 insertions, 3 deletions
diff --git a/src/main/kotlin/skytils/skytilsmod/commands/impl/TrackCooldownCommand.kt b/src/main/kotlin/skytils/skytilsmod/commands/impl/TrackCooldownCommand.kt index 6258de8a..48609144 100644 --- a/src/main/kotlin/skytils/skytilsmod/commands/impl/TrackCooldownCommand.kt +++ b/src/main/kotlin/skytils/skytilsmod/commands/impl/TrackCooldownCommand.kt @@ -28,7 +28,7 @@ object TrackCooldownCommand : BaseCommand("trackcooldown", listOf("cooldowntrack override fun getCommandUsage(sender: ICommandSender): String = "/trackcooldown <cooldown> <ability>" override fun processCommand(sender: ICommandSender, args: Array<String>) { - if (args.size < 2) throw WrongUsageException("You must specify valid arguments.") + if (args.size < 2) throw WrongUsageException(getCommandUsage(sender)) val seconds = args[0].toDoubleOrNull() ?: throw WrongUsageException("You must specify a valid number") val ability = args.drop(1).joinToString(" ") if (ability.isBlank()) throw WrongUsageException("You must specify valid arguments.") diff --git a/src/main/kotlin/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/skytils/skytilsmod/core/Config.kt index 8861dba3..ceea45d8 100644 --- a/src/main/kotlin/skytils/skytilsmod/core/Config.kt +++ b/src/main/kotlin/skytils/skytilsmod/core/Config.kt @@ -383,6 +383,13 @@ object Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sortin var necronHealth = 0 @Property( + type = PropertyType.SWITCH, name = "Spirit Bear Timer", + description = "Shows the time it takes for the Spirit Bears to spawn.", + category = "Dungeons", subcategory = "Quality of Life" + ) + var spiritBearTimer = false + + @Property( type = PropertyType.SWITCH, name = "Spirit Leap Names", description = "Shows names next to the heads on the Spirit Leap menu.", category = "Dungeons", subcategory = "Quality of Life" diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt index 50e6f026..8bcd3fd8 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/dungeons/DungeonFeatures.kt @@ -31,12 +31,12 @@ import net.minecraft.entity.monster.EntitySkeleton import net.minecraft.entity.passive.EntityBat import net.minecraft.event.ClickEvent import net.minecraft.event.HoverEvent +import net.minecraft.init.Blocks import net.minecraft.init.Items import net.minecraft.inventory.ContainerChest import net.minecraft.item.EnumDyeColor import net.minecraft.item.ItemSkull -import net.minecraft.network.play.server.S29PacketSoundEffect -import net.minecraft.network.play.server.S45PacketTitle +import net.minecraft.network.play.server.* import net.minecraft.potion.Potion import net.minecraft.util.AxisAlignedBB import net.minecraft.util.BlockPos @@ -97,9 +97,40 @@ class DungeonFeatures { private var alertedSpiritPet = false private const val SPIRIT_PET_TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTU5NTg2MjAyNjE5OSwKICAicHJvZmlsZUlkIiA6ICI0ZWQ4MjMzNzFhMmU0YmI3YTVlYWJmY2ZmZGE4NDk1NyIsCiAgInByb2ZpbGVOYW1lIiA6ICJGaXJlYnlyZDg4IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzhkOWNjYzY3MDY3N2QwY2ViYWFkNDA1OGQ2YWFmOWFjZmFiMDlhYmVhNWQ4NjM3OWEwNTk5MDJmMmZlMjI2NTUiCiAgICB9CiAgfQp9" + private var lastLitUpTime = -1L + private val lastBlockPos = BlockPos(207, 77, 234) init { LividGuiElement() + SpiritBearSpawnTimer() + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + fun onReceivePacketHighest(event: ReceiveEvent) { + event.apply { + if (hasBossSpawned && Skytils.config.spiritBearTimer && dungeonFloor?.endsWith('4') == true) { + when (packet) { + is S23PacketBlockChange -> { + if (packet.blockPosition == lastBlockPos) { + val time = System.currentTimeMillis() + lastLitUpTime = if (packet.blockState.block === Blocks.sea_lantern) time else -1L + printDevMessage("light $lastLitUpTime", "spiritbear") + } + } + is S02PacketChat -> { + if (lastLitUpTime != -1L && DevTools.getToggle("spiritbear") && packet.chatComponent.formattedText == "§r§a§lA §r§5§lSpirit Bear §r§a§lhas appeared!§r") { + UChat.chat("chat ${System.currentTimeMillis() - lastLitUpTime}") + lastLitUpTime = -1L + } + } + is S0CPacketSpawnPlayer -> { + if (lastLitUpTime != -1L) { + printDevMessage("spawn ${System.currentTimeMillis() - lastLitUpTime}", "spiritbear") + } + } + } + } } } @@ -543,6 +574,51 @@ class DungeonFeatures { livid = null foundLivid = false alertedSpiritPet = false + lastLitUpTime = -1L + } + + class SpiritBearSpawnTimer : GuiElement("Spirit Bear Spawn Timer", FloatPair(0.05f, 0.4f)) { + override fun render() { + if (toggled && hasBossSpawned && dungeonFloor?.endsWith('4') == true) { + val sr = UResolution + val leftAlign = actualX < sr.scaledWidth / 2f + val alignment = if (leftAlign) TextAlignment.LEFT_RIGHT else TextAlignment.RIGHT_LEFT + ScreenRenderer.fontRenderer.drawString( + "Spirit Bear ${System.currentTimeMillis() - lastLitUpTime + 3400}", + if (leftAlign) 0f else width.toFloat(), + 0f, + CommonColors.PURPLE, + alignment, + SmartFontRenderer.TextShadow.NORMAL + ) + } + } + + override fun demoRender() { + val sr = UResolution + val leftAlign = actualX < sr.scaledWidth / 2f + val alignment = if (leftAlign) TextAlignment.LEFT_RIGHT else TextAlignment.RIGHT_LEFT + ScreenRenderer.fontRenderer.drawString( + "Spirit Bear: 3400ms", + if (leftAlign) 0f else 0f + width, + 0f, + CommonColors.PURPLE, + alignment, + SmartFontRenderer.TextShadow.NORMAL + ) + } + + override val height: Int + get() = ScreenRenderer.fontRenderer.FONT_HEIGHT + override val width: Int + get() = ScreenRenderer.fontRenderer.getStringWidth("Spirit Bear: 3400ms") + + override val toggled: Boolean + get() = Skytils.config.spiritBearTimer + + init { + Skytils.guiManager.registerElement(this) + } } internal class LividGuiElement : GuiElement("Livid HP", FloatPair(0.05f, 0.4f)) { |