Fix texture packs
This commit is contained in:
parent
f53ccbf796
commit
87a79edf72
File diff suppressed because it is too large
Load Diff
|
@ -5,6 +5,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -164,7 +165,44 @@ public class RenderEngine {
|
|||
}
|
||||
|
||||
public void refreshTextures() {
|
||||
textureMap.clear();
|
||||
System.out.println("Refreshing Textures!");
|
||||
TexturePackBase var1 = this.field_6527_k.selectedTexturePack;
|
||||
Iterator var2 = this.textureNameToImageMap.keySet().iterator();
|
||||
|
||||
EaglerImage var4;
|
||||
while(var2.hasNext()) {
|
||||
int var3 = ((Integer)var2.next()).intValue();
|
||||
var4 = (EaglerImage)this.textureNameToImageMap.get(Integer.valueOf(var3));
|
||||
this.setupTexture(var4, var3);
|
||||
}
|
||||
|
||||
var2 = this.textureMap.keySet().iterator();
|
||||
|
||||
while(var2.hasNext()) {
|
||||
String var8 = (String)var2.next();
|
||||
|
||||
try {
|
||||
if(var8.startsWith("%%")) {
|
||||
this.clampTexture = true;
|
||||
String[] s1 = var8.split("%%");
|
||||
var4 = this.readTextureImage(var1.func_6481_a(s1[1]));
|
||||
} else if(var8.startsWith("%blur%")) {
|
||||
this.blurTexture = true;
|
||||
String[] s1 = var8.split("%blur%");
|
||||
var4 = this.readTextureImage(var1.func_6481_a(s1[1]));
|
||||
} else {
|
||||
var4 = this.readTextureImage(var1.func_6481_a(var8));
|
||||
}
|
||||
|
||||
int var5 = ((Integer)this.textureMap.get(var8)).intValue();
|
||||
this.setupTexture(var4, var5);
|
||||
this.blurTexture = false;
|
||||
this.clampTexture = false;
|
||||
} catch (IOException var6) {
|
||||
var6.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static HashMap<String, Integer> textureMap;
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
|
@ -15,12 +15,11 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
public class TexturePackCustom extends TexturePackBase {
|
||||
|
||||
private HashMap<String, byte[]> filePool = new HashMap<String, byte[]>();
|
||||
|
||||
public TexturePackCustom(String s) {
|
||||
this.texturePackFileName = s;
|
||||
|
||||
try {
|
||||
deleteExistingTexturePackFiles();
|
||||
byte[] data = GL11.readFile("texturepacks/" + s);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||
ZipInputStream zis = new ZipInputStream(bais);
|
||||
|
@ -36,7 +35,11 @@ public class TexturePackCustom extends TexturePackBase {
|
|||
|
||||
byte[] fileData = baos.toByteArray();
|
||||
System.out.println(entry.getName());
|
||||
filePool.put(entry.getName(), fileData);
|
||||
String name = entry.getName();
|
||||
if(name.startsWith("/")) {
|
||||
name = name.substring(1, name.length() - 1);
|
||||
}
|
||||
GL11.writeFile("texturepackdata/" + name.replace(" ", ""), fileData);
|
||||
}
|
||||
|
||||
zis.closeEntry();
|
||||
|
@ -58,7 +61,8 @@ public class TexturePackCustom extends TexturePackBase {
|
|||
|
||||
public void func_6485_a(Minecraft var1) throws IOException {
|
||||
try {
|
||||
InputStream var3 = new ByteArrayInputStream(filePool.get("pack.txt"));
|
||||
byte[] data = GL11.readFile("texturepackdata/pack.txt");
|
||||
InputStream var3 = new ByteArrayInputStream(data);
|
||||
BufferedReader var4 = new BufferedReader(new InputStreamReader(var3));
|
||||
this.firstDescriptionLine = this.func_6492_b(var4.readLine());
|
||||
this.secondDescriptionLine = this.func_6492_b(var4.readLine());
|
||||
|
@ -72,7 +76,8 @@ public class TexturePackCustom extends TexturePackBase {
|
|||
int packPNG = -1;
|
||||
|
||||
public void func_6483_c(Minecraft var1) {
|
||||
if(filePool.containsKey("pack.png")) {
|
||||
byte[] data = GL11.readFile("texturepackdata/pack.png");
|
||||
if(data != null) {
|
||||
if(packPNG == -1) {
|
||||
packPNG = getTexture("pack.png");
|
||||
}
|
||||
|
@ -85,7 +90,7 @@ public class TexturePackCustom extends TexturePackBase {
|
|||
|
||||
private int getTexture(String s) {
|
||||
try {
|
||||
byte[] b = filePool.get(s);
|
||||
byte[] b = GL11.readFile("texturepackdata/" + s);
|
||||
Minecraft.getMinecraft().renderEngine.singleIntBuffer.clear();
|
||||
GLAllocation.generateTextureNames(Minecraft.getMinecraft().renderEngine.singleIntBuffer);
|
||||
int i = Minecraft.getMinecraft().renderEngine.singleIntBuffer.get(0);
|
||||
|
@ -97,10 +102,34 @@ public class TexturePackCustom extends TexturePackBase {
|
|||
}
|
||||
|
||||
public byte[] func_6481_a(String var1) {
|
||||
if(filePool.containsKey(var1)) {
|
||||
return filePool.get(var1);
|
||||
String path = var1;
|
||||
if(path.startsWith("/")) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
System.out.println(path);
|
||||
byte[] data = GL11.readFile("texturepackdata/" + path.replace(" ", ""));
|
||||
|
||||
if(data == null) {
|
||||
return GL11.loadResourceBytes(var1);
|
||||
}
|
||||
|
||||
return GL11.loadResourceBytes(var1);
|
||||
System.out.println("Texture Found in texture pack: " + path);
|
||||
return data;
|
||||
}
|
||||
|
||||
private void deleteExistingTexturePackFiles() {
|
||||
String path = "texturepackdata/";
|
||||
Collection<GL11.FileEntry> lst = GL11.listFiles(path, true, true);
|
||||
for(GL11.FileEntry t : lst) {
|
||||
if(!t.isDirectory) {
|
||||
GL11.deleteFile(t.path);
|
||||
}
|
||||
}
|
||||
for(GL11.FileEntry t : lst) {
|
||||
if(t.isDirectory) {
|
||||
GL11.deleteFile(t.path);
|
||||
}
|
||||
}
|
||||
GL11.deleteFile(path);
|
||||
}
|
||||
}
|
||||
|
|
2949
web/js/app.js
2949
web/js/app.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user