Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 46 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ if (sc_loader == "fabric") {
mappings "net.fabricmc:yarn:${yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
// MCEF [Keksuccino's Fork] was renamed to Rinku; the old `mcef-keksuccino`
// slug no longer resolves on Modrinth's maven. The 2.2.x artifacts are
// still served under the new slug, so only the artifact id changes here.
include(modImplementation("maven.modrinth:rinku:${mcef_version}"))
include(modImplementation("maven.modrinth:rinku:${rinku_version}"))
}
} else {
neoForge {
Expand All @@ -90,8 +87,52 @@ if (sc_loader == "fabric") {
}
}
}
// Rinku ships its NeoForge builds inconsistently: 26.2 has classes at the
// top level, but 1.21.1 and 26.1.2 are jarJar wrappers whose real mod sits
// in META-INF/jarjar/. NeoForge unpacks that at runtime, so the game is
// happy either way — javac is not, and sees an empty jar. Compile against
// whatever actually holds the classes; the published artifact stays on the
// runtime classpath untouched.
configurations {
rinkuArtifact
}

dependencies {
rinkuArtifact "maven.modrinth:rinku:${rinku_version}"
runtimeOnly "maven.modrinth:rinku:${rinku_version}"
}

def rinkuClassesDir = layout.buildDirectory.dir('rinku-compile')
def unwrapRinku = tasks.register('unwrapRinku') {
def artifact = configurations.rinkuArtifact
inputs.files(artifact)
outputs.dir(rinkuClassesDir)
doLast {
def dir = rinkuClassesDir.get().asFile
dir.deleteDir()
dir.mkdirs()
def outer = artifact.singleFile
def target = new File(dir, 'rinku.jar')
new java.util.zip.ZipFile(outer).withCloseable { zip ->
def nested = zip.entries().toList().find {
it.name.startsWith('META-INF/jarjar/') && it.name.endsWith('.jar')
}
if (nested != null) {
target.withOutputStream { out -> out << zip.getInputStream(nested) }
logger.lifecycle("rinku: compiling against nested ${nested.name}")
} else {
target.bytes = outer.bytes
}
}
}
}

