diff options
Diffstat (limited to 'src')
7 files changed, 115 insertions, 9 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index 0bb39e2..d8dea01 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -4,15 +4,13 @@ import com.dulkirfabric.DulkirModFabric.EVENT_BUS import com.dulkirfabric.commands.ConfigCommand import com.dulkirfabric.commands.DynamicKeyCommand import com.dulkirfabric.commands.JoinDungeonCommands -import com.dulkirfabric.events.BlockOutlineEvent -import com.dulkirfabric.events.ClientTickEvent -import com.dulkirfabric.events.MouseScrollEvent -import com.dulkirfabric.events.WorldRenderLastEvent +import com.dulkirfabric.events.* import com.dulkirfabric.events.chat.ChatReceivedEvent import com.dulkirfabric.events.chat.ModifyCommandEvent import com.dulkirfabric.events.chat.OverlayReceivedEvent import com.dulkirfabric.features.* import com.dulkirfabric.features.chat.AbiPhoneDND +import com.dulkirfabric.util.TablistUtils import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents @@ -27,6 +25,7 @@ import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents * purposes, as the list of features is planned to be quite large. */ object Registrations { + private var tickCount: Int = 0 fun registerCommands() { val cre = ClientCommandRegistrationCallback.EVENT @@ -57,12 +56,18 @@ object Registrations { EVENT_BUS.subscribe(AbiPhoneDND) EVENT_BUS.subscribe(InventoryScale) EVENT_BUS.subscribe(AliasImpl) + EVENT_BUS.subscribe(EffigyDisplay) + EVENT_BUS.subscribe(TablistUtils) } fun registerEvents() { // Register Custom Tick event, so we can use it like 1.8.9 forge ClientTickEvents.START_CLIENT_TICK.register( - ClientTickEvents.StartTick { _ -> ClientTickEvent.post() } + ClientTickEvents.StartTick { _ -> + ClientTickEvent.post() + if (tickCount % 20 == 0) LongUpdateEvent.post() + tickCount++ + } ) ClientReceiveMessageEvents.ALLOW_GAME.register( ClientReceiveMessageEvents.AllowGame { message, overlay -> diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt index 408d180..c9fd0dd 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -98,6 +98,9 @@ class DulkirConfig { general.addEntry( entryBuilder.mkToggle(Text.literal("AbiPhone Caller ID"), configOptions::abiPhoneCallerID) ) + general.addEntry( + entryBuilder.mkToggle(Text.literal("Inactive Effigy Waypoints"), configOptions::inactiveEffigyDisplay) + ) val shortcuts = builder.getOrCreateCategory(Text.literal("Shortcuts")) shortcuts.addEntry( @@ -152,7 +155,8 @@ class DulkirConfig { var abiPhoneDND: Boolean = false, var abiPhoneCallerID: Boolean = false, var tooltipScale: Float = 1f, - var statusEffectHidden: Boolean = false + var statusEffectHidden: Boolean = false, + var inactiveEffigyDisplay: Boolean = false ) @Serializable diff --git a/src/main/kotlin/com/dulkirfabric/events/LongUpdateEvent.kt b/src/main/kotlin/com/dulkirfabric/events/LongUpdateEvent.kt new file mode 100644 index 0000000..c56cd0b --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/events/LongUpdateEvent.kt @@ -0,0 +1,8 @@ +package com.dulkirfabric.events + +import com.dulkirfabric.events.base.Event + +/** + * Utility event for tasks that only run 1 time per second + */ +object LongUpdateEvent: Event()
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt b/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt new file mode 100644 index 0000000..9e8c75f --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt @@ -0,0 +1,61 @@ +package com.dulkirfabric.features + +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.LongUpdateEvent +import com.dulkirfabric.events.WorldRenderLastEvent +import com.dulkirfabric.util.ScoreBoardUtils +import com.dulkirfabric.util.TablistUtils +import com.dulkirfabric.util.Utils +import com.dulkirfabric.util.WorldRenderUtils +import meteordevelopment.orbit.EventHandler +import net.minecraft.text.Style +import net.minecraft.text.Text +import net.minecraft.util.Formatting +import net.minecraft.util.math.Vec3d + +object EffigyDisplay { + private var effigyWaypoints = arrayOf( + Effigy(Vec3d(150.5, 76.0, 95.5)), + Effigy(Vec3d(193.5, 90.0, 119.5)), + Effigy(Vec3d(235.5, 107.0, 147.5)), + Effigy(Vec3d(293.5, 93.0, 134.5)), + Effigy(Vec3d(262.5, 96.0, 94.5)), + Effigy(Vec3d(240.5, 126.0, 118.5)) + ) + + private val c7OnlyRegex = Regex("[^c7]") + + @EventHandler + fun onRender(event: WorldRenderLastEvent) { + // if we have any waypoints that need rendering, Do so. + for (effigy in effigyWaypoints) { + if (effigy.render) { + WorldRenderUtils.renderWaypoint( + Text.literal("Inactive").setStyle(Style.EMPTY.withColor(Formatting.GOLD)), event.context, effigy.coords + ) + } + } + } + @EventHandler + fun checkEffigies(event: LongUpdateEvent) { + if (!DulkirConfig.configOptions.inactiveEffigyDisplay) return + if (!Utils.isInSkyblock()) return + if (TablistUtils.area != "The Rift") { + effigyWaypoints.forEach { it.render = false } + return + } + val lines = ScoreBoardUtils.getLinesWithColor() ?: return + if (lines.size <= 7) return + if (!lines[3].contains("Stillgore")) return + val effigyStatusLine = lines[6].replace(c7OnlyRegex, "").substring(1) + if (effigyStatusLine.length != 6) return + for (i in 0..5) { + effigyWaypoints[i].render = (effigyStatusLine[i] == '7') + } + } + + /** + * data class for storing the effigy coordinates and whether they need to be rendered + */ + data class Effigy(val coords: Vec3d, var render: Boolean = false) +}
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt index 93c4ad9..8ad270d 100644 --- a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt +++ b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt @@ -12,10 +12,9 @@ object RenderTest { @EventHandler fun onRender(event: WorldRenderLastEvent) { - WorldRenderUtils.renderWaypoint( Text.literal("Home Base").setStyle(Style.EMPTY.withColor(Color(255, 100, 150, 255).rgb)), event.context, - Vec3d(-183.5, 79.0, -465.5), false + Vec3d(-183.5, 79.0, -465.5) ) } }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt new file mode 100644 index 0000000..a0999f6 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/util/TablistUtils.kt @@ -0,0 +1,28 @@ +package com.dulkirfabric.util + +import com.dulkirfabric.DulkirModFabric.mc +import com.dulkirfabric.events.LongUpdateEvent +import meteordevelopment.orbit.EventHandler +import net.minecraft.client.network.PlayerListEntry + +object TablistUtils { + var tablist: List<PlayerListEntry>? = null + private val areaPattern = "Area: (.+)".toRegex() + var area: String = "" + + @EventHandler + fun onLongUpdate(event: LongUpdateEvent) { + if (mc.player == null) return + tablist = mc.inGameHud.playerListHud.collectPlayerEntries() + area = updateArea() + } + + private fun updateArea(): String { + if (tablist == null) return "" + tablist!!.forEach { + val match = areaPattern.find(it.displayName?.string ?: return@forEach) ?: return@forEach + return match.groupValues[1] + } + return "" + } +}
\ No newline at end of file diff --git a/src/main/resources/dulkirmod.accesswidener b/src/main/resources/dulkirmod.accesswidener index 548d92b..3497be0 100644 --- a/src/main/resources/dulkirmod.accesswidener +++ b/src/main/resources/dulkirmod.accesswidener @@ -1,2 +1,3 @@ accessWidener v2 named -accessible field net/minecraft/client/render/WorldRenderer bufferBuilders Lnet/minecraft/client/render/BufferBuilderStorage;
\ No newline at end of file +accessible field net/minecraft/client/render/WorldRenderer bufferBuilders Lnet/minecraft/client/render/BufferBuilderStorage; +accessible method net/minecraft/client/gui/hud/PlayerListHud collectPlayerEntries ()Ljava/util/List;
\ No newline at end of file |