fixed skin issue

This commit is contained in:
LAX1DUDE 2022-03-09 17:51:58 -08:00
parent 9f2bcf7e9d
commit 37bfa17c72
9 changed files with 43 additions and 25 deletions

View file

@ -41,27 +41,31 @@ public class PluginEaglerSkins extends Plugin implements Listener {
if(event.getSender() instanceof UserConnection && event.getData().length > 0) {
String user = ((UserConnection)event.getSender()).getName();
byte[] msg = event.getData();
if("EAG|MySkin".equals(event.getTag())) {
int t = (int)msg[0] & 0xFF;
if(t >= 0 && t < SKIN_DATA_SIZE.length && msg.length == (SKIN_DATA_SIZE[t] + 1)) {
if(msg.length == 2) {
if(((int)msg[1] & 0xFF) >= VALID_DEFAULT_SKINS) {
msg[1] = 0;
try {
if("EAG|MySkin".equals(event.getTag())) {
int t = (int)msg[0] & 0xFF;
if(t >= 0 && t < SKIN_DATA_SIZE.length && msg.length == (SKIN_DATA_SIZE[t] + 1)) {
if(msg.length == 2) {
if(((int)msg[1] & 0xFF) >= VALID_DEFAULT_SKINS) {
msg[1] = 0;
}
}
skinCollection.put(user, msg);
}
}else if("EAG|FetchSkin".equals(event.getTag())) {
if(msg.length > 2) {
String fetch = new String(msg, 2, msg.length - 2, StandardCharsets.UTF_8);
byte[] data;
if((data = skinCollection.get(fetch)) != null) {
byte[] conc = new byte[data.length + 2];
conc[0] = msg[0]; conc[1] = msg[1]; //synchronization cookie
System.arraycopy(data, 0, conc, 2, data.length);
((UserConnection)event.getSender()).sendData("EAG|UserSkin", conc);
}
}
skinCollection.put(user, msg);
}
}else if("EAG|FetchSkin".equals(event.getTag())) {
if(msg.length > 2) {
String fetch = new String(msg, 2, msg.length - 2, StandardCharsets.UTF_8);
byte[] data;
if((data = skinCollection.get(fetch)) != null) {
byte[] conc = new byte[data.length + 2];
conc[0] = msg[0]; conc[1] = msg[1]; //synchronization cookie
System.arraycopy(data, 0, conc, 2, data.length);
((UserConnection)event.getSender()).sendData("EAG|UserSkin", conc);
}
}
}catch(Throwable t) {
// hacker
}
}
}

View file

@ -4,7 +4,7 @@ public class ConfigConstants {
public static boolean profanity = false;
public static final String version = "22w07a";
public static final String version = "22w10a";
public static final String mainMenuString = "eaglercraft " + version;
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft";

View file

@ -119,7 +119,9 @@ public class DefaultSkinRenderer {
break;
}
skinGLUnits.put(pp, Minecraft.getMinecraft().renderEngine.setupTextureRaw(skinToLoad, w, h));
if(skinToLoad.length / 4 == w * h) {
skinGLUnits.put(pp, Minecraft.getMinecraft().renderEngine.setupTextureRaw(skinToLoad, w, h));
}
}
skinGLTimeout.put(pp, System.currentTimeMillis());
Integer i = skinGLUnits.get(pp);

View file

@ -60,6 +60,11 @@ public class EaglerProfile {
}
int t = getSkinSize(data.length);
if(t == -1) {
return -1;
}
int w, h;
switch(t) {

View file

@ -256,9 +256,10 @@ public class GuiScreenEditProfile extends GuiScreen {
if(name.length() > 32) {
name = name.substring(0, 32);
}
EaglerProfile.addSkin(name, rawSkin);
selectedSlot = EaglerProfile.skinNames.size() - 1;
this.dropDownOptions = EaglerProfile.concatArrays(EaglerProfile.skinNames.toArray(new String[0]), defaultOptions);
if(EaglerProfile.addSkin(name, rawSkin) != -1) {
selectedSlot = EaglerProfile.skinNames.size() - 1;
this.dropDownOptions = EaglerProfile.concatArrays(EaglerProfile.skinNames.toArray(new String[0]), defaultOptions);
}
}
}

View file

@ -496,6 +496,9 @@ public class Minecraft implements Runnable {
this.currentScreen.onGuiClosed();
}
while(EaglerAdapter.keysNext());
while(EaglerAdapter.mouseNext());
if (par1GuiScreen == null && this.theWorld == null) {
par1GuiScreen = new GuiMainMenu();
} else if (par1GuiScreen == null && this.thePlayer.getHealth() <= 0) {

View file

@ -25,7 +25,9 @@ public class Packet250CustomPayload extends Packet {
this.length = par2ArrayOfByte.length;
if (this.length > 32767) {
throw new IllegalArgumentException("Payload may not be larger than 32k");
System.err.println("Tried to send '" + this.channel + "' with size " + this.length + " which is larger than the 32k so it was truncated down to 1 byte");
this.length = 1;
this.data = new byte[] { (byte) 0xFF };
}
}
}

View file

@ -1539,6 +1539,8 @@ public class RenderGlobal implements IWorldAccess {
* Plays the specified record. Arg: recordName, x, y, z
*/
public void playRecord(String par1Str, int par2, int par3, int par4) {
Minecraft.getMinecraft().displayEaglercraftText("records have been deleted to reduce file size");
ItemRecord var5 = ItemRecord.getRecord(par1Str);
if (par1Str != null && var5 != null) {

View file

@ -17,7 +17,6 @@ import org.teavm.jso.ajax.ReadyStateChangeHandler;
import org.teavm.jso.ajax.XMLHttpRequest;
import org.teavm.jso.browser.TimerHandler;
import org.teavm.jso.browser.Window;
import org.teavm.jso.core.JSNumber;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.events.KeyboardEvent;
import org.teavm.jso.dom.events.MessageEvent;