aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-07-20 12:02:02 -0500
committeringlettronald <inglettronald@gmail.com>2023-07-20 12:02:02 -0500
commit253a9bffcf3a3f8f99bb426b7b6d8031e73c82ba (patch)
tree3509e61375e3df362a48a9b044d82d11d8fff62d /src/main/kotlin
parent261370d3539579b23f3cf07733d310e9ff35becb (diff)
downloadDulkirMod-Fabric-253a9bffcf3a3f8f99bb426b7b6d8031e73c82ba.tar.gz
DulkirMod-Fabric-253a9bffcf3a3f8f99bb426b7b6d8031e73c82ba.tar.bz2
DulkirMod-Fabric-253a9bffcf3a3f8f99bb426b7b6d8031e73c82ba.zip
Ported some arachne features from 1.8
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt1
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt10
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt83
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt67
4 files changed, 160 insertions, 1 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index 669edb1..135b6af 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -67,6 +67,7 @@ object Registrations {
EVENT_BUS.subscribe(TablistUtils)
EVENT_BUS.subscribe(CullExplosionParticles)
EVENT_BUS.subscribe(CooldownDisplays)
+ EVENT_BUS.subscribe(ArachneFeatures)
}
fun registerEvents() {
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index a3a73aa..d8beafe 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -113,6 +113,12 @@ class DulkirConfig {
.setTooltip(Text.literal("Set to 0 to disable. (Time in seconds)"))
.build()
)
+ general.addEntry(
+ entryBuilder.mkToggle(Text.literal("Arachne Keeper Waypoints"), configOptions::arachneKeeperWaypoints)
+ )
+ general.addEntry(
+ entryBuilder.mkToggle(Text.literal("Arachne Boss Spawn Timer"), configOptions::arachneSpawnTimer)
+ )
val shortcuts = builder.getOrCreateCategory(Text.literal("Shortcuts"))
shortcuts.addEntry(
@@ -234,7 +240,9 @@ class DulkirConfig {
var handSwingDuration: Int = 6,
var cancelReEquip: Boolean = false,
var duraCooldown: Boolean = false,
- var alarmTimeout: Int = 300
+ var alarmTimeout: Int = 300,
+ var arachneKeeperWaypoints: Boolean = false,
+ var arachneSpawnTimer: Boolean = false
)
@Serializable
diff --git a/src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt b/src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt
new file mode 100644
index 0000000..be8ad51
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt
@@ -0,0 +1,83 @@
+package com.dulkirfabric.features
+
+import com.dulkirfabric.config.DulkirConfig
+import com.dulkirfabric.events.WorldRenderLastEvent
+import com.dulkirfabric.events.chat.ChatReceivedEvent
+import com.dulkirfabric.util.TablistUtils
+import com.dulkirfabric.util.TextUtils
+import com.dulkirfabric.util.TextUtils.unformattedString
+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 ArachneFeatures {
+
+ private val keeperWaypoints: Set<POI> = setOf(
+ POI(Vec3d(-208.5, 44.5, -259.5), Text.literal("1").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-311.5, 43.5, -232.5), Text.literal("2").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-230.5, 57.5, -307.5), Text.literal("3").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-269.5, 47.5, -166.5), Text.literal("4").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-292.5, 47.5, -167.5), Text.literal("5").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-291.5, 47.5, -183.5), Text.literal("6").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-282.5, 47.5, -195.5), Text.literal("7").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-262.5, 49.5, -191.5), Text.literal("8").setStyle(Style.EMPTY.withColor(Formatting.GOLD))),
+ POI(Vec3d(-269.5, 61.5, -159.5), Text.literal("9").setStyle(Style.EMPTY.withColor(Formatting.GOLD)))
+ )
+
+ data class POI(val pos: Vec3d, val name: Text)
+
+ private val spawnRegex = "\\[BOSS] Arachne: (With your sacrifice.)|(A befitting welcome!)".toRegex()
+
+ private var startmillis: Long = -1
+ private var endmillis: Long = -1
+ private var spawnmillis: Long = -1
+ private var bigboy: Boolean = false
+ @EventHandler
+ fun onRenderWorldLast(event: WorldRenderLastEvent) {
+ if (TablistUtils.area != "Spider's Den") return
+ if (!DulkirConfig.configOptions.arachneKeeperWaypoints) return
+ keeperWaypoints.forEach {
+ WorldRenderUtils.renderWaypoint(it.name, event.context, it.pos)
+ }
+ }
+
+ @EventHandler
+ fun onChat(event: ChatReceivedEvent) {
+ if (!DulkirConfig.configOptions.arachneSpawnTimer) return
+ if (TablistUtils.area != "Spider's Den") return
+ val str = event.message.unformattedString.trim()
+ if (str matches spawnRegex) {
+ bigboy = false
+ startmillis = System.currentTimeMillis()
+ } else if (str.startsWith('☄') && str.contains("Something is awakening!")) {
+ if (str.contains("Arachne Crystal!")) bigboy = true
+ spawnmillis = System.currentTimeMillis()
+ } else if (str.startsWith("Runecrafting:")) {
+ endmillis = System.currentTimeMillis()
+ if (startmillis > -1) {
+ val killtime = (endmillis - startmillis).toFloat() / 1000
+ TextUtils.info("§6Arachne took §7$killtime §6seconds to kill.")
+ }
+ }
+ }
+
+ @EventHandler
+ fun onWorldRenderLast(event: WorldRenderLastEvent) {
+ if (!DulkirConfig.configOptions.arachneSpawnTimer) return
+ if (TablistUtils.area != "Spider's Den") return
+ if (spawnmillis <=startmillis) return
+
+ var time: Int = if (bigboy) {
+ (40 - (System.currentTimeMillis() - spawnmillis) / 1000).toInt()
+ } else {
+ (18 - (System.currentTimeMillis() - spawnmillis) / 1000).toInt()
+ }
+ if (time < 0) time = 0
+ WorldRenderUtils.drawText(Text.literal(time.toString()).setStyle(Style.EMPTY.withColor(Formatting.LIGHT_PURPLE)),
+ event.context, Vec3d(-282.5, 50.8, -178.5))
+ }
+
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt b/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt
index 9f25ab4..c8ec492 100644
--- a/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt
@@ -202,6 +202,73 @@ object WorldRenderUtils {
matrices.pop()
}
+ /**
+ * If you intend to show with distance, use a waypoint I think. If you're looking at this
+ * statement and screaming at me for forgetting some use case, either let me know or compile
+ * a method that accomplishes your goals based off of this example code. Neither of these
+ * things should be incredibly difficult.
+ */
+ fun drawText(
+ text: Text,
+ context: WorldRenderContext,
+ pos: Vec3d,
+ depthTest: Boolean = true,
+ scale: Float = 1f
+ ) {
+ if (depthTest) {
+ RenderSystem.disableDepthTest()
+ }
+ RenderSystem.enableBlend()
+ RenderSystem.defaultBlendFunc()
+ RenderSystem.disableCull()
+
+ val vertexConsumer = context.worldRenderer().bufferBuilders.entityVertexConsumers
+ val matrices = context.matrixStack()
+ matrices.push()
+ matrices.translate(
+ pos.x - context.camera().pos.x,
+ pos.y - context.camera().pos.y,
+ pos.z - context.camera().pos.z
+ )
+ matrices.multiply(context.camera().rotation)
+ matrices.scale(-.025f * scale, -.025f * scale, -1F)
+ val matrix4f = matrices.peek().positionMatrix
+ val textRenderer = MinecraftClient.getInstance().textRenderer
+ val j: Int = (.25 * 255.0f).toInt() shl 24
+ val buf = vertexConsumer.getBuffer(RenderLayer.getTextBackgroundSeeThrough())
+ buf.vertex(matrix4f, -1.0f - textRenderer.getWidth(text) / 2, -1.0f, 0.0f)
+ .color(j)
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
+ .next()
+ buf.vertex(matrix4f, -1.0f - textRenderer.getWidth(text) / 2, textRenderer.fontHeight.toFloat(), 0.0f)
+ .color(j)
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
+ .next()
+ buf.vertex(matrix4f, textRenderer.getWidth(text).toFloat() / 2, textRenderer.fontHeight.toFloat(), 0.0f)
+ .color(j)
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
+ .next()
+ buf.vertex(matrix4f, textRenderer.getWidth(text).toFloat() / 2, -1.0f, 0.0f)
+ .color(j)
+ .light(LightmapTextureManager.MAX_BLOCK_LIGHT_COORDINATE)
+ .next()
+
+ matrices.translate(0F, 0F, 0.01F)
+
+ textRenderer.draw(
+ text, -textRenderer.getWidth(text).toFloat() / 2, 0f, 0xFFFFFF, false, matrix4f, vertexConsumer,
+ TextRenderer.TextLayerType.SEE_THROUGH,
+ 0, LightmapTextureManager.MAX_LIGHT_COORDINATE
+ )
+
+ vertexConsumer.drawCurrentLayer()
+ matrices.pop()
+ RenderSystem.setShaderColor(1F, 1F, 1F, 1F)
+ RenderSystem.enableDepthTest()
+ RenderSystem.enableCull()
+ RenderSystem.disableBlend()
+ }
+
fun renderWaypoint(
text: Text,
context: WorldRenderContext,