aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric')
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt6
-rw-r--r--src/main/kotlin/com/dulkirfabric/commands/AnimationCommand.kt5
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt24
-rw-r--r--src/main/kotlin/com/dulkirfabric/events/HudRenderEvent.kt9
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt2
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/RenderTest.kt8
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt35
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/render/AnimationPreset.kt (renamed from src/main/kotlin/com/dulkirfabric/util/AnimationPreset.kt)2
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/render/GlowingEntityInterface.kt (renamed from src/main/kotlin/com/dulkirfabric/util/GlowingEntityInterface.kt)6
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/render/HudRenderUtil.kt41
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/render/ItemChangeHandler.kt (renamed from src/main/kotlin/com/dulkirfabric/util/ItemChangeHandler.kt)2
-rw-r--r--src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt (renamed from src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt)2
14 files changed, 125 insertions, 21 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index ffcf85f..04eb9d8 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -8,12 +8,14 @@ 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.features.chat.BridgeBotFormatter
import com.dulkirfabric.util.TablistUtils
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents
import net.fabricmc.fabric.api.client.message.v1.ClientSendMessageEvents
+import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents
@@ -66,6 +68,7 @@ object Registrations {
EVENT_BUS.subscribe(CullExplosionParticles)
EVENT_BUS.subscribe(CooldownDisplays)
EVENT_BUS.subscribe(ArachneFeatures)
+ EVENT_BUS.subscribe(BridgeBotFormatter)
}
fun registerEvents() {
@@ -104,5 +107,8 @@ object Registrations {
ServerWorldEvents.LOAD.register { server, world ->
WorldLoadEvent(server, world).post()
}
+ HudRenderCallback.EVENT.register { context, delta ->
+ HudRenderEvent(context, delta).post()
+ }
}
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/commands/AnimationCommand.kt b/src/main/kotlin/com/dulkirfabric/commands/AnimationCommand.kt
index 34da0cb..39a9f11 100644
--- a/src/main/kotlin/com/dulkirfabric/commands/AnimationCommand.kt
+++ b/src/main/kotlin/com/dulkirfabric/commands/AnimationCommand.kt
@@ -1,14 +1,11 @@
package com.dulkirfabric.commands
import com.dulkirfabric.config.DulkirConfig
-import com.dulkirfabric.util.AnimationPreset
+import com.dulkirfabric.util.render.AnimationPreset
import com.dulkirfabric.util.TextUtils
import com.google.gson.Gson
import com.mojang.brigadier.CommandDispatcher
-import com.mojang.brigadier.arguments.StringArgumentType
import com.mojang.brigadier.builder.LiteralArgumentBuilder
-import com.mojang.brigadier.builder.RequiredArgumentBuilder
-import me.shedaniel.autoconfig.ConfigData
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.command.CommandRegistryAccess
import java.awt.Toolkit
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index 2795668..06b19ad 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -17,7 +17,7 @@ import com.dulkirfabric.DulkirModFabric.mc
import com.dulkirfabric.config.ConfigHelper.mkKeyField
import com.dulkirfabric.config.ConfigHelper.mkStringField
import com.dulkirfabric.config.ConfigHelper.mkToggle
-import com.dulkirfabric.util.AnimationPreset
+import com.dulkirfabric.util.render.AnimationPreset
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
import kotlinx.serialization.decodeFromString
@@ -169,7 +169,7 @@ class DulkirConfig {
)
animations.addEntry(
entryBuilder.startIntSlider(Text.literal("posY"), configOptions.animationPreset.posY, -150, 150)
- .setSaveConsumer { newValue -> configOptions.animationPreset.posZ = newValue }
+ .setSaveConsumer { newValue -> configOptions.animationPreset.posY = newValue }
.setDefaultValue(0)
.build()
)
@@ -219,6 +219,21 @@ class DulkirConfig {
.build()
)
+ val bridge = builder.getOrCreateCategory(Text.literal("Bridge Features"))
+
+ bridge.addEntry(
+ entryBuilder.mkToggle(Text.literal("Format Bridge Messages"), configOptions::bridgeFormatter)
+ )
+ bridge.addEntry(
+ entryBuilder.mkStringField(Text.literal("Bridge Bot IGN"), configOptions::bridgeBotName)
+ )
+ bridge.addEntry(
+ entryBuilder.startColorField(Text.literal("Bridge User Color"), configOptions.bridgeNameColor)
+ .setDefaultValue(Formatting.GOLD.colorValue!!)
+ .setSaveConsumer { newValue -> configOptions.bridgeNameColor = newValue }
+ .build()
+ )
+
builder.transparentBackground()
screen = builder.build()
}
@@ -246,7 +261,10 @@ class DulkirConfig {
var duraCooldown: Boolean = false,
var alarmTimeout: Int = 300,
var arachneKeeperWaypoints: Boolean = false,
- var arachneSpawnTimer: Boolean = false
+ var arachneSpawnTimer: Boolean = false,
+ var bridgeFormatter: Boolean = false,
+ var bridgeBotName: String = "Dilkur",
+ var bridgeNameColor: Int = Formatting.GOLD.colorValue!!
)
@Serializable
diff --git a/src/main/kotlin/com/dulkirfabric/events/HudRenderEvent.kt b/src/main/kotlin/com/dulkirfabric/events/HudRenderEvent.kt
new file mode 100644
index 0000000..51895ee
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/events/HudRenderEvent.kt
@@ -0,0 +1,9 @@
+package com.dulkirfabric.events
+
+import com.dulkirfabric.events.base.Event
+import net.minecraft.client.gui.DrawContext
+
+data class HudRenderEvent(
+ val context: DrawContext,
+ val delta: Float
+): Event()
diff --git a/src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt b/src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt
index be8ad51..695e610 100644
--- a/src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/ArachneFeatures.kt
@@ -6,7 +6,7 @@ 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 com.dulkirfabric.util.render.WorldRenderUtils
import meteordevelopment.orbit.EventHandler
import net.minecraft.text.Style
import net.minecraft.text.Text
diff --git a/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt b/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
index df306e1..3aa3121 100644
--- a/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/CustomBlockOutline.kt
@@ -3,7 +3,7 @@ package com.dulkirfabric.features
import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.BlockOutlineEvent
import com.dulkirfabric.util.ColorUtil
-import com.dulkirfabric.util.WorldRenderUtils
+import com.dulkirfabric.util.render.WorldRenderUtils
import meteordevelopment.orbit.EventHandler
import net.minecraft.util.math.Box
diff --git a/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt b/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt
index 9e8c75f..257a200 100644
--- a/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/EffigyDisplay.kt
@@ -6,7 +6,7 @@ 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 com.dulkirfabric.util.render.WorldRenderUtils
import meteordevelopment.orbit.EventHandler
import net.minecraft.text.Style
import net.minecraft.text.Text
diff --git a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt
index 4799e0c..3cc489d 100644
--- a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt
@@ -2,8 +2,7 @@ package com.dulkirfabric.features
import com.dulkirfabric.events.EntityLoadEvent
import com.dulkirfabric.events.WorldRenderLastEvent
-import com.dulkirfabric.util.GlowingEntityInterface
-import com.dulkirfabric.util.WorldRenderUtils
+import com.dulkirfabric.util.render.WorldRenderUtils
import meteordevelopment.orbit.EventHandler
import net.minecraft.text.Style
import net.minecraft.text.Text
@@ -23,11 +22,12 @@ object RenderTest {
// if (it is GlowingEntityInterface)
// it.setDulkirEntityGlow(true, Color(255, 255, 255, 255), Random(it.id).nextBoolean())
// }
+ //HudRenderUtil.drawTitle(event.context, Text.literal("Hello World!"))
}
@EventHandler
fun onLoadEnt(event: EntityLoadEvent) {
- if (event.entity !is GlowingEntityInterface) return
- event.entity.setDulkirEntityGlow(true, Color(0, 0, 255, 255),false)
+ //if (event.entity !is GlowingEntityInterface) return
+ //event.entity.setDulkirEntityGlow(true, Color(0, 0, 255, 255),false)
}
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt b/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt
new file mode 100644
index 0000000..f956791
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt
@@ -0,0 +1,35 @@
+package com.dulkirfabric.features.chat
+
+import com.dulkirfabric.config.DulkirConfig
+import com.dulkirfabric.events.chat.ChatReceivedEvent
+import com.dulkirfabric.util.TextUtils
+import com.dulkirfabric.util.Utils
+import meteordevelopment.orbit.EventHandler
+import net.minecraft.text.Style
+import net.minecraft.text.Text
+import net.minecraft.util.Formatting
+
+object BridgeBotFormatter {
+ private val bridgeRegex: Regex = "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9][[A-Z]+])?§f: ([^>]+)(?: >| »|:) (.+)".toRegex()
+
+ @EventHandler
+ fun onChat(event: ChatReceivedEvent) {
+ if (!DulkirConfig.configOptions.bridgeFormatter) return
+
+ val message = event.message.string
+ if (bridgeRegex matches message) {
+ val matchResult = bridgeRegex.find(message)
+ val (prefix, name, playerName) = matchResult!!.destructured
+ if (TextUtils.stripColorCodes(name).equals(DulkirConfig.configOptions.bridgeBotName, ignoreCase = true)) {
+ val newPrefix = if (prefix == "§2Guild") "§2Bridge" else "§3Bridge"
+ event.message.siblings[0] = Text.literal(
+ "$newPrefix > "
+ ).append(Text.literal(playerName).setStyle(Style.EMPTY.withColor(DulkirConfig.configOptions.bridgeNameColor)))
+ .append(": ")
+ event.message.siblings[1] = Text.literal(
+ event.message.siblings[1].string.replace("$playerName > ", "")
+ ).setStyle(event.message.siblings[1].style)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/util/AnimationPreset.kt b/src/main/kotlin/com/dulkirfabric/util/render/AnimationPreset.kt
index 67f5b00..af4388b 100644
--- a/src/main/kotlin/com/dulkirfabric/util/AnimationPreset.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/render/AnimationPreset.kt
@@ -1,4 +1,4 @@
-package com.dulkirfabric.util
+package com.dulkirfabric.util.render
import kotlinx.serialization.Serializable
diff --git a/src/main/kotlin/com/dulkirfabric/util/GlowingEntityInterface.kt b/src/main/kotlin/com/dulkirfabric/util/render/GlowingEntityInterface.kt
index 9b129fd..3033d19 100644
--- a/src/main/kotlin/com/dulkirfabric/util/GlowingEntityInterface.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/render/GlowingEntityInterface.kt
@@ -1,13 +1,11 @@
-package com.dulkirfabric.util
+package com.dulkirfabric.util.render
import java.awt.Color
interface GlowingEntityInterface {
- fun setDulkirEntityGlow(shouldGlow: Boolean = false, glowColor: Color, shouldESP: Boolean = false)
+ fun setDulkirEntityGlow(shouldGlow: Boolean = false, glowColor: Color)
fun shouldDulkirEntityGlow() : Boolean
fun getDulkirEntityGlowColor() : Color?
-
- fun shouldDulkirEntityESP() : Boolean
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/util/render/HudRenderUtil.kt b/src/main/kotlin/com/dulkirfabric/util/render/HudRenderUtil.kt
new file mode 100644
index 0000000..e055b60
--- /dev/null
+++ b/src/main/kotlin/com/dulkirfabric/util/render/HudRenderUtil.kt
@@ -0,0 +1,41 @@
+package com.dulkirfabric.util.render
+
+import com.dulkirfabric.DulkirModFabric.mc
+import com.dulkirfabric.events.HudRenderEvent
+import meteordevelopment.orbit.EventHandler
+import net.minecraft.client.gui.DrawContext
+import net.minecraft.text.Text
+import java.time.Duration
+
+object HudRenderUtil {
+
+ private var curTitle: Text? = null
+ private var clearTime: Long = -1
+
+ private fun drawTitle(context: DrawContext, content: Text) {
+ val matrices = context.matrices
+ val tr = mc.textRenderer
+ val w = tr.getWidth(content)
+ val sf: Float = mc.window.scaledWidth / w.toFloat() / 3
+ matrices.push()
+ matrices.translate(mc.window.scaledWidth / 3f, mc.window.scaledHeight / 2f, 0f)
+ matrices.scale(sf, sf, 1f)
+ context.drawText(tr, content, 0, -tr.fontHeight / 2, -1, true)
+ matrices.pop()
+ }
+
+ fun drawTitle(content: Text, duration: Duration) {
+ curTitle = content
+ clearTime = System.currentTimeMillis() + duration.toMillis()
+ }
+
+ @EventHandler
+ fun onHudRender(event: HudRenderEvent) {
+ val content = curTitle ?: return
+ if (System.currentTimeMillis() >= clearTime) {
+ curTitle = null
+ return
+ }
+ drawTitle(event.context, content)
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/util/ItemChangeHandler.kt b/src/main/kotlin/com/dulkirfabric/util/render/ItemChangeHandler.kt
index 7a98f7f..7f6193e 100644
--- a/src/main/kotlin/com/dulkirfabric/util/ItemChangeHandler.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/render/ItemChangeHandler.kt
@@ -1,4 +1,4 @@
-package com.dulkirfabric.util
+package com.dulkirfabric.util.render
import com.dulkirfabric.events.TooltipRenderChangeEvent
diff --git a/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt
index c8ec492..ceb631d 100644
--- a/src/main/kotlin/com/dulkirfabric/util/WorldRenderUtils.kt
+++ b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt
@@ -1,4 +1,4 @@
-package com.dulkirfabric.util
+package com.dulkirfabric.util.render
import com.mojang.blaze3d.systems.RenderSystem
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext