
Crash on open a web page
JLSkyzer opened this issue ยท 0 comments
Hello, when i try to open a page my game crash.
My page :
/*
* MCEF (Minecraft Chromium Embedded Framework)
* Copyright (C) 2023 CinemaMod Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/
package fr.eriniumgroup.eriniumadventure.automation;
import com.cinemamod.mcef.MCEF;
import com.cinemamod.mcef.MCEFBrowser;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
public class WikiPage extends Screen {
private static final int BROWSER_DRAW_OFFSET = 20;
private MCEFBrowser browser;
public WikiPage(Component component) {
super(component);
}
@Override
protected void init() {
super.init();
if (browser == null) {
String url = "https://jlskyzer-home.netlify.app";
boolean transparent = true;
browser = MCEF.createBrowser(url, transparent);
resizeBrowser();
}
}
private int mouseX(double x) {
return (int) ((x - BROWSER_DRAW_OFFSET) * minecraft.getWindow().getGuiScale());
}
private int mouseY(double y) {
return (int) ((y - BROWSER_DRAW_OFFSET) * minecraft.getWindow().getGuiScale());
}
private int scaleX(double x) {
return (int) ((x - BROWSER_DRAW_OFFSET * 2) * minecraft.getWindow().getGuiScale());
}
private int scaleY(double y) {
return (int) ((y - BROWSER_DRAW_OFFSET * 2) * minecraft.getWindow().getGuiScale());
}
private void resizeBrowser() {
if (width > 100 && height > 100) {
browser.resize(scaleX(width), scaleY(height));
}
}
@Override
public void resize(Minecraft minecraft, int i, int j) {
super.resize(minecraft, i, j);
resizeBrowser();
}
@Override
public void onClose() {
browser.close();
super.onClose();
}
@Override
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
super.render(guiGraphics, i, j, f);
RenderSystem.disableDepthTest();
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
RenderSystem.setShaderTexture(0, browser.getRenderer().getTextureID());
Tesselator t = Tesselator.getInstance();
BufferBuilder buffer = t.getBuilder();
buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
buffer.vertex(BROWSER_DRAW_OFFSET, height - BROWSER_DRAW_OFFSET, 0).uv(0.0f, 1.0f).color(255, 255, 255, 255).endVertex();
buffer.vertex(width - BROWSER_DRAW_OFFSET, height - BROWSER_DRAW_OFFSET, 0).uv(1.0f, 1.0f).color(255, 255, 255, 255).endVertex();
buffer.vertex(width - BROWSER_DRAW_OFFSET, BROWSER_DRAW_OFFSET, 0).uv(1.0f, 0.0f).color(255, 255, 255, 255).endVertex();
buffer.vertex(BROWSER_DRAW_OFFSET, BROWSER_DRAW_OFFSET, 0).uv(0.0f, 0.0f).color(255, 255, 255, 255).endVertex();
t.end();
RenderSystem.setShaderTexture(0, 0);
RenderSystem.enableDepthTest();
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
browser.sendMousePress(mouseX(mouseX), mouseY(mouseY), button);
browser.setFocus(true);
return super.mouseClicked(mouseX, mouseY, button);
}
@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
browser.sendMouseRelease(mouseX(mouseX), mouseY(mouseY), button);
browser.setFocus(true);
return super.mouseReleased(mouseX, mouseY, button);
}
@Override
public void mouseMoved(double mouseX, double mouseY) {
browser.sendMouseMove(mouseX(mouseX), mouseY(mouseY));
super.mouseMoved(mouseX, mouseY);
}
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
browser.sendMouseWheel(mouseX(mouseX), mouseY(mouseY), delta, 0);
return super.mouseScrolled(mouseX, mouseY, delta);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
browser.sendKeyPress(keyCode, scanCode, modifiers);
browser.setFocus(true);
return super.keyPressed(keyCode, scanCode, modifiers);
}
@Override
public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
browser.sendKeyRelease(keyCode, scanCode, modifiers);
browser.setFocus(true);
return super.keyReleased(keyCode, scanCode, modifiers);
}
@Override
public boolean charTyped(char codePoint, int modifiers) {
if (codePoint == (char) 0) return false;
browser.sendKeyTyped(codePoint, modifiers);
browser.setFocus(true);
return super.charTyped(codePoint, modifiers);
}
}
The code i execute :
package fr.eriniumgroup.eriniumadventure.automation.procedures;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.glfw.GLFW;
import fr.eriniumgroup.eriniumadventure.automation.WikiPage;
public class OpenWikiProcedure {
private static final Minecraft minecraft = Minecraft.getInstance();
@OnlyIn(Dist.CLIENT)
public static void execute() {
if (!(minecraft.screen instanceof WikiPage)) {
// Display the ExampleScreen web browser
minecraft.setScreen(new WikiPage(
Component.literal("Wiki")
));
}
}
}
The crash and latest log
latest.log
crash-2023-12-22_20.19.32-client.txt