Update #39 - Fix various issues with the client

This commit is contained in:
lax1dude
2024-09-26 21:47:56 -07:00
parent c0eddc3dfd
commit 82a70b7649
24 changed files with 314 additions and 45 deletions

View File

@ -61,7 +61,7 @@ public class ArrayUtils {
public static String hexString(byte[] bytesIn) {
char[] ret = new char[bytesIn.length << 1];
for(int i = 0; i < bytesIn.length; ++i) {
ret[i << 1] = hex.charAt((bytesIn[i] >> 4) & 15);
ret[i << 1] = hex.charAt((bytesIn[i] >>> 4) & 15);
ret[(i << 1) + 1] = hex.charAt(bytesIn[i] & 15);
}
return new String(ret);

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 = "u38";
public static final String projectForkVersion = "u39";
public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -20,18 +20,20 @@ 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 = "u38";
public static final String projectOriginVersion = "u39";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
// EPK Version Identifier
public static final String EPKVersionIdentifier = "u39"; // Set to null to disable EPK version check
// Updating configuration
public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 38;
public static final int updateBundlePackageVersionInt = 39;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -271,6 +271,7 @@ public class EaglerFolderResourcePack extends AbstractResourcePack {
public static void loadRemoteResourcePack(String url, String hash, Consumer<EaglerFolderResourcePack> cb, Consumer<Runnable> ast, Runnable loading) {
if (!isSupported || !hash.matches("^[a-f0-9]{40}$")) {
logger.error("Invalid character in resource pack hash! (is it lowercase?)");
cb.accept(null);
return;
}
@ -292,8 +293,9 @@ public class EaglerFolderResourcePack extends AbstractResourcePack {
digest.update(arr, 0, arr.length);
byte[] hashOut = new byte[20];
digest.doFinal(hashOut, 0);
if(!hash.equals(ArrayUtils.hexString(hashOut))) {
logger.error("Downloaded resource pack hash does not equal expected resource pack hash!");
String hashOutStr = ArrayUtils.hexString(hashOut);
if(!hash.equals(hashOutStr)) {
logger.error("Downloaded resource pack hash does not equal expected resource pack hash! ({} != {})", hashOutStr, hash);
cb.accept(null);
return;
}

View File

@ -9,6 +9,7 @@ import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.lax1dude.eaglercraft.v1_8.HString;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@ -464,7 +465,7 @@ public class EaglerProfile {
rand = new EaglercraftRandom();
do {
username = defaultNames[rand.nextInt(defaultNames.length)] + defaultNames[rand.nextInt(defaultNames.length)] + (100 + rand.nextInt(900));
username = HString.format("%s%s%04d", defaultNames[rand.nextInt(defaultNames.length)], defaultNames[rand.nextInt(defaultNames.length)], rand.nextInt(10000));
}while(username.length() > 16);
setName(username);
@ -479,4 +480,8 @@ public class EaglerProfile {
}
public static boolean isDefaultUsername(String str) {
return str.toLowerCase().matches("^(yeeish|yee|yeer|yeeler|eagler|eagl|darver|darvler|vool|vigg|deev|yigg|yeeg){2}\\d{2,4}$");
}
}

View File

@ -0,0 +1,61 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
/**
* Copyright (c) 2024 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class GuiScreenDefaultUsernameNote extends GuiScreen {
private final GuiScreen back;
private final GuiScreen cont;
public GuiScreenDefaultUsernameNote(GuiScreen back, GuiScreen cont) {
this.back = back;
this.cont = cont;
}
public void initGui() {
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 6 + 112, I18n.format("defaultUsernameDetected.changeUsername")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 6 + 142, I18n.format("defaultUsernameDetected.continueAnyway")));
this.buttonList.add(new GuiButton(2, this.width / 2 - 100, this.height / 6 + 172, I18n.format("defaultUsernameDetected.doNotShow")));
}
public void drawScreen(int par1, int par2, float par3) {
this.drawDefaultBackground();
this.drawCenteredString(fontRendererObj, I18n.format("defaultUsernameDetected.title"), this.width / 2, 70, 11184810);
this.drawCenteredString(fontRendererObj, I18n.format("defaultUsernameDetected.text0", EaglerProfile.getName()), this.width / 2, 90, 16777215);
this.drawCenteredString(fontRendererObj, I18n.format("defaultUsernameDetected.text1"), this.width / 2, 105, 16777215);
this.drawCenteredString(fontRendererObj, I18n.format("defaultUsernameDetected.text2"), this.width / 2, 120, 16777215);
super.drawScreen(par1, par2, par3);
}
@Override
protected void actionPerformed(GuiButton parGuiButton) {
if(parGuiButton.id == 0) {
this.mc.displayGuiScreen(back);
}else if(parGuiButton.id == 1) {
this.mc.displayGuiScreen(cont);
}else if(parGuiButton.id == 2) {
this.mc.gameSettings.hideDefaultUsernameWarning = true;
this.mc.gameSettings.saveOptions();
this.mc.displayGuiScreen(cont);
}
}
}

View File

@ -315,7 +315,11 @@ public class GuiScreenEditProfile extends GuiScreen {
if(par1GuiButton.id == 0) {
safeProfile();
EaglerProfile.save();
this.mc.displayGuiScreen((GuiScreen) parent);
if(!this.mc.gameSettings.hideDefaultUsernameWarning && EaglerProfile.isDefaultUsername(EaglerProfile.getName())) {
this.mc.displayGuiScreen(new GuiScreenDefaultUsernameNote(this, parent));
}else {
this.mc.displayGuiScreen(parent);
}
}else if(par1GuiButton.id == 1) {
EagRuntime.displayFileChooser("image/png", "png");
}else if(par1GuiButton.id == 2) {