dependencies {
implementation "maven.modrinth:rinku:${mcef_version}"
// Point at the jar itself, not the directory holding it — a directory
// on the compile classpath is searched for loose .class files only.
compileOnly files(rinkuClassesDir.map { it.file('rinku.jar') }) {
builtBy unwrapRinku
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/land/webgui/WebGUIClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package land.webgui;

import com.cinemamod.mcef.MCEF;
import de.keksuccino.rinku.Rinku;
//? if fabric {
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
Expand All @@ -24,12 +24,12 @@ public final class WebGUIClient
//? if fabric {
@Override
public void onInitializeClient() {
MCEF.scheduleForInit(success -> {
Rinku.scheduleForInit(success -> {
if (!success) {
WebGUIMod.LOGGER.error("MCEF (Chromium) failed to initialize — web GUI will not work.");
WebGUIMod.LOGGER.error("Rinku (Chromium) failed to initialize — web GUI will not work.");
return;
}
MCEF.getClient().addDisplayHandler(new WebviewBrowserConsoleLogger());
Rinku.getClient().addDisplayHandler(new WebviewBrowserConsoleLogger());
WebviewPageToClientBridge.register();
WebviewPageLoadHooks.register();
WebGUIMod.LOGGER.info("WebGUI bridge ready (console log, page↔game, client data).");
Expand Down Expand Up @@ -108,7 +108,7 @@ private static void onLeaveWorld() {
}

private static void handleOpenPayload(net.minecraft.client.MinecraftClient client, int mode, String url) {
if (!MCEF.isInitialized()) {
if (!Rinku.isInitialized()) {
if (client.player != null) {
client.player.sendMessage(net.minecraft.text.Text.translatable("message.webgui.mcef_not_ready"), false);
}
Expand All @@ -123,12 +123,12 @@ private static void handleOpenPayload(net.minecraft.client.MinecraftClient clien
}
//? } else {
/*public static void initClient(IEventBus modBus) {
MCEF.scheduleForInit(success -> {
Rinku.scheduleForInit(success -> {
if (!success) {
WebGUIMod.LOGGER.error("MCEF (Chromium) failed to initialize - web GUI will not work.");
WebGUIMod.LOGGER.error("Rinku (Chromium) failed to initialize - web GUI will not work.");
return;
}
MCEF.getClient().addDisplayHandler(new WebviewBrowserConsoleLogger());
Rinku.getClient().addDisplayHandler(new WebviewBrowserConsoleLogger());
WebviewPageToClientBridge.register();
WebviewPageLoadHooks.register();
WebGUIMod.LOGGER.info("WebGUI bridge ready (console log, page<->game, client data).");
Expand Down Expand Up @@ -182,7 +182,7 @@ private static void onClientTick(ClientTickEvent.Post event) {
}

private static void handleOpenPayload(Minecraft client, int mode, String url) {
if (!MCEF.isInitialized()) {
if (!Rinku.isInitialized()) {
if (client.player != null) {
//? if >=26 {
client.player.sendSystemMessage(
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/land/webgui/WebGUIKeys.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package land.webgui;

import com.cinemamod.mcef.MCEF;
import de.keksuccino.rinku.Rinku;
//? if fabric {
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -117,7 +117,7 @@ private static void tryOpenMainMenu(MinecraftClient client) {
if (client.currentScreen instanceof WebViewScreen) {
return;
}
if (!MCEF.isInitialized()) {
if (!Rinku.isInitialized()) {
if (client.player != null) {
client.player.sendMessage(Text.translatable("message.webgui.mcef_not_ready"), false);
}
Expand All @@ -134,7 +134,7 @@ private static void tryOpenMainMenu(MinecraftClient client) {
//? }
return;
}
if (!MCEF.isInitialized()) {
if (!Rinku.isInitialized()) {
if (client.player != null) {
//? if >=26 {
client.player.sendSystemMessage(Component.translatable("message.webgui.mcef_not_ready"));
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/land/webgui/WebHudOverlay.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package land.webgui;

import com.cinemamod.mcef.MCEF;
import com.cinemamod.mcef.MCEFBrowser;
import de.keksuccino.rinku.Rinku;
import de.keksuccino.rinku.RinkuBrowser;
//? if fabric {
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -60,7 +60,7 @@ public static boolean shouldDeliverHudBrowserInput(MinecraftClient client) {
//? } else {
/*public static boolean shouldDeliverHudBrowserInput(Minecraft client) {*/
//? }
if (client == null || !MCEF.isInitialized()) {
if (client == null || !Rinku.isInitialized()) {
return false;
}
//? if fabric {
Expand All @@ -86,7 +86,7 @@ public static boolean shouldForwardHudArrowKeys(MinecraftClient client) {
//? } else {
/*public static boolean shouldForwardHudArrowKeys(Minecraft client) {*/
//? }
if (client == null || !MCEF.isInitialized()) {
if (client == null || !Rinku.isInitialized()) {
return false;
}
//? if fabric {
Expand Down Expand Up @@ -229,7 +229,7 @@ public static void toggleHud(MinecraftClient client) {
//? }
return;
}
if (!MCEF.isInitialized()) {
if (!Rinku.isInitialized()) {
notifyMcefMissing(client);
return;
}
Expand Down Expand Up @@ -262,7 +262,7 @@ public static void toggleInteractive(MinecraftClient client) {
//? } else {
/*public static void toggleInteractive(Minecraft client) {*/
//? }
if (!MCEF.isInitialized()) {
if (!Rinku.isInitialized()) {
return;
}
//? if fabric {
Expand Down Expand Up @@ -356,7 +356,7 @@ public static void onGuiClosed(MinecraftClient client) {
}
}

static void onHudBrowserLoadStart(MCEFBrowser browser) {
static void onHudBrowserLoadStart(RinkuBrowser browser) {
if (browser == null) {
return;
}
Expand All @@ -365,7 +365,7 @@ static void onHudBrowserLoadStart(MCEFBrowser browser) {
}
}

static void onHudBrowserLoadFinished(MCEFBrowser browser) {
static void onHudBrowserLoadFinished(RinkuBrowser browser) {
if (browser == null) {
return;
}
Expand Down Expand Up @@ -407,7 +407,7 @@ private static void onHudRender(RenderGuiEvent.Post event) {
if (!hudVisible) {
return;
}
MCEFBrowser browser = WebSession.hudBrowser();
RinkuBrowser browser = WebSession.hudBrowser();
if (browser == null) {
return;
}
Expand All @@ -429,7 +429,7 @@ private static void onHudRender(RenderGuiEvent.Post event) {
//? if >=1.21.5 {
net.minecraft.util.Identifier tex = browser.getTextureIdentifier();
//? } else {
/*net.minecraft.util.Identifier tex = browser.getTextureLocation();*/
/*net.minecraft.util.Identifier tex = browser.getTextureIdentifier();*/
//? }
if (tex == null) {
return;
Expand All @@ -446,7 +446,7 @@ private static void onHudRender(RenderGuiEvent.Post event) {
//? if >=1.21.5 {
net.minecraft.resources.Identifier tex = browser.getTextureIdentifier();
//? } else {
net.minecraft.resources.ResourceLocation tex = browser.getTextureLocation();
net.minecraft.resources.ResourceLocation tex = browser.getTextureIdentifier();
//? }
if (tex == null) return;
int sw = client.getWindow().getGuiScaledWidth();
Expand Down Expand Up @@ -502,7 +502,7 @@ static void resizeBrowser(MinecraftClient client) {
//? } else {
/*static void resizeBrowser(Minecraft client) {*/
//? }
MCEFBrowser browser = WebSession.hudBrowser();
RinkuBrowser browser = WebSession.hudBrowser();
if (browser == null) {
return;
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/land/webgui/WebSession.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package land.webgui;

import com.cinemamod.mcef.MCEF;
import com.cinemamod.mcef.MCEFBrowser;
import de.keksuccino.rinku.Rinku;
import de.keksuccino.rinku.RinkuBrowser;

public final class WebSession {
private static MCEFBrowser browser;
private static MCEFBrowser suspendedHudBrowser;
private static RinkuBrowser browser;
private static RinkuBrowser suspendedHudBrowser;
private static Mode mode = Mode.NONE;

public enum Mode {
Expand All @@ -16,11 +16,11 @@ public enum Mode {

private WebSession() {}

public static MCEFBrowser browser() {
public static RinkuBrowser browser() {
return browser;
}

public static MCEFBrowser hudBrowser() {
public static RinkuBrowser hudBrowser() {
if (mode == Mode.HUD_OVERLAY) {
return browser;
}
Expand Down Expand Up @@ -70,29 +70,29 @@ public static void closeGuiAndRestoreHud() {
WebviewClientBridge.clearCache();
}

public static MCEFBrowser openForGui(String url) {
public static RinkuBrowser openForGui(String url) {
closeSuspendedHudBrowser();
if (mode == Mode.HUD_OVERLAY && browser != null) {
suspendedHudBrowser = browser;
browser = null;
} else {
closeActiveBrowser();
}
browser = MCEF.createBrowser(url, true);
browser = Rinku.createBrowser(url, true);
mode = Mode.GUI_SCREEN;
WebviewClientBridge.clearCache();
return browser;
}

public static MCEFBrowser openForHud(String url) {
public static RinkuBrowser openForHud(String url) {
closeSuspendedHudBrowser();
if (mode == Mode.HUD_OVERLAY && browser != null) {
browser.loadURL(url);
WebviewClientBridge.clearCache();
return browser;
}
closeActiveBrowser();
browser = MCEF.createBrowser(url, true);
browser = Rinku.createBrowser(url, true);
mode = Mode.HUD_OVERLAY;
WebviewClientBridge.clearCache();
return browser;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/land/webgui/WebViewLayout.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package land.webgui;

import com.cinemamod.mcef.MCEFBrowser;
import de.keksuccino.rinku.RinkuBrowser;
import org.lwjgl.glfw.GLFW;

/**
* Sizing/scale helpers for the embedded browser. The browser view is the physical framebuffer size
* (so its texture draws 1:1 → crisp on HiDPI), and CEF page zoom scales the content up by the OS
* content scale so the page's CSS viewport stays logical and independent of Minecraft's GUI Scale.
* Uses only the public {@link MCEFBrowser#setZoomLevel} API — no device_scale_factor, no reflection.
* Uses only the public {@link RinkuBrowser#setZoomLevel} API — no device_scale_factor, no reflection.
*/
final class WebViewLayout {
private WebViewLayout() {}
Expand Down Expand Up @@ -40,7 +40,7 @@ static double zoomLevel() {
}

/** Applies the content-scale zoom. CEF may reset zoom on navigation, so call after load too. */
static void applyZoom(MCEFBrowser browser) {
static void applyZoom(RinkuBrowser browser) {
if (browser == null) {
return;
}
Expand Down
Loading
Loading