Update #30 - Fixed various client bugs

This commit is contained in:
lax1dude
2024-05-18 23:17:29 -07:00
parent 32fda35ace
commit c6ac781036
50 changed files with 798 additions and 446 deletions

View File

@ -61,7 +61,7 @@ public class EaglerSkinTexture implements ITextureObject {
}
System.arraycopy(pixels, 0, this.pixels, 0, pixels.length);
if(textureId != -1) {
TextureUtil.uploadTextureImageAllocate(textureId, new ImageData(width, height, pixels, true), false, false);
TextureUtil.uploadTextureImageSub(textureId, new ImageData(width, height, pixels, true), 0, 0, false, false);
}
}

View File

@ -73,14 +73,20 @@ public class GuiScreenEditProfile extends GuiScreen {
}
private void updateOptions() {
DefaultSkins[] arr = DefaultSkins.defaultSkinsMap;
if(!EagRuntime.getConfiguration().isAllowFNAWSkins()) {
DefaultSkins[] arrNoFNAW = new DefaultSkins[arr.length - 5];
System.arraycopy(arr, 0, arrNoFNAW, 0, arrNoFNAW.length);
arr = arrNoFNAW;
}
int numCustom = EaglerProfile.customSkins.size();
String[] n = new String[numCustom + DefaultSkins.defaultSkinsMap.length];
String[] n = new String[numCustom + arr.length];
for(int i = 0; i < numCustom; ++i) {
n[i] = EaglerProfile.customSkins.get(i).name;
}
int numDefault = DefaultSkins.defaultSkinsMap.length;
int numDefault = arr.length;
for(int j = 0; j < numDefault; ++j) {
n[numCustom + j] = DefaultSkins.defaultSkinsMap[j].name;
n[numCustom + j] = arr[j].name;
}
dropDownOptions = n;
}
@ -106,6 +112,10 @@ public class GuiScreenEditProfile extends GuiScreen {
GlStateManager.translate(skinX + 2, skinY - 9, 0.0f);
GlStateManager.scale(0.75f, 0.75f, 0.75f);
if(selectedSlot > dropDownOptions.length - 1) {
selectedSlot = 0;
}
int numberOfCustomSkins = EaglerProfile.customSkins.size();
int skid = selectedSlot - numberOfCustomSkins;
SkinModel selectedSkinModel = skid < 0 ? EaglerProfile.customSkins.get(selectedSlot).model : DefaultSkins.getSkinFromId(skid).model;

View File

@ -56,11 +56,15 @@ public class GuiScreenImportExportProfile extends GuiScreen {
FileChooserResult result = EagRuntime.getFileChooserResult();
if(result != null) {
mc.loadingScreen.eaglerShow(I18n.format("settingsBackup.importing.1"), "settingsBackup.importing.2");
ProfileImporter importer = new ProfileImporter(result.fileData);
try {
ProfileImporter importer = new ProfileImporter(result.fileData);
importer.readHeader();
mc.displayGuiScreen(new GuiScreenImportProfile(importer, back));
}catch(IOException ex) {
try {
importer.close();
} catch (IOException e) {
}
EagRuntime.debugPrintStackTrace(ex);
mc.displayGuiScreen(new GuiScreenGenericErrorMessage("settingsBackup.importing.failed.1", "settingsBackup.importing.failed.2", back));
}

View File

@ -62,6 +62,14 @@ public class GuiScreenImportProfile extends GuiScreen {
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 140, I18n.format("gui.cancel")));
}
@Override
public void onGuiClosed() {
try {
importer.close();
} catch (IOException e) {
}
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 0) {
if(!doImportProfile && !doImportSettings && !doImportServers && !doImportResourcePacks) {

View File

@ -69,98 +69,97 @@ public class ProfileExporter {
osb.write(new byte[]{(byte)255,(byte)255,(byte)255,(byte)255}); // this will be replaced with the file count
osb.write('G');
OutputStream os = EaglerZLIB.newGZIPOutputStream(osb);
os.write(new byte[]{(byte)72,(byte)69,(byte)65,(byte)68}); // HEAD
os.write(new byte[]{(byte)9,(byte)102,(byte)105,(byte)108,(byte)101,(byte)45,(byte)116,(byte)121,
(byte)112,(byte)101}); // 9 + file-type
os.write(new byte[]{(byte)0,(byte)0,(byte)0,(byte)14,(byte)101,(byte)112,(byte)107,(byte)47,(byte)112,(byte)114,(byte)111,
(byte)102,(byte)105,(byte)108,(byte)101,(byte)49,(byte)56,(byte)56}); // 14 + epk/profile188
os.write('>');
os.write(new byte[]{(byte)72,(byte)69,(byte)65,(byte)68}); // HEAD
os.write(new byte[]{(byte)12,(byte)102,(byte)105,(byte)108,(byte)101,(byte)45,(byte)101,(byte)120,
(byte)112,(byte)111,(byte)114,(byte)116,(byte)115,(byte)0,(byte)0,(byte)0,(byte)1}); // 12 + file-exports + 1
os.write((doExportProfile ? 1 : 0) | (doExportSettings ? 2 : 0) | (doExportServers ? 4 : 0) | (doExportResourcePacks ? 8 : 0));
os.write('>');
int fileCount = 2;
if(doExportProfile) {
byte[] profileData = EaglerProfile.write();
if(profileData == null) {
throw new IOException("Could not write profile data!");
}
exportFileToEPK("_eaglercraftX.p", profileData, os);
++fileCount;
}
if(doExportSettings) {
logger.info("Exporting game settings...");
byte[] gameSettings = Minecraft.getMinecraft().gameSettings.writeOptions();
if(gameSettings == null) {
throw new IOException("Could not write game settings!");
}
exportFileToEPK("_eaglercraftX.g", gameSettings, os);
++fileCount;
logger.info("Exporting relay settings...");
byte[] relays = RelayManager.relayManager.write();
if(relays == null) {
throw new IOException("Could not write relay settings!");
}
exportFileToEPK("_eaglercraftX.r", relays, os);
++fileCount;
}
if(doExportServers) {
logger.info("Exporting server list...");
byte[] servers = ServerList.getServerList().writeServerList();
if(servers == null) {
throw new IOException("Could not write server list!");
}
exportFileToEPK("_eaglercraftX.s", servers, os);
++fileCount;
}
logger.info("Exporting certificates...");
UpdateCertificate cert = UpdateService.getClientCertificate();
if(cert != null) {
exportFileToEPK("certs/main.cert", cert.rawCertData, os);
++fileCount;
}
Collection<UpdateCertificate> updatesExport = UpdateService.getAvailableUpdates();
int cc = 0;
for(UpdateCertificate cert2 : updatesExport) {
exportFileToEPK("certs/c" + (cc++) + ".cert", cert2.rawCertData, os);
++fileCount;
}
if(doExportResourcePacks) {
logger.info("Exporting resource packs...");
byte[] packManifest = (new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json")).getAllBytes();
if(packManifest != null) {
exportFileToEPK(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json", packManifest, os);
try(OutputStream os = EaglerZLIB.newGZIPOutputStream(osb)) {
os.write(new byte[]{(byte)72,(byte)69,(byte)65,(byte)68}); // HEAD
os.write(new byte[]{(byte)9,(byte)102,(byte)105,(byte)108,(byte)101,(byte)45,(byte)116,(byte)121,
(byte)112,(byte)101}); // 9 + file-type
os.write(new byte[]{(byte)0,(byte)0,(byte)0,(byte)14,(byte)101,(byte)112,(byte)107,(byte)47,(byte)112,(byte)114,(byte)111,
(byte)102,(byte)105,(byte)108,(byte)101,(byte)49,(byte)56,(byte)56}); // 14 + epk/profile188
os.write('>');
os.write(new byte[]{(byte)72,(byte)69,(byte)65,(byte)68}); // HEAD
os.write(new byte[]{(byte)12,(byte)102,(byte)105,(byte)108,(byte)101,(byte)45,(byte)101,(byte)120,
(byte)112,(byte)111,(byte)114,(byte)116,(byte)115,(byte)0,(byte)0,(byte)0,(byte)1}); // 12 + file-exports + 1
os.write((doExportProfile ? 1 : 0) | (doExportSettings ? 2 : 0) | (doExportServers ? 4 : 0) | (doExportResourcePacks ? 8 : 0));
os.write('>');
if(doExportProfile) {
byte[] profileData = EaglerProfile.write();
if(profileData == null) {
throw new IOException("Could not write profile data!");
}
exportFileToEPK("_eaglercraftX.p", profileData, os);
++fileCount;
VFile2 baseDir = new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS);
List<VFile2> files = baseDir.listFiles(true);
logger.info("({} files to export)", files.size());
for(int i = 0, l = files.size(); i < l; ++i) {
VFile2 f = files.get(i);
if(f.getPath().equals(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json")) {
continue;
}
exportFileToEPK(f.getPath(), f.getAllBytes(), os);
}
if(doExportSettings) {
logger.info("Exporting game settings...");
byte[] gameSettings = Minecraft.getMinecraft().gameSettings.writeOptions();
if(gameSettings == null) {
throw new IOException("Could not write game settings!");
}
exportFileToEPK("_eaglercraftX.g", gameSettings, os);
++fileCount;
logger.info("Exporting relay settings...");
byte[] relays = RelayManager.relayManager.write();
if(relays == null) {
throw new IOException("Could not write relay settings!");
}
exportFileToEPK("_eaglercraftX.r", relays, os);
++fileCount;
}
if(doExportServers) {
logger.info("Exporting server list...");
byte[] servers = ServerList.getServerList().writeServerList();
if(servers == null) {
throw new IOException("Could not write server list!");
}
exportFileToEPK("_eaglercraftX.s", servers, os);
++fileCount;
}
logger.info("Exporting certificates...");
UpdateCertificate cert = UpdateService.getClientCertificate();
if(cert != null) {
exportFileToEPK("certs/main.cert", cert.rawCertData, os);
++fileCount;
}
Collection<UpdateCertificate> updatesExport = UpdateService.getAvailableUpdates();
int cc = 0;
for(UpdateCertificate cert2 : updatesExport) {
exportFileToEPK("certs/c" + (cc++) + ".cert", cert2.rawCertData, os);
++fileCount;
}
if(doExportResourcePacks) {
logger.info("Exporting resource packs...");
byte[] packManifest = (new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json")).getAllBytes();
if(packManifest != null) {
exportFileToEPK(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json", packManifest, os);
++fileCount;
if(i > 0 && i % 100 == 0) {
logger.info("Exported {} files", i);
VFile2 baseDir = new VFile2(EaglerFolderResourcePack.RESOURCE_PACKS);
List<VFile2> files = baseDir.listFiles(true);
logger.info("({} files to export)", files.size());
for(int i = 0, l = files.size(); i < l; ++i) {
VFile2 f = files.get(i);
if(f.getPath().equals(EaglerFolderResourcePack.RESOURCE_PACKS + "/manifest.json")) {
continue;
}
exportFileToEPK(f.getPath(), f.getAllBytes(), os);
++fileCount;
if(i > 0 && i % 100 == 0) {
logger.info("Exported {} files", i);
}
}
}
}
os.write(new byte[]{(byte)69,(byte)78,(byte)68,(byte)36}); // END$
}
os.write(new byte[]{(byte)69,(byte)78,(byte)68,(byte)36}); // END$
os.close();
osb.write(new byte[]{(byte)58,(byte)58,(byte)58,(byte)89,(byte)69,(byte)69,(byte)58,(byte)62}); // :::YEE:>
byte[] ret = osb.toByteArray();

View File

@ -1,5 +1,6 @@
package net.lax1dude.eaglercraft.v1_8.profile;
import java.io.Closeable;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
@ -29,7 +30,7 @@ import net.minecraft.client.multiplayer.ServerList;
* POSSIBILITY OF SUCH DAMAGE.
*
*/
public class ProfileImporter {
public class ProfileImporter implements Closeable {
private static final Logger logger = LogManager.getLogger("ProfileImporter");
@ -148,4 +149,9 @@ public class ProfileImporter {
}
logger.info("Import complete!");
}
@Override
public void close() throws IOException {
epkDecompiler.close();
}
}

View File

@ -468,4 +468,13 @@ public class RenderHighPoly extends RenderPlayer {
GlStateManager.popMatrix();
}
}
public void renderLivingAt(AbstractClientPlayer abstractclientplayer, double d0, double d1, double d2) {
if (abstractclientplayer.isEntityAlive() && abstractclientplayer.isPlayerSleeping()) {
super.renderLivingAt(abstractclientplayer, d0 - (double) abstractclientplayer.renderOffsetX,
d1 - (double) abstractclientplayer.renderOffsetY, d2 - (double) abstractclientplayer.renderOffsetZ);
} else {
super.renderLivingAt(abstractclientplayer, d0, d1, d2);
}
}
}

View File

@ -46,7 +46,7 @@ public enum SkinModel {
private SkinModel(int id, HighPolySkin highPoly) {
this.id = id;
this.width = 256;
this.height = 128;
this.height = 256;
this.profileSkinType = "eagler";
this.sanitize = true;
this.highPoly = highPoly;