added world import/export
This commit is contained in:
parent
d2ed7b1895
commit
dbdbd8caad
BIN
lwjgl-rundir/downloads/New World.epk
Normal file
BIN
lwjgl-rundir/downloads/New World.epk
Normal file
Binary file not shown.
|
@ -31,6 +31,15 @@ selectWorld.enterName=World Name
|
|||
selectWorld.resultFolder=Will be saved in:
|
||||
selectWorld.enterSeed=Seed for the World Generator
|
||||
selectWorld.seedInfo=Leave blank for a random seed
|
||||
selectWorld.export=Export
|
||||
selectWorld.wannaImport=what do you wanna do?
|
||||
selectWorld.import=Import Existing World
|
||||
selectWorld.exportQuestion1=Are you sure you want to export this world?
|
||||
selectWorld.exportQuestion2=You cannot exit this page until the export is complete
|
||||
selectWorld.importQuestion1=Are you sure you want to import a world?
|
||||
selectWorld.importQuestion2=You cannot exit this page until the import is complete
|
||||
selectWorld.importConfirm=Import
|
||||
selectWorld.importName=What do you want to name this world?
|
||||
|
||||
multiplayer.title=Play Multiplayer
|
||||
multiplayer.connect=Connect
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.awt.datatransfer.DataFlavor;
|
|||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -1577,6 +1576,10 @@ public class EaglerAdapterImpl2 {
|
|||
return (new File(filesystemBaseDirectory, stripPath(path))).isDirectory();
|
||||
}
|
||||
|
||||
public static final boolean pathExists(String path) {
|
||||
return (new File(filesystemBaseDirectory, stripPath(path))).exists();
|
||||
}
|
||||
|
||||
public static final void writeFile(String path, byte[] data) {
|
||||
try {
|
||||
File f = new File(filesystemBaseDirectory, stripPath(path));
|
||||
|
@ -1771,5 +1774,19 @@ public class EaglerAdapterImpl2 {
|
|||
public static final ISaveFormat getConfiguredSaveFormat() {
|
||||
return svformat;
|
||||
}
|
||||
|
||||
public static final void downloadFile(String filename, byte[] data) {
|
||||
File downloadDir = new File("downloads");
|
||||
downloadDir.mkdirs();
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(new File(downloadDir, filename));
|
||||
out.write(data);
|
||||
out.close();
|
||||
System.out.println("fake downloaded file '" + filename + "' to the debug directory");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to 'download' file: " + filename);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,438 +0,0 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.EntityClientPlayerMP;
|
||||
import net.minecraft.src.EntityOtherPlayerMP;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.ModelBiped;
|
||||
import net.minecraft.src.ModelBlaze;
|
||||
import net.minecraft.src.ModelEnderman;
|
||||
import net.minecraft.src.ModelSkeleton;
|
||||
import net.minecraft.src.ModelVillager;
|
||||
import net.minecraft.src.ModelZombie;
|
||||
import net.minecraft.src.OpenGlHelper;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.RenderEnderman;
|
||||
import net.minecraft.src.RenderHelper;
|
||||
import net.minecraft.src.RenderManager;
|
||||
|
||||
public class DefaultSkinRenderer {
|
||||
|
||||
public static final TextureLocation[] defaultVanillaSkins = new TextureLocation[] {
|
||||
new TextureLocation("/skins/01.default_steve.png"),
|
||||
new TextureLocation("/skins/02.default_alex.png"),
|
||||
new TextureLocation("/skins/03.tennis_steve.png"),
|
||||
new TextureLocation("/skins/04.tennis_alex.png"),
|
||||
new TextureLocation("/skins/05.tuxedo_steve.png"),
|
||||
new TextureLocation("/skins/06.tuxedo_alex.png"),
|
||||
new TextureLocation("/skins/07.athlete_steve.png"),
|
||||
new TextureLocation("/skins/08.athlete_alex.png"),
|
||||
new TextureLocation("/skins/09.cyclist_steve.png"),
|
||||
new TextureLocation("/skins/10.cyclist_alex.png"),
|
||||
new TextureLocation("/skins/11.boxer_steve.png"),
|
||||
new TextureLocation("/skins/12.boxer_alex.png"),
|
||||
new TextureLocation("/skins/13.prisoner_steve.png"),
|
||||
new TextureLocation("/skins/14.prisoner_alex.png"),
|
||||
new TextureLocation("/skins/15.scottish_steve.png"),
|
||||
new TextureLocation("/skins/16.scottish_alex.png"),
|
||||
new TextureLocation("/skins/17.dev_steve.png"),
|
||||
new TextureLocation("/skins/18.dev_alex.png"),
|
||||
new TextureLocation("/skins/19.herobrine.png"),
|
||||
new TextureLocation("/mob/enderman.png"),
|
||||
new TextureLocation("/mob/skeleton.png"),
|
||||
new TextureLocation("/mob/fire.png"),
|
||||
new TextureLocation("/skins/20.barney.png"),
|
||||
new TextureLocation("/skins/21.slime.png"),
|
||||
new TextureLocation("/skins/22.noob.png"),
|
||||
new TextureLocation("/skins/23.trump.png"),
|
||||
new TextureLocation("/skins/24.notch.png"),
|
||||
new TextureLocation("/skins/25.creeper.png"),
|
||||
new TextureLocation("/skins/26.zombie.png"),
|
||||
new TextureLocation("/skins/27.pig.png"),
|
||||
new TextureLocation("/skins/28.squid.png"),
|
||||
new TextureLocation("/skins/29.mooshroom.png"),
|
||||
new TextureLocation("/mob/villager/villager.png"),
|
||||
new TextureLocation("/skins/30.longarms.png"),
|
||||
new TextureLocation("/skins/31.laxdude.png")
|
||||
};
|
||||
|
||||
public static final boolean[] defaultVanillaSkinClassicOrSlimVariants = new boolean[] {
|
||||
false, true,
|
||||
false, true,
|
||||
false, true,
|
||||
false, true,
|
||||
false, true,
|
||||
false, true,
|
||||
false, true,
|
||||
false, true,
|
||||
false, true
|
||||
};
|
||||
|
||||
private static final HashMap<Integer,EntityOtherPlayerMP> skinCookies = new HashMap();
|
||||
private static final HashMap<EntityOtherPlayerMP,Integer> skinGLUnits = new HashMap();
|
||||
private static final HashMap<EntityOtherPlayerMP,Long> skinGLTimeout = new HashMap();
|
||||
|
||||
private static long lastClean = 0l;
|
||||
|
||||
public static void deleteOldSkins() {
|
||||
if(System.currentTimeMillis() - lastClean > 60000l) {
|
||||
lastClean = System.currentTimeMillis();
|
||||
Iterator<Entry<EntityOtherPlayerMP,Long>> itr = skinGLTimeout.entrySet().iterator();
|
||||
while(itr.hasNext()) {
|
||||
Entry<EntityOtherPlayerMP,Long> ee = itr.next();
|
||||
if(System.currentTimeMillis() - ee.getValue() > 80000l) {
|
||||
itr.remove();
|
||||
if(skinGLUnits.containsKey(ee.getKey())) {
|
||||
Minecraft.getMinecraft().renderEngine.deleteTexture(skinGLUnits.remove(ee.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<Entry<Integer, EntityOtherPlayerMP>> itr2 = skinCookies.entrySet().iterator();
|
||||
while(itr2.hasNext()) {
|
||||
Entry<Integer, EntityOtherPlayerMP> e = itr2.next();
|
||||
if(e.getValue().isDead) {
|
||||
itr2.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean bindSyncedSkin(EntityPlayer p) {
|
||||
if(p instanceof EntityClientPlayerMP) {
|
||||
return false;
|
||||
}else if(p instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP pp = (EntityOtherPlayerMP) p;
|
||||
if(pp.skinPacket != null) {
|
||||
if(((int)pp.skinPacket[0] & 0xFF) != 4) {
|
||||
if(!skinGLUnits.containsKey(pp)) {
|
||||
byte[] skinToLoad = new byte[pp.skinPacket.length - 1];
|
||||
System.arraycopy(pp.skinPacket, 1, skinToLoad, 0, skinToLoad.length);
|
||||
int w, h;
|
||||
|
||||
switch((int)pp.skinPacket[0] & 0xFF) {
|
||||
default:
|
||||
case 0:
|
||||
w = 64;
|
||||
h = 32;
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
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) {
|
||||
skinGLUnits.put(pp, Minecraft.getMinecraft().renderEngine.setupTextureRaw(skinToLoad, w, h));
|
||||
}
|
||||
}
|
||||
skinGLTimeout.put(pp, System.currentTimeMillis());
|
||||
Integer i = skinGLUnits.get(pp);
|
||||
if(i != null && i.intValue() > 0) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(i.intValue());
|
||||
}else {
|
||||
defaultVanillaSkins[0].bindTexture();
|
||||
}
|
||||
}else {
|
||||
if(((int)pp.skinPacket[1] & 0xFF) < defaultVanillaSkins.length) {
|
||||
defaultVanillaSkins[(int)pp.skinPacket[1] & 0xFF].bindTexture();
|
||||
}
|
||||
}
|
||||
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().addToSendQueue(new Packet250CustomPayload("EAG|FetchSkin", pkt)); //TODO: add
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void skinResponse(byte[] data) {
|
||||
int cookie = ((int)data[0] & 0xFF) | (((int)data[1] & 0xFF) << 8);
|
||||
if(skinCookies.containsKey(cookie) && (data.length > 3)) {
|
||||
EntityOtherPlayerMP p = skinCookies.remove(cookie);
|
||||
byte[] packet = new byte[data.length - 2];
|
||||
System.arraycopy(data, 2, packet, 0, packet.length);
|
||||
p.skinPacket = packet;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isNewSkin(int id) {
|
||||
return !(id == 0 || id == 2 || id == 4 || id == 6 || id == 8 || id == 10 || id == 12 || id == 14 || id == 18 || id == 28);
|
||||
}
|
||||
|
||||
public static boolean isAlexSkin(int id) {
|
||||
return id < defaultVanillaSkinClassicOrSlimVariants.length && defaultVanillaSkinClassicOrSlimVariants[id];
|
||||
}
|
||||
|
||||
public static boolean isStandardModel(int id) {
|
||||
return !isZombieModel(id) && !(id == 19 || id == 20 || id == 21 || id == 32 || id == 33 || id == 34);
|
||||
}
|
||||
|
||||
public static boolean isZombieModel(int id) {
|
||||
return id == 18 || id == 28;
|
||||
}
|
||||
|
||||
public static boolean isPlayerNewSkin(EntityPlayer p) {
|
||||
if(p instanceof EntityClientPlayerMP) {
|
||||
if(EaglerProfile.presetSkinId <= -1) {
|
||||
int type = EaglerProfile.getSkinSize(EaglerProfile.skins.get(EaglerProfile.customSkinId).data.length);
|
||||
return (type == 1 || type == 3);
|
||||
}else {
|
||||
return isNewSkin(EaglerProfile.presetSkinId);
|
||||
}
|
||||
}else if(p instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP pp = (EntityOtherPlayerMP) p;
|
||||
if(pp.skinPacket != null) {
|
||||
if(pp.skinPacket[0] != (byte)4) {
|
||||
return (pp.skinPacket[0] == (byte)1) || (pp.skinPacket[0] == (byte)3) || (pp.skinPacket[0] == (byte)5) || (pp.skinPacket[0] == (byte)6);
|
||||
}else {
|
||||
return isNewSkin((int)pp.skinPacket[1] & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPlayerNewSkinSlim(EntityPlayer p) {
|
||||
if(p instanceof EntityClientPlayerMP) {
|
||||
if(EaglerProfile.presetSkinId == -1) {
|
||||
return EaglerProfile.skins.get(EaglerProfile.customSkinId).slim;
|
||||
}else {
|
||||
return isAlexSkin(EaglerProfile.presetSkinId);
|
||||
}
|
||||
}else if(p instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP pp = (EntityOtherPlayerMP) p;
|
||||
if(pp.skinPacket != null) {
|
||||
if(pp.skinPacket[0] != (byte)4) {
|
||||
return (pp.skinPacket[0] == (byte)5) || (pp.skinPacket[0] == (byte)6);
|
||||
}else {
|
||||
return isAlexSkin((int)pp.skinPacket[1] & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPlayerStandard(EntityPlayer p) {
|
||||
if(p instanceof EntityClientPlayerMP) {
|
||||
if(EaglerProfile.presetSkinId == -1) {
|
||||
return true;
|
||||
}else {
|
||||
return isStandardModel(EaglerProfile.presetSkinId);
|
||||
}
|
||||
}else if(p instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP pp = (EntityOtherPlayerMP) p;
|
||||
if(pp.skinPacket != null) {
|
||||
if(pp.skinPacket[0] != (byte)4) {
|
||||
return true;
|
||||
}else {
|
||||
return isStandardModel((int)pp.skinPacket[1] & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getPlayerRenderer(EntityPlayer p) {
|
||||
if(p instanceof EntityClientPlayerMP) {
|
||||
if(EaglerProfile.presetSkinId == -1) {
|
||||
return 0;
|
||||
}else {
|
||||
return EaglerProfile.presetSkinId;
|
||||
}
|
||||
}else if(p instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP pp = (EntityOtherPlayerMP) p;
|
||||
if(pp.skinPacket != null) {
|
||||
if(pp.skinPacket[0] != (byte)4) {
|
||||
return 0;
|
||||
}else {
|
||||
return (int)pp.skinPacket[1] & 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ModelBiped oldSkinRenderer = null;
|
||||
public static ModelBipedNewSkins newSkinRenderer = null;
|
||||
public static ModelBipedNewSkins newSkinRendererSlim = null;
|
||||
public static ModelZombie zombieRenderer = null;
|
||||
public static ModelVillager villagerRenderer = null;
|
||||
public static ModelEnderman endermanRenderer = null;
|
||||
public static ModelBlaze blazeRenderer = null;
|
||||
public static ModelSkeleton skeletonRenderer = null;
|
||||
|
||||
public static void renderPlayerPreview(int x, int y, int mx, int my, int id2) {
|
||||
int id = id2 - EaglerProfile.skins.size();
|
||||
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_CULL_FACE);
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glTranslatef((float) x, (float) (y - 80), 100.0F);
|
||||
EaglerAdapter.glScalef(50.0f, 50.0f, 50.0f);
|
||||
EaglerAdapter.glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
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);
|
||||
EaglerAdapter.glRotatef(((x - mx) * 0.06f), 0.0f, 1.0f, 0.0f);
|
||||
EaglerAdapter.glTranslatef(0.0F, -1.0F, 0.0F);
|
||||
|
||||
if(id < 0) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(EaglerProfile.skins.get(id2).glTex);
|
||||
}else {
|
||||
defaultVanillaSkins[id].bindTexture();
|
||||
}
|
||||
|
||||
if(isStandardModel(id) || id < 0) {
|
||||
if(oldSkinRenderer == null) oldSkinRenderer = new ModelBiped(0.0F, 0.0F, 64, 32);
|
||||
if(newSkinRenderer == null) newSkinRenderer = new ModelBipedNewSkins(0.0F, false);
|
||||
if(newSkinRendererSlim == null) newSkinRendererSlim = new ModelBipedNewSkins(0.0F, true);
|
||||
oldSkinRenderer.isChild = false;
|
||||
newSkinRenderer.isChild = false;
|
||||
newSkinRendererSlim.isChild = false;
|
||||
boolean isNew = isNewSkin(id);
|
||||
if(id < 0) {
|
||||
int type = EaglerProfile.getSkinSize(EaglerProfile.skins.get(id2).data.length);
|
||||
isNew = (type == 1 || type == 3);
|
||||
}
|
||||
if(isNew) {
|
||||
if((id < 0 && EaglerProfile.skins.get(id2).slim) || (id >= 0 && isAlexSkin(id))) {
|
||||
newSkinRendererSlim.blockTransparentSkin = true;
|
||||
newSkinRendererSlim.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
newSkinRendererSlim.blockTransparentSkin = false;
|
||||
}else {
|
||||
newSkinRenderer.blockTransparentSkin = true;
|
||||
newSkinRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
newSkinRenderer.blockTransparentSkin = false;
|
||||
}
|
||||
}else {
|
||||
oldSkinRenderer.blockTransparentSkin = true;
|
||||
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;
|
||||
}
|
||||
}else if(isZombieModel(id)) {
|
||||
if(zombieRenderer == null) zombieRenderer = new ModelZombie(0.0F, true);
|
||||
zombieRenderer.isChild = false;
|
||||
zombieRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
}else if(id == 32) {
|
||||
if(villagerRenderer == null) villagerRenderer = new ModelVillager(0.0F);
|
||||
villagerRenderer.isChild = false;
|
||||
villagerRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
}else if(id == 19) {
|
||||
if(endermanRenderer == null) endermanRenderer = new ModelEnderman();
|
||||
endermanRenderer.isChild = false;
|
||||
endermanRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
EaglerAdapter.glColor4f(1.4f, 1.4f, 1.4f, 1.0f);
|
||||
//EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
//EaglerAdapter.glDisable(EaglerAdapter.GL_ALPHA_TEST);
|
||||
//EaglerAdapter.glBlendFunc(EaglerAdapter.GL_ONE, EaglerAdapter.GL_ONE);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_DEPTH_TEST);
|
||||
RenderEnderman.tex_eyes.bindTexture();
|
||||
endermanRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_ALPHA_TEST);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_DEPTH_TEST);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}else if(id == 20) {
|
||||
if(skeletonRenderer == null) skeletonRenderer = new ModelSkeleton(0.0F);
|
||||
skeletonRenderer.isChild = false;
|
||||
skeletonRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
}else if(id == 21) {
|
||||
if(blazeRenderer == null) blazeRenderer = new ModelBlaze();
|
||||
blazeRenderer.isChild = false;
|
||||
EaglerAdapter.glColor4f(1.5f, 1.5f, 1.5f, 1.0f);
|
||||
blazeRenderer.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
}
|
||||
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
EaglerAdapter.glPopMatrix();
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
|
||||
}
|
||||
|
||||
public static void renderAlexOrSteve(int x, int y, int mx, int my, boolean alex) {
|
||||
ModelBipedNewSkins bp;
|
||||
if(alex) {
|
||||
if(newSkinRendererSlim == null) {
|
||||
newSkinRendererSlim = new ModelBipedNewSkins(0.0F, true);
|
||||
}
|
||||
bp = newSkinRendererSlim;
|
||||
}else {
|
||||
if(newSkinRenderer == null) {
|
||||
newSkinRenderer = new ModelBipedNewSkins(0.0F, false);
|
||||
}
|
||||
bp = newSkinRenderer;
|
||||
}
|
||||
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_CULL_FACE);
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glTranslatef((float) x, (float) (y - 80), 100.0F);
|
||||
EaglerAdapter.glScalef(50.0f, 50.0f, 50.0f);
|
||||
EaglerAdapter.glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
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);
|
||||
EaglerAdapter.glRotatef(((x - mx) * 0.06f), 0.0f, 1.0f, 0.0f);
|
||||
EaglerAdapter.glTranslatef(0.0F, -1.0F, 0.0F);
|
||||
|
||||
bp.isChild = false;
|
||||
bp.render(null, 0.0f, 0.0f, (float)(System.currentTimeMillis() % 100000) / 50f, ((x - mx) * 0.06f), ((y - my) * -0.1f), 0.0625F);
|
||||
|
||||
EaglerAdapter.glPopMatrix();
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
|
||||
}
|
||||
|
||||
public static boolean isPlayerPreviewNew(int id2) {
|
||||
int id = id2 - EaglerProfile.skins.size();
|
||||
if(id < 0) {
|
||||
return EaglerProfile.skins.get(id2).data.length == EaglerProfile.SKIN_DATA_SIZE[1] || EaglerProfile.skins.get(id2).data.length == EaglerProfile.SKIN_DATA_SIZE[3];
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,210 +0,0 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.NBTBase;
|
||||
import net.minecraft.src.NBTTagByteArray;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class EaglerProfile {
|
||||
|
||||
public static class EaglerProfileSkin {
|
||||
public String name;
|
||||
public byte[] data;
|
||||
public boolean slim;
|
||||
public int glTex;
|
||||
public EaglerProfileSkin(String name, byte[] data, boolean slim, int glTex) {
|
||||
this.name = name;
|
||||
this.data = data;
|
||||
this.slim = slim;
|
||||
this.glTex = glTex;
|
||||
}
|
||||
}
|
||||
|
||||
public static String username;
|
||||
public static int presetSkinId;
|
||||
public static int customSkinId;
|
||||
|
||||
public static String myChannel;
|
||||
|
||||
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 final EaglercraftRandom rand;
|
||||
|
||||
public static int getSkinSize(int len) {
|
||||
for(int i = 0; i < SKIN_DATA_SIZE.length; ++i) {
|
||||
if(len == SKIN_DATA_SIZE[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static byte[] getSkinPacket() {
|
||||
if(presetSkinId == -1) {
|
||||
byte[] d = skins.get(customSkinId).data;
|
||||
byte[] d2 = new byte[1 + d.length];
|
||||
d2[0] = (byte) getSkinSize(d.length);
|
||||
if(d2[0] == (byte)1 && skins.get(customSkinId).slim) {
|
||||
d2[0] = (byte)5;
|
||||
}
|
||||
if(d2[0] == (byte)3 && skins.get(customSkinId).slim) {
|
||||
d2[0] = (byte)6;
|
||||
}
|
||||
System.arraycopy(d, 0, d2, 1, d.length);
|
||||
return d2;
|
||||
}else {
|
||||
return new byte[] { (byte)4, (byte)presetSkinId };
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] concatArrays(String[] a, String[] b) {
|
||||
String[] r = new String[a.length + b.length];
|
||||
System.arraycopy(a, 0, r, 0, a.length);
|
||||
System.arraycopy(b, 0, r, a.length, b.length);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static int addSkin(String name, byte[] data, boolean slim) {
|
||||
int i = -1;
|
||||
for(int j = 0, l = skins.size(); j < l; ++j) {
|
||||
if(skins.get(j).name.equalsIgnoreCase(name)) {
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int t = getSkinSize(data.length);
|
||||
|
||||
if(t == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int w, h;
|
||||
|
||||
switch(t) {
|
||||
default:
|
||||
case 0:
|
||||
w = 64;
|
||||
h = 32;
|
||||
break;
|
||||
case 1:
|
||||
case 5:
|
||||
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);
|
||||
if(i == -1) {
|
||||
i = skins.size();
|
||||
skins.add(new EaglerProfileSkin(name, data, slim, im));
|
||||
}else {
|
||||
skins.get(i).glTex = im;
|
||||
skins.get(i).data = data;
|
||||
skins.get(i).slim = slim;
|
||||
}
|
||||
return i;
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
String[] usernameDefaultWords = ConfigConstants.profanity ? new String[] {
|
||||
"Eagler",
|
||||
"Eagler",
|
||||
"Bitch",
|
||||
"Cock",
|
||||
"Milf",
|
||||
"Milf",
|
||||
"Yeer",
|
||||
"Groon",
|
||||
"Eag",
|
||||
"Deevis",
|
||||
"Chode",
|
||||
"Deev",
|
||||
"Deev",
|
||||
"Fucker",
|
||||
"Fucking",
|
||||
"Dumpster",
|
||||
"Dumpster",
|
||||
"Cum",
|
||||
"Chad",
|
||||
"Egg",
|
||||
"Fudgler",
|
||||
"Fudgli",
|
||||
"Yee",
|
||||
"Yee",
|
||||
"Yee",
|
||||
"Yeet",
|
||||
"Flumpter",
|
||||
"Darvy",
|
||||
"Darver",
|
||||
"Darver",
|
||||
"Fuck",
|
||||
"Fuck",
|
||||
"Frick",
|
||||
"Eagler",
|
||||
"Vigg",
|
||||
"Vigg",
|
||||
"Cunt",
|
||||
"Darvig"
|
||||
} : new String[] {
|
||||
"Yeeish",
|
||||
"Yeeish",
|
||||
"Yee",
|
||||
"Yee",
|
||||
"Yeer",
|
||||
"Yeeler",
|
||||
"Eagler",
|
||||
"Eagl",
|
||||
"Darver",
|
||||
"Darvler",
|
||||
"Vool",
|
||||
"Vigg",
|
||||
"Vigg",
|
||||
"Deev",
|
||||
"Yigg",
|
||||
"Yeeg"
|
||||
};
|
||||
|
||||
rand = new EaglercraftRandom();
|
||||
|
||||
do {
|
||||
username = usernameDefaultWords[rand.nextInt(usernameDefaultWords.length)] + usernameDefaultWords[rand.nextInt(usernameDefaultWords.length)] + (10 + rand.nextInt(90));
|
||||
}while(username.length() > 16);
|
||||
|
||||
presetSkinId = rand.nextInt(GuiScreenEditProfile.defaultOptions.length);
|
||||
myChannel = username + "_" + (100 + rand.nextInt(900));
|
||||
customSkinId = -1;
|
||||
}
|
||||
|
||||
public static void loadFromStorage() {
|
||||
if(!LocalStorageManager.profileSettingsStorage.hasNoTags()) {
|
||||
presetSkinId = LocalStorageManager.profileSettingsStorage.getInteger("ps");
|
||||
customSkinId = LocalStorageManager.profileSettingsStorage.getInteger("cs");
|
||||
username = LocalStorageManager.profileSettingsStorage.getString("name");
|
||||
myChannel = username + "_" + (100 + rand.nextInt(900));
|
||||
NBTTagCompound n = LocalStorageManager.profileSettingsStorage.getCompoundTag("skins");
|
||||
for(Object s : NBTTagCompound.getTagMap(n).keySet()) {
|
||||
String s2 = (String)s;
|
||||
NBTBase k = n.getTag(s2);
|
||||
if(k.getId() == (byte)7) {
|
||||
addSkin(s2, ((NBTTagByteArray)k).byteArray, false);
|
||||
}else if(k.getId() == (byte)10) {
|
||||
addSkin(s2, ((NBTTagCompound)k).getByteArray("data"), ((NBTTagCompound)k).getBoolean("slim"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,463 +0,0 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerProfile.EaglerProfileSkin;
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.GuiTextField;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
|
||||
public class GuiScreenEditProfile extends GuiScreen {
|
||||
|
||||
private GuiScreen parent;
|
||||
private GuiTextField username;
|
||||
|
||||
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;
|
||||
|
||||
private boolean newSkinWaitSteveOrAlex = false;
|
||||
|
||||
private static final TextureLocation gui = new TextureLocation("/gui/gui.png");
|
||||
|
||||
public static final String[] defaultOptions = new String[] {
|
||||
"Default Steve",
|
||||
"Default Alex",
|
||||
"Tennis Steve",
|
||||
"Tennis Alex",
|
||||
"Tuxedo Steve",
|
||||
"Tuxedo Alex",
|
||||
"Athlete Steve",
|
||||
"Athlete Alex",
|
||||
"Cyclist Steve",
|
||||
"Cyclist Alex",
|
||||
"Boxer Steve",
|
||||
"Boxer Alex",
|
||||
"Prisoner Steve",
|
||||
"Prisoner Alex",
|
||||
"Scottish Steve",
|
||||
"Scottish Alex",
|
||||
"Developer Steve",
|
||||
"Developer Alex",
|
||||
"Herobrine",
|
||||
"Enderman",
|
||||
"Skeleton",
|
||||
"Blaze",
|
||||
"Barney",
|
||||
"Slime",
|
||||
"Noob",
|
||||
"Trump",
|
||||
"Notch",
|
||||
"Creeper",
|
||||
"Zombie",
|
||||
"Pig",
|
||||
"Squid",
|
||||
"Mooshroom",
|
||||
"Villager"
|
||||
};
|
||||
|
||||
protected String screenTitle = "Edit Profile";
|
||||
|
||||
public GuiScreenEditProfile(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
reconcatDD();
|
||||
}
|
||||
|
||||
private void reconcatDD() {
|
||||
String[] n = new String[EaglerProfile.skins.size()];
|
||||
for(int i = 0; i < n.length; ++i) {
|
||||
n[i] = EaglerProfile.skins.get(i).name;
|
||||
}
|
||||
|
||||
this.dropDownOptions = EaglerProfile.concatArrays(n, defaultOptions);
|
||||
}
|
||||
|
||||
private GuiButton button0, button1, button2, button10, button11, button12;
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
EaglerAdapter.enableRepeatEvents(true);
|
||||
StringTranslate var1 = StringTranslate.getInstance();
|
||||
this.screenTitle = var1.translateKey("profile.title");
|
||||
this.username = new GuiTextField(this.fontRenderer, this.width / 2 - 20 + 1, this.height / 6 + 24 + 1, 138, 20);
|
||||
this.username.setFocused(true);
|
||||
this.username.setText(EaglerProfile.username);
|
||||
selectedSlot = EaglerProfile.presetSkinId == -1 ? EaglerProfile.customSkinId : (EaglerProfile.presetSkinId + EaglerProfile.skins.size());
|
||||
//this.buttonList.add(new GuiButton(0, this.width / 2 - 100, 140, "eeeee"));
|
||||
this.buttonList.add(button0 = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, var1.translateKey("gui.done")));
|
||||
this.buttonList.add(button1 = new GuiButton(2, this.width / 2 - 21, this.height / 6 + 110, 71, 20, var1.translateKey("profile.addSkin")));
|
||||
this.buttonList.add(button2 = new GuiButton(3, this.width / 2 - 21 + 71, this.height / 6 + 110, 72, 20, var1.translateKey("profile.clearSkin")));
|
||||
//this.buttonList.add(new GuiButton(200, this.width / 2, this.height / 6 + 72, 150, 20, var1.translateKey("gui.done")));
|
||||
}
|
||||
|
||||
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, var1.translateKey("profile.screenname"), this.width / 2 - 20, this.height / 6 + 8, 10526880);
|
||||
this.drawString(this.fontRenderer, var1.translateKey("profile.playerSkin"), this.width / 2 - 20, this.height / 6 + 66, 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);
|
||||
|
||||
this.username.drawTextBox();
|
||||
if(dropDownOpen || newSkinWaitSteveOrAlex) {
|
||||
super.drawScreen(0, 0, par3);
|
||||
}else {
|
||||
super.drawScreen(mx, my, par3);
|
||||
}
|
||||
|
||||
skinX = this.width / 2 - 20;
|
||||
skinY = this.height / 6 + 82;
|
||||
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);
|
||||
|
||||
skinX = this.width / 2 - 20;
|
||||
skinY = this.height / 6 + 103;
|
||||
skinWidth = 140;
|
||||
skinHeight = (this.height - skinY - 10);
|
||||
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) {
|
||||
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;
|
||||
|
||||
if(newSkinWaitSteveOrAlex && selectedSlot < EaglerProfile.skins.size()) {
|
||||
skinWidth = 70;
|
||||
skinHeight = 120;
|
||||
|
||||
EaglerProfile.EaglerProfileSkin eee = EaglerProfile.skins.get(selectedSlot);
|
||||
|
||||
EaglerAdapter.glClear(EaglerAdapter.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
skinX = this.width / 2 - 90;
|
||||
skinY = this.height / 4;
|
||||
xx = skinX + 35;
|
||||
yy = skinY + 117;
|
||||
|
||||
boolean mouseOver = mx >= skinX && my >= skinY && mx < skinX + skinWidth && my < skinY + skinHeight;
|
||||
int cc = mouseOver ? 0xFFDDDD99 : 0xFF555555;
|
||||
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
|
||||
drawRect(0, 0, width, height, 0xbb000000);
|
||||
drawRect(skinX, skinY, skinX + skinWidth, skinY + skinHeight, 0xbb000000);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
|
||||
|
||||
drawRect(skinX, skinY, skinX + 1, skinY + skinHeight, cc);
|
||||
drawRect(skinX, skinY, skinX + skinWidth, skinY + 1, cc);
|
||||
drawRect(skinX + skinWidth - 1, skinY, skinX + skinWidth, skinY + skinHeight, cc);
|
||||
drawRect(skinX, skinY + skinHeight - 1, skinX + skinWidth, skinY + skinHeight, cc);
|
||||
|
||||
if(mouseOver) {
|
||||
drawCenteredString(fontRenderer, "Steve", skinX + skinWidth / 2, skinY + skinHeight + 6, cc);
|
||||
}
|
||||
|
||||
this.mc.renderEngine.bindTexture(eee.glTex);
|
||||
DefaultSkinRenderer.renderAlexOrSteve(xx, yy, mx, my, false);
|
||||
|
||||
skinX = this.width / 2 + 20;
|
||||
skinY = this.height / 4;
|
||||
xx = skinX + 35;
|
||||
yy = skinY + 117;
|
||||
|
||||
mouseOver = mx >= skinX && my >= skinY && mx < skinX + skinWidth && my < skinY + skinHeight;
|
||||
cc = mouseOver ? 0xFFDDDD99 : 0xFF555555;
|
||||
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
drawRect(skinX, skinY, skinX + skinWidth, skinY + skinHeight, 0xbb000000);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND);
|
||||
|
||||
drawRect(skinX, skinY, skinX + 1, skinY + skinHeight, cc);
|
||||
drawRect(skinX, skinY, skinX + skinWidth, skinY + 1, cc);
|
||||
drawRect(skinX + skinWidth - 1, skinY, skinX + skinWidth, skinY + skinHeight, cc);
|
||||
drawRect(skinX, skinY + skinHeight - 1, skinX + skinWidth, skinY + skinHeight, cc);
|
||||
|
||||
if(mouseOver) {
|
||||
drawCenteredString(fontRenderer, "Alex", skinX + skinWidth / 2, skinY + skinHeight + 8, cc);
|
||||
}
|
||||
|
||||
this.mc.renderEngine.bindTexture(eee.glTex);
|
||||
DefaultSkinRenderer.renderAlexOrSteve(xx, yy, mx, my, true);
|
||||
}else {
|
||||
skinX = this.width / 2 - 120;
|
||||
skinY = this.height / 6 + 8;
|
||||
skinWidth = 80;
|
||||
skinHeight = 130;
|
||||
if(DefaultSkinRenderer.isPlayerPreviewNew(selectedSlot)) {
|
||||
int w = fontRenderer.getStringWidth("1.8") + 4;
|
||||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
|
||||
drawString(fontRenderer, "1.8", (int)((skinX + skinWidth) / 0.75f) - w, (int)((skinY + skinHeight) / 0.75f) - 12, 0xFFBBBB66);
|
||||
EaglerAdapter.glPopMatrix();
|
||||
}
|
||||
DefaultSkinRenderer.renderPlayerPreview(xx, yy, newSkinWaitSteveOrAlex ? width / 2 : mx, newSkinWaitSteveOrAlex ? height / 2 : my, selectedSlot);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handleMouseInput() {
|
||||
super.handleMouseInput();
|
||||
if(dropDownOpen) {
|
||||
int var1 = EaglerAdapter.mouseGetEventDWheel();
|
||||
if(var1 < 0) {
|
||||
scrollPos += 3;
|
||||
}
|
||||
if(var1 > 0) {
|
||||
scrollPos -= 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
EaglerProfile.username = this.username.getText().length() == 0 ? "null" : this.username.getText();
|
||||
EaglerProfile.presetSkinId = selectedSlot - EaglerProfile.skins.size();
|
||||
if(EaglerProfile.presetSkinId < 0) {
|
||||
EaglerProfile.presetSkinId = -1;
|
||||
EaglerProfile.customSkinId = selectedSlot;
|
||||
}else {
|
||||
EaglerProfile.customSkinId = -1;
|
||||
}
|
||||
|
||||
LocalStorageManager.profileSettingsStorage.setInteger("ps", EaglerProfile.presetSkinId);
|
||||
LocalStorageManager.profileSettingsStorage.setInteger("cs", EaglerProfile.customSkinId);
|
||||
LocalStorageManager.profileSettingsStorage.setString("name", EaglerProfile.username);
|
||||
|
||||
NBTTagCompound skins = new NBTTagCompound();
|
||||
for(int i = 0, l = EaglerProfile.skins.size(); i < l; i++) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setByteArray("data", EaglerProfile.skins.get(i).data);
|
||||
nbt.setBoolean("slim", EaglerProfile.skins.get(i).slim);
|
||||
skins.setTag(EaglerProfile.skins.get(i).name, nbt);
|
||||
}
|
||||
LocalStorageManager.profileSettingsStorage.setCompoundTag("skins", skins);
|
||||
|
||||
LocalStorageManager.saveStorageP();
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(!dropDownOpen) {
|
||||
if(par1GuiButton.id == 200) {
|
||||
save();
|
||||
this.mc.displayGuiScreen((GuiScreen) parent);
|
||||
}else if(par1GuiButton.id == 2) {
|
||||
EaglerAdapter.openFileChooser("png", "image/png");
|
||||
}else if(par1GuiButton.id == 3) {
|
||||
for(EaglerProfileSkin i : EaglerProfile.skins) {
|
||||
this.mc.renderEngine.deleteTexture(i.glTex);
|
||||
}
|
||||
EaglerProfile.skins.clear();
|
||||
this.dropDownOptions = defaultOptions;
|
||||
this.selectedSlot = 0;
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
this.username.updateCursorCounter();
|
||||
|
||||
if(dropDownOpen) {
|
||||
if(EaglerAdapter.mouseIsButtonDown(0)) {
|
||||
int skinX = this.width / 2 - 20;
|
||||
int skinY = this.height / 6 + 103;
|
||||
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 == 64 && img.h == 32) || (img.w == 64 && img.h == 64) || (img.w == 128 && img.h == 64) || (img.w == 128 && img.h == 128))) return;
|
||||
byte[] rawSkin = new byte[img.data.length * 4];
|
||||
for(int i = 0; i < img.data.length; i++) {
|
||||
int i2 = i * 4; int i3 = img.data[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);
|
||||
}
|
||||
if((img.w == 64 && img.h == 64) || (img.w == 128 && img.h == 128)) {
|
||||
newSkinWaitSteveOrAlex = true;
|
||||
}
|
||||
int k;
|
||||
if((k = EaglerProfile.addSkin(name, rawSkin, false)) != -1) {
|
||||
selectedSlot = k;
|
||||
reconcatDD();
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onGuiClosed() {
|
||||
EaglerAdapter.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
this.username.textboxKeyTyped(par1, par2);
|
||||
|
||||
String text = username.getText();
|
||||
if(text.length() > 16) text = text.substring(0, 16);
|
||||
text = text.replaceAll("[^A-Za-z0-9\\-_]", "_");
|
||||
this.username.setText(text);
|
||||
|
||||
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) {
|
||||
if(newSkinWaitSteveOrAlex) {
|
||||
int skinX = this.width / 2 - 90;
|
||||
int skinY = this.height / 4;
|
||||
int skinWidth = 70;
|
||||
int skinHeight = 120;
|
||||
if(par1 >= skinX && par2 >= skinY && par1 < skinX + skinWidth && par2 < skinY + skinHeight) {
|
||||
if(selectedSlot < EaglerProfile.skins.size()) {
|
||||
newSkinWaitSteveOrAlex = false;
|
||||
EaglerProfile.skins.get(selectedSlot).slim = false;
|
||||
save();
|
||||
}
|
||||
return;
|
||||
}
|
||||
skinX = this.width / 2 + 20;
|
||||
skinY = this.height / 4;
|
||||
if(par1 >= skinX && par2 >= skinY && par1 < skinX + skinWidth && par2 < skinY + skinHeight) {
|
||||
if(selectedSlot < EaglerProfile.skins.size()) {
|
||||
EaglerProfile.skins.get(selectedSlot).slim = true;
|
||||
newSkinWaitSteveOrAlex = false;
|
||||
save();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}else if(selectedSlot < EaglerProfile.skins.size()) {
|
||||
int skinX = this.width / 2 - 120;
|
||||
int skinY = this.height / 6 + 8;
|
||||
int skinWidth = 80;
|
||||
int skinHeight = 130;
|
||||
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);
|
||||
if(type == 1 || type == 3) {
|
||||
newSkinWaitSteveOrAlex = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
if(par1 >= skinX && par1 < (skinX + 20) && par2 >= skinY && par2 < (skinY + 22)) {
|
||||
dropDownOpen = !dropDownOpen;
|
||||
}
|
||||
|
||||
skinX = this.width / 2 - 20;
|
||||
skinY = this.height / 6 + 82;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,243 +0,0 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.GuiIngameMenu;
|
||||
import net.minecraft.src.GuiMainMenu;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.GuiSlider2;
|
||||
import net.minecraft.src.GuiTextField;
|
||||
import net.minecraft.src.ScaledResolution;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
|
||||
public class GuiScreenVoiceChannel extends GuiScreen {
|
||||
|
||||
public GuiScreenVoiceChannel(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
protected String screenTitle = "Voice Channel";
|
||||
private GuiScreen parent;
|
||||
private GuiTextField channel;
|
||||
|
||||
private GuiButton done;
|
||||
private GuiButton connect;
|
||||
private GuiButton disconnect;
|
||||
private GuiSlider2 slider;
|
||||
|
||||
public void initGui() {
|
||||
StringTranslate var1 = StringTranslate.getInstance();
|
||||
this.screenTitle = var1.translateKey("voice.title");
|
||||
this.channel = new GuiTextField(this.fontRenderer, this.width / 2 - 98, this.height / 6 + 24, 195, 20);
|
||||
this.channel.setText(EaglerProfile.myChannel);
|
||||
EaglerAdapter.enableRepeatEvents(true);
|
||||
this.buttonList.add(done = new GuiButton(200, this.width / 2 - 100, this.height / 6 + 148, var1.translateKey("gui.done")));
|
||||
this.buttonList.add(connect = new GuiButton(1, this.width / 2 - 100, this.height / 6 + 52, 99, 20, var1.translateKey("voice.connect")));
|
||||
this.buttonList.add(disconnect = new GuiButton(2, this.width / 2 + 1, this.height / 6 + 52, 99, 20, var1.translateKey("voice.disconnect")));
|
||||
this.buttonList.add(slider = new GuiSlider2(3, this.width / 2 - 100, this.height / 6 + 103, 200, 20, 0.5f, 2.0f));
|
||||
}
|
||||
|
||||
public void onGuiClosed() {
|
||||
EaglerAdapter.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
public void drawScreen(int mx, int my, float par3) {
|
||||
this.drawDefaultBackground();
|
||||
StringTranslate var1 = StringTranslate.getInstance();
|
||||
this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 15, 16777215);
|
||||
this.drawString(this.fontRenderer, var1.translateKey("voice.addr"), this.width / 2 - 98, this.height / 6 + 8, 10526880);
|
||||
if(voiceRelayed) {
|
||||
this.drawCenteredString(this.fontRenderer, var1.translateKey("voice.warning1"), this.width / 2, this.height / 6 + 125, 0xffcccc);
|
||||
this.drawCenteredString(this.fontRenderer, var1.translateKey("voice.warning2"), this.width / 2, this.height / 6 + 136, 0xffcccc);
|
||||
this.drawCenteredString(this.fontRenderer, var1.translateKey("voice.warning3"), this.width / 2, this.height / 6 + 147, 0xffcccc);
|
||||
this.drawString(this.fontRenderer, var1.translateKey("voice.volume"), this.width / 2 - 98, this.height / 6 + 81, 10526880);
|
||||
slider.yPosition = this.height / 6 + 95;
|
||||
done.yPosition = this.height / 6 + 168;
|
||||
}else {
|
||||
this.drawString(this.fontRenderer, var1.translateKey("voice.volume"), this.width / 2 - 98, this.height / 6 + 89, 10526880);
|
||||
slider.yPosition = this.height / 6 + 103;
|
||||
done.yPosition = this.height / 6 + 148;
|
||||
}
|
||||
super.drawScreen(mx, my, par3);
|
||||
this.channel.drawTextBox();
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id == 200) {
|
||||
this.mc.displayGuiScreen(parent);
|
||||
}else if(par1GuiButton.id == 1) {
|
||||
EaglerAdapter.voiceConnect(channel.getText());
|
||||
}else if(par1GuiButton.id == 2) {
|
||||
EaglerAdapter.voiceEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
this.channel.updateCursorCounter();
|
||||
this.connect.enabled = !voiceActive;
|
||||
this.disconnect.enabled = voiceActive;
|
||||
this.channel.setEnabled(!voiceActive);
|
||||
this.slider.enabled = voiceActive;
|
||||
}
|
||||
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
this.channel.textboxKeyTyped(par1, par2);
|
||||
}
|
||||
|
||||
protected void mouseClicked(int par1, int par2, int par3) {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
this.channel.mouseClicked(par1, par2, par3);
|
||||
}
|
||||
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final TextureLocation tex_gui = new TextureLocation("/gui/gui.png");
|
||||
|
||||
private static String[] connectedUsers = new String[0];
|
||||
private static String[] talkingUsers = new String[0];
|
||||
private static boolean voiceActive = false;
|
||||
private static boolean voiceRelayed = false;
|
||||
|
||||
public static void tickVoiceConnection() {
|
||||
voiceActive = EaglerAdapter.voiceActive();
|
||||
if(voiceActive) {
|
||||
voiceRelayed = EaglerAdapter.voiceRelayed();
|
||||
connectedUsers = EaglerAdapter.voiceUsers();
|
||||
talkingUsers = EaglerAdapter.voiceUsersTalking();
|
||||
Arrays.sort(talkingUsers);
|
||||
Arrays.sort(connectedUsers);
|
||||
}else {
|
||||
voiceRelayed = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static long fadeInTimer = 0l;
|
||||
|
||||
public static void drawOverlay() {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(System.currentTimeMillis() - fadeInTimer < 1500l) {
|
||||
ScaledResolution res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_ALPHA_TEST);
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_DEPTH_TEST);
|
||||
EaglerAdapter.glDepthMask(false);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
|
||||
float i = (float)(System.currentTimeMillis() - fadeInTimer) / 600f;
|
||||
i = 1.0f / (i + 1.0f);
|
||||
i = i * i * 1.08f - 0.08f;
|
||||
if(i < 0.0f) i = 0.0f;
|
||||
drawRect(0, 0, res.getScaledWidth(), res.getScaledHeight(), ((int)(i * 255f) << 24) | 0xffffff);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_ALPHA_TEST);
|
||||
if(System.currentTimeMillis() - fadeInTimer < 130l) {
|
||||
mc.showWarningText();
|
||||
}
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_DEPTH_TEST);
|
||||
EaglerAdapter.glDepthMask(true);
|
||||
}
|
||||
boolean titleScreen = (mc.currentScreen != null && (mc.currentScreen instanceof GuiMainMenu));
|
||||
if(voiceActive && !(titleScreen && ((GuiMainMenu)mc.currentScreen).showAck) && !mc.gameSettings.showDebugInfo) {
|
||||
ScaledResolution res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
|
||||
int width = res.getScaledWidth(); int height = res.getScaledHeight();
|
||||
if(titleScreen) {
|
||||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glTranslatef(0f, 12f, 0f);
|
||||
}
|
||||
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_TEXTURE_2D);
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
String line1 = "voice connected";
|
||||
String line2 = "" + connectedUsers.length + " users listening";
|
||||
int ll1 = mc.fontRenderer.getStringWidth(line1);
|
||||
int ll2 = mc.fontRenderer.getStringWidth(line2);
|
||||
drawRect(width - 17 - ll1 - 6, 0, width, 20, 0x33000000);
|
||||
|
||||
if(mc.gameSettings.keyBindPlayerList.pressed || (mc.currentScreen != null && ((mc.currentScreen instanceof GuiIngameMenu) || (mc.currentScreen instanceof GuiScreenVoiceChannel)))) {
|
||||
if(connectedUsers.length > 0) {
|
||||
int wid = 0;
|
||||
for(int i = 0; i < connectedUsers.length; ++i) {
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
int sw = mc.fontRenderer.getStringWidth(connectedUsers[i]);
|
||||
mc.fontRenderer.drawStringWithShadow(connectedUsers[i], width - 12 - sw, 26 + i*11, 0xffeeeeee);
|
||||
if(wid < sw) {
|
||||
wid = sw;
|
||||
}
|
||||
|
||||
boolean isTalking = false;
|
||||
for(int j = 0; j < talkingUsers.length; ++j) {
|
||||
if(talkingUsers[j].equals(connectedUsers[i])) {
|
||||
isTalking = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tex_gui.bindTexture();
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 0.65f);
|
||||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glTranslatef(width - 9, 27 + i*11, 0f);
|
||||
EaglerAdapter.glScalef(0.5f, 0.5f, 0.5f);
|
||||
static_drawTexturedModalRect(0, 0, isTalking ? 208 : 224, 0, 15, 15);
|
||||
EaglerAdapter.glPopMatrix();
|
||||
}
|
||||
|
||||
drawRect(width - wid - 15, 24, width, 26 + connectedUsers.length*11, 0x33000000);
|
||||
}
|
||||
}else {
|
||||
if(talkingUsers.length > 0) {
|
||||
int wid = 0;
|
||||
for(int i = 0; i < talkingUsers.length; ++i) {
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
int sw = mc.fontRenderer.getStringWidth(talkingUsers[i]);
|
||||
mc.fontRenderer.drawStringWithShadow(talkingUsers[i], width - 12 - sw, 26 + i*11, 0xffeeeeee);
|
||||
if(wid < sw) {
|
||||
wid = sw;
|
||||
}
|
||||
|
||||
tex_gui.bindTexture();
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 0.65f);
|
||||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glTranslatef(width - 9, 27 + i*11, 0f);
|
||||
EaglerAdapter.glScalef(0.5f, 0.5f, 0.5f);
|
||||
static_drawTexturedModalRect(0, 0, 208, 0, 15, 15);
|
||||
EaglerAdapter.glPopMatrix();
|
||||
}
|
||||
|
||||
drawRect(width - wid - 15, 24, width, 26 + talkingUsers.length*11, 0x33000000);
|
||||
}
|
||||
}
|
||||
|
||||
mc.fontRenderer.drawStringWithShadow(line1, width - 16 - ll1 - 4, 2, 0xffffffff);
|
||||
|
||||
EaglerAdapter.glPushMatrix();
|
||||
EaglerAdapter.glTranslatef(width - 20, 11f, 0f);
|
||||
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
|
||||
mc.fontRenderer.drawStringWithShadow(line2, -ll2, 0, 0xffffffff);
|
||||
EaglerAdapter.glPopMatrix();
|
||||
|
||||
boolean b = ((System.currentTimeMillis() / 800l) % 2l) == 1l;
|
||||
|
||||
tex_gui.bindTexture();
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND);
|
||||
EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA);
|
||||
EaglerAdapter.glColor4f(1.0f, 1.0f, 1.0f, 0.65f);
|
||||
static_drawTexturedModalRect(width - 17, 2, b ? 192 : 224, 0, 15, 15);
|
||||
|
||||
if(titleScreen) {
|
||||
EaglerAdapter.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.ModelBiped;
|
||||
import net.minecraft.src.ModelRenderer;
|
||||
|
||||
public class ModelBipedNewSkins extends ModelBiped {
|
||||
public ModelRenderer field_178734_a;
|
||||
public ModelRenderer field_178732_b;
|
||||
public ModelRenderer field_178733_c;
|
||||
public ModelRenderer field_178731_d;
|
||||
public ModelRenderer field_178730_v;
|
||||
private ModelRenderer field_178729_w;
|
||||
private ModelRenderer field_178736_x;
|
||||
private boolean isAlex;
|
||||
|
||||
public ModelBipedNewSkins(float p_i46304_1_, boolean p_i46304_2_)
|
||||
{
|
||||
super(p_i46304_1_, 0.0F, 64, 64);
|
||||
this.isAlex = p_i46304_2_;
|
||||
this.field_178736_x = new ModelRenderer(this, 24, 0);
|
||||
this.field_178736_x.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, p_i46304_1_);
|
||||
this.field_178729_w = new ModelRenderer(this, 0, 0);
|
||||
this.field_178729_w.setTextureSize(64, 32);
|
||||
this.field_178729_w.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, p_i46304_1_);
|
||||
|
||||
if (p_i46304_2_)
|
||||
{
|
||||
this.bipedLeftArm = new ModelRenderer(this, 32, 48);
|
||||
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, p_i46304_1_);
|
||||
this.bipedLeftArm.setRotationPoint(5.0F, 2.5F, 0.0F);
|
||||
this.bipedRightArm = new ModelRenderer(this, 40, 16);
|
||||
this.bipedRightArm.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, p_i46304_1_);
|
||||
this.bipedRightArm.setRotationPoint(-5.0F, 2.5F, 0.0F);
|
||||
this.field_178734_a = new ModelRenderer(this, 48, 48);
|
||||
this.field_178734_a.addBox(-1.0F, -2.0F, -2.0F, 3, 12, 4, p_i46304_1_ + 0.25F);
|
||||
this.field_178734_a.setRotationPoint(5.0F, 2.5F, 0.0F);
|
||||
this.field_178732_b = new ModelRenderer(this, 40, 32);
|
||||
this.field_178732_b.addBox(-2.0F, -2.0F, -2.0F, 3, 12, 4, p_i46304_1_ + 0.25F);
|
||||
this.field_178732_b.setRotationPoint(-5.0F, 2.5F, 10.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.bipedLeftArm = new ModelRenderer(this, 32, 48);
|
||||
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, p_i46304_1_);
|
||||
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F);
|
||||
this.field_178734_a = new ModelRenderer(this, 48, 48);
|
||||
this.field_178734_a.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, p_i46304_1_ + 0.25F);
|
||||
this.field_178734_a.setRotationPoint(5.0F, 2.0F, 0.0F);
|
||||
this.field_178732_b = new ModelRenderer(this, 40, 32);
|
||||
this.field_178732_b.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, p_i46304_1_ + 0.25F);
|
||||
this.field_178732_b.setRotationPoint(-5.0F, 2.0F, 10.0F);
|
||||
}
|
||||
|
||||
this.bipedLeftLeg = new ModelRenderer(this, 16, 48);
|
||||
this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, p_i46304_1_);
|
||||
this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F, 0.0F);
|
||||
this.field_178733_c = new ModelRenderer(this, 0, 48);
|
||||
this.field_178733_c.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, p_i46304_1_ + 0.25F);
|
||||
this.field_178733_c.setRotationPoint(1.9F, 12.0F, 0.0F);
|
||||
this.field_178731_d = new ModelRenderer(this, 0, 32);
|
||||
this.field_178731_d.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, p_i46304_1_ + 0.25F);
|
||||
this.field_178731_d.setRotationPoint(-1.9F, 12.0F, 0.0F);
|
||||
this.field_178730_v = new ModelRenderer(this, 16, 32);
|
||||
this.field_178730_v.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, p_i46304_1_ + 0.25F);
|
||||
this.field_178730_v.setRotationPoint(0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the models various rotation angles then renders the model.
|
||||
*/
|
||||
public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) {
|
||||
super.render(p_78088_1_, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_);
|
||||
//EaglerAdapter.glPushMatrix();
|
||||
|
||||
//if (p_78088_1_ != null && p_78088_1_.isSneaking()) {
|
||||
// EaglerAdapter.glTranslatef(0.0F, 0.2F, 0.0F);
|
||||
//}
|
||||
|
||||
this.field_178733_c.render(p_78088_7_);
|
||||
this.field_178731_d.render(p_78088_7_);
|
||||
this.field_178734_a.render(p_78088_7_);
|
||||
this.field_178732_b.render(p_78088_7_);
|
||||
this.field_178730_v.render(p_78088_7_);
|
||||
|
||||
//EaglerAdapter.glPopMatrix();
|
||||
}
|
||||
|
||||
public void func_178727_b(float p_178727_1_) {
|
||||
func_178685_a(this.bipedHead, this.field_178736_x);
|
||||
this.field_178736_x.rotationPointX = 0.0F;
|
||||
this.field_178736_x.rotationPointY = 0.0F;
|
||||
this.field_178736_x.render(p_178727_1_);
|
||||
}
|
||||
|
||||
public void func_178728_c(float p_178728_1_) {
|
||||
this.field_178729_w.render(p_178728_1_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the model's various rotation angles. For bipeds, par1 and par2 are used
|
||||
* for animating the movement of arms and legs, where par1 represents the
|
||||
* time(so that arms and legs swing back and forth) and par2 represents how
|
||||
* "far" arms and legs can swing at most.
|
||||
*/
|
||||
public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) {
|
||||
super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, p_78087_7_);
|
||||
func_178685_a(this.bipedLeftLeg, this.field_178733_c);
|
||||
func_178685_a(this.bipedRightLeg, this.field_178731_d);
|
||||
func_178685_a(this.bipedLeftArm, this.field_178734_a);
|
||||
func_178685_a(this.bipedRightArm, this.field_178732_b);
|
||||
func_178685_a(this.bipedBody, this.field_178730_v);
|
||||
}
|
||||
|
||||
public void func_178725_a() {
|
||||
this.bipedRightArm.render(0.0625F);
|
||||
this.field_178732_b.render(0.0625F);
|
||||
}
|
||||
|
||||
public void func_178726_b() {
|
||||
this.bipedLeftArm.render(0.0625F);
|
||||
this.field_178734_a.render(0.0625F);
|
||||
}
|
||||
|
||||
public void postRenderHiddenArm(float p_178718_1_) {
|
||||
if (this.isAlex) {
|
||||
++this.bipedRightArm.rotationPointX;
|
||||
this.bipedRightArm.postRender(p_178718_1_);
|
||||
--this.bipedRightArm.rotationPointX;
|
||||
} else {
|
||||
this.bipedRightArm.postRender(p_178718_1_);
|
||||
}
|
||||
}
|
||||
|
||||
public static void func_178685_a(ModelRenderer p_178685_0_, ModelRenderer p_178685_1_)
|
||||
{
|
||||
p_178685_1_.rotateAngleX = p_178685_0_.rotateAngleX;
|
||||
p_178685_1_.rotateAngleY = p_178685_0_.rotateAngleY;
|
||||
p_178685_1_.rotateAngleZ = p_178685_0_.rotateAngleZ;
|
||||
p_178685_1_.rotationPointX = p_178685_0_.rotationPointX;
|
||||
p_178685_1_.rotationPointY = p_178685_0_.rotationPointY;
|
||||
p_178685_1_.rotationPointZ = p_178685_0_.rotationPointZ;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,145 +0,0 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.Packet;
|
||||
|
||||
public class WebsocketNetworkManager implements INetworkManager {
|
||||
|
||||
private NetHandler netHandler;
|
||||
private String serverURI;
|
||||
|
||||
public WebsocketNetworkManager(String uri, String eagler, NetHandler netHandler) throws IOException {
|
||||
this.serverURI = uri;
|
||||
this.netHandler = netHandler;
|
||||
if(!EaglerAdapter.startConnection(uri)) {
|
||||
throw new IOException("websocket to "+uri+" failed");
|
||||
}
|
||||
EaglerAdapter.setDebugVar("minecraftServer", uri);
|
||||
}
|
||||
|
||||
public void setNetHandler(NetHandler netHandler) {
|
||||
this.netHandler = netHandler;
|
||||
}
|
||||
|
||||
private ByteArrayOutputStream sendBuffer = new ByteArrayOutputStream();
|
||||
|
||||
public void addToSendQueue(Packet var1) {
|
||||
try {
|
||||
sendBuffer.reset();
|
||||
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
||||
Packet.writePacket(var1, yee);
|
||||
EaglerAdapter.writePacket(sendBuffer.toByteArray());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void wakeThreads() {
|
||||
}
|
||||
|
||||
private static class ByteBufferDirectInputStream extends InputStream {
|
||||
private ByteBuffer buf;
|
||||
private ByteBufferDirectInputStream(ByteBuffer b) {
|
||||
this.buf = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return buf.remaining() > 0 ? ((int)buf.get() & 0xFF) : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() {
|
||||
return buf.remaining();
|
||||
}
|
||||
}
|
||||
|
||||
private ByteBuffer oldChunkBuffer = null;
|
||||
private LinkedList<ByteBuffer> readChunks = new LinkedList();
|
||||
|
||||
public void processReadPackets() {
|
||||
readChunks.clear();
|
||||
|
||||
if(oldChunkBuffer != null) {
|
||||
readChunks.add(oldChunkBuffer);
|
||||
}
|
||||
|
||||
byte[] packet;
|
||||
while((packet = EaglerAdapter.readPacket()) != null) {
|
||||
readChunks.add(ByteBuffer.wrap(packet));
|
||||
}
|
||||
if(!readChunks.isEmpty()) {
|
||||
int cap = 0;
|
||||
for(ByteBuffer b : readChunks) {
|
||||
cap += b.limit();
|
||||
}
|
||||
|
||||
ByteBuffer stream = ByteBuffer.allocate(cap);
|
||||
for(ByteBuffer b : readChunks) {
|
||||
stream.put(b);
|
||||
}
|
||||
stream.flip();
|
||||
|
||||
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
|
||||
while(stream.hasRemaining()) {
|
||||
stream.mark();
|
||||
try {
|
||||
Packet pkt = Packet.readPacket(packetStream, false);
|
||||
//System.out.println(pkt.toString());
|
||||
pkt.processPacket(this.netHandler);
|
||||
} catch (EOFException e) {
|
||||
stream.reset();
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
continue;
|
||||
} catch (Throwable e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if(stream.hasRemaining()) {
|
||||
oldChunkBuffer = stream.slice();
|
||||
}else {
|
||||
oldChunkBuffer = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void serverShutdown() {
|
||||
if(EaglerAdapter.connectionOpen()) {
|
||||
EaglerAdapter.endConnection();
|
||||
EaglerAdapter.setDebugVar("minecraftServer", "null");
|
||||
}
|
||||
}
|
||||
|
||||
public int packetSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void networkShutdown(String var1, Object... var2) {
|
||||
serverShutdown();
|
||||
}
|
||||
|
||||
public void closeConnections() {
|
||||
if(EaglerAdapter.connectionOpen()) {
|
||||
EaglerAdapter.endConnection();
|
||||
EaglerAdapter.setDebugVar("minecraftServer", "null");
|
||||
}
|
||||
}
|
||||
|
||||
public String getServerURI() {
|
||||
return this.serverURI;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,13 +11,14 @@ import net.lax1dude.eaglercraft.SHA1Digest;
|
|||
|
||||
public class EPKCompiler {
|
||||
|
||||
private final ByteArrayOutputStream osb = new ByteArrayOutputStream();
|
||||
private final ByteArrayOutputStream osb;
|
||||
private DataOutputStream os;
|
||||
private Deflater d;
|
||||
private final SHA1Digest dig = new SHA1Digest();
|
||||
|
||||
public EPKCompiler(String name) {
|
||||
public EPKCompiler(String name, int initialSize) {
|
||||
try {
|
||||
osb = new ByteArrayOutputStream(initialSize);
|
||||
d = new Deflater(9);
|
||||
os = new DataOutputStream(osb);
|
||||
os.write("EAGPKG!!".getBytes(Charset.forName("UTF-8")));
|
||||
|
|
|
@ -49,7 +49,6 @@ public class EaglercraftSaveManager implements ISaveFormat {
|
|||
}
|
||||
String folderName = t.getName();
|
||||
String dir = t.path;
|
||||
System.out.println(dir);
|
||||
byte[] lvl = EaglerAdapter.readFile(dir + "/lvl");
|
||||
if(lvl != null) {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package net.lax1dude.eaglercraft.beta;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.GuiCreateWorld;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.PlayerControllerSP;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
|
||||
public class GuiCreateOrImport extends GuiScreen {
|
||||
|
||||
private final GuiScreen parent;
|
||||
private String title;
|
||||
|
||||
public GuiCreateOrImport(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
this.title = StringTranslate.getInstance().translateKey("selectWorld.wannaImport");
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
StringTranslate st = StringTranslate.getInstance();
|
||||
controlList.add(new GuiButton(0, (width - 200) / 2, height / 3 + 5, st.translateKey("selectWorld.create")));
|
||||
controlList.add(new GuiButton(1, (width - 200) / 2, height / 3 + 29, st.translateKey("selectWorld.import")));
|
||||
controlList.add(new GuiButton(2, (width - 200) / 2, height / 3 + 53, st.translateKey("gui.cancel")));
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
if(guibutton.id == 0) {
|
||||
mc.displayGuiScreen(new GuiCreateWorld(parent));
|
||||
}else if(guibutton.id == 1) {
|
||||
final String folder = ImportExport.importWorld(mc.loadingScreen);
|
||||
if(folder == null) {
|
||||
mc.displayGuiScreen(new GuiSomethingFailed(parent, "Import Failed", "the world is incompatible or corrupt", "maybe use an EPK decompiler to debug"));
|
||||
}else if(folder.equals("$cancelled$")) {
|
||||
mc.displayGuiScreen(parent);
|
||||
}else {
|
||||
mc.displayGuiScreen(new GuiWhatDoYouWantToName(folder, new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(String str) {
|
||||
ImportExport.renameImportedWorld(folder, str);
|
||||
mc.playerController = new PlayerControllerSP(mc);
|
||||
mc.startWorld(folder, str, 0l);
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}else if(guibutton.id == 2) {
|
||||
mc.displayGuiScreen(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
drawDefaultBackground();
|
||||
drawCenteredString(fontRenderer, title, width / 2, height / 4, 0xffffff);
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package net.lax1dude.eaglercraft.beta;
|
||||
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
|
||||
public class GuiSomethingFailed extends GuiScreen {
|
||||
|
||||
private final String title;
|
||||
private final String[] description;
|
||||
private final GuiScreen cont;
|
||||
|
||||
public GuiSomethingFailed(GuiScreen cont, String title, String... description) {
|
||||
this.cont = cont;
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
controlList.add(new GuiButton(0, (width - 200) / 2, height / 4 + 32 + description.length * 10, StringTranslate.getInstance().translateKey("gui.cancel")));
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
drawDefaultBackground();
|
||||
int h = height / 4;
|
||||
drawCenteredString(fontRenderer, title, width / 2, h, 0xffffff);
|
||||
h += 16;
|
||||
for(String s : description) {
|
||||
drawCenteredString(fontRenderer, s, width / 2, h, 0xffcccc);
|
||||
h += 10;
|
||||
}
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
public void actionPerformed(GuiButton bnt) {
|
||||
if(bnt.id == 0) {
|
||||
mc.displayGuiScreen(cont);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package net.lax1dude.eaglercraft.beta;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.GuiDisableButton;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
|
||||
public class GuiWhatDoYouWantToName extends GuiScreen {
|
||||
|
||||
private final Consumer<String> cont;
|
||||
private final String defaultName;
|
||||
private final String title;
|
||||
private GuiDisableButton nameField;
|
||||
|
||||
public GuiWhatDoYouWantToName(String defaultName, Consumer<String> cont) {
|
||||
this.defaultName = defaultName;
|
||||
this.cont = cont;
|
||||
this.title = StringTranslate.getInstance().translateKey("selectWorld.importName");
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
nameField = new GuiDisableButton(fontRenderer, width / 2 - 100, height / 3, 200, 20, defaultName);
|
||||
controlList.add(new GuiButton(0, (width - 200) / 2, height / 3 + 35, StringTranslate.getInstance().translateKey("gui.done")));
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
drawDefaultBackground();
|
||||
drawCenteredString(fontRenderer, title, width / 2, height / 4, 0xFFFFFF);
|
||||
nameField.func_22067_c();
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
public void actionPerformed(GuiButton bnt) {
|
||||
if(bnt.id == 0) {
|
||||
String s = nameField.func_22071_a();
|
||||
if (MathHelper.func_22282_a(s)) {
|
||||
s = defaultName;
|
||||
}
|
||||
cont.accept(s);
|
||||
}
|
||||
}
|
||||
|
||||
protected void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
nameField.func_22072_a(c, i);
|
||||
}
|
||||
|
||||
protected void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
nameField.func_22069_a(i, j, k);
|
||||
}
|
||||
|
||||
}
|
161
src/main/java/net/lax1dude/eaglercraft/beta/ImportExport.java
Normal file
161
src/main/java/net/lax1dude/eaglercraft/beta/ImportExport.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
package net.lax1dude.eaglercraft.beta;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.beta.EPKDecompiler.FileEntry;
|
||||
import net.minecraft.src.IProgressUpdate;
|
||||
import net.minecraft.src.NBTBase;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
|
||||
public class ImportExport {
|
||||
|
||||
private static IProgressUpdate prog = null;
|
||||
private static String progressTitle = null;
|
||||
private static long lastProgressUpdate = 0l;
|
||||
|
||||
private static String formatFloat(float f) {
|
||||
return String.format("%.2f", f);
|
||||
}
|
||||
|
||||
private static void progress(int p) {
|
||||
long t = System.currentTimeMillis();
|
||||
if(t - lastProgressUpdate < 100l) {
|
||||
return;
|
||||
}
|
||||
lastProgressUpdate = t;
|
||||
String s;
|
||||
if(p < 1000) {
|
||||
s = "" + p + " B";
|
||||
}else if(p < 1000000) {
|
||||
s = "" + formatFloat(p / 1000f) + " kB";
|
||||
}else {
|
||||
s = "" + formatFloat(p / 1000000f) + " MB";
|
||||
}
|
||||
prog.displayLoadingString(progressTitle, s);
|
||||
}
|
||||
|
||||
public static String importWorld(IProgressUpdate loadingScreen) {
|
||||
progressTitle = "Importing World";
|
||||
prog = loadingScreen;
|
||||
loadingScreen.displayLoadingString("Importing World", "(please wait)");
|
||||
EaglerAdapter.openFileChooser("epk", "application/epk");
|
||||
|
||||
byte[] loaded;
|
||||
while((loaded = EaglerAdapter.getFileChooserResult()) == null) {
|
||||
long t = System.currentTimeMillis();
|
||||
if(t - lastProgressUpdate < 100l) {
|
||||
continue;
|
||||
}
|
||||
lastProgressUpdate = t;
|
||||
loadingScreen.displayLoadingString("Importing World", "(please wait)");
|
||||
}
|
||||
if(loaded.length == 0) {
|
||||
return "$cancelled$";
|
||||
}
|
||||
|
||||
String name = EaglerAdapter.getFileChooserResultName();
|
||||
name = name.replaceAll("[^A-Za-z0-9\\-_]", "_").trim();
|
||||
|
||||
while(EaglerAdapter.pathExists("saves/" + name)) {
|
||||
name = "_" + name;
|
||||
}
|
||||
|
||||
loadingScreen.displayLoadingString("Importing World", "Extracting EPK");
|
||||
|
||||
try {
|
||||
EPKDecompiler loader = new EPKDecompiler(loaded);
|
||||
int counter = 0;
|
||||
FileEntry f;
|
||||
while((f = loader.readFile()) != null) {
|
||||
EaglerAdapter.writeFile("saves/" + name + "/" + f.name, f.data);
|
||||
counter += f.data.length;
|
||||
progress(counter);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
NBTBase b = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(EaglerAdapter.readFile("saves/" + name + "/lvl"))));
|
||||
if(!(b instanceof NBTTagCompound)) {
|
||||
throw new IOException("NBT in saves/" + name + "/lvl is corrupt!");
|
||||
}
|
||||
}catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("The folder 'saves/" + name + "/' will be deleted");
|
||||
FilesystemUtils.recursiveDeleteDirectory("saves/" + name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static void renameImportedWorld(String name, String displayName) {
|
||||
byte[] lvl = EaglerAdapter.readFile("saves/" + name + "/lvl");
|
||||
if(lvl != null) {
|
||||
try {
|
||||
NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(lvl)));
|
||||
if(nbt instanceof NBTTagCompound) {
|
||||
NBTTagCompound w = (NBTTagCompound)nbt;
|
||||
w.setString("LevelName", displayName);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(lvl.length + 16 + displayName.length() * 2); // should be large enough
|
||||
NBTBase.writeTag(w, new DataOutputStream(out));
|
||||
EaglerAdapter.writeFile("saves/" + name + "/lvl", out.toByteArray());
|
||||
}else {
|
||||
throw new IOException("file 'saves/" + name + "/lvl' does not contain an NBTTagCompound");
|
||||
}
|
||||
}catch(IOException e) {
|
||||
System.err.println("Failed to modify world data for 'saves/" + name + "/lvl'");
|
||||
System.err.println("It will be kept for future recovery");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean exportWorld(IProgressUpdate loadingScreen, String name, String downloadName) {
|
||||
progressTitle = "Exporting World";
|
||||
prog = loadingScreen;
|
||||
loadingScreen.displayLoadingString("Exporting World", "(please wait)");
|
||||
|
||||
if(!EaglerAdapter.fileExists("saves/" + name + "/lvl")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
String dir = "saves/" + name;
|
||||
|
||||
try {
|
||||
EPKCompiler comp = new EPKCompiler(dir, 409600000);
|
||||
Collection<EaglerAdapter.FileEntry> lst = EaglerAdapter.listFilesRecursive(dir);
|
||||
Iterator<EaglerAdapter.FileEntry> itr = lst.iterator();
|
||||
while(itr.hasNext()) {
|
||||
EaglerAdapter.FileEntry t = itr.next();
|
||||
if(t.path.startsWith(dir + "/")) {
|
||||
byte[] dat = EaglerAdapter.readFile(t.path);
|
||||
if(dat != null) {
|
||||
String fn = t.path.substring(dir.length() + 1);
|
||||
comp.append(fn, dat);
|
||||
size += dat.length;
|
||||
progress(size);
|
||||
}
|
||||
}
|
||||
}
|
||||
loadingScreen.displayLoadingString("Exporting World", "finishing...");
|
||||
EaglerAdapter.downloadFile(downloadName, comp.complete());
|
||||
return true;
|
||||
}catch(Throwable t) {
|
||||
System.err.println("Export of '" + name + "' failed!");
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -155,7 +155,7 @@ public class GuiScreen extends Gui {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void deleteWorld(boolean flag, int i) {
|
||||
public void confirmClicked(boolean flag, int i) {
|
||||
}
|
||||
|
||||
protected Minecraft mc;
|
||||
|
|
|
@ -8,6 +8,10 @@ import java.text.DateFormat;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.beta.GuiCreateOrImport;
|
||||
import net.lax1dude.eaglercraft.beta.GuiSomethingFailed;
|
||||
import net.lax1dude.eaglercraft.beta.ImportExport;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class GuiSelectWorld extends GuiScreen {
|
||||
|
@ -52,19 +56,16 @@ public class GuiSelectWorld extends GuiScreen {
|
|||
|
||||
public void initGui2() {
|
||||
StringTranslate stringtranslate = StringTranslate.getInstance();
|
||||
controlList.add(field_22104_s = new GuiButton(1, width / 2 - 154, height - 52, 150, 20,
|
||||
stringtranslate.translateKey("selectWorld.select")));
|
||||
controlList.add(field_22095_r = new GuiButton(6, width / 2 - 154, height - 28, 70, 20,
|
||||
stringtranslate.translateKey("selectWorld.rename")));
|
||||
controlList.add(field_22103_t = new GuiButton(2, width / 2 - 74, height - 28, 70, 20,
|
||||
stringtranslate.translateKey("selectWorld.delete")));
|
||||
controlList.add(new GuiButton(3, width / 2 + 4, height - 52, 150, 20,
|
||||
stringtranslate.translateKey("selectWorld.create")));
|
||||
controlList
|
||||
.add(new GuiButton(0, width / 2 + 4, height - 28, 150, 20, stringtranslate.translateKey("gui.cancel")));
|
||||
controlList.add(field_22104_s = new GuiButton(1, width / 2 - 154, height - 52, 150, 20, stringtranslate.translateKey("selectWorld.select")));
|
||||
controlList.add(field_22095_r = new GuiButton(6, width / 2 - 154, height - 28, 70, 20, stringtranslate.translateKey("selectWorld.rename")));
|
||||
controlList.add(field_22103_t = new GuiButton(2, width / 2 - 74, height - 28, 70, 20, stringtranslate.translateKey("selectWorld.delete")));
|
||||
controlList.add(new GuiButton(3, width / 2 + 4, height - 52, 150, 20, stringtranslate.translateKey("selectWorld.create")));
|
||||
controlList.add(export = new GuiButton(7, width / 2 + 4, height - 28, 70, 20, stringtranslate.translateKey("selectWorld.export")));
|
||||
controlList.add(new GuiButton(0, width / 2 + 4 + 80, height - 28, 70, 20, stringtranslate.translateKey("gui.cancel")));
|
||||
field_22104_s.enabled = false;
|
||||
field_22095_r.enabled = false;
|
||||
field_22103_t.enabled = false;
|
||||
export.enabled = false;
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
|
@ -87,9 +88,21 @@ public class GuiSelectWorld extends GuiScreen {
|
|||
} else if (guibutton.id == 1) {
|
||||
selectWorld(field_22101_l);
|
||||
} else if (guibutton.id == 3) {
|
||||
mc.displayGuiScreen(new GuiCreateWorld(this));
|
||||
mc.displayGuiScreen(new GuiCreateOrImport(this));
|
||||
} else if (guibutton.id == 6) {
|
||||
mc.displayGuiScreen(new GuiRenameWorld(this, func_22091_c(field_22101_l)));
|
||||
} else if (guibutton.id == 7) {
|
||||
String s = func_22094_d(field_22101_l);
|
||||
if (s != null) {
|
||||
isExporting = true;
|
||||
StringTranslate stringtranslate = StringTranslate.getInstance();
|
||||
String s1 = stringtranslate.translateKey("selectWorld.exportQuestion1");
|
||||
String s2 = stringtranslate.translateKey("selectWorld.exportQuestion2");
|
||||
String s3 = stringtranslate.translateKey("selectWorld.export");
|
||||
String s4 = stringtranslate.translateKey("gui.cancel");
|
||||
GuiYesNo guiyesno = new GuiYesNo(this, s1, s2, s3, s4, field_22101_l);
|
||||
mc.displayGuiScreen(guiyesno);
|
||||
}
|
||||
} else if (guibutton.id == 0) {
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
} else {
|
||||
|
@ -112,7 +125,7 @@ public class GuiSelectWorld extends GuiScreen {
|
|||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
public void deleteWorld(boolean flag, int i) {
|
||||
public void confirmClicked(boolean flag, int i) {
|
||||
if (field_22096_q) {
|
||||
field_22096_q = false;
|
||||
if (flag) {
|
||||
|
@ -122,6 +135,17 @@ public class GuiSelectWorld extends GuiScreen {
|
|||
func_22084_k();
|
||||
}
|
||||
mc.displayGuiScreen(this);
|
||||
}else if (isExporting) {
|
||||
isExporting = false;
|
||||
if (flag) {
|
||||
if(!ImportExport.exportWorld(mc.loadingScreen, func_22091_c(i), func_22094_d(i) + ".epk")) {
|
||||
mc.displayGuiScreen(new GuiSomethingFailed(this, "Export Failed", "An exception was encountered while exporting '" + func_22091_c(i) + "'", "Check the game's console"));
|
||||
}else {
|
||||
mc.displayGuiScreen(this);
|
||||
}
|
||||
}else {
|
||||
mc.displayGuiScreen(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,6 +179,10 @@ public class GuiSelectWorld extends GuiScreen {
|
|||
return guiselectworld.field_22103_t;
|
||||
}
|
||||
|
||||
static GuiButton getExportButton(GuiSelectWorld guiselectworld) {
|
||||
return guiselectworld.export;
|
||||
}
|
||||
|
||||
static String func_22087_f(GuiSelectWorld guiselectworld) {
|
||||
return guiselectworld.field_22098_o;
|
||||
}
|
||||
|
@ -177,7 +205,9 @@ public class GuiSelectWorld extends GuiScreen {
|
|||
private String field_22098_o;
|
||||
private String field_22097_p;
|
||||
private boolean field_22096_q;
|
||||
private boolean isExporting;
|
||||
private GuiButton field_22095_r;
|
||||
private GuiButton field_22104_s;
|
||||
private GuiButton field_22103_t;
|
||||
private GuiButton export;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ class GuiWorldSlot extends GuiSlot {
|
|||
GuiSelectWorld.func_22083_c(field_22266_a).enabled = flag1;
|
||||
GuiSelectWorld.func_22085_d(field_22266_a).enabled = flag1;
|
||||
GuiSelectWorld.func_22092_e(field_22266_a).enabled = flag1;
|
||||
GuiSelectWorld.getExportButton(field_22266_a).enabled = flag1;
|
||||
if (flag && flag1) {
|
||||
field_22266_a.selectWorld(i);
|
||||
}
|
||||
|
@ -58,8 +59,7 @@ class GuiWorldSlot extends GuiSlot {
|
|||
GuiSelectWorld.func_22093_g(field_22266_a).format(new Date(saveformatcomparator.func_22163_e())))
|
||||
.toString();
|
||||
long l1 = saveformatcomparator.func_22159_c();
|
||||
s1 = (new StringBuilder()).append(s1).append(", ").append((float) (((l1 / 1024L) * 100L) / 1024L) / 100F)
|
||||
.append(" MB)").toString();
|
||||
s1 = (new StringBuilder()).append(s1).append(")").toString();
|
||||
String s2 = "";
|
||||
if (saveformatcomparator.func_22161_d()) {
|
||||
s2 = (new StringBuilder()).append(GuiSelectWorld.func_22088_h(field_22266_a)).append(" ").append(s2)
|
||||
|
|
|
@ -23,7 +23,7 @@ public class GuiYesNo extends GuiScreen {
|
|||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
parentScreen.deleteWorld(guibutton.id == 0, worldNumber);
|
||||
parentScreen.confirmClicked(guibutton.id == 0, worldNumber);
|
||||
}
|
||||
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
|
|
|
@ -9,6 +9,8 @@ public interface IProgressUpdate {
|
|||
public abstract void func_594_b(String s);
|
||||
|
||||
public abstract void displayLoadingString(String s);
|
||||
|
||||
public abstract void displayLoadingString(String s, String s1);
|
||||
|
||||
public abstract void setLoadingProgress(int i);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,23 @@ public class LoadingScreenRenderer implements IProgressUpdate {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void displayLoadingString(String s, String s1) {
|
||||
if (!mc.running) {
|
||||
if (field_1005_e) {
|
||||
return;
|
||||
} else {
|
||||
throw new MinecraftError();
|
||||
}
|
||||
} else {
|
||||
field_1006_d = 0L;
|
||||
field_1004_a = s1;
|
||||
field_1007_c = s;
|
||||
setLoadingProgress(-1);
|
||||
field_1006_d = 0L;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLoadingProgress(int i) {
|
||||
if (!mc.running) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user