Skip to content

Commit

Permalink
⚗️ uh i guess the game launches now bc glfw shit
Browse files Browse the repository at this point in the history
  • Loading branch information
asoji committed Jul 1, 2024
1 parent 352aa05 commit d0b35be
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ group = project.property("maven_group")!!

repositories {
maven { url = uri("https://maven.parchmentmc.org") }
maven { url = uri("https://mvn.devos.one/snapshots") }
maven { url = uri("https://raw.githubusercontent.com/kotlin-graphics/mary/master") }
}
maven { url = uri("https://mvn.devos.one/snapshots") } }

//All dependencies and their versions are in ./gradle/libs.versions.toml
dependencies {
Expand All @@ -45,6 +43,7 @@ dependencies {
//Fabric
modImplementation(libs.fabric.loader)
modImplementation(libs.fabric.api)
modImplementation(libs.fabric.language.kotlin) // how did i not have this

implementation(libs.bundles.imgui) {
exclude(group = "org.lwjgl")
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fab
fabric_language_kotlin = { module = "net.fabricmc:fabric-language-kotlin", version.ref = "fabric_language_kotlin" }
imgui-binding = { module = "io.github.spair:imgui-java-binding", version.ref = "imgui-java" }
imgui-lwjgl3 = { module = "io.github.spair:imgui-java-lwjgl3", version.ref = "imgui-java" }
imgui-native-windows = { module = "io.github.spair:imgui-java-natives-windows", version.ref = "imgui-java" }
imgui-native-linux = { module = "io.github.spair:imgui-java-natives-linux", version.ref = "imgui-java" }

[bundles]
imgui = [ "imgui-binding", "imgui-lwjgl3" ]
imgui = [ "imgui-binding", "imgui-lwjgl3", "imgui-native-linux", "imgui-native-windows" ]

[plugins]
grgit = { id = "org.ajoberstar.grgit", version = "5.2.1"}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gay.asoji.innerpastels.mixins;

import com.mojang.blaze3d.platform.Window;
import gay.asoji.innerpastels.client.imgui.InnerPastelsImGuiImpl;
import net.minecraft.client.Minecraft;
import net.minecraft.client.main.GameConfig;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Minecraft.class)
public class MinecraftClientMixin {
@Shadow @Final private Window window;

@Inject(at = @At("TAIL"),method = "<init>")
private void onGLFWInit(GameConfig gameConfig, CallbackInfo ci){
InnerPastelsImGuiImpl.INSTANCE.glfwInit(window.getWindow());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,24 @@ class InnerPastelsClient : ClientModInitializer {

override fun onInitializeClient() {
if (FabricLoader.getInstance().isDevelopmentEnvironment) {
// THIS IS PROBABLY NOT CORRECT, IF IT ISNT, FUCKING REMOVE IT LATER, ALL CONTEXT CREATION SHOULD PROBABLY BE FUCKING LEFT TO THE IMPL [OR THE PANEL ITSELF]?
ImGui.createContext()
initializeDevKeybinds()
}

HudRenderCallback.EVENT.register { gui, tickDelta ->
if (!isImGuiRenderEnabled) {
return@register
}
implGl3.renderDrawData(ImGui.getDrawData())
implGlfw.newFrame()
ImGui.newFrame()

panels.forEach {
it.render(ImBoolean())
}

implGl3.renderDrawData(ImGui.getDrawData())
ImGui.render()
endFrame(windowHandle)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ object InnerPastelsImGuiImpl {
fun glfwInit(handle: Long) {
implGlfw.init(handle, false)
implGl3.init()
ImGui.createContext()

ImGui.createContext()
imGuiInit()
windowHandle = handle
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/innerpastels.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"package": "gay.asoji.innerpastels.mixins",
"compatibilityLevel": "JAVA_21",
"mixins": [

],
"client": [
"MinecraftClientMixin",
"KeyboardHandlerMixin",
"MouseHandlerMixin"
],
Expand Down

0 comments on commit d0b35be

Please sign in to comment.