diff options
Diffstat (limited to 'src/main')
-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 |
9 files changed, 73 insertions, 22 deletions
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 |