added multiplayer capes

This commit is contained in:
LAX1DUDE 2022-06-29 23:23:12 -07:00
parent 6191d0ef77
commit 13ee2375fa
28 changed files with 720 additions and 85 deletions

View File

@ -13,10 +13,12 @@ import net.md_5.bungee.api.plugin.PluginDescription;
import net.md_5.bungee.event.EventHandler;
public class PluginEaglerSkins extends Plugin implements Listener {
private final HashMap<String,byte[]> skinCollection = new HashMap();
private static final int[] SKIN_DATA_SIZE = new int[] { 64*32*4, 64*64*4, 128*64*4, 128*128*4, 1, 64*64*4, 128*128*4 };
private final HashMap<String,byte[]> capeCollection = new HashMap();
private static final int[] SKIN_DATA_SIZE = new int[] { 64*32*4, 64*64*4, -9, -9, 1, 64*64*4, -9 }; // 128 pixel skins crash clients
private static final int[] CAPE_DATA_SIZE = new int[] { 32*32*4, -9, 1 };
public PluginEaglerSkins() {
super(new PluginDescription("EaglerSkins", PluginEaglerSkins.class.getName(), "1.0.0", "LAX1DUDE", Collections.emptySet(), null));
@ -45,6 +47,11 @@ public class PluginEaglerSkins extends Plugin implements Listener {
if(t >= 0 && t < SKIN_DATA_SIZE.length && msg.length == (SKIN_DATA_SIZE[t] + 1)) {
skinCollection.put(user, msg);
}
}else if("EAG|MyCape".equals(event.getTag())) {
int t = (int)msg[0] & 0xFF;
if(t >= 0 && t < CAPE_DATA_SIZE.length && msg.length == (CAPE_DATA_SIZE[t] + 1)) {
capeCollection.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);
@ -53,6 +60,12 @@ public class PluginEaglerSkins extends Plugin implements Listener {
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);
if((data = capeCollection.get(fetch)) != null) {
byte[] conc2 = new byte[conc.length + data.length];
System.arraycopy(conc, 0, conc2, 0, conc.length);
System.arraycopy(data, 0, conc2, conc.length, data.length);
conc = conc2;
}
((UserConnection)event.getSender()).sendData("EAG|UserSkin", conc);
}
}
@ -66,6 +79,7 @@ public class PluginEaglerSkins extends Plugin implements Listener {
@EventHandler
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
skinCollection.remove(event.getPlayer().getName());
capeCollection.remove(event.getPlayer().getName());
}
}

View File

