mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-09-27 03:00:52 +00:00
update
This commit is contained in:
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MinecraftUSkinEditor
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace MinecraftUSkinEditor
|
||||
public byte[] data;
|
||||
public List<object[]> entries = new List<object[]>();
|
||||
}
|
||||
|
||||
public bool IsLittleEndian;
|
||||
public int pckType = 0;
|
||||
|
||||
public Dictionary<int, string> types = new Dictionary<int, string>();
|
||||
@@ -33,7 +33,16 @@ namespace MinecraftUSkinEditor
|
||||
|
||||
public PCK(string filename)
|
||||
{
|
||||
Read(File.ReadAllBytes(filename));
|
||||
try
|
||||
{
|
||||
Read(File.ReadAllBytes(filename));
|
||||
IsLittleEndian = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
ReadVita(File.ReadAllBytes(filename));
|
||||
IsLittleEndian = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] endianReverseUnicode(byte[] str)
|
||||
@@ -49,41 +58,39 @@ namespace MinecraftUSkinEditor
|
||||
|
||||
public static string readMineString(FileData f)
|
||||
{
|
||||
int length = f.readInt() * 2;
|
||||
Console.WriteLine(length.ToString());
|
||||
return Encoding.Unicode.GetString(endianReverseUnicode(f.readBytes(length)));
|
||||
|
||||
}
|
||||
int length = f.readInt() * 2;
|
||||
Console.WriteLine(length.ToString());
|
||||
return Encoding.Unicode.GetString(endianReverseUnicode(f.readBytes(length)));
|
||||
|
||||
}
|
||||
public static string readMineStringVita(FileData f)
|
||||
{
|
||||
int length = f.readInt() / 20000000;
|
||||
Console.WriteLine(length.ToString() + " - caught");
|
||||
return Encoding.Unicode.GetString(endianReverseUnicode(f.readBytes(length)));
|
||||
|
||||
}
|
||||
int length = f.readIntVita() * 2;
|
||||
Console.WriteLine(length.ToString());
|
||||
return Encoding.Unicode.GetString((f.readBytes(length)));
|
||||
|
||||
public static string readMineStringVita2(FileData f)
|
||||
{
|
||||
int length = (f.readInt() / 20000000) * 2;
|
||||
Console.WriteLine(length.ToString() + " - caught");
|
||||
return Encoding.Unicode.GetString(endianReverseUnicode(f.readBytes(length)));
|
||||
|
||||
}
|
||||
|
||||
public void Read(byte[] data)
|
||||
{
|
||||
pckType = 0;
|
||||
types = new Dictionary<int, string>();
|
||||
typeCodes = new Dictionary<string, int>();
|
||||
mineFiles = new List<MineFile>();
|
||||
|
||||
FileData fileData = new FileData(data);
|
||||
fileData.Endian = Endianness.Big;
|
||||
fileData.readInt();
|
||||
int entryTypeCount = fileData.readInt();
|
||||
//int a = 0;
|
||||
for (int i = 0; i < entryTypeCount; i++)
|
||||
{
|
||||
int unk = fileData.readInt();
|
||||
string text = "";
|
||||
try
|
||||
{
|
||||
text = readMineString(fileData);
|
||||
text = readMineString(fileData);
|
||||
//File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\exp\\PCKDump" + a + ".bin", text);
|
||||
//a++;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -148,6 +155,91 @@ namespace MinecraftUSkinEditor
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadVita(byte[] data)
|
||||
{
|
||||
pckType = 0;
|
||||
types = new Dictionary<int, string>();
|
||||
typeCodes = new Dictionary<string, int>();
|
||||
mineFiles = new List<MineFile>();
|
||||
|
||||
FileData fileData = new FileData(data);
|
||||
fileData.Endian = Endianness.Big;
|
||||
fileData.readIntVita();
|
||||
int entryTypeCount = fileData.readIntVita();
|
||||
//int a = 0;
|
||||
for (int i = 0; i < entryTypeCount; i++)
|
||||
{
|
||||
int unk = fileData.readIntVita();
|
||||
string text = "";
|
||||
try
|
||||
{
|
||||
text = readMineStringVita(fileData);
|
||||
//File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\exp\\PCKDump" + a + ".bin", text);
|
||||
//a++;
|
||||
}
|
||||
catch
|
||||
{
|
||||
text = "Hello!";
|
||||
}
|
||||
types.Add(unk, text);
|
||||
typeCodes.Add(text, unk);
|
||||
fileData.skip(4);
|
||||
}
|
||||
|
||||
int itemCount = fileData.readIntVita();
|
||||
|
||||
Console.WriteLine(itemCount);
|
||||
// no metadata
|
||||
if (entryTypeCount == 0)
|
||||
{
|
||||
Console.WriteLine("PckType0");
|
||||
}
|
||||
// type 1 or 2
|
||||
else if (itemCount < 3)
|
||||
{
|
||||
pckType = itemCount;
|
||||
if (pckType == 1)
|
||||
{
|
||||
Console.WriteLine("PckType1");
|
||||
itemCount = fileData.readIntVita();
|
||||
}
|
||||
if (pckType == 2)
|
||||
Console.WriteLine("PckType2");
|
||||
}
|
||||
// regular pck
|
||||
else
|
||||
{
|
||||
Console.WriteLine("NormalPCK");
|
||||
}
|
||||
|
||||
|
||||
for (int j = 0; j < itemCount; j++)
|
||||
{
|
||||
MineFile mineFile = new MineFile();
|
||||
mineFile.filesize = fileData.readIntVita();
|
||||
mineFile.type = fileData.readIntVita();
|
||||
int length = fileData.readIntVita() * 2;
|
||||
mineFile.name = Encoding.Unicode.GetString((fileData.readBytes(length)));
|
||||
fileData.skip(4);
|
||||
mineFiles.Add(mineFile);
|
||||
}
|
||||
|
||||
foreach (MineFile mineFile2 in mineFiles)
|
||||
{
|
||||
int num4 = fileData.readIntVita();
|
||||
for (int k = 0; k < num4; k++)
|
||||
{
|
||||
object[] array = new object[2];
|
||||
int key = fileData.readIntVita();
|
||||
array[0] = types[key];
|
||||
array[1] = readMineStringVita(fileData);
|
||||
fileData.skip(4);
|
||||
mineFile2.entries.Add(array);
|
||||
}
|
||||
mineFile2.data = fileData.readBytes(mineFile2.filesize);
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeMinecraftString(FileOutput f, string str)
|
||||
{
|
||||
byte[] bytes = Encoding.Unicode.GetBytes(str);
|
||||
@@ -156,6 +248,15 @@ namespace MinecraftUSkinEditor
|
||||
f.writeInt(0);
|
||||
}
|
||||
|
||||
private static void writeMinecraftStringVita(FileOutput f, string str)
|
||||
{
|
||||
Console.WriteLine("WriteVita -- " + str);
|
||||
byte[] bytes = Encoding.Unicode.GetBytes(str);
|
||||
f.writeIntVita(bytes.Length / 2);
|
||||
f.writeBytes((bytes));
|
||||
f.writeIntVita(0);
|
||||
}
|
||||
|
||||
public byte[] Rebuild()
|
||||
{
|
||||
FileOutput fileOutput = new FileOutput();
|
||||
@@ -196,5 +297,46 @@ namespace MinecraftUSkinEditor
|
||||
}
|
||||
return fileOutput.getBytes();
|
||||
}
|
||||
|
||||
public byte[] RebuildVita()
|
||||
{
|
||||
FileOutput fileOutput = new FileOutput();
|
||||
fileOutput.Endian = Endianness.Big;
|
||||
fileOutput.writeIntVita(3);
|
||||
fileOutput.writeIntVita(this.types.Count);
|
||||
foreach (int num in this.types.Keys)
|
||||
{
|
||||
fileOutput.writeIntVita(num);
|
||||
PCK.writeMinecraftStringVita(fileOutput, this.types[num]);
|
||||
}
|
||||
fileOutput.writeIntVita(this.mineFiles.Count);
|
||||
foreach (PCK.MineFile mineFile in this.mineFiles)
|
||||
{
|
||||
fileOutput.writeIntVita(mineFile.data.Length);
|
||||
fileOutput.writeIntVita(mineFile.type);
|
||||
PCK.writeMinecraftStringVita(fileOutput, mineFile.name);
|
||||
}
|
||||
foreach (PCK.MineFile mineFile2 in this.mineFiles)
|
||||
{
|
||||
string str = "";
|
||||
try
|
||||
{
|
||||
fileOutput.writeIntVita(mineFile2.entries.Count);
|
||||
foreach (object[] array in mineFile2.entries)
|
||||
{
|
||||
str = array[0].ToString();
|
||||
fileOutput.writeIntVita(this.typeCodes[(string)array[0]]);
|
||||
PCK.writeMinecraftStringVita(fileOutput, (string)array[1]);
|
||||
}
|
||||
fileOutput.writeBytes(mineFile2.data);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(str + " is not in the main metadatabase");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return fileOutput.getBytes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user