nearly done with texture pack redo
todo: server texture packs & clean up so desktop runtime works
This commit is contained in:
parent
334c565fee
commit
c3bb53977d
|
@ -4,10 +4,11 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import com.jcraft.jzlib.InflaterInputStream;
|
||||
|
||||
public class EaglerInflater {
|
||||
public class EaglerMisc {
|
||||
|
||||
public static byte[] uncompress(byte[] input) throws IOException {
|
||||
return getBytesFromInputStream(new InflaterInputStream(new ByteArrayInputStream(input)));
|
||||
|
@ -22,4 +23,17 @@ public class EaglerInflater {
|
|||
return os.toByteArray();
|
||||
}
|
||||
|
||||
public static String bytesToString(byte[] bb) {
|
||||
if (bb == null) return "";
|
||||
return new String(bb, Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
public static String[] bytesToLines(byte[] bb) {
|
||||
String contents = bytesToString(bb);
|
||||
if(contents.isEmpty()) {
|
||||
return new String[0];
|
||||
}else {
|
||||
return contents.replace("\r\n", "\n").split("[\r\n]");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -208,7 +208,7 @@ public class TextureTerrainMap implements IconRegister {
|
|||
|
||||
EaglerAdapter.glTexParameteri(EaglerAdapter.GL_TEXTURE_2D, EaglerAdapter.GL_TEXTURE_MAX_LEVEL, 4);
|
||||
|
||||
String dat = EaglerAdapter.fileContents("/" + map.basePath + name + ".txt");
|
||||
String dat = EaglerMisc.bytesToString(Minecraft.getMinecraft().texturePackList.getSelectedTexturePack().getResourceAsBytes("/" + map.basePath + name + ".txt"));
|
||||
if(dat != null) System.out.println("Found animation info for: " + map.basePath + name + ".png");
|
||||
if(dat == null || (dat = dat.trim()).isEmpty()) {
|
||||
framesIdx = new int[divs];
|
||||
|
|
|
@ -3,7 +3,8 @@ package net.minecraft.src;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class AchievementMap {
|
||||
/** Holds the singleton instance of AchievementMap. */
|
||||
|
@ -14,7 +15,8 @@ public class AchievementMap {
|
|||
|
||||
private AchievementMap() {
|
||||
try {
|
||||
for(String str : EaglerAdapter.fileContentsLines("/achievement/map.txt")) {
|
||||
String[] strs = EaglerMisc.bytesToLines(Minecraft.getMinecraft().texturePackList.getSelectedTexturePack().getResourceAsBytes("/achievement/map.txt"));
|
||||
for(String str : strs) {
|
||||
String[] var3 = str.split(",");
|
||||
int var4 = Integer.parseInt(var3[0]);
|
||||
this.guidMap.put(Integer.valueOf(var4), var3[1]);
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.lax1dude.eaglercraft.GuiScreenSingleplayerLoading;
|
|||
import net.lax1dude.eaglercraft.IntegratedServer;
|
||||
import net.lax1dude.eaglercraft.LocalStorageManager;
|
||||
import net.lax1dude.eaglercraft.TextureLocation;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
|
@ -175,7 +176,7 @@ public class GuiMainMenu extends GuiScreen {
|
|||
|
||||
if(this.ackLines.isEmpty()) {
|
||||
int width = 315;
|
||||
String file = EaglerAdapter.fileContents("/credits.txt");
|
||||
String file = EaglerMisc.bytesToString(Minecraft.getMinecraft().texturePackList.getSelectedTexturePack().getResourceAsBytes("/credits.txt"));
|
||||
if(file == null) {
|
||||
for(int i = 0; i < 30; ++i) {
|
||||
this.ackLines.add(" -- file not found -- ");
|
||||
|
|
|
@ -2,7 +2,7 @@ package net.minecraft.src;
|
|||
|
||||
import net.lax1dude.eaglercraft.EPKDecompiler;
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.EaglerInflater;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
import net.lax1dude.eaglercraft.adapter.teavm.vfs.VFile;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -112,7 +112,7 @@ public class GuiTexturePacks extends GuiScreen {
|
|||
ZipEntry entry;
|
||||
while ((entry = zipInputStream.getNextEntry()) != null) {
|
||||
if (entry.isDirectory()) continue;
|
||||
new VFile(fileLocation, safeName, entry.getName()).setAllBytes(EaglerInflater.getBytesFromInputStream(zipInputStream));
|
||||
new VFile(fileLocation, safeName, entry.getName()).setAllBytes(EaglerMisc.getBytesFromInputStream(zipInputStream));
|
||||
}
|
||||
zipInputStream.close();
|
||||
} else {
|
||||
|
@ -138,6 +138,9 @@ public class GuiTexturePacks extends GuiScreen {
|
|||
|
||||
if (par1) {
|
||||
new VFile(fileLocation, ((ITexturePack) var3.get(par2)).getTexturePackFileName()).deleteAll();
|
||||
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(0));
|
||||
this.mc.renderEngine.refreshTextures();
|
||||
this.mc.renderGlobal.loadRenderers();
|
||||
} else {
|
||||
try {
|
||||
this.mc.texturePackList.setTexturePack((ITexturePack) var3.get(par2));
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.lax1dude.eaglercraft.EaglerAdapter;
|
|||
import net.lax1dude.eaglercraft.EaglerProfile;
|
||||
import net.lax1dude.eaglercraft.EaglercraftRandom;
|
||||
import net.lax1dude.eaglercraft.TextureLocation;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
||||
|
||||
public class GuiWinGame extends GuiScreen {
|
||||
|
@ -70,7 +71,8 @@ public class GuiWinGame extends GuiScreen {
|
|||
EaglercraftRandom var5 = new EaglercraftRandom(8124371L);
|
||||
int var6;
|
||||
|
||||
for(String str : EaglerAdapter.fileContentsLines("/title/win.txt")) {
|
||||
String[] strs = EaglerMisc.bytesToLines(mc.texturePackList.getSelectedTexturePack().getResourceAsBytes("/title/win.txt"));
|
||||
for(String str : strs) {
|
||||
String var7;
|
||||
String var8;
|
||||
|
||||
|
@ -88,7 +90,8 @@ public class GuiWinGame extends GuiScreen {
|
|||
this.lines.add("");
|
||||
}
|
||||
|
||||
for(String str : EaglerAdapter.fileContentsLines("/title/credits.txt")) {
|
||||
strs = EaglerMisc.bytesToLines(mc.texturePackList.getSelectedTexturePack().getResourceAsBytes("/title/credits.txt"));
|
||||
for(String str : strs) {
|
||||
var1 = var1.replaceAll("PLAYERNAME", EaglerProfile.username);
|
||||
var1 = var1.replaceAll("\t", " ");
|
||||
this.lines.addAll(this.mc.fontRenderer.listFormattedStringToWidth(var1, var3));
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.io.DataInputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerInflater;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
|
||||
public class Packet51MapChunk extends Packet {
|
||||
/** The x-position of the transmitted chunk, in chunk coordinates. */
|
||||
|
@ -82,7 +82,7 @@ public class Packet51MapChunk extends Packet {
|
|||
var3 += 256;
|
||||
}
|
||||
|
||||
this.compressedChunkData = EaglerInflater.uncompress(temp);
|
||||
this.compressedChunkData = EaglerMisc.uncompress(temp);
|
||||
}else {
|
||||
this.tempLength &= 0xFFFFFFF;
|
||||
this.compressedChunkData = new byte[this.tempLength];
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.io.DataOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerInflater;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
|
||||
public class Packet56MapChunks extends Packet {
|
||||
private int[] chunkPostX;
|
||||
|
@ -56,7 +56,7 @@ public class Packet56MapChunks extends Packet {
|
|||
chunkDataNotCompressed = new byte[this.dataLength];
|
||||
}
|
||||
par1DataInputStream.readFully(chunkDataNotCompressed, 0, this.dataLength);
|
||||
var3 = EaglerInflater.uncompress(chunkDataNotCompressed);
|
||||
var3 = EaglerMisc.uncompress(chunkDataNotCompressed);
|
||||
}
|
||||
|
||||
int var5 = 0;
|
||||
|
|
|
@ -5,7 +5,8 @@ import java.util.IllegalFormatException;
|
|||
import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class StringTranslate {
|
||||
/** Is the private singleton instance of StringTranslate. */
|
||||
|
@ -42,7 +43,7 @@ public class StringTranslate {
|
|||
}
|
||||
|
||||
private void loadLanguage(Properties par1Properties, String par2Str) throws IOException {
|
||||
String[] var3 = EaglerAdapter.fileContents("/lang/" + par2Str + ".lang").replace('\r', '\n')
|
||||
String[] var3 = EaglerMisc.bytesToString(Minecraft.getMinecraft().texturePackList.getSelectedTexturePack().getResourceAsBytes("/lang/" + par2Str + ".lang")).replace('\r', '\n')
|
||||
.replaceAll("\n+", "\n").split("\n");
|
||||
|
||||
for (String var4 : var3) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.io.InputStreamReader;
|
|||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.EaglerImage;
|
||||
import net.lax1dude.eaglercraft.EaglerInflater;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
import net.lax1dude.eaglercraft.adapter.teavm.vfs.VFile;
|
||||
|
||||
public abstract class TexturePackImplementation implements ITexturePack
|
||||
|
@ -77,7 +77,9 @@ public abstract class TexturePackImplementation implements ITexturePack
|
|||
try
|
||||
{
|
||||
var1 = this.func_98137_a("/pack.png", false);
|
||||
this.thumbnailImage = EaglerImage.loadImage(EaglerInflater.getBytesFromInputStream(var1));
|
||||
if (var1 != null) {
|
||||
this.thumbnailImage = EaglerImage.loadImage(EaglerMisc.getBytesFromInputStream(var1));
|
||||
}
|
||||
}
|
||||
catch (IOException var11)
|
||||
{
|
||||
|
@ -163,11 +165,24 @@ public abstract class TexturePackImplementation implements ITexturePack
|
|||
*/
|
||||
public byte[] getResourceAsBytes(String par1Str)
|
||||
{
|
||||
InputStream is = null;
|
||||
byte[] res = null;
|
||||
try {
|
||||
return EaglerInflater.getBytesFromInputStream(this.func_98137_a(par1Str, true));
|
||||
is = this.func_98137_a(par1Str, true);
|
||||
if (is == null) return null;
|
||||
res = EaglerMisc.getBytesFromInputStream(is);
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException ignored) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
protected abstract InputStream func_98139_b(String var1) throws IOException;
|
||||
|
|
|
@ -3,7 +3,8 @@ package net.minecraft.src;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.EaglerMisc;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class TextureStitched implements Icon {
|
||||
private final String textureName;
|
||||
|
@ -171,7 +172,7 @@ public class TextureStitched implements Icon {
|
|||
public void readAnimationInfo(String path) {
|
||||
ArrayList var2 = new ArrayList();
|
||||
try {
|
||||
String var3 = EaglerAdapter.fileContents(path).trim();
|
||||
String var3 = EaglerMisc.bytesToString(Minecraft.getMinecraft().texturePackList.getSelectedTexturePack().getResourceAsBytes(path)).trim();
|
||||
|
||||
if (var3.length() > 0) {
|
||||
String[] var4 = var3.split(",");
|
||||
|
|
|
@ -6,7 +6,7 @@ public class SYS {
|
|||
|
||||
static {
|
||||
|
||||
VirtualFilesystem.VFSHandle vh = VirtualFilesystem.openVFS("_net_lax1dude_eaglercraft_adapter_teavm_vfs_VirtualFilesystem_1_5_2_eagStorage");
|
||||
VirtualFilesystem.VFSHandle vh = VirtualFilesystem.openVFS("eagStorage2");
|
||||
|
||||
if(vh.vfs == null) {
|
||||
System.err.println("Could not init filesystem!");
|
||||
|
|
Loading…
Reference in New Issue
Block a user