Made a better texture pack implementation
This commit is contained in:
parent
56087b1dae
commit
52ef44273a
71
src/main/java/net/PeytonPlayz585/util/zip/ZipFile.java
Normal file
71
src/main/java/net/PeytonPlayz585/util/zip/ZipFile.java
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
package net.PeytonPlayz585.util.zip;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
|
import net.PeytonPlayz585.fileutils.FileEntry;
|
||||||
|
|
||||||
|
public class ZipFile {
|
||||||
|
|
||||||
|
private List<ZipEntry> entries = new ArrayList<ZipEntry>();
|
||||||
|
private HashMap<String, byte[]> filePool = new HashMap<String, byte[]>();
|
||||||
|
|
||||||
|
public ZipFile(ZipInputStream zis) throws IOException {
|
||||||
|
ZipEntry entry;
|
||||||
|
while ((entry = zis.getNextEntry()) != null) {
|
||||||
|
entries.add(entry);
|
||||||
|
|
||||||
|
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
|
byte[] buffer = new byte[(int)entry.getSize()];
|
||||||
|
int len;
|
||||||
|
while ((len = zis.read(buffer)) > 0) {
|
||||||
|
baos.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] fileData = baos.toByteArray();
|
||||||
|
filePool.put(entry.getName(), fileData);
|
||||||
|
}
|
||||||
|
|
||||||
|
zis.closeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
zis.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZipFile(FileEntry file) throws IOException {
|
||||||
|
this(new ZipInputStream(new ByteArrayInputStream(File.readFile(file.path))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZipEntry getEntry(String name) {
|
||||||
|
for(int i = 0; i < entries.size(); i++) {
|
||||||
|
ZipEntry entry = entries.get(i);
|
||||||
|
if(entry != null) {
|
||||||
|
if(entry.getName().equals(name)) {
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getInputStream(ZipEntry entry) {
|
||||||
|
String name = entry.getName();
|
||||||
|
return new ByteArrayInputStream(filePool.get(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
entries.clear();
|
||||||
|
filePool.clear();
|
||||||
|
entries = new ArrayList<ZipEntry>();
|
||||||
|
filePool = new HashMap<String, byte[]>();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,11 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.PeytonPlayz585.fileutils.File;
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
import net.PeytonPlayz585.fileutils.FileChooserResult;
|
import net.PeytonPlayz585.fileutils.FileChooserResult;
|
||||||
import net.PeytonPlayz585.input.Mouse;
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
public class GuiTexturePacks extends GuiScreen {
|
public class GuiTexturePacks extends GuiScreen {
|
||||||
protected GuiScreen field_6461_a;
|
protected GuiScreen field_6461_a;
|
||||||
|
@ -17,6 +16,7 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
private int field_6456_m = this.width;
|
private int field_6456_m = this.width;
|
||||||
private int field_6455_n = -2;
|
private int field_6455_n = -2;
|
||||||
private int field_6454_o = -1;
|
private int field_6454_o = -1;
|
||||||
|
private String fileLocation = "texturepacksNEW";
|
||||||
|
|
||||||
public GuiTexturePacks(GuiScreen var1) {
|
public GuiTexturePacks(GuiScreen var1) {
|
||||||
this.field_6461_a = var1;
|
this.field_6461_a = var1;
|
||||||
|
@ -35,7 +35,7 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
protected void actionPerformed(GuiButton var1) {
|
protected void actionPerformed(GuiButton var1) {
|
||||||
if(var1.enabled) {
|
if(var1.enabled) {
|
||||||
if(var1.id == 5) {
|
if(var1.id == 5) {
|
||||||
GL11.EaglerAdapterImpl2.displayFileChooser("application/zip", "zip");
|
GL11.EaglerAdapterImpl2.displayFileChooser("zip", "application/zip");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(var1.id == 6) {
|
if(var1.id == 6) {
|
||||||
|
@ -161,6 +161,7 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
var16.startDrawingQuads();
|
var16.startDrawingQuads();
|
||||||
var16.setColorRGBA_I(0, 0);
|
var16.setColorRGBA_I(0, 0);
|
||||||
|
@ -179,26 +180,29 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
var16.addVertexWithUV((double)this.field_6457_l, (double)(this.field_6458_j - var18), 0.0D, 0.0D, 0.0D);
|
var16.addVertexWithUV((double)this.field_6457_l, (double)(this.field_6458_j - var18), 0.0D, 0.0D, 0.0D);
|
||||||
var16.draw();
|
var16.draw();
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
|
||||||
|
if(GL11.EaglerAdapterImpl2.fileChooserHasResult()) {
|
||||||
|
FileChooserResult result = GL11.EaglerAdapterImpl2.getFileChooserResult();
|
||||||
|
|
||||||
|
if(result != null) {
|
||||||
|
File.writeFile(this.fileLocation + "/" + result.fileName, result.fileData);
|
||||||
|
|
||||||
|
//Refresh GUI to show newly added texture packs
|
||||||
|
this.mc.displayGuiScreen(new GuiTexturePacks(this.field_6461_a));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.drawCenteredString(this.fontRenderer, "Select Texture Pack", this.width / 2, 16, 16777215);
|
this.drawCenteredString(this.fontRenderer, "Select Texture Pack", this.width / 2, 16, 16777215);
|
||||||
this.drawCenteredString(this.fontRenderer, "(Upload texture pack files here)", this.width / 2 - 77, this.height - 26, 8421504);
|
this.drawCenteredString(this.fontRenderer, "(Place texture pack files here)", this.width / 2 - 77, this.height - 26, 8421504);
|
||||||
super.drawScreen(var1, var2, var3);
|
super.drawScreen(var1, var2, var3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
super.updateScreen();
|
super.updateScreen();
|
||||||
--this.field_6454_o;
|
--this.field_6454_o;
|
||||||
|
|
||||||
FileChooserResult packFile = null;
|
|
||||||
if (GL11.EaglerAdapterImpl2.fileChooserHasResult()) {
|
|
||||||
packFile = GL11.EaglerAdapterImpl2.getFileChooserResult();
|
|
||||||
}
|
|
||||||
if(packFile == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
File.writeFile("texturepacks/" + packFile.fileName, packFile.fileData);
|
|
||||||
Minecraft.getMinecraft().displayGuiScreen(new GuiTexturePacks(field_6461_a));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_6452_a(int var1, int var2, int var3, int var4) {
|
public void func_6452_a(int var1, int var2, int var3, int var4) {
|
||||||
|
@ -216,3 +220,4 @@ public class GuiTexturePacks extends GuiScreen {
|
||||||
var5.draw();
|
var5.draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -8,6 +9,7 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.PeytonPlayz585.awt.image.BufferedImage;
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
|
import net.PeytonPlayz585.awt.image.ImageIO;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.opengl.GL11;
|
||||||
|
|
||||||
public class RenderEngine {
|
public class RenderEngine {
|
||||||
|
@ -17,7 +19,7 @@ public class RenderEngine {
|
||||||
textureMap = new HashMap<String, Integer>();
|
textureMap = new HashMap<String, Integer>();
|
||||||
textureNameToImageMap = new HashMap<Integer, BufferedImage>();
|
textureNameToImageMap = new HashMap<Integer, BufferedImage>();
|
||||||
singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
|
singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
|
||||||
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
|
imageDataB1 = GLAllocation.createDirectByteBuffer(1048576);
|
||||||
textureList = new ArrayList<TextureFX>();
|
textureList = new ArrayList<TextureFX>();
|
||||||
clampTexture = false;
|
clampTexture = false;
|
||||||
blurTexture = false;
|
blurTexture = false;
|
||||||
|
@ -140,8 +142,10 @@ public class RenderEngine {
|
||||||
texturefx.func_783_a();
|
texturefx.func_783_a();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage readTextureImage(byte[] inputstream) throws IOException {
|
private BufferedImage readTextureImage(InputStream var1) throws IOException {
|
||||||
return GL11.EaglerAdapterImpl2.loadPNG(inputstream);
|
BufferedImage var2 = ImageIO.read(var1);
|
||||||
|
var1.close();
|
||||||
|
return var2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindTexture(int i) {
|
public void bindTexture(int i) {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.awt.image.ImageIO;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public abstract class TexturePackBase {
|
public abstract class TexturePackBase {
|
||||||
|
@ -26,7 +27,7 @@ public abstract class TexturePackBase {
|
||||||
public void func_6483_c(Minecraft var1) {
|
public void func_6483_c(Minecraft var1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] func_6481_a(String s) {
|
public InputStream func_6481_a(String var1) {
|
||||||
return GL11.EaglerAdapterImpl2.loadResourceBytes(s);
|
return ImageIO.getResourceAsStream(var1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +1,27 @@
|
||||||
package net.minecraft.src;
|
package net.minecraft.src;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
|
||||||
|
|
||||||
import net.PeytonPlayz585.fileutils.File;
|
import net.PeytonPlayz585.awt.image.BufferedImage;
|
||||||
|
import net.PeytonPlayz585.awt.image.ImageIO;
|
||||||
import net.PeytonPlayz585.fileutils.FileEntry;
|
import net.PeytonPlayz585.fileutils.FileEntry;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
import net.PeytonPlayz585.util.zip.ZipFile;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
public class TexturePackCustom extends TexturePackBase {
|
public class TexturePackCustom extends TexturePackBase {
|
||||||
|
private ZipFile field_6496_e;
|
||||||
|
private int texturePackName = -1;
|
||||||
|
private BufferedImage field_6494_g;
|
||||||
|
private FileEntry field_6493_h;
|
||||||
|
|
||||||
public TexturePackCustom(String s) {
|
public TexturePackCustom(FileEntry var1) {
|
||||||
this.texturePackFileName = s;
|
this.texturePackFileName = var1.getName();
|
||||||
|
this.field_6493_h = var1;
|
||||||
try {
|
|
||||||
deleteExistingTexturePackFiles();
|
|
||||||
byte[] data = File.readFile("texturepacks/" + s);
|
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
|
||||||
ZipInputStream zis = new ZipInputStream(bais);
|
|
||||||
|
|
||||||
ZipEntry entry;
|
|
||||||
while ((entry = zis.getNextEntry()) != null) {
|
|
||||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
|
||||||
byte[] buffer = new byte[(int)entry.getSize()];
|
|
||||||
int len;
|
|
||||||
while ((len = zis.read(buffer)) > 0) {
|
|
||||||
baos.write(buffer, 0, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] fileData = baos.toByteArray();
|
|
||||||
System.out.println(entry.getName());
|
|
||||||
String name = entry.getName();
|
|
||||||
if(name.startsWith("/")) {
|
|
||||||
name = name.substring(1, name.length() - 1);
|
|
||||||
}
|
|
||||||
File.writeFile("texturepackdata/" + name.replace(" ", ""), fileData);
|
|
||||||
}
|
|
||||||
|
|
||||||
zis.closeEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
zis.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String func_6492_b(String var1) {
|
private String func_6492_b(String var1) {
|
||||||
|
@ -62,76 +33,94 @@ public class TexturePackCustom extends TexturePackBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_6485_a(Minecraft var1) throws IOException {
|
public void func_6485_a(Minecraft var1) throws IOException {
|
||||||
|
ZipFile var2 = null;
|
||||||
|
InputStream var3 = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] data = File.readFile("texturepackdata/pack.txt");
|
var2 = new ZipFile(this.field_6493_h);
|
||||||
InputStream var3 = new ByteArrayInputStream(data);
|
|
||||||
BufferedReader var4 = new BufferedReader(new InputStreamReader(var3));
|
try {
|
||||||
this.firstDescriptionLine = this.func_6492_b(var4.readLine());
|
var3 = var2.getInputStream(var2.getEntry("pack.txt"));
|
||||||
this.secondDescriptionLine = this.func_6492_b(var4.readLine());
|
BufferedReader var4 = new BufferedReader(new InputStreamReader(var3));
|
||||||
var4.close();
|
this.firstDescriptionLine = this.func_6492_b(var4.readLine());
|
||||||
var3.close();
|
this.secondDescriptionLine = this.func_6492_b(var4.readLine());
|
||||||
} catch(IOException e) {
|
var4.close();
|
||||||
e.printStackTrace();
|
var3.close();
|
||||||
|
} catch (Exception var20) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var3 = var2.getInputStream(var2.getEntry("pack.png"));
|
||||||
|
this.field_6494_g = ImageIO.read(var3);
|
||||||
|
var3.close();
|
||||||
|
} catch (Exception var19) {
|
||||||
|
}
|
||||||
|
|
||||||
|
var2.close();
|
||||||
|
} catch (Exception var21) {
|
||||||
|
var21.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
var3.close();
|
||||||
|
} catch (Exception var18) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var2.close();
|
||||||
|
} catch (Exception var17) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int packPNG = -1;
|
public void func_6484_b(Minecraft var1) {
|
||||||
|
if(this.field_6494_g != null) {
|
||||||
|
var1.renderEngine.deleteTexture(this.texturePackName);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.closeTexturePackFile();
|
||||||
|
}
|
||||||
|
|
||||||
public void func_6483_c(Minecraft var1) {
|
public void func_6483_c(Minecraft var1) {
|
||||||
byte[] data = File.readFile("texturepackdata/pack.png");
|
if(this.field_6494_g != null && this.texturePackName < 0) {
|
||||||
if(data != null) {
|
this.texturePackName = var1.renderEngine.allocateAndSetupTexture(this.field_6494_g);
|
||||||
if(packPNG == -1) {
|
}
|
||||||
packPNG = getTexture("pack.png");
|
|
||||||
}
|
if(this.field_6494_g != null) {
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, packPNG);
|
var1.renderEngine.bindTexture(this.texturePackName);
|
||||||
} else {
|
} else {
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var1.renderEngine.getTexture("/gui/unknown_pack.png"));
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, var1.renderEngine.getTexture("/gui/unknown_pack.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getTexture(String s) {
|
public void func_6482_a() {
|
||||||
try {
|
try {
|
||||||
byte[] b = File.readFile("texturepackdata/" + s);
|
this.field_6496_e = new ZipFile(this.field_6493_h);
|
||||||
Minecraft.getMinecraft().renderEngine.singleIntBuffer.clear();
|
} catch (Exception var2) {
|
||||||
GLAllocation.generateTextureNames(Minecraft.getMinecraft().renderEngine.singleIntBuffer);
|
|
||||||
int i = Minecraft.getMinecraft().renderEngine.singleIntBuffer.get(0);
|
|
||||||
Minecraft.getMinecraft().renderEngine.setupTexture(Minecraft.getMinecraft().renderEngine.readTextureImage(b), i);
|
|
||||||
return i;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException("!!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] func_6481_a(String var1) {
|
public void closeTexturePackFile() {
|
||||||
String path = var1;
|
try {
|
||||||
if(path.startsWith("/")) {
|
this.field_6496_e.close();
|
||||||
path = path.substring(1);
|
} catch (Exception var2) {
|
||||||
}
|
|
||||||
System.out.println(path);
|
|
||||||
byte[] data = File.readFile("texturepackdata/" + path.replace(" ", ""));
|
|
||||||
|
|
||||||
if(data == null) {
|
|
||||||
return GL11.EaglerAdapterImpl2.loadResourceBytes(var1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Texture Found in texture pack: " + path);
|
this.field_6496_e = null;
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteExistingTexturePackFiles() {
|
public InputStream func_6481_a(String var1) {
|
||||||
String path = "texturepackdata/";
|
try {
|
||||||
Collection<FileEntry> lst = File.listFiles(path, true, true);
|
ZipEntry var2 = this.field_6496_e.getEntry(var1.substring(1));
|
||||||
for(FileEntry t : lst) {
|
if(var2 != null) {
|
||||||
if(!t.isDirectory) {
|
return this.field_6496_e.getInputStream(var2);
|
||||||
File.deleteFile(t.path);
|
}
|
||||||
}
|
} catch (Exception var3) {
|
||||||
}
|
}
|
||||||
for(FileEntry t : lst) {
|
|
||||||
if(t.isDirectory) {
|
return ImageIO.getResourceAsStream(var1);
|
||||||
File.deleteFile(t.path);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
File.deleteFile(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,7 +9,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import net.PeytonPlayz585.fileutils.File;
|
import net.PeytonPlayz585.fileutils.File;
|
||||||
import net.PeytonPlayz585.fileutils.FileEntry;
|
import net.PeytonPlayz585.fileutils.FileEntry;
|
||||||
import net.PeytonPlayz585.opengl.GL11;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class TexturePackList {
|
public class TexturePackList {
|
||||||
|
@ -19,10 +17,12 @@ public class TexturePackList {
|
||||||
public TexturePackBase selectedTexturePack;
|
public TexturePackBase selectedTexturePack;
|
||||||
private Map field_6538_d = new HashMap();
|
private Map field_6538_d = new HashMap();
|
||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
|
private String texturePackDir = "texturepacksNEW";
|
||||||
private String field_6535_g;
|
private String field_6535_g;
|
||||||
|
|
||||||
public TexturePackList(Minecraft var1) {
|
public TexturePackList(Minecraft var1) {
|
||||||
this.mc = var1;
|
this.mc = var1;
|
||||||
|
|
||||||
this.field_6535_g = var1.gameSettings.skin;
|
this.field_6535_g = var1.gameSettings.skin;
|
||||||
this.func_6532_a();
|
this.func_6532_a();
|
||||||
this.selectedTexturePack.func_6482_a();
|
this.selectedTexturePack.func_6482_a();
|
||||||
|
@ -46,33 +46,36 @@ public class TexturePackList {
|
||||||
ArrayList var1 = new ArrayList();
|
ArrayList var1 = new ArrayList();
|
||||||
this.selectedTexturePack = null;
|
this.selectedTexturePack = null;
|
||||||
var1.add(this.defaultTexturePack);
|
var1.add(this.defaultTexturePack);
|
||||||
|
//if(this.texturePackDir.exists() && this.texturePackDir.isDirectory()) {
|
||||||
|
FileEntry[] var2 = File.listFiles(this.texturePackDir);
|
||||||
|
FileEntry[] var3 = var2;
|
||||||
|
int var4 = var2.length;
|
||||||
|
|
||||||
Collection<FileEntry> var2 = File.listFiles("texturepacks/", false, false);
|
for(int var5 = 0; var5 < var4; ++var5) {
|
||||||
Collection<FileEntry> var3 = var2;
|
FileEntry var6 = var3[var5];
|
||||||
int var4 = var2.size();
|
if(var6.isFile() && var6.getName().toLowerCase().endsWith(".zip")) {
|
||||||
|
String var7 = var6.getName() + ":" + var6.length() + ":" + var6.lastModified();
|
||||||
|
|
||||||
for(int var5 = 0; var5 < var4; ++var5) {
|
try {
|
||||||
FileEntry var6 = (FileEntry) var2.toArray()[var5];
|
if(!this.field_6538_d.containsKey(var7)) {
|
||||||
String var7 = var6.getName();
|
TexturePackCustom var8 = new TexturePackCustom(var6);
|
||||||
|
var8.field_6488_d = var7;
|
||||||
|
this.field_6538_d.put(var7, var8);
|
||||||
|
var8.func_6485_a(this.mc);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
TexturePackBase var12 = (TexturePackBase)this.field_6538_d.get(var7);
|
||||||
if(!this.field_6538_d.containsKey(var7)) {
|
if(var12.texturePackFileName.equals(this.field_6535_g)) {
|
||||||
TexturePackCustom var8 = new TexturePackCustom(var6.getName());
|
this.selectedTexturePack = var12;
|
||||||
var8.field_6488_d = var7;
|
}
|
||||||
this.field_6538_d.put(var7, var8);
|
|
||||||
var8.func_6485_a(this.mc);
|
var1.add(var12);
|
||||||
|
} catch (IOException var9) {
|
||||||
|
var9.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TexturePackBase var12 = (TexturePackBase)this.field_6538_d.get(var7);
|
|
||||||
if(var12.texturePackFileName.equals(this.field_6535_g)) {
|
|
||||||
this.selectedTexturePack = var12;
|
|
||||||
}
|
|
||||||
|
|
||||||
var1.add(var12);
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
if(this.selectedTexturePack == null) {
|
if(this.selectedTexturePack == null) {
|
||||||
this.selectedTexturePack = this.defaultTexturePack;
|
this.selectedTexturePack = this.defaultTexturePack;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user