@ -31,11 +31,32 @@ menu.convertingLevel=Converting world
menu.simulating=Simulating the world for a bit
menu.respawning=Respawning
menu.shareToLan=Open to LAN
menu.skinCapeSettings=Skins/Capes Settings...
menu.skinCapeSettingsNote0=I put the button up here so
menu.skinCapeSettingsNote1=lazy people can find it
menu.skinCapeSettings.skinCustomization=Skin Customization
menu.skinCapeSettings.skinCustomization.cape=Cape
menu.skinCapeSettings.skinCustomization.jacket=Jacket
menu.skinCapeSettings.skinCustomization.hat=Hat
menu.skinCapeSettings.skinCustomization.leftArm=Left Sleeve
menu.skinCapeSettings.skinCustomization.rightArm=Right Sleeve
menu.skinCapeSettings.skinCustomization.leftPants=Left Pants Leg
menu.skinCapeSettings.skinCustomization.rightPants=Right Pants Leg
menu.skinCapeSettings.skinCustomization.allOff=All Off
menu.skinCapeSettings.skinCustomization.allOn=All On
menu.skinCapeSettings.skinCustomization.otherPlayers=Other Players
menu.skinCapeSettings.skinCustomization.showErasersOn=Eraser Skins: Enable
menu.skinCapeSettings.skinCustomization.showErasersOff=Eraser Skins: Disable
menu.skinCapeSettings.skinCustomization.showOtherCapes=Show Capes
profile.title=Edit Profile
profile.capeTitle=Select Cape
profile.screenname=Screenname
profile.playerSkin=Player Skin
profile.playerCape=Player Cape
profile.addSkin=Add Skin
profile.addCape=Add Cape
profile.capes=Capes
profile.clearSkin=Clear List
fancyGraphicsNote=go to -> Options -> Video Settings on the pause menu to enable fancy graphics and smooth lighting
@ -293,7 +314,7 @@ options.particles=Particles
options.particles.all=All
options.particles.decreased=Decreased
options.particles.minimal=Minimal
options.multiplayer.title=Multiplayer Settings...
options.multiplayer.title=Chat Settings...
options.chat.title=Chat Settings...
options.chat.visibility=Chat
options.chat.visibility.full=Shown

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import net.lax1dude.eaglercraft.EaglerProfile.EaglerProfileCape;
import net.minecraft.client.Minecraft;
import net.minecraft.src.EntityClientPlayerMP;
import net.minecraft.src.EntityOtherPlayerMP;
@ -58,6 +59,30 @@ public class DefaultSkinRenderer {
null, null, null, null, null
};
public static final TextureLocation[] defaultVanillaCapes = new TextureLocation[] {
null,
new TextureLocation("/skins/c01.minecon_2011.png"),
new TextureLocation("/skins/c02.minecon_2012.png"),
new TextureLocation("/skins/c03.minecon_2013.png"),
new TextureLocation("/skins/c04.minecon_2015.png"),
new TextureLocation("/skins/c05.minecon_2016.png"),
new TextureLocation("/skins/c06.microsoft_account.png"),
new TextureLocation("/skins/c07.mapmaker.png"),
new TextureLocation("/skins/c08.mojang_old.png"),
new TextureLocation("/skins/c09.mojang_new.png"),
new TextureLocation("/skins/c10.jira_mod.png"),
new TextureLocation("/skins/c11.mojang_very_old.png"),
new TextureLocation("/skins/c12.scrolls.png"),
new TextureLocation("/skins/c13.cobalt.png"),
new TextureLocation("/skins/c14.translator.png"),
new TextureLocation("/skins/c15.millionth_account.png"),
new TextureLocation("/skins/c16.prismarine.png"),
new TextureLocation("/skins/c17.snowman.png"),
new TextureLocation("/skins/c18.spade.png"),
new TextureLocation("/skins/c19.birthday.png"),
new TextureLocation("/skins/c20.db.png")
};
public static final HighPolySkin[] defaultHighPoly = new HighPolySkin[] {
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
@ -81,6 +106,7 @@ public class DefaultSkinRenderer {
private static final HashMap<Integer,EntityOtherPlayerMP> skinCookies = new HashMap();
private static final HashMap<EntityOtherPlayerMP,Integer> skinGLUnits = new HashMap();
private static final HashMap<EntityOtherPlayerMP,Integer> capeGLUnits = new HashMap();
private static final HashMap<EntityOtherPlayerMP,Long> skinGLTimeout = new HashMap();
private static long lastClean = 0l;
@ -96,6 +122,9 @@ public class DefaultSkinRenderer {
if(skinGLUnits.containsKey(ee.getKey())) {
Minecraft.getMinecraft().renderEngine.deleteTexture(skinGLUnits.remove(ee.getKey()));
}
if(capeGLUnits.containsKey(ee.getKey())) {
Minecraft.getMinecraft().renderEngine.deleteTexture(capeGLUnits.remove(ee.getKey()));
}
}
}
Iterator<Entry<Integer, EntityOtherPlayerMP>> itr2 = skinCookies.entrySet().iterator();
@ -114,9 +143,10 @@ public class DefaultSkinRenderer {
}else if(p instanceof EntityOtherPlayerMP) {
EntityOtherPlayerMP pp = (EntityOtherPlayerMP) p;
if(pp.skinPacket != null) {
if(((int)pp.skinPacket[0] & 0xFF) != 4) {
int type = ((int)pp.skinPacket[0] & 0xFF);
if(type != 4 && type >= 0 && type < EaglerProfile.SKIN_DATA_SIZE.length) {
if(!skinGLUnits.containsKey(pp)) {
byte[] skinToLoad = new byte[pp.skinPacket.length - 1];
byte[] skinToLoad = new byte[EaglerProfile.SKIN_DATA_SIZE[type]];
System.arraycopy(pp.skinPacket, 1, skinToLoad, 0, skinToLoad.length);
int w, h;
@ -131,15 +161,6 @@ public class DefaultSkinRenderer {
w = 64;
h = 64;
break;
case 2:
w = 128;
h = 64;
break;
case 3:
case 6:
w = 128;
h = 128;
break;
}
if(skinToLoad.length / 4 == w * h) {
@ -160,16 +181,7 @@ public class DefaultSkinRenderer {
}
return true;
}else {
if(!skinCookies.containsValue(pp)) {
int cookie = (int)(System.nanoTime() % 65536);
skinCookies.put(cookie, pp);
byte[] n = pp.username.getBytes();
byte[] pkt = new byte[n.length + 2];
System.arraycopy(n, 0, pkt, 2, n.length);
pkt[0] = (byte)(cookie & 0xFF);
pkt[1] = (byte)((cookie >> 8) & 0xFF);
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new Packet250CustomPayload("EAG|FetchSkin", pkt));
}
requestSkin(pp);
}
return false;
}else {
@ -177,6 +189,114 @@ public class DefaultSkinRenderer {
}
}
public static boolean bindSyncedCape(EntityPlayer p) {
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
EaglerAdapter.glPushMatrix();
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
if(p instanceof EntityClientPlayerMP) {
if(EaglerProfile.presetCapeId < 0) {
EaglerProfileCape cp = EaglerProfile.capes.get(EaglerProfile.customCapeId);
if(cp != null) {
Minecraft.getMinecraft().renderEngine.bindTexture(cp.glTex);
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
EaglerAdapter.glScalef(2.0f, 1.0f, 1.0f);
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
return true;
}else {
return false;
}
}else {
if(EaglerProfile.presetCapeId < defaultVanillaCapes.length) {
TextureLocation loc = defaultVanillaCapes[EaglerProfile.presetCapeId];
if(loc == null) {
return false;
}else {
loc.bindTexture();
return true;
}
}else {
return false;
}
}
}else if(p instanceof EntityOtherPlayerMP) {
EntityOtherPlayerMP pp = (EntityOtherPlayerMP) p;
if(pp.skinPacket != null) {
int tp = ((int)pp.skinPacket[0] & 0xFF);
if(tp >= 0 && tp < EaglerProfile.SKIN_DATA_SIZE.length) {
int offset = 1 + EaglerProfile.SKIN_DATA_SIZE[tp];
if(pp.skinPacket.length > offset) {
int capeType = (int)pp.skinPacket[offset] & 0xFF;
if(capeType >= 0 && capeType < EaglerProfile.CAPE_DATA_SIZE.length) {
int len = EaglerProfile.CAPE_DATA_SIZE[capeType];
if(pp.skinPacket.length > offset + len) {
if(capeType != 2) {
if(!capeGLUnits.containsKey(pp)) {
byte[] dataToLoad = new byte[len];
System.arraycopy(pp.skinPacket, offset + 1, dataToLoad, 0, len);
int w, h;
switch(capeType) {
case 0:
default:
w = 32;
h = 32;
break;
}
if(dataToLoad.length / 4 == w * h) {
capeGLUnits.put(pp, Minecraft.getMinecraft().renderEngine.setupTextureRaw(dataToLoad, w, h));
}
}
skinGLTimeout.put(pp, System.currentTimeMillis());
Integer i = capeGLUnits.get(pp);
if(i != null && i.intValue() > 0) {
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
EaglerAdapter.glScalef(2.0f, 1.0f, 1.0f);
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
Minecraft.getMinecraft().renderEngine.bindTexture(i.intValue());
return true;
}else {
return false;
}
}else {
int preset = (int)pp.skinPacket[offset + 1] & 0xFF;
if(preset < defaultVanillaCapes.length) {
TextureLocation loc = defaultVanillaCapes[preset];
if(loc == null) {
return false;
}else {
loc.bindTexture();
return true;
}
}else {
return false;
}
}
}
}
}
}
}else {
requestSkin(pp);
}
}
return false;
}
private static void requestSkin(EntityOtherPlayerMP pp) {
if(!skinCookies.containsValue(pp)) {
int cookie = (int)(System.nanoTime() % 65536);
skinCookies.put(cookie, pp);
byte[] n = pp.username.getBytes();
byte[] pkt = new byte[n.length + 2];
System.arraycopy(n, 0, pkt, 2, n.length);
pkt[0] = (byte)(cookie & 0xFF);
pkt[1] = (byte)((cookie >> 8) & 0xFF);
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new Packet250CustomPayload("EAG|FetchSkin", pkt));
}
}
public static void skinResponse(byte[] data) {
int cookie = ((int)data[0] & 0xFF) | (((int)data[1] & 0xFF) << 8);
if(skinCookies.containsKey(cookie) && (data.length > 3)) {
@ -322,6 +442,10 @@ public class DefaultSkinRenderer {
public static ModelSkeleton skeletonRenderer = null;
public static void renderPlayerPreview(int x, int y, int mx, int my, int id2) {
boolean capeMode = (id2 & 0x10000) == 0x10000;
if(capeMode) {
id2 -= 0x10000;
}
int id = id2 - EaglerProfile.skins.size();
boolean highPoly = isHighPoly(id);
@ -341,7 +465,13 @@ public class DefaultSkinRenderer {
EaglerAdapter.glScalef(1.0F, -1.0F, 1.0F);
RenderHelper.enableGUIStandardItemLighting();
EaglerAdapter.glTranslatef(0.0F, 1.0F, 0.0F);
EaglerAdapter.glRotatef(((y - my) * -0.06f), 1.0f, 0.0f, 0.0f);
if(capeMode) {
EaglerAdapter.glRotatef(140.0f, 0.0f, 1.0f, 0.0f);
mx = x - (x - mx) - 20;
EaglerAdapter.glRotatef(((y - my) * -0.02f), 1.0f, 0.0f, 0.0f);
}else {
EaglerAdapter.glRotatef(((y - my) * -0.06f), 1.0f, 0.0f, 0.0f);
}
EaglerAdapter.glRotatef(((x - mx) * 0.06f), 0.0f, 1.0f, 0.0f);
EaglerAdapter.glTranslatef(0.0F, -1.0F, 0.0F);
@ -426,6 +556,33 @@ public class DefaultSkinRenderer {
oldSkinRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
oldSkinRenderer.blockTransparentSkin = false;
}
if(capeMode && !(EaglerProfile.presetCapeId >= 0 && defaultVanillaCapes[EaglerProfile.presetCapeId] == null)) {
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(0.0F, 0.0F, 0.150F);
EaglerAdapter.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
EaglerAdapter.glRotatef(-6.0F, 1.0F, 0.0F, 0.0F);
if(EaglerProfile.presetCapeId < 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(EaglerProfile.capes.get(EaglerProfile.customCapeId).glTex);
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
EaglerAdapter.glPushMatrix();
EaglerAdapter.glScalef(2.0f, 1.0f, 1.0f);
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
}else {
defaultVanillaCapes[EaglerProfile.presetCapeId].bindTexture();
}
oldSkinRenderer.bipedCloak.render(0.0625F);
if(EaglerProfile.presetCapeId < 0) {
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
EaglerAdapter.glPopMatrix();
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
}
EaglerAdapter.glPopMatrix();
}
}else if(isZombieModel(id)) {
if(zombieRenderer == null) zombieRenderer = new ModelZombie(0.0F, true);
zombieRenderer.isChild = false;

View File

@ -21,17 +21,33 @@ public class EaglerProfile {
this.glTex = glTex;
}
}
public static class EaglerProfileCape {
public String name;
public byte[] data;
public int glTex;
public EaglerProfileCape(String name, byte[] data, int glTex) {
this.name = name;
this.data = data;
this.glTex = glTex;
}
}
public static String username;
public static int presetSkinId;
public static int customSkinId;
public static int presetCapeId;
public static int customCapeId;
public static int newSkinNotificationIndex = 0;
public static String myChannel;
public static final int[] SKIN_DATA_SIZE = new int[] { 64*32*4, 64*64*4, -9, -9, 1, 64*64*4, -9 };
public static final int[] CAPE_DATA_SIZE = new int[] { 32*32*4, -9, 1 };
public static final int[] SKIN_DATA_SIZE = new int[] { 64*32*4, 64*64*4, 128*64*4, 128*128*4, 2, 64*64*4, 128*128*4 };
public static ArrayList<EaglerProfileSkin> skins = new ArrayList();
public static ArrayList<EaglerProfileCape> capes = new ArrayList();
public static final EaglercraftRandom rand;
@ -44,11 +60,27 @@ public class EaglerProfile {
return -1;
}
public static int getCapeSize(int len) {
for(int i = 0; i < CAPE_DATA_SIZE.length; ++i) {
if(len == CAPE_DATA_SIZE[i]) {
return i;
}
}
return -1;
}
public static byte[] getSkinPacket() {
if(presetSkinId == -1) {
byte[] d = skins.get(customSkinId).data;
if(d == null) {
return new byte[] { (byte)4, (byte)0 };
}
byte[] d2 = new byte[1 + d.length];
d2[0] = (byte) getSkinSize(d.length);
int sz = getSkinSize(d.length);
if(sz < 0) {
return new byte[] { (byte)4, (byte)0 };
}
d2[0] = (byte) sz;
if(d2[0] == (byte)1 && skins.get(customSkinId).slim) {
d2[0] = (byte)5;
}
@ -62,6 +94,25 @@ public class EaglerProfile {
}
}
public static byte[] getCapePacket() {
if(presetCapeId == -1) {
byte[] d = capes.get(customCapeId).data;
if(d == null) {
return new byte[] { (byte)2, (byte)0 };
}
byte[] d2 = new byte[1 + d.length];
int sz = getCapeSize(d.length);
if(sz < 0) {
return new byte[] { (byte)2, (byte)0 };
}
d2[0] = (byte) sz;
System.arraycopy(d, 0, d2, 1, d.length);
return d2;
}else {
return new byte[] { (byte)2, (byte)presetCapeId };
}
}
public static String[] concatArrays(String[] a, String[] b) {
String[] r = new String[a.length + b.length];
System.arraycopy(a, 0, r, 0, a.length);
@ -96,15 +147,6 @@ public class EaglerProfile {
w = 64;
h = 64;
break;
case 2:
w = 128;
h = 64;
break;
case 3:
case 6:
w = 128;
h = 128;
break;
}
int im = Minecraft.getMinecraft().renderEngine.setupTextureRaw(data, w, h);
@ -120,6 +162,42 @@ public class EaglerProfile {
}
public static int addCape(String name, byte[] data) {
int i = -1;
for(int j = 0, l = capes.size(); j < l; ++j) {
if(capes.get(j).name.equalsIgnoreCase(name)) {
i = j;
break;
}
}
int t = getCapeSize(data.length);
if(t == -1) {
return -1;
}
int w, h;
switch(t) {
default:
case 0:
w = 32;
h = 32;
break;
}
int im = Minecraft.getMinecraft().renderEngine.setupTextureRaw(data, w, h);
if(i == -1) {
i = capes.size();
capes.add(new EaglerProfileCape(name, data, im));
}else {
capes.get(i).glTex = im;
capes.get(i).data = data;
}
return i;
}
static {
String[] usernameDefaultWords = ConfigConstants.profanity ? new String[] {
"Eagler", "Eagler", "Bitch", "Cock", "Milf", "Milf", "Yeer", "Groon",
@ -147,6 +225,8 @@ public class EaglerProfile {
if(!LocalStorageManager.profileSettingsStorage.hasNoTags()) {
presetSkinId = LocalStorageManager.profileSettingsStorage.getInteger("ps");
customSkinId = LocalStorageManager.profileSettingsStorage.getInteger("cs");
presetCapeId = LocalStorageManager.profileSettingsStorage.getInteger("pc");
customCapeId = LocalStorageManager.profileSettingsStorage.getInteger("cc");
username = LocalStorageManager.profileSettingsStorage.getString("name");
newSkinNotificationIndex = LocalStorageManager.profileSettingsStorage.getInteger("nsi");
if(newSkinNotificationIndex == 0) {
@ -163,6 +243,13 @@ public class EaglerProfile {
addSkin(s2, ((NBTTagCompound)k).getByteArray("data"), ((NBTTagCompound)k).getBoolean("slim"));
}
}
n = LocalStorageManager.profileSettingsStorage.getCompoundTag("capes");
for(Object s : NBTTagCompound.getTagMap(n).keySet()) {
NBTTagCompound ct = n.getCompoundTag((String)s);
addCape((String)s, ct.getByteArray("data"));
}
}else {
newSkinNotificationIndex = GuiScreenEditProfile.newDefaultNotice;
}
}

View File

@ -0,0 +1,307 @@
package net.lax1dude.eaglercraft;
import net.lax1dude.eaglercraft.EaglerProfile.EaglerProfileCape;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.StringTranslate;
public class GuiScreenEditCape extends GuiScreen {
private boolean dropDownOpen = false;
private String[] dropDownOptions;
private int slotsVisible = 0;
private int selectedSlot = 0;
private int scrollPos = -1;
private int skinsHeight = 0;
private boolean dragging = false;
private int mousex = 0;
private int mousey = 0;
public static final String[] defaultVanillaCapeNames = new String[] {
"No Cape",
"Minecon 2011",
"Minecon 2012",
"Minecon 2013",
"Minecon 2015",
"Minecon 2016",
"Microsoft Account",
"Realms Mapmaker",
"Mojang Old",
"Mojang New",
"Jira Moderator",
"Mojang Very Old",
"Scrolls",
"Cobalt",
"Lang Translator",
"Millionth Player",
"Prismarine",
"Snowman",
"Spade",
"Birthday",
"dB"
};
protected String screenTitle = "Select Cape";
private GuiScreen parent;
private int skinToShow;
public GuiScreenEditCape(GuiScreen parent, int skinToShow) {
this.parent = parent;
this.skinToShow = skinToShow;
reconcatDD();
this.selectedSlot = EaglerProfile.presetCapeId < 0 ? EaglerProfile.customCapeId : (EaglerProfile.presetCapeId + EaglerProfile.capes.size());
}
public void initGui() {
super.initGui();
EaglerAdapter.enableRepeatEvents(true);
StringTranslate var1 = StringTranslate.getInstance();
screenTitle = var1.translateKey("profile.capeTitle");
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done")));
this.buttonList.add(new GuiButton(2, this.width / 2 - 21, this.height / 6 + 81, 71, 20, var1.translateKey("profile.addCape")));
this.buttonList.add(new GuiButton(3, this.width / 2 - 21 + 71, this.height / 6 + 81, 72, 20, var1.translateKey("profile.clearSkin")));
}
public void onGuiClosed() {
EaglerAdapter.enableRepeatEvents(false);
}
private void reconcatDD() {
String[] n = new String[EaglerProfile.capes.size()];
for(int i = 0; i < n.length; ++i) {
n[i] = EaglerProfile.capes.get(i).name;
}
this.dropDownOptions = EaglerProfile.concatArrays(n, defaultVanillaCapeNames);
}
private static final TextureLocation gui = new TextureLocation("/gui/gui.png");
public void drawScreen(int mx, int my, float par3) {
StringTranslate var1 = StringTranslate.getInstance();
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 15, 16777215);
this.drawString(this.fontRenderer, "Player Cape", this.width / 2 - 20, this.height / 6 + 37, 10526880);
mousex = mx;
mousey = my;
int skinX = this.width / 2 - 120;
int skinY = this.height / 6 + 8;
int skinWidth = 80;
int skinHeight = 130;
drawRect(skinX, skinY, skinX + skinWidth, skinY + skinHeight, -6250336);
drawRect(skinX + 1, skinY + 1, skinX + skinWidth - 1, skinY + skinHeight - 1, 0xff000015);
if(dropDownOpen) {
super.drawScreen(-1, -1, par3);
}else {
super.drawScreen(mx, my, par3);
}
skinX = this.width / 2 - 20;
skinY = this.height / 6 + 53;
skinWidth = 140;
skinHeight = 22;
drawRect(skinX, skinY, skinX + skinWidth, skinY + skinHeight, -6250336);
drawRect(skinX + 1, skinY + 1, skinX + skinWidth - 21, skinY + skinHeight - 1, -16777216);
drawRect(skinX + skinWidth - 20, skinY + 1, skinX + skinWidth - 1, skinY + skinHeight - 1, -16777216);
EaglerAdapter.glColor4f(1f, 1f, 1f, 1f);
gui.bindTexture();
drawTexturedModalRect(skinX + skinWidth - 18, skinY + 3, 0, 240, 16, 16);
this.fontRenderer.drawStringWithShadow(dropDownOptions[selectedSlot], skinX + 5, skinY + 7, 14737632);
EaglerProfile.customCapeId = (selectedSlot < EaglerProfile.capes.size()) ? selectedSlot : -1;
EaglerProfile.presetCapeId = EaglerProfile.customCapeId < 0 ? (selectedSlot - EaglerProfile.capes.size()) : -1;
skinX = this.width / 2 - 20;
skinY = this.height / 6 + 74;
skinWidth = 140;
skinHeight = (this.height - skinY - 4);
slotsVisible = (skinHeight / 10);
if(slotsVisible > dropDownOptions.length) slotsVisible = dropDownOptions.length;
skinHeight = slotsVisible * 10 + 7;
skinsHeight = skinHeight;
if(scrollPos == -1) {
scrollPos = selectedSlot - 2;
}
if(scrollPos > (dropDownOptions.length - slotsVisible)) {
scrollPos = (dropDownOptions.length - slotsVisible);
}
if(scrollPos < 0) {
scrollPos = 0;
}
if(dropDownOpen) {
drawRect(skinX, skinY, skinX + skinWidth, skinY + skinHeight, -6250336);
drawRect(skinX + 1, skinY + 1, skinX + skinWidth - 1, skinY + skinHeight - 1, -16777216);
for(int i = 0; i < slotsVisible; i++) {
if(i + scrollPos < dropDownOptions.length) {
int idx = i + scrollPos - EaglerProfile.capes.size();
if(selectedSlot == i + scrollPos) {
drawRect(skinX + 1, skinY + i*10 + 4, skinX + skinWidth - 1, skinY + i*10 + 14, 0x77ffffff);
}else if(mx >= skinX && mx < (skinX + skinWidth - 10) && my >= (skinY + i*10 + 5) && my < (skinY + i*10 + 15)) {
drawRect(skinX + 1, skinY + i*10 + 4, skinX + skinWidth - 1, skinY + i*10 + 14, 0x55ffffff);
}
this.fontRenderer.drawStringWithShadow(dropDownOptions[i + scrollPos], skinX + 5, skinY + 5 + i*10, 14737632);
}
}
int scrollerSize = skinHeight * slotsVisible / dropDownOptions.length;
int scrollerPos = skinHeight * scrollPos / dropDownOptions.length;
drawRect(skinX + skinWidth - 4, skinY + scrollerPos + 1, skinX + skinWidth - 1, skinY + scrollerPos + scrollerSize, 0xff888888);
}
int xx = this.width / 2 - 80;
int yy = this.height / 6 + 130;
DefaultSkinRenderer.renderPlayerPreview(xx, yy, mx, my, skinToShow | 0x10000);
}
protected void actionPerformed(GuiButton par1GuiButton) {
if(!dropDownOpen) {
if(par1GuiButton.id == 200) {
mc.displayGuiScreen(parent);
}else if(par1GuiButton.id == 2) {
EaglerAdapter.openFileChooser("png", "image/png");
}else if(par1GuiButton.id == 3) {
for(EaglerProfileCape i : EaglerProfile.capes) {
this.mc.renderEngine.deleteTexture(i.glTex);
}
EaglerProfile.capes.clear();
this.dropDownOptions = defaultVanillaCapeNames;
this.selectedSlot = 0;
}
}
}
public void updateScreen() {
if(dropDownOpen) {
if(EaglerAdapter.mouseIsButtonDown(0)) {
int skinX = this.width / 2 - 20;
int skinY = this.height / 6 + 74;
int skinWidth = 140;
if(mousex >= (skinX + skinWidth - 10) && mousex < (skinX + skinWidth) && mousey >= skinY && mousey < (skinY + skinsHeight)) {
dragging = true;
}
if(dragging) {
int scrollerSize = skinsHeight * slotsVisible / dropDownOptions.length;
scrollPos = (mousey - skinY - (scrollerSize / 2)) * dropDownOptions.length / skinsHeight;
}
}else {
dragging = false;
}
}else {
dragging = false;
}
byte[] b;
if((b = EaglerAdapter.getFileChooserResult()) != null && b.length > 0) {
EaglerImage img = EaglerImage.loadImage(b);
if(!((img.w == 32 && img.h == 32) || (img.w == 64 && img.h == 64) || (img.w == 64 && img.h == 32) || (img.w == 64 && img.h == 128))) return;
int[] loadSkin = img.data;
if(img.w == 64 && img.h == 32) {
loadSkin = grabPiece(loadSkin, 32, 32, 64);
}else if(img.w == 128 && img.h == 64) {
loadSkin = grabPiece(loadSkin, 64, 64, 128);
}
byte[] rawSkin = new byte[loadSkin.length * 4];
for(int i = 0; i < loadSkin.length; i++) {
int i2 = i * 4; int i3 = loadSkin[i];
rawSkin[i2] = (byte)(i3);
rawSkin[i2 + 1] = (byte)(i3 >> 8);
rawSkin[i2 + 2] = (byte)(i3 >> 16);
rawSkin[i2 + 3] = (byte)(i3 >> 24);
}
String name = EaglerAdapter.getFileChooserResultName();
if(name.length() > 32) {
name = name.substring(0, 32);
}
int k;
if((k = EaglerProfile.addCape(name, rawSkin)) != -1) {
selectedSlot = k;
reconcatDD();
}
}
}
private int[] grabPiece(int[] input, int w, int h, int sw) {
int[] ret = new int[w * h];
for(int i = 0; i < h; ++i) {
System.arraycopy(input, i * sw, ret, i * w, w);
}
return ret;
}
public void handleMouseInput() {
super.handleMouseInput();
if(dropDownOpen) {
int var1 = EaglerAdapter.mouseGetEventDWheel();
if(var1 < 0) {
scrollPos += 3;
}
if(var1 > 0) {
scrollPos -= 3;
}
}
}
protected void keyTyped(char par1, int par2) {
if(par2 == 200 && selectedSlot > 0) {
--selectedSlot;
scrollPos = selectedSlot - 2;
}
if(par2 == 208 && selectedSlot < (dropDownOptions.length - 1)) {
++selectedSlot;
scrollPos = selectedSlot - 2;
}
}
protected void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
if (par3 == 0) {
int skinX = this.width / 2 + 140 - 40;
int skinY = this.height / 6 + 53;
if(par1 >= skinX && par1 < (skinX + 20) && par2 >= skinY && par2 < (skinY + 22)) {
dropDownOpen = !dropDownOpen;
}
skinX = this.width / 2 - 20;
skinY = this.height / 6 + 53;
int skinWidth = 140;
int skinHeight = skinsHeight;
if(!(par1 >= skinX && par1 < (skinX + skinWidth) && par2 >= skinY && par2 < (skinY + skinHeight + 22))) {
dropDownOpen = false;
dragging = false;
}
skinY += 21;
if(dropDownOpen && !dragging) {
for(int i = 0; i < slotsVisible; i++) {
if(i + scrollPos < dropDownOptions.length) {
if(selectedSlot != i + scrollPos) {
if(par1 >= skinX && par1 < (skinX + skinWidth - 10) && par2 >= (skinY + i*10 + 5) && par2 < (skinY + i*10 + 15) && selectedSlot != i + scrollPos) {
selectedSlot = i + scrollPos;
dropDownOpen = false;
dragging = false;
}
}
}
}
}
}
}
}

View File

@ -1,6 +1,7 @@
package net.lax1dude.eaglercraft;
import net.lax1dude.eaglercraft.EaglerProfile.EaglerProfileSkin;
import net.minecraft.src.EnumChatFormatting;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.GuiTextField;
@ -115,7 +116,6 @@ public class GuiScreenEditProfile extends GuiScreen {
if(cnt <= 0) {
this.drawString(this.fontRenderer, var1.translateKey("profile.playerSkin"), this.width / 2 - 20, this.height / 6 + 66, 10526880);
}
mousex = mx;
mousey = my;
@ -127,6 +127,25 @@ public class GuiScreenEditProfile extends GuiScreen {
drawRect(skinX, skinY, skinX + skinWidth, skinY + skinHeight, -6250336);
drawRect(skinX + 1, skinY + 1, skinX + skinWidth - 1, skinY + skinHeight - 1, 0xff000015);
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(skinX + 2, skinY - 9, 0.0f);
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
int skid = selectedSlot - EaglerProfile.skins.size();
if(skid < 0) {
skid = 0;
}
if(DefaultSkinRenderer.isStandardModel(skid) || DefaultSkinRenderer.isZombieModel(skid)) {
String capesText = var1.translateKey("profile.capes");
int color = 10526880;
if(mx > skinX - 10 && my > skinY - 16 && mx < skinX + (fontRenderer.getStringWidth(capesText) / 0.75f) + 10 && my < skinY + 7) {
color = 0xFFCCCC44;
}
this.drawString(this.fontRenderer, EnumChatFormatting.UNDERLINE + capesText, 0, 0, color);
}
EaglerAdapter.glPopMatrix();
this.username.drawTextBox();
if(dropDownOpen || newSkinWaitSteveOrAlex) {
super.drawScreen(0, 0, par3);
@ -298,9 +317,11 @@ public class GuiScreenEditProfile extends GuiScreen {
}else {
EaglerProfile.customSkinId = -1;
}
LocalStorageManager.profileSettingsStorage.setInteger("ps", EaglerProfile.presetSkinId);
LocalStorageManager.profileSettingsStorage.setInteger("cs", EaglerProfile.customSkinId);
LocalStorageManager.profileSettingsStorage.setInteger("pc", EaglerProfile.presetCapeId);
LocalStorageManager.profileSettingsStorage.setInteger("cc", EaglerProfile.customCapeId);
LocalStorageManager.profileSettingsStorage.setInteger("nsi", EaglerProfile.newSkinNotificationIndex);
LocalStorageManager.profileSettingsStorage.setString("name", EaglerProfile.username);
@ -313,6 +334,14 @@ public class GuiScreenEditProfile extends GuiScreen {
}
LocalStorageManager.profileSettingsStorage.setCompoundTag("skins", skins);
NBTTagCompound capes = new NBTTagCompound();
for(int i = 0, l = EaglerProfile.capes.size(); i < l; i++) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setByteArray("data", EaglerProfile.capes.get(i).data);
capes.setTag(EaglerProfile.capes.get(i).name, nbt);
}
LocalStorageManager.profileSettingsStorage.setCompoundTag("capes", capes);
LocalStorageManager.saveStorageP();
}
@ -434,9 +463,9 @@ public class GuiScreenEditProfile extends GuiScreen {
return;
}else if(selectedSlot < EaglerProfile.skins.size()) {
int skinX = this.width / 2 - 120;
int skinY = this.height / 6 + 8;
int skinY = this.height / 6 + 18;
int skinWidth = 80;
int skinHeight = 130;
int skinHeight = 120;
if(par1 >= skinX && par2 >= skinY && par1 < skinX + skinWidth && par2 < skinY + skinHeight) {
if(selectedSlot < EaglerProfile.skins.size()) {
int type = EaglerProfile.getSkinSize(EaglerProfile.skins.get(selectedSlot).data.length);
@ -449,7 +478,6 @@ public class GuiScreenEditProfile extends GuiScreen {
}
super.mouseClicked(par1, par2, par3);
this.username.mouseClicked(par1, par2, par3);
if (par3 == 0) {
int skinX = this.width / 2 + 140 - 40;
int skinY = this.height / 6 + 82;
@ -492,7 +520,21 @@ public class GuiScreenEditProfile extends GuiScreen {
}
}
}
int skid = selectedSlot - EaglerProfile.skins.size();
if(skid < 0) {
skid = 0;
}
if(DefaultSkinRenderer.isStandardModel(skid) || DefaultSkinRenderer.isZombieModel(skid)) {
skinX = this.width / 2 - 120;
skinY = this.height / 6 + 8;
String capesText = StringTranslate.getInstance().translateKey("profile.capes");
if(par1 > skinX - 10 && par2 > skinY - 16 && par1 < skinX + (fontRenderer.getStringWidth(capesText) / 0.75f) + 10 && par2 < skinY + 7) {
save();
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
this.mc.displayGuiScreen(new GuiScreenEditCape(this, selectedSlot));
}
}
}
}

View File

@ -77,6 +77,7 @@ public class GuiConnecting extends GuiScreen {
this.clientHandler = new NetClientHandler(this.mc, uri, 0);
this.clientHandler.addToSendQueue(new Packet2ClientProtocol(69, EaglerProfile.username, uria, port));
this.clientHandler.addToSendQueue(new Packet250CustomPayload("EAG|MySkin", EaglerProfile.getSkinPacket()));
this.clientHandler.addToSendQueue(new Packet250CustomPayload("EAG|MyCape", EaglerProfile.getCapePacket()));
} catch (IOException e) {
try {
this.clientHandler.disconnect();

View File

@ -605,49 +605,55 @@ public class RenderPlayer extends RenderLiving {
float var11;
if (par1EntityPlayer.username.equalsIgnoreCase("LAX1DUDE") && !par1EntityPlayer.isInvisible() && !par1EntityPlayer.getHideCape() && renderType != 21) {
lax1dude_cape.bindTexture();
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(0.0F, 0.0F, 0.125F);
double var21 = par1EntityPlayer.field_71091_bM + (par1EntityPlayer.field_71094_bP - par1EntityPlayer.field_71091_bM) * (double) par2
- (par1EntityPlayer.prevPosX + (par1EntityPlayer.posX - par1EntityPlayer.prevPosX) * (double) par2);
double var24 = par1EntityPlayer.field_71096_bN + (par1EntityPlayer.field_71095_bQ - par1EntityPlayer.field_71096_bN) * (double) par2
- (par1EntityPlayer.prevPosY + (par1EntityPlayer.posY - par1EntityPlayer.prevPosY) * (double) par2);
double var9 = par1EntityPlayer.field_71097_bO + (par1EntityPlayer.field_71085_bR - par1EntityPlayer.field_71097_bO) * (double) par2
- (par1EntityPlayer.prevPosZ + (par1EntityPlayer.posZ - par1EntityPlayer.prevPosZ) * (double) par2);
var11 = par1EntityPlayer.prevRenderYawOffset + (par1EntityPlayer.renderYawOffset - par1EntityPlayer.prevRenderYawOffset) * par2;
double var12 = (double) MathHelper.sin(var11 * (float) Math.PI / 180.0F);
double var14 = (double) (-MathHelper.cos(var11 * (float) Math.PI / 180.0F));
float var16 = (float) var24 * 10.0F;
if (var16 < -6.0F) {
var16 = -6.0F;
if(DefaultSkinRenderer.isStandardModel(renderType) || DefaultSkinRenderer.isZombieModel(renderType)) {
if(!par1EntityPlayer.isInvisible() && !par1EntityPlayer.getHideCape()) {
if(DefaultSkinRenderer.bindSyncedCape(par1EntityPlayer)) {
EaglerAdapter.glPushMatrix();
EaglerAdapter.glTranslatef(0.0F, 0.0F, 0.125F);
double var21 = par1EntityPlayer.field_71091_bM + (par1EntityPlayer.field_71094_bP - par1EntityPlayer.field_71091_bM) * (double) par2
- (par1EntityPlayer.prevPosX + (par1EntityPlayer.posX - par1EntityPlayer.prevPosX) * (double) par2);
double var24 = par1EntityPlayer.field_71096_bN + (par1EntityPlayer.field_71095_bQ - par1EntityPlayer.field_71096_bN) * (double) par2
- (par1EntityPlayer.prevPosY + (par1EntityPlayer.posY - par1EntityPlayer.prevPosY) * (double) par2);
double var9 = par1EntityPlayer.field_71097_bO + (par1EntityPlayer.field_71085_bR - par1EntityPlayer.field_71097_bO) * (double) par2
- (par1EntityPlayer.prevPosZ + (par1EntityPlayer.posZ - par1EntityPlayer.prevPosZ) * (double) par2);
var11 = par1EntityPlayer.prevRenderYawOffset + (par1EntityPlayer.renderYawOffset - par1EntityPlayer.prevRenderYawOffset) * par2;
double var12 = (double) MathHelper.sin(var11 * (float) Math.PI / 180.0F);
double var14 = (double) (-MathHelper.cos(var11 * (float) Math.PI / 180.0F));
float var16 = (float) var24 * 10.0F;
if (var16 < -6.0F) {
var16 = -6.0F;
}
if (var16 > 32.0F) {
var16 = 32.0F;
}
float var17 = (float) (var21 * var12 + var9 * var14) * 100.0F;
float var18 = (float) (var21 * var14 - var9 * var12) * 100.0F;
if (var17 < 0.0F) {
var17 = 0.0F;
}
float var19 = par1EntityPlayer.prevCameraYaw + (par1EntityPlayer.cameraYaw - par1EntityPlayer.prevCameraYaw) * par2;
var16 += MathHelper.sin((par1EntityPlayer.prevDistanceWalkedModified + (par1EntityPlayer.distanceWalkedModified - par1EntityPlayer.prevDistanceWalkedModified) * par2) * 6.0F) * 32.0F * var19;
if (par1EntityPlayer.isSneaking()) {
var16 += 25.0F;
}
EaglerAdapter.glRotatef(6.0F + var17 / 2.0F + var16, 1.0F, 0.0F, 0.0F);
EaglerAdapter.glRotatef(var18 / 2.0F, 0.0F, 0.0F, 1.0F);
EaglerAdapter.glRotatef(-var18 / 2.0F, 0.0F, 1.0F, 0.0F);
EaglerAdapter.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
this.modelBipedMain.renderCloak(0.0625F);
EaglerAdapter.glPopMatrix();
}
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_TEXTURE);
EaglerAdapter.glPopMatrix();
EaglerAdapter.glMatrixMode(EaglerAdapter.GL_MODELVIEW);
}
if (var16 > 32.0F) {
var16 = 32.0F;
}
float var17 = (float) (var21 * var12 + var9 * var14) * 100.0F;
float var18 = (float) (var21 * var14 - var9 * var12) * 100.0F;
if (var17 < 0.0F) {
var17 = 0.0F;
}
float var19 = par1EntityPlayer.prevCameraYaw + (par1EntityPlayer.cameraYaw - par1EntityPlayer.prevCameraYaw) * par2;
var16 += MathHelper.sin((par1EntityPlayer.prevDistanceWalkedModified + (par1EntityPlayer.distanceWalkedModified - par1EntityPlayer.prevDistanceWalkedModified) * par2) * 6.0F) * 32.0F * var19;
if (par1EntityPlayer.isSneaking()) {
var16 += 25.0F;
}
EaglerAdapter.glRotatef(6.0F + var17 / 2.0F + var16, 1.0F, 0.0F, 0.0F);
EaglerAdapter.glRotatef(var18 / 2.0F, 0.0F, 0.0F, 1.0F);
EaglerAdapter.glRotatef(-var18 / 2.0F, 0.0F, 1.0F, 0.0F);
EaglerAdapter.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
this.modelBipedMain.renderCloak(0.0625F);
EaglerAdapter.glPopMatrix();
}
}