diff --git a/build.gradle.kts b/build.gradle.kts index d1594f4b..4c221c6d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -99,6 +99,8 @@ repositories { mavenCentral() maven("https://maven.parchmentmc.org") maven("https://mvn.devos.one/snapshots") + maven { url = uri("https://api.modrinth.com/maven") } + } //All dependencies and their versions are in ./gradle/libs.versions.toml @@ -115,6 +117,7 @@ dependencies { modImplementation(libs.fabric.loader) modImplementation(libs.fabric.api) modImplementation(libs.fabric.language.kotlin) // how did i not have this + modImplementation(libs.sodium) include(implementation("com.moulberry:mixinconstraints:1.0.1")!!) listOf( diff --git a/gradle.properties b/gradle.properties index 0f0303a9..81d72f18 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx4G org.gradle.parallel=true # Mod Properties -mod_version=1.3.3 +mod_version=1.3.4 maven_group=gay.asoji archives_base_name=innerpastels diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 24fd3ba2..c79f095b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,14 +4,16 @@ minecraft = "1.21" fabric-loader = "0.15.11" fabric-api = "0.102.0+1.21" fabric-language-kotlin = "1.11.0+kotlin.2.0.0" -imgui-java = "1.86.12" dokka = "1.9.10" +sodium_version = "mc1.21-0.6.0-beta.1-fabric" + [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" } fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" } fabric_language_kotlin = { module = "net.fabricmc:fabric-language-kotlin", version.ref = "fabric-language-kotlin" } +sodium = { module = "maven.modrinth:sodium", version.ref = "sodium_version" } [plugins] grgit = { id = "org.ajoberstar.grgit", version = "5.2.1"} diff --git a/src/main/java/gay/asoji/innerpastels/mixins/RenderSystemMixin.java b/src/main/java/gay/asoji/innerpastels/mixins/RenderSystemMixin.java new file mode 100644 index 00000000..7e405188 --- /dev/null +++ b/src/main/java/gay/asoji/innerpastels/mixins/RenderSystemMixin.java @@ -0,0 +1,29 @@ +package gay.asoji.innerpastels.mixins; + +import com.mojang.blaze3d.systems.RenderSystem; +import gay.asoji.innerpastels.client.ImGuiClient; +import gay.asoji.innerpastels.client.imgui.InnerPastelsImGuiImpl; +import imgui.type.ImBoolean; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(RenderSystem.class) +public class RenderSystemMixin { + @Inject(method = "flipFrame", at = @At("HEAD"), remap = false) + private static void imgui$renderImGui(long handle, CallbackInfo ci) { + InnerPastelsImGuiImpl.INSTANCE.initialize(handle); + InnerPastelsImGuiImpl.INSTANCE.startFrame(); + + if (ImGuiClient.INSTANCE.isImGuiRenderEnabled()) { + ImGuiClient.INSTANCE.getPanels().forEach((it) -> { + it.theme(); + it.render(new ImBoolean()); + } + ); + } + + InnerPastelsImGuiImpl.INSTANCE.endFrame(); + } +} diff --git a/src/main/kotlin/gay/asoji/innerpastels/client/ImGuiClient.kt b/src/main/kotlin/gay/asoji/innerpastels/client/ImGuiClient.kt index 1705570e..bbcbfc18 100644 --- a/src/main/kotlin/gay/asoji/innerpastels/client/ImGuiClient.kt +++ b/src/main/kotlin/gay/asoji/innerpastels/client/ImGuiClient.kt @@ -6,10 +6,13 @@ import gay.asoji.innerpastels.client.imgui.InnerPastelsImGuiImpl import gay.asoji.innerpastels.client.imgui.InnerPastelsImGuiImpl.endFrame import gay.asoji.innerpastels.client.imgui.InnerPastelsImGuiImpl.initialize import gay.asoji.innerpastels.client.imgui.InnerPastelsImGuiImpl.startFrame +import gay.asoji.innerpastels.client.imgui.TestDockSpace +import gay.asoji.innerpastels.client.imgui.TestPanel import gay.asoji.innerpastels.events.InputAction import gay.asoji.innerpastels.events.KeyInputEvent import gay.asoji.innerpastels.events.MouseInputEvent import gay.asoji.innerpastels.events.MouseScrollInputEvent +import imgui.ImGui import imgui.type.ImBoolean import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper @@ -19,7 +22,8 @@ import net.minecraft.client.Minecraft import org.lwjgl.glfw.GLFW object ImGuiClient { - private var isImGuiRenderEnabled: Boolean = false + var isImGuiRenderEnabled: Boolean = false + private set val DEVELOPER_UI_BINDING = KeyMapping( "key.innerpastels.developerui", @@ -43,35 +47,22 @@ object ImGuiClient { } fun init() { -// panels.addAll( // testing stuff -// listOf( -// object : ImGuiPanel { -// override fun theme() { -// -// } -// -// override fun render(open_: ImBoolean) { -// ImGui.showDemoWindow() -// } -// }, -// TestDockSpace, TestPanel -// ) -// ) + panels.addAll( // testing stuff + listOf( + object : ImGuiPanel { + override fun theme() { - initializeDevKeybinds() - HudRenderCallback.EVENT.register { gui, tickDelta -> - initialize(Minecraft.getInstance().window.window) - startFrame() + } - if (isImGuiRenderEnabled) { - panels.forEach { - it.theme() - it.render(ImBoolean()) - } - } + override fun render(open_: ImBoolean) { + ImGui.showDemoWindow() + } + }, + TestDockSpace, TestPanel + ) + ) - endFrame() - } + initializeDevKeybinds() KeyInputEvent.EVENT.register { key, action, mods, scanCode -> when (action ?: return@register) { diff --git a/src/main/resources/innerpastels.mixins.json b/src/main/resources/innerpastels.mixins.json index 0708a503..c1e33224 100644 --- a/src/main/resources/innerpastels.mixins.json +++ b/src/main/resources/innerpastels.mixins.json @@ -10,7 +10,8 @@ "GLFWInitMixin", "KeyboardHandlerMixin", "MinecraftMixin", - "MouseHandlerMixin" + "MouseHandlerMixin", + "RenderSystemMixin" ], "injectors": { "defaultRequire": 1