diff options
-rw-r--r-- | .kotlin/errors/errors-1729354010601.log | 4 | ||||
-rw-r--r-- | build.gradle.kts | 1 | ||||
-rw-r--r-- | root.gradle.kts | 3 | ||||
-rw-r--r-- | src/main/kotlin/AllModules.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/Constants.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/event/TickEvent.kt | 6 | ||||
-rw-r--r-- | src/main/kotlin/event/UltraEvent.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/event/UltraNotifierEvents.kt | 5 | ||||
-rw-r--r-- | src/main/kotlin/gui/MessageUi.kt | 26 | ||||
-rw-r--r-- | src/main/kotlin/util/identifierutil.kt | 11 | ||||
-rw-r--r-- | src/main/kotlin/util/render/ScreenRenderUtils.kt | 39 | ||||
-rw-r--r-- | src/main/resources/assets/ultranotifier/textures/gui/square_panel.png | bin | 0 -> 711 bytes |
12 files changed, 80 insertions, 23 deletions
diff --git a/.kotlin/errors/errors-1729354010601.log b/.kotlin/errors/errors-1729354010601.log new file mode 100644 index 0000000..7cd151b --- /dev/null +++ b/.kotlin/errors/errors-1729354010601.log @@ -0,0 +1,4 @@ +kotlin version: 2.0.20 +error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output: + 1. Kotlin compile daemon is ready + diff --git a/build.gradle.kts b/build.gradle.kts index aedae03..43ceec2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { id("java") kotlin("jvm") + id("com.google.devtools.ksp") id("com.github.johnrengelman.shadow") } diff --git a/root.gradle.kts b/root.gradle.kts index dc2911a..94f4f55 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -4,7 +4,8 @@ import moe.nea.sharedbuild.Versions plugins { id("dev.deftu.gradle.preprocess") version "0.7.1" // id("fabric-loom") version "1.6-SNAPSHOT" apply false - kotlin("jvm") version "1.9.23" apply false + kotlin("jvm") version "2.0.20" apply false + id("com.google.devtools.ksp") version "2.0.20-1.0.24" apply false id("gg.essential.loom") version "1.6.+" apply false id("dev.architectury.architectury-pack200") version "0.1.3" id("com.github.johnrengelman.shadow") version "8.1.1" apply false diff --git a/src/main/kotlin/AllModules.kt b/src/main/kotlin/AllModules.kt index 1626bea..0e10687 100644 --- a/src/main/kotlin/AllModules.kt +++ b/src/main/kotlin/AllModules.kt @@ -2,6 +2,7 @@ package moe.nea.ultranotifier import moe.nea.ultranotifier.commands.Commands import moe.nea.ultranotifier.event.SubscriptionTarget +import moe.nea.ultranotifier.event.TickEvent import moe.nea.ultranotifier.gui.ScreenUtil object AllModules { @@ -9,5 +10,6 @@ object AllModules { ChatStore, Commands, ScreenUtil, + TickEvent, ) } diff --git a/src/main/kotlin/Constants.kt b/src/main/kotlin/Constants.kt index d29d106..46d4236 100644 --- a/src/main/kotlin/Constants.kt +++ b/src/main/kotlin/Constants.kt @@ -29,5 +29,9 @@ object Constants { //$$ "1.16.5" //#elseif MC == 11602 //$$ "1.16.2" +//#elseif MC == 12100 +//$$ "1.21" +//#elseif MC == 12101 +//$$ "1.21.1" //#endif } diff --git a/src/main/kotlin/event/TickEvent.kt b/src/main/kotlin/event/TickEvent.kt index 8643261..4bd2c6c 100644 --- a/src/main/kotlin/event/TickEvent.kt +++ b/src/main/kotlin/event/TickEvent.kt @@ -4,10 +4,10 @@ package moe.nea.ultranotifier.event import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents //#endif -class TickEvent : UltraEvent() { +class TickEvent : UltraEvent(), UltraEvent.Silent<TickEvent> { - companion object { - init { + companion object : SubscriptionTarget { + override fun init() { //#if FABRIC ClientTickEvents.END_CLIENT_TICK.register(ClientTickEvents.EndTick { TickEvent().post() diff --git a/src/main/kotlin/event/UltraEvent.kt b/src/main/kotlin/event/UltraEvent.kt index 4f615c1..80f63fc 100644 --- a/src/main/kotlin/event/UltraEvent.kt +++ b/src/main/kotlin/event/UltraEvent.kt @@ -7,6 +7,8 @@ abstract class UltraEvent : me.bush.eventbus.event.Event() //#endif { + interface Silent<T> where T : Silent<T>, T : UltraEvent + //#if FORGE //$$ override fun isCancelable(): Boolean { //$$ return this.isCancellable() diff --git a/src/main/kotlin/event/UltraNotifierEvents.kt b/src/main/kotlin/event/UltraNotifierEvents.kt index 7190b63..9c1e1ee 100644 --- a/src/main/kotlin/event/UltraNotifierEvents.kt +++ b/src/main/kotlin/event/UltraNotifierEvents.kt @@ -9,9 +9,12 @@ object UltraNotifierEvents { //#else me.bush.eventbus.bus.EventBus { UltraNotifier.logger.warn("EventBus: $it") } //#endif + @JvmStatic fun <T : UltraEvent> post(event: T): T { - UltraNotifier.logger.info("Posting $event") + if (event !is UltraEvent.Silent<*>) { + UltraNotifier.logger.info("Posting $event") + } eventBus.post(event) return event } diff --git a/src/main/kotlin/gui/MessageUi.kt b/src/main/kotlin/gui/MessageUi.kt index f4012da..f3feeb7 100644 --- a/src/main/kotlin/gui/MessageUi.kt +++ b/src/main/kotlin/gui/MessageUi.kt @@ -1,29 +1,19 @@ package moe.nea.ultranotifier.gui -import gg.essential.universal.UGraphics import gg.essential.universal.UMatrixStack import gg.essential.universal.UScreen +import moe.nea.ultranotifier.util.render.ScreenRenderUtils +import moe.nea.ultranotifier.util.ultraIdentifier import java.awt.Color class MessageUi : UScreen() { override fun onDrawScreen(matrixStack: UMatrixStack, mouseX: Int, mouseY: Int, partialTicks: Float) { super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks) - fillRect(matrixStack, - 0.0, 0.0, width.toDouble(), height.toDouble(), Color.RED) + ScreenRenderUtils.fillRect(matrixStack, 0.0, 0.0, width.toDouble(), height.toDouble(), Color.RED) + ScreenRenderUtils.renderTexture( + ultraIdentifier("textures/gui/square_panel.png"), + matrixStack, + 200.0, 0.0, 300.0, 100.0 + ) } - - fun fillRect( - matrixStack: UMatrixStack, - left: Double, top: Double, right: Double, bottom: Double, - color: Color, - ) { - val buffer = UGraphics.getFromTessellator() - buffer.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_COLOR) - buffer.pos(matrixStack, left, top, 0.0).color(color).endVertex() - buffer.pos(matrixStack, left, bottom, 0.0).color(color).endVertex() - buffer.pos(matrixStack, right, bottom, 0.0).color(color).endVertex() - buffer.pos(matrixStack, right, top, 0.0).color(color).endVertex() - buffer.drawDirect() - } - } diff --git a/src/main/kotlin/util/identifierutil.kt b/src/main/kotlin/util/identifierutil.kt new file mode 100644 index 0000000..e94e15c --- /dev/null +++ b/src/main/kotlin/util/identifierutil.kt @@ -0,0 +1,11 @@ +package moe.nea.ultranotifier.util + +import moe.nea.ultranotifier.Constants +import net.minecraft.util.Identifier + +fun identifier(namespace: String, path: String): Identifier { + return Identifier(namespace, path) +} + +fun vanillaIdentifier(path: String) = identifier("minecraft", path) +fun ultraIdentifier(path: String) = identifier(Constants.MOD_ID, path) diff --git a/src/main/kotlin/util/render/ScreenRenderUtils.kt b/src/main/kotlin/util/render/ScreenRenderUtils.kt new file mode 100644 index 0000000..6a659bf --- /dev/null +++ b/src/main/kotlin/util/render/ScreenRenderUtils.kt @@ -0,0 +1,39 @@ +package moe.nea.ultranotifier.util.render + +import gg.essential.universal.UGraphics +import gg.essential.universal.UMatrixStack +import net.minecraft.util.Identifier +import java.awt.Color + +object ScreenRenderUtils { + fun fillRect( + matrixStack: UMatrixStack, + left: Double, top: Double, + right: Double, bottom: Double, + color: Color, + ) { + val buffer = UGraphics.getFromTessellator() + buffer.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_COLOR) + buffer.pos(matrixStack, left, top, 0.0).color(color).endVertex() + buffer.pos(matrixStack, left, bottom, 0.0).color(color).endVertex() + buffer.pos(matrixStack, right, bottom, 0.0).color(color).endVertex() + buffer.pos(matrixStack, right, top, 0.0).color(color).endVertex() + buffer.drawDirect() + } + + fun renderTexture( + identifier: Identifier, + matrixStack: UMatrixStack, + left: Double, top: Double, + right: Double, bottom: Double, + ) { + UGraphics.bindTexture(0, identifier) + val graphics = UGraphics.getFromTessellator() + graphics.beginWithDefaultShader(UGraphics.DrawMode.QUADS, UGraphics.CommonVertexFormats.POSITION_TEXTURE) + graphics.pos(matrixStack, left, top, 0.0).tex(0.0, 0.0).endVertex() + graphics.pos(matrixStack, left, bottom, 0.0).tex(0.0, 1.0).endVertex() + graphics.pos(matrixStack, right, bottom, 0.0).tex(1.0, 1.0).endVertex() + graphics.pos(matrixStack, right, top, 0.0).tex(1.0, 0.0).endVertex() + graphics.drawDirect() + } +} diff --git a/src/main/resources/assets/ultranotifier/textures/gui/square_panel.png b/src/main/resources/assets/ultranotifier/textures/gui/square_panel.png Binary files differnew file mode 100644 index 0000000..fdca83b --- /dev/null +++ b/src/main/resources/assets/ultranotifier/textures/gui/square_panel.png |