This commit is contained in:
eaglercraft 2024-06-16 17:02:14 -07:00
commit 0bb03a581b
40 changed files with 340 additions and 154 deletions

View file

@ -121,20 +121,24 @@ public class EaglerInputStream extends InputStream {
}
public static byte[] inputStreamToBytes(InputStream is) throws IOException {
if (is instanceof EaglerInputStream) {
return ((EaglerInputStream) is).getAsArray();
} else if (is instanceof ByteArrayInputStream) {
byte[] ret = new byte[is.available()];
is.read(ret);
return ret;
} else {
EaglerOutputStream os = new EaglerOutputStream(1024);
byte[] buf = new byte[1024];
int i;
while ((i = is.read(buf)) != -1) {
os.write(buf, 0, i);
try {
if (is instanceof EaglerInputStream) {
return ((EaglerInputStream) is).getAsArray();
} else if (is instanceof ByteArrayInputStream) {
byte[] ret = new byte[is.available()];
is.read(ret);
return ret;
} else {
EaglerOutputStream os = new EaglerOutputStream(1024);
byte[] buf = new byte[1024];
int i;
while ((i = is.read(buf)) != -1) {
os.write(buf, 0, i);
}
return os.toByteArray();
}
return os.toByteArray();
}finally {
is.close();
}
}

View file

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u34";
public static final String projectForkVersion = "u35";
public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -20,7 +20,7 @@ public class EaglercraftVersion {
public static final String projectOriginName = "EaglercraftX";
public static final String projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8";
public static final String projectOriginVersion = "u34";
public static final String projectOriginVersion = "u35";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
@ -31,7 +31,7 @@ public class EaglercraftVersion {
public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 34;
public static final int updateBundlePackageVersionInt = 35;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View file

@ -74,6 +74,8 @@ public interface IClientConfigAdapter {
String getLocalStorageNamespace();
boolean isEnableMinceraft();
IClientConfigAdapterHooks getHooks();
}

View file

@ -66,7 +66,6 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

View file

@ -3,6 +3,7 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture;
import java.io.IOException;
import java.io.InputStream;
import net.lax1dude.eaglercraft.v1_8.IOUtils;
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
/**
@ -75,4 +76,15 @@ public class EaglerBitwisePackedTexture {
return img;
}
public static ImageData loadTextureSafe(InputStream is, int alpha) throws IOException {
ImageData bufferedimage;
try {
bufferedimage = loadTexture(is, alpha);
} finally {
IOUtils.closeQuietly(is);
}
return bufferedimage;
}
}

View file

@ -73,7 +73,7 @@ public class PBRTextureMapUtils {
}catch(Throwable t) {
}
try {
return EaglerBitwisePackedTexture.loadTexture(resMgr.getResource(new ResourceLocation("eagler:glsl/deferred/assets_pbr/" + fname + ".ebp")).getInputStream(), 255);
return EaglerBitwisePackedTexture.loadTextureSafe(resMgr.getResource(new ResourceLocation("eagler:glsl/deferred/assets_pbr/" + fname + ".ebp")).getInputStream(), 255);
}catch(Throwable t) {
// dead code because teavm
t.toString();

View file

@ -4,7 +4,6 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.ExtGLEnums.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

View file

@ -17,30 +17,21 @@ package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
*/
class DynamicLightInstance {
public final String lightName;
long lastCacheHit = 0l;
double posX;
double posY;
double posZ;
float radius;
public DynamicLightInstance(String lightName) {
this.lightName = lightName;
public DynamicLightInstance() {
}
public void updateLight(double posX, double posY, double posZ, float radius) {
this.lastCacheHit = System.currentTimeMillis();
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.radius = radius;
}
public void destroy() {
}
public float getRadiusInWorld() {
return radius;
}

View file

@ -8,7 +8,6 @@ import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionShader.FixedFunctionSta
import net.lax1dude.eaglercraft.v1_8.opengl.IExtPipelineCompiler;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderSource;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program.DynamicLightsExtPipelineShader;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.minecraft.client.renderer.GLAllocation;
/**

View file

@ -1,10 +1,9 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionPipeline;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
@ -31,14 +30,15 @@ import net.minecraft.util.MathHelper;
public class DynamicLightsStateManager {
static final DynamicLightsPipelineCompiler deferredExtPipeline = new DynamicLightsPipelineCompiler();
static final Map<String, DynamicLightInstance> lightRenderers = new HashMap();
private static List<DynamicLightInstance> lightInstancePool = new ArrayList();
private static int instancePoolIndex = 0;
private static int maxListLengthTracker = 0;
static final List<DynamicLightInstance> lightRenderList = new LinkedList();
static final Matrix4f inverseViewMatrix = new Matrix4f();
static int inverseViewMatrixSerial = 0;
static DynamicLightBucketLoader bucketLoader = null;
static DynamicLightsAcceleratedEffectRenderer accelParticleRenderer = null;
static int lastTotal = 0;
static long renderTimeout = 5000l;
private static long lastTick = 0l;
public static final void enableDynamicLightsRender() {
@ -52,6 +52,9 @@ public class DynamicLightsStateManager {
accelParticleRenderer = new DynamicLightsAcceleratedEffectRenderer();
accelParticleRenderer.initialize();
}
lightRenderList.clear();
instancePoolIndex = 0;
maxListLengthTracker = 0;
}
public static final void bindAcceleratedEffectRenderer(EffectRenderer renderer) {
@ -72,6 +75,8 @@ public class DynamicLightsStateManager {
}
destroyAll();
lightRenderList.clear();
instancePoolIndex = 0;
maxListLengthTracker = 0;
}
public static final boolean isDynamicLightsRender() {
@ -99,21 +104,27 @@ public class DynamicLightsStateManager {
public static final void renderDynamicLight(String lightName, double posX, double posY, double posZ, float radius) {
if(bucketLoader != null) {
DynamicLightInstance dl = lightRenderers.get(lightName);
if(dl == null) {
lightRenderers.put(lightName, dl = new DynamicLightInstance(lightName));
DynamicLightInstance dl;
if(instancePoolIndex < lightInstancePool.size()) {
dl = lightInstancePool.get(instancePoolIndex);
}else {
lightInstancePool.add(dl = new DynamicLightInstance());
}
++instancePoolIndex;
dl.updateLight(posX, posY, posZ, radius);
lightRenderList.add(dl);
}
}
public static final void clearRenderList() {
if(instancePoolIndex > maxListLengthTracker) {
maxListLengthTracker = instancePoolIndex;
}
lightRenderList.clear();
instancePoolIndex = 0;
}
public static final void commitLightSourceBuckets(double renderPosX, double renderPosY, double renderPosZ) {
updateTimers();
lastTotal = lightRenderList.size();
if(bucketLoader != null) {
bucketLoader.clearBuckets();
@ -131,7 +142,8 @@ public class DynamicLightsStateManager {
bucketLoader.setRenderPos(renderPosX, renderPosY, renderPosZ);
bucketLoader.truncateOverflowingBuffers();
}
lightRenderList.clear();
updateTimers();
clearRenderList();
}
public static final void setupInverseViewMatrix() {
@ -141,25 +153,21 @@ public class DynamicLightsStateManager {
private static final void updateTimers() {
long millis = System.currentTimeMillis();
if(millis - lastTick > 1000l) {
if(millis - lastTick > 5000l) {
lastTick = millis;
Iterator<DynamicLightInstance> itr = lightRenderers.values().iterator();
while(itr.hasNext()) {
DynamicLightInstance dl = itr.next();
if(millis - dl.lastCacheHit > renderTimeout) {
dl.destroy();
itr.remove();
if(maxListLengthTracker < (lightInstancePool.size() >> 1)) {
List<DynamicLightInstance> newPool = new ArrayList(Math.max(maxListLengthTracker, 16));
for(int i = 0; i < maxListLengthTracker; ++i) {
newPool.add(lightInstancePool.get(i));
}
lightInstancePool = newPool;
}
maxListLengthTracker = 0;
}
}
public static final void destroyAll() {
Iterator<DynamicLightInstance> itr = lightRenderers.values().iterator();
while(itr.hasNext()) {
itr.next().destroy();
}
lightRenderers.clear();
lightInstancePool = new ArrayList();
}
public static String getF3String() {

View file

@ -1,11 +1,7 @@
package net.lax1dude.eaglercraft.v1_8.opengl.ext.dynamiclights.program;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_FRAGMENT_SHADER;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_VERTEX_SHADER;
import java.util.ArrayList;
import java.util.List;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;

View file

@ -586,6 +586,7 @@ public class Minecraft implements IThreadListener {
}
ShaderSource.clearCache();
GuiMainMenu.doResourceReloadHack();
this.mcLanguageManager.parseLanguageMetadata(arraylist);
if (this.renderGlobal != null) {

View file

@ -5,12 +5,14 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion;
@ -19,7 +21,6 @@ import net.lax1dude.eaglercraft.v1_8.Mouse;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.crypto.MD5Digest;
import net.lax1dude.eaglercraft.v1_8.crypto.SHA1Digest;
import net.lax1dude.eaglercraft.v1_8.internal.EnumCursorType;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
@ -72,8 +73,6 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
private float updateCounter;
private boolean isDefault;
private static final int lendef = 5987;
private static final byte[] md5def = new byte[] { -61, -53, -36, 27, 24, 27, 103, -31, -58, -116, 113, -60, -67, -8,
-77, 30 };
private static final byte[] sha1def = new byte[] { -107, 77, 108, 49, 11, -100, -8, -119, -1, -100, -85, -55, 18,
-69, -107, 113, -93, -101, -79, 32 };
private String splashText;
@ -90,6 +89,8 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
private static final ResourceLocation splashTexts = new ResourceLocation("texts/splashes.txt");
private static final ResourceLocation minecraftTitleTextures = new ResourceLocation(
"textures/gui/title/minecraft.png");
private static final ResourceLocation minecraftTitleBlurFlag = new ResourceLocation(
"textures/gui/title/background/enable_blur.txt");
private static final ResourceLocation eaglerGuiTextures = new ResourceLocation("eagler:gui/eagler_gui.png");
/**+
* An array of all the paths to the panorama pictures.
@ -110,8 +111,13 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
private static ResourceLocation backgroundTexture = null;
private GuiUpdateCheckerOverlay updateCheckerOverlay;
private GuiButton downloadOfflineButton;
private boolean enableBlur = true;
private boolean shouldReload = false;
private static GuiMainMenu instance = null;
public GuiMainMenu() {
instance = this;
this.splashText = "missingno";
updateCheckerOverlay = new GuiUpdateCheckerOverlay(false, this);
BufferedReader bufferedreader = null;
@ -153,30 +159,59 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
this.updateCounter = RANDOM.nextFloat();
reloadResourceFlags();
}
private void reloadResourceFlags() {
if (Minecraft.getMinecraft().isDemo()) {
this.isDefault = false;
} else {
MD5Digest md5 = new MD5Digest();
SHA1Digest sha1 = new SHA1Digest();
byte[] md5out = new byte[16];
byte[] sha1out = new byte[20];
try {
byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(Minecraft.getMinecraft().getResourceManager()
.getResource(minecraftTitleTextures).getInputStream());
if (bytes != null) {
md5.update(bytes, 0, bytes.length);
sha1.update(bytes, 0, bytes.length);
md5.doFinal(md5out, 0);
sha1.doFinal(sha1out, 0);
this.isDefault = bytes.length == lendef && Arrays.equals(md5out, md5def)
&& Arrays.equals(sha1out, sha1def);
} else {
if (!EagRuntime.getConfiguration().isEnableMinceraft()) {
this.isDefault = false;
} else {
try {
byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(Minecraft.getMinecraft()
.getResourceManager().getResource(minecraftTitleTextures).getInputStream());
if (bytes != null && bytes.length == lendef) {
SHA1Digest sha1 = new SHA1Digest();
byte[] sha1out = new byte[20];
sha1.update(bytes, 0, bytes.length);
sha1.doFinal(sha1out, 0);
this.isDefault = Arrays.equals(sha1out, sha1def);
} else {
this.isDefault = false;
}
} catch (IOException e) {
this.isDefault = false;
}
} catch (IOException e) {
this.isDefault = false;
}
}
this.enableBlur = true;
try {
byte[] bytes = EaglerInputStream.inputStreamToBytesQuiet(
Minecraft.getMinecraft().getResourceManager().getResource(minecraftTitleBlurFlag).getInputStream());
if (bytes != null) {
String[] blurCfg = EagUtils.linesArray(new String(bytes, StandardCharsets.UTF_8));
for (int i = 0; i < blurCfg.length; ++i) {
String s = blurCfg[i];
if (s.startsWith("enable_blur=")) {
s = s.substring(12).trim();
this.enableBlur = s.equals("1") || s.equals("true");
break;
}
}
}
} catch (IOException e) {
;
}
}
public static void doResourceReloadHack() {
if (instance != null) {
instance.shouldReload = true;
}
}
/**+
@ -187,6 +222,10 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
if (downloadOfflineButton != null) {
downloadOfflineButton.enabled = !UpdateService.shouldDisableDownloadButton();
}
if (shouldReload) {
reloadResourceFlags();
shouldReload = false;
}
}
/**+
@ -372,19 +411,25 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
GlStateManager.matrixMode(GL_PROJECTION);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
if (enableBlur) {
GlStateManager.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
} else {
GlStateManager.gluPerspective(85.0F, (float) width / (float) height, 0.05F, 10.0F);
}
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
if (enableBlur) {
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
}
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.disableCull();
GlStateManager.depthMask(false);
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
byte b0 = 8;
byte b0 = enableBlur ? (byte) 8 : (byte) 1;
for (int i = 0; i < b0 * b0; ++i) {
GlStateManager.pushMatrix();
@ -521,7 +566,11 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
*/
public void drawScreen(int i, int j, float f) {
GlStateManager.disableAlpha();
this.renderSkybox(i, j, f);
if (enableBlur) {
this.renderSkybox(i, j, f);
} else {
this.drawPanorama(i, j, f);
}
GlStateManager.enableAlpha();
short short1 = 274;
int k = this.width / 2 - short1 / 2;
@ -530,7 +579,11 @@ public class GuiMainMenu extends GuiScreen implements GuiYesNoCallback {
this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE);
this.mc.getTextureManager().bindTexture(minecraftTitleTextures);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (this.isDefault || (double) this.updateCounter < 1.0E-4D) {
boolean minc = (double) this.updateCounter < 1.0E-4D;
if (this.isDefault) {
minc = !minc;
}
if (minc) {
this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44);
this.drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44);
this.drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44);

View file

@ -174,7 +174,12 @@ public class ServerData {
this.serverMOTD = motd.length() > 0
? (motd.length() > 1 ? motd.getString(0) + "\n" + motd.getString(1) : motd.getString(0))
: "";
this.populationInfo = "" + motdData.getInt("online") + "/" + motdData.getInt("max");
int max = motdData.getInt("max");
if (max > 0) {
this.populationInfo = "" + motdData.getInt("online") + "/" + max;
} else {
this.populationInfo = "" + motdData.getInt("online");
}
this.playerList = null;
JSONArray players = motdData.optJSONArray("players");
if (players.length() > 0) {