Skip to content

Commit

Permalink
it can compile now
Browse files Browse the repository at this point in the history
  • Loading branch information
javaarchive committed Jun 14, 2022
1 parent 518a7a9 commit baad847
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 51 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// le config
modImplementation "curse.maven:forgeconfigapiport-fabric-547434:3671141"
}

processResources {
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/net/montoyo/mcef/example/ExampleMod.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.montoyo.mcef.example;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
Expand Down Expand Up @@ -56,6 +57,8 @@ public void onInit() {
api.registerDisplayHandler(this);
api.registerJSQueryHandler(this);
}

ClientTickEvents.START_CLIENT_TICK.register(client -> this.onTickStart());
}

public void setBackup(BrowserScreen bu) {
Expand Down Expand Up @@ -86,14 +89,12 @@ else if(backup != null)
return null;
}

public void onTick(TickEvent ev) {
if(ev.phase == TickEvent.Phase.START && ev.side == Side.CLIENT && ev.type == TickEvent.Type.CLIENT) {
//Check if our key was pressed
if(key.isPressed() && !(mc.currentScreen instanceof BrowserScreen)) {
//Display the web browser UI.
mc.setScreen(hasBackup() ? backup : new BrowserScreen());
backup = null;
}
public void onTickStart() {
// Check if our key was pressed
if(key.isPressed() && !(mc.currentScreen instanceof BrowserScreen)) {
//Display the web browser UI.
mc.setScreen(hasBackup() ? backup : new BrowserScreen());
backup = null;
}
}

Expand Down Expand Up @@ -149,10 +150,10 @@ public boolean handleQuery(IBrowser b, long queryId, String query, boolean persi
public void cancelQuery(IBrowser b, long queryId) {
}

@SubscribeEvent
/*@SubscribeEvent
public void onDrawHUD(RenderGameOverlayEvent.Post ev) {
if(hudBrowser != null)
hudBrowser.drawScreen(0, 0, 0.f);
}
}*/

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package net.montoyo.mcef.mixins;

import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(MinecraftClient.class)
public class ForgeInitEquavilentMixin {
}
4 changes: 2 additions & 2 deletions src/main/java/net/montoyo/mcef/remote/RemoteConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Map.Entry;
import java.util.Set;

import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;
import net.montoyo.mcef.setup.FileListing;
import org.cef.OS;

Expand Down Expand Up @@ -170,7 +170,7 @@ else if(OS.isLinux())

JsonElement mcVersions = json.get("latestVersions");
if(mcVersions != null && mcVersions.isJsonObject()) {
JsonElement cVer = mcVersions.getAsJsonObject().get(Minecraft.getMinecraft().getVersion());
JsonElement cVer = mcVersions.getAsJsonObject().get(MinecraftClient.getInstance().getGameVersion());

if(cVer != null && cVer.isJsonPrimitive())
version = cVer.getAsString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package net.montoyo.mcef.utilities;

import net.minecraftforge.fml.common.ProgressManager;

public class ForgeProgressListener implements IProgressListener {

private ProgressManager.ProgressBar progressBar = null;
private int lastVal = 0;

private void stepUntil(int val) {
//FIXME: Bad, disgusting, and everything...
// FIXME: oh this doesn't do anything rlly
while(lastVal < val) {
progressBar.step("" + val + "%");
lastVal++;
}
}
Expand All @@ -22,22 +19,12 @@ public void onProgressed(double d) {

@Override
public void onTaskChanged(String name) {
if(progressBar != null) {
stepUntil(100);
ProgressManager.pop(progressBar);
}

progressBar = ProgressManager.push(name, 100, false);
lastVal = 0;
}

@Override
public void onProgressEnd() {
if(progressBar != null) {
stepUntil(100);
ProgressManager.pop(progressBar);
progressBar = null;
}

}

}
46 changes: 24 additions & 22 deletions src/main/java/org/cef/browser/CefRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

package org.cef.browser;

import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.montoyo.mcef.MCEF;
import net.montoyo.mcef.utilities.Log;
import org.lwjgl.opengl.EXTBgra;

import java.awt.*;
import java.nio.ByteBuffer;
import java.util.ArrayList;

import static org.lwjgl.opengl.EXTBGRA.GL_BGRA_EXT;
import static org.lwjgl.opengl.GL11.*;

public class CefRenderer {
Expand Down Expand Up @@ -54,17 +55,17 @@ protected int getTextureID() {
}

protected void initialize() {
GlStateManager.enableTexture2D();
GlStateManager._enableTexture();
texture_id_[0] = glGenTextures();

if (MCEF.CHECK_VRAM_LEAK)
GL_TEXTURES.add(texture_id_[0]);

GlStateManager.bindTexture(texture_id_[0]);
GlStateManager._bindTexture(texture_id_[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
GlStateManager.bindTexture(0);
GlStateManager._bindTexture(0);
}

protected void cleanup() {
Expand All @@ -83,14 +84,15 @@ protected void render(double x1, double y1, double x2, double y2) {
Tessellator t = Tessellator.getInstance();
BufferBuilder vb = t.getBuffer();

GlStateManager.bindTexture(texture_id_[0]);
vb.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
vb.pos(x1, y1, 0.0).tex(0.0, 1.0).color(255, 255, 255, 255).endVertex();
vb.pos(x2, y1, 0.0).tex(1.f, 1.f).color(255, 255, 255, 255).endVertex();
vb.pos(x2, y2, 0.0).tex(1.f, 0.0).color(255, 255, 255, 255).endVertex();
vb.pos(x1, y2, 0.0).tex(0.0, 0.0).color(255, 255, 255, 255).endVertex();
GlStateManager._bindTexture(texture_id_[0]);
// previously GL_QUADS for drawmode
vb.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
vb.vertex(x1, y1, 0.0).texture(0.0f, 1.0f).color(255, 255, 255, 255);
vb.vertex(x2, y1, 0.0).texture(1.f, 1.f).color(255, 255, 255, 255);
vb.vertex(x2, y2, 0.0).texture(1.f, 0.0f).color(255, 255, 255, 255);
vb.vertex(x1, y2, 0.0).texture(0.0f, 0.0f).color(255, 255, 255, 255);
t.draw();
GlStateManager.bindTexture(0);
GlStateManager._bindTexture(0);
}

protected void onPopupSize(Rectangle rect) {
Expand Down Expand Up @@ -124,7 +126,7 @@ protected void clearPopupRects() {

protected void onPaint(boolean popup, Rectangle[] dirtyRects, ByteBuffer buffer, int width, int height, boolean completeReRender) {
if (transparent_) // Enable alpha blending.
GlStateManager.enableBlend();
GlStateManager._enableBlend();

final int size = (width * height) << 2;
if (size > buffer.limit()) {
Expand All @@ -133,8 +135,8 @@ protected void onPaint(boolean popup, Rectangle[] dirtyRects, ByteBuffer buffer,
}

// Enable 2D textures.
GlStateManager.enableTexture2D();
GlStateManager.bindTexture(texture_id_[0]);
GlStateManager._enableTexture();
GlStateManager._bindTexture(texture_id_[0]);

int oldAlignement = glGetInteger(GL_UNPACK_ALIGNMENT);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
Expand All @@ -144,7 +146,7 @@ protected void onPaint(boolean popup, Rectangle[] dirtyRects, ByteBuffer buffer,
// Update/resize the whole texture.
view_width_ = width;
view_height_ = height;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, view_width_, view_height_, 0, EXTBgra.GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, view_width_, view_height_, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer);
} else {
glPixelStorei(GL_UNPACK_ROW_LENGTH, view_width_);

Expand All @@ -155,7 +157,7 @@ protected void onPaint(boolean popup, Rectangle[] dirtyRects, ByteBuffer buffer,
else {
glPixelStorei(GL_UNPACK_SKIP_PIXELS, rect.x);
glPixelStorei(GL_UNPACK_SKIP_ROWS, rect.y);
glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width, rect.height, EXTBgra.GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer);
glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width, rect.height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer);
}
}

Expand Down Expand Up @@ -187,14 +189,14 @@ protected void onPaint(boolean popup, Rectangle[] dirtyRects, ByteBuffer buffer,
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, EXTBgra.GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer);
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
}

glPixelStorei(GL_UNPACK_ALIGNMENT, oldAlignement);
GlStateManager.bindTexture(0);
GlStateManager._bindTexture(0);
}

protected void setSpin(float spinX, float spinY) {
Expand Down

0 comments on commit baad847

Please sign in to comment.