mirror of
https://github.com/catfoolyou/Beta-1.4_01.git
synced 2025-06-02 03:10:57 -05:00
Begin migrating to other saveformat
This commit is contained in:
parent
e4b43a0e6d
commit
42fd4b5534
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Ant-Version: Apache Ant 1.8.2
|
||||
Created-By: 1.6.0_26-b03-384-10M3425 (Apple Inc.)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class ChunkFilePattern implements FilenameFilter {
|
||||
|
||||
private ChunkFilePattern() {
|
||||
}
|
||||
|
||||
public boolean accept(File file, String s) {
|
||||
Matcher matcher = field_22189_a.matcher(s);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
ChunkFilePattern(Empty2 empty2) {
|
||||
this();
|
||||
}
|
||||
|
||||
public static final Pattern field_22189_a = Pattern.compile("c\\.(-?[0-9a-z]+)\\.(-?[0-9a-z]+)\\.dat");
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class ChunkFolderPattern implements FileFilter {
|
||||
|
||||
private ChunkFolderPattern() {
|
||||
}
|
||||
|
||||
public boolean accept(File file) {
|
||||
if (file.isDirectory()) {
|
||||
Matcher matcher = field_22392_a.matcher(file.getName());
|
||||
return matcher.matches();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ChunkFolderPattern(Empty2 empty2) {
|
||||
this();
|
||||
}
|
||||
|
||||
public static final Pattern field_22392_a = Pattern.compile("[0-9a-z]|([0-9a-z][0-9a-z])");
|
||||
|
||||
}
|
126
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/ChunkLoader.java
Normal file
126
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/ChunkLoader.java
Normal file
@ -0,0 +1,126 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.lax1dude.eaglercraft.beta.EaglercraftChunkLoader;
|
||||
import net.minecraft.src.Chunk;
|
||||
import net.minecraft.src.CompressedStreamTools;
|
||||
import net.minecraft.src.IChunkLoader;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
|
||||
public class ChunkLoader implements IChunkLoader {
|
||||
|
||||
public ChunkLoader(File file, boolean flag) {
|
||||
saveDir = file;
|
||||
createIfNecessary = flag;
|
||||
}
|
||||
|
||||
private File chunkFileForXZ(int i, int j) {
|
||||
String s = (new StringBuilder()).append("c.").append(Integer.toString(i, 36)).append(".")
|
||||
.append(Integer.toString(j, 36)).append(".dat").toString();
|
||||
String s1 = Integer.toString(i & 0x3f, 36);
|
||||
String s2 = Integer.toString(j & 0x3f, 36);
|
||||
File file = new File(saveDir, s1);
|
||||
if (!file.exists()) {
|
||||
if (createIfNecessary) {
|
||||
file.mkdir();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
file = new File(file, s2);
|
||||
if (!file.exists()) {
|
||||
if (createIfNecessary) {
|
||||
file.mkdir();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
file = new File(file, s);
|
||||
if (!file.exists() && !createIfNecessary) {
|
||||
return null;
|
||||
} else {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
public Chunk loadChunk(World world, int i, int j) {
|
||||
File file = chunkFileForXZ(i, j);
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
FileInputStream fileinputstream = new FileInputStream(file);
|
||||
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream);
|
||||
if (!nbttagcompound.hasKey("Level")) {
|
||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
||||
.append(" is missing level data, skipping").toString());
|
||||
return null;
|
||||
}
|
||||
if (!nbttagcompound.getCompoundTag("Level").hasKey("Blocks")) {
|
||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
||||
.append(" is missing block data, skipping").toString());
|
||||
return null;
|
||||
}
|
||||
Chunk chunk = EaglercraftChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
||||
if (!chunk.isAtLocation(i, j)) {
|
||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
||||
.append(" is in the wrong location; relocating. (Expected ").append(i).append(", ")
|
||||
.append(j).append(", got ").append(chunk.xPosition).append(", ").append(chunk.zPosition)
|
||||
.append(")").toString());
|
||||
nbttagcompound.setInteger("xPos", i);
|
||||
nbttagcompound.setInteger("zPos", j);
|
||||
chunk = EaglercraftChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
||||
}
|
||||
return chunk;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveChunk(World world, Chunk chunk) {
|
||||
world.checkSessionLock();
|
||||
File file = chunkFileForXZ(chunk.xPosition, chunk.zPosition);
|
||||
if (file.exists()) {
|
||||
WorldInfo worldinfo = world.func_22144_v();
|
||||
worldinfo.setSizeOnDisk(worldinfo.getSizeOnDisk() - file.length());
|
||||
}
|
||||
try {
|
||||
File file1 = new File(saveDir, "tmp_chunk.dat");
|
||||
FileOutputStream fileoutputstream = new FileOutputStream(file1);
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound.setTag("Level", nbttagcompound1);
|
||||
EaglercraftChunkLoader.storeChunkInCompound(chunk, world, nbttagcompound1);
|
||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, fileoutputstream);
|
||||
fileoutputstream.close();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
file1.renameTo(file);
|
||||
WorldInfo worldinfo1 = world.func_22144_v();
|
||||
worldinfo1.setSizeOnDisk(worldinfo1.getSizeOnDisk() + file.length());
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void func_814_a() {
|
||||
}
|
||||
|
||||
public void saveExtraData() {
|
||||
}
|
||||
|
||||
public void saveExtraChunkData(World world, Chunk chunk) {
|
||||
}
|
||||
|
||||
private File saveDir;
|
||||
private boolean createIfNecessary;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
class Empty2 {
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
class FileMatcher implements Comparable {
|
||||
|
||||
public FileMatcher(File file) {
|
||||
field_22326_a = file;
|
||||
Matcher matcher = ChunkFilePattern.field_22189_a.matcher(file.getName());
|
||||
if (matcher.matches()) {
|
||||
field_22325_b = Integer.parseInt(matcher.group(1), 36);
|
||||
field_22327_c = Integer.parseInt(matcher.group(2), 36);
|
||||
} else {
|
||||
field_22325_b = 0;
|
||||
field_22327_c = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int func_22322_a(FileMatcher filematcher) {
|
||||
int i = field_22325_b >> 5;
|
||||
int j = filematcher.field_22325_b >> 5;
|
||||
if (i == j) {
|
||||
int k = field_22327_c >> 5;
|
||||
int l = filematcher.field_22327_c >> 5;
|
||||
return k - l;
|
||||
} else {
|
||||
return i - j;
|
||||
}
|
||||
}
|
||||
|
||||
public File func_22324_a() {
|
||||
return field_22326_a;
|
||||
}
|
||||
|
||||
public int func_22323_b() {
|
||||
return field_22325_b;
|
||||
}
|
||||
|
||||
public int func_22321_c() {
|
||||
return field_22327_c;
|
||||
}
|
||||
|
||||
public int compareTo(Object obj) {
|
||||
return func_22322_a((FileMatcher) obj);
|
||||
}
|
||||
|
||||
private final File field_22326_a;
|
||||
private final int field_22325_b;
|
||||
private final int field_22327_c;
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import net.lax1dude.eaglercraft.beta.EaglercraftChunkLoader;
|
||||
import net.minecraft.src.Chunk;
|
||||
import net.minecraft.src.CompressedStreamTools;
|
||||
import net.minecraft.src.IChunkLoader;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
|
||||
public class McRegionChunkLoader implements IChunkLoader {
|
||||
|
||||
public McRegionChunkLoader(File file) {
|
||||
field_22184_a = file;
|
||||
}
|
||||
|
||||
public Chunk loadChunk(World world, int i, int j) {
|
||||
java.io.DataInputStream datainputstream = RegionFileCache.func_22194_c(field_22184_a, i, j);
|
||||
NBTTagCompound nbttagcompound;
|
||||
if (datainputstream != null) {
|
||||
try {
|
||||
nbttagcompound = CompressedStreamTools.func_1141_a(datainputstream);
|
||||
} catch (IOException e) {
|
||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
||||
.append(" is corrupt:").append(e.toString()).toString());
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (!nbttagcompound.hasKey("Level")) {
|
||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
||||
.append(" is missing level data, skipping").toString());
|
||||
return null;
|
||||
}
|
||||
if (!nbttagcompound.getCompoundTag("Level").hasKey("Blocks")) {
|
||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
||||
.append(" is missing block data, skipping").toString());
|
||||
return null;
|
||||
}
|
||||
Chunk chunk = EaglercraftChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
||||
if (!chunk.isAtLocation(i, j)) {
|
||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
||||
.append(" is in the wrong location; relocating. (Expected ").append(i).append(", ").append(j)
|
||||
.append(", got ").append(chunk.xPosition).append(", ").append(chunk.zPosition).append(")")
|
||||
.toString());
|
||||
nbttagcompound.setInteger("xPos", i);
|
||||
nbttagcompound.setInteger("zPos", j);
|
||||
chunk = EaglercraftChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public void saveChunk(World world, Chunk chunk) {
|
||||
world.checkSessionLock();
|
||||
try {
|
||||
DataOutputStream dataoutputstream = RegionFileCache.func_22190_d(field_22184_a, chunk.xPosition,
|
||||
chunk.zPosition);
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound.setTag("Level", nbttagcompound1);
|
||||
EaglercraftChunkLoader.storeChunkInCompound(chunk, world, nbttagcompound1);
|
||||
CompressedStreamTools.func_1139_a(nbttagcompound, dataoutputstream);
|
||||
dataoutputstream.close();
|
||||
WorldInfo worldinfo = world.func_22144_v();
|
||||
worldinfo.func_22297_b(worldinfo.func_22306_g()
|
||||
+ (long) RegionFileCache.func_22191_b(field_22184_a, chunk.xPosition, chunk.zPosition));
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveExtraChunkData(World world, Chunk chunk) {
|
||||
}
|
||||
|
||||
public void func_814_a() {
|
||||
}
|
||||
|
||||
public void saveExtraData() {
|
||||
}
|
||||
|
||||
private final File field_22184_a;
|
||||
}
|
269
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/RegionFile.java
Normal file
269
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/RegionFile.java
Normal file
@ -0,0 +1,269 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.*;
|
||||
|
||||
public class RegionFile {
|
||||
|
||||
public RegionFile(File file) {
|
||||
field_22214_h = 0L;
|
||||
field_22212_b = file;
|
||||
func_22204_b((new StringBuilder()).append("REGION LOAD ").append(field_22212_b).toString());
|
||||
field_22215_g = 0;
|
||||
try {
|
||||
if (file.exists()) {
|
||||
field_22214_h = file.lastModified();
|
||||
}
|
||||
field_22219_c = new RandomAccessFile(file, "rw");
|
||||
if (field_22219_c.length() < 4096L) {
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
field_22219_c.writeInt(0);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 1024; j++) {
|
||||
field_22219_c.writeInt(0);
|
||||
}
|
||||
|
||||
field_22215_g += 8192;
|
||||
}
|
||||
if ((field_22219_c.length() & 4095L) != 0L) {
|
||||
for (int k = 0; (long) k < (field_22219_c.length() & 4095L); k++) {
|
||||
field_22219_c.write(0);
|
||||
}
|
||||
|
||||
}
|
||||
int l = (int) field_22219_c.length() / 4096;
|
||||
field_22216_f = new ArrayList(l);
|
||||
for (int i1 = 0; i1 < l; i1++) {
|
||||
field_22216_f.add(Boolean.valueOf(true));
|
||||
}
|
||||
|
||||
field_22216_f.set(0, Boolean.valueOf(false));
|
||||
field_22216_f.set(1, Boolean.valueOf(false));
|
||||
field_22219_c.seek(0L);
|
||||
for (int j1 = 0; j1 < 1024; j1++) {
|
||||
int l1 = field_22219_c.readInt();
|
||||
field_22218_d[j1] = l1;
|
||||
if (l1 == 0 || (l1 >> 8) + (l1 & 0xff) > field_22216_f.size()) {
|
||||
continue;
|
||||
}
|
||||
for (int j2 = 0; j2 < (l1 & 0xff); j2++) {
|
||||
field_22216_f.set((l1 >> 8) + j2, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int k1 = 0; k1 < 1024; k1++) {
|
||||
int i2 = field_22219_c.readInt();
|
||||
field_22217_e[k1] = i2;
|
||||
}
|
||||
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int func_22209_a() {
|
||||
int i = field_22215_g;
|
||||
field_22215_g = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
private void func_22211_a(String s) {
|
||||
}
|
||||
|
||||
private void func_22204_b(String s) {
|
||||
func_22211_a((new StringBuilder()).append(s).append("\n").toString());
|
||||
}
|
||||
|
||||
private void func_22199_a(String s, int i, int j, String s1) {
|
||||
func_22211_a((new StringBuilder()).append("REGION ").append(s).append(" ").append(field_22212_b.getName())
|
||||
.append("[").append(i).append(",").append(j).append("] = ").append(s1).toString());
|
||||
}
|
||||
|
||||
private void func_22197_a(String s, int i, int j, int k, String s1) {
|
||||
func_22211_a((new StringBuilder()).append("REGION ").append(s).append(" ").append(field_22212_b.getName())
|
||||
.append("[").append(i).append(",").append(j).append("] ").append(k).append("B = ").append(s1)
|
||||
.toString());
|
||||
}
|
||||
|
||||
private void func_22201_b(String s, int i, int j, String s1) {
|
||||
func_22199_a(s, i, j, (new StringBuilder()).append(s1).append("\n").toString());
|
||||
}
|
||||
|
||||
public synchronized DataInputStream func_22210_a(int i, int j) {
|
||||
if (func_22206_d(i, j)) {
|
||||
func_22201_b("READ", i, j, "out of bounds");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
int k = func_22207_e(i, j);
|
||||
if (k == 0) {
|
||||
return null;
|
||||
}
|
||||
int l = k >> 8;
|
||||
int i1 = k & 0xff;
|
||||
if (l + i1 > field_22216_f.size()) {
|
||||
func_22201_b("READ", i, j, "invalid sector");
|
||||
return null;
|
||||
}
|
||||
field_22219_c.seek(l * 4096);
|
||||
int j1 = field_22219_c.readInt();
|
||||
if (j1 > 4096 * i1) {
|
||||
func_22201_b("READ", i, j, (new StringBuilder()).append("invalid length: ").append(j1)
|
||||
.append(" > 4096 * ").append(i1).toString());
|
||||
return null;
|
||||
}
|
||||
byte byte0 = field_22219_c.readByte();
|
||||
if (byte0 == 1) {
|
||||
byte abyte0[] = new byte[j1 - 1];
|
||||
field_22219_c.read(abyte0);
|
||||
DataInputStream datainputstream = new DataInputStream(
|
||||
new GZIPInputStream(new ByteArrayInputStream(abyte0)));
|
||||
return datainputstream;
|
||||
}
|
||||
if (byte0 == 2) {
|
||||
byte abyte1[] = new byte[j1 - 1];
|
||||
field_22219_c.read(abyte1);
|
||||
DataInputStream datainputstream1 = new DataInputStream(
|
||||
new InflaterInputStream(new ByteArrayInputStream(abyte1)));
|
||||
return datainputstream1;
|
||||
} else {
|
||||
func_22201_b("READ", i, j, (new StringBuilder()).append("unknown version ").append(byte0).toString());
|
||||
return null;
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
func_22201_b("READ", i, j, "exception");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public DataOutputStream func_22205_b(int i, int j) {
|
||||
if (func_22206_d(i, j)) {
|
||||
return null;
|
||||
} else {
|
||||
return new DataOutputStream(new DeflaterOutputStream(new RegionFileChunkBuffer(this, i, j)));
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized void func_22203_a(int i, int j, byte abyte0[], int k) {
|
||||
try {
|
||||
int l = func_22207_e(i, j);
|
||||
int i1 = l >> 8;
|
||||
int l1 = l & 0xff;
|
||||
int i2 = (k + 5) / 4096 + 1;
|
||||
if (i2 >= 256) {
|
||||
return;
|
||||
}
|
||||
if (i1 != 0 && l1 == i2) {
|
||||
func_22197_a("SAVE", i, j, k, "rewrite");
|
||||
func_22200_a(i1, abyte0, k);
|
||||
} else {
|
||||
for (int j2 = 0; j2 < l1; j2++) {
|
||||
field_22216_f.set(i1 + j2, Boolean.valueOf(true));
|
||||
}
|
||||
|
||||
int k2 = field_22216_f.indexOf(Boolean.valueOf(true));
|
||||
int l2 = 0;
|
||||
if (k2 != -1) {
|
||||
int i3 = k2;
|
||||
do {
|
||||
if (i3 >= field_22216_f.size()) {
|
||||
break;
|
||||
}
|
||||
if (l2 != 0) {
|
||||
if (((Boolean) field_22216_f.get(i3)).booleanValue()) {
|
||||
l2++;
|
||||
} else {
|
||||
l2 = 0;
|
||||
}
|
||||
} else if (((Boolean) field_22216_f.get(i3)).booleanValue()) {
|
||||
k2 = i3;
|
||||
l2 = 1;
|
||||
}
|
||||
if (l2 >= i2) {
|
||||
break;
|
||||
}
|
||||
i3++;
|
||||
} while (true);
|
||||
}
|
||||
if (l2 >= i2) {
|
||||
func_22197_a("SAVE", i, j, k, "reuse");
|
||||
int j1 = k2;
|
||||
func_22198_a(i, j, j1 << 8 | i2);
|
||||
for (int j3 = 0; j3 < i2; j3++) {
|
||||
field_22216_f.set(j1 + j3, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
func_22200_a(j1, abyte0, k);
|
||||
} else {
|
||||
func_22197_a("SAVE", i, j, k, "grow");
|
||||
field_22219_c.seek(field_22219_c.length());
|
||||
int k1 = field_22216_f.size();
|
||||
for (int k3 = 0; k3 < i2; k3++) {
|
||||
field_22219_c.write(field_22213_a);
|
||||
field_22216_f.add(Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
field_22215_g += 4096 * i2;
|
||||
func_22200_a(k1, abyte0, k);
|
||||
func_22198_a(i, j, k1 << 8 | i2);
|
||||
}
|
||||
}
|
||||
func_22208_b(i, j, (int) (System.currentTimeMillis() / 1000L));
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void func_22200_a(int i, byte abyte0[], int j) throws IOException {
|
||||
func_22204_b((new StringBuilder()).append(" ").append(i).toString());
|
||||
field_22219_c.seek(i * 4096);
|
||||
field_22219_c.writeInt(j + 1);
|
||||
field_22219_c.writeByte(2);
|
||||
field_22219_c.write(abyte0, 0, j);
|
||||
}
|
||||
|
||||
private boolean func_22206_d(int i, int j) {
|
||||
return i < 0 || i >= 32 || j < 0 || j >= 32;
|
||||
}
|
||||
|
||||
private int func_22207_e(int i, int j) {
|
||||
return field_22218_d[i + j * 32];
|
||||
}
|
||||
|
||||
public boolean func_22202_c(int i, int j) {
|
||||
return func_22207_e(i, j) != 0;
|
||||
}
|
||||
|
||||
private void func_22198_a(int i, int j, int k) throws IOException {
|
||||
field_22218_d[i + j * 32] = k;
|
||||
field_22219_c.seek((i + j * 32) * 4);
|
||||
field_22219_c.writeInt(k);
|
||||
}
|
||||
|
||||
private void func_22208_b(int i, int j, int k) throws IOException {
|
||||
field_22217_e[i + j * 32] = k;
|
||||
field_22219_c.seek(4096 + (i + j * 32) * 4);
|
||||
field_22219_c.writeInt(k);
|
||||
}
|
||||
|
||||
public void func_22196_b() throws IOException {
|
||||
field_22219_c.close();
|
||||
}
|
||||
|
||||
private static final byte field_22213_a[] = new byte[4096];
|
||||
private final File field_22212_b;
|
||||
private RandomAccessFile field_22219_c;
|
||||
private final int field_22218_d[] = new int[1024];
|
||||
private final int field_22217_e[] = new int[1024];
|
||||
private ArrayList field_22216_f;
|
||||
private int field_22215_g;
|
||||
private long field_22214_h;
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.*;
|
||||
|
||||
public class RegionFileCache {
|
||||
|
||||
private RegionFileCache() {
|
||||
}
|
||||
|
||||
public static synchronized RegionFile func_22193_a(File file, int i, int j) {
|
||||
File file1 = new File(file, "region");
|
||||
File file2 = new File(file1,
|
||||
(new StringBuilder()).append("r.").append(i >> 5).append(".").append(j >> 5).append(".mcr").toString());
|
||||
Reference reference = (Reference) field_22195_a.get(file2);
|
||||
if (reference != null) {
|
||||
RegionFile regionfile = (RegionFile) reference.get();
|
||||
if (regionfile != null) {
|
||||
return regionfile;
|
||||
}
|
||||
}
|
||||
if (!file1.exists()) {
|
||||
file1.mkdirs();
|
||||
}
|
||||
if (field_22195_a.size() >= 256) {
|
||||
func_22192_a();
|
||||
}
|
||||
RegionFile regionfile1 = new RegionFile(file2);
|
||||
field_22195_a.put(file2, new SoftReference(regionfile1));
|
||||
return regionfile1;
|
||||
}
|
||||
|
||||
public static synchronized void func_22192_a() {
|
||||
Iterator iterator = field_22195_a.values().iterator();
|
||||
do {
|
||||
if (!iterator.hasNext()) {
|
||||
break;
|
||||
}
|
||||
Reference reference = (Reference) iterator.next();
|
||||
try {
|
||||
RegionFile regionfile = (RegionFile) reference.get();
|
||||
if (regionfile != null) {
|
||||
regionfile.func_22196_b();
|
||||
}
|
||||
} catch (Throwable ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
}
|
||||
} while (true);
|
||||
field_22195_a.clear();
|
||||
}
|
||||
|
||||
public static int func_22191_b(File file, int i, int j) {
|
||||
RegionFile regionfile = func_22193_a(file, i, j);
|
||||
return regionfile.func_22209_a();
|
||||
}
|
||||
|
||||
public static DataInputStream func_22194_c(File file, int i, int j) {
|
||||
RegionFile regionfile = func_22193_a(file, i, j);
|
||||
return regionfile.func_22210_a(i & 0x1f, j & 0x1f);
|
||||
}
|
||||
|
||||
public static DataOutputStream func_22190_d(File file, int i, int j) {
|
||||
RegionFile regionfile = func_22193_a(file, i, j);
|
||||
return regionfile.func_22205_b(i & 0x1f, j & 0x1f);
|
||||
}
|
||||
|
||||
private static final Map field_22195_a = new HashMap();
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
class RegionFileChunkBuffer extends ByteArrayOutputStream {
|
||||
|
||||
public RegionFileChunkBuffer(RegionFile regionfile, int i, int j) {
|
||||
super(8096);
|
||||
field_22284_a = regionfile;
|
||||
field_22283_b = i;
|
||||
field_22285_c = j;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
field_22284_a.func_22203_a(field_22283_b, field_22285_c, buf, count);
|
||||
}
|
||||
|
||||
private int field_22283_b;
|
||||
private int field_22285_c;
|
||||
final RegionFile field_22284_a; /* synthetic field */
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import net.minecraft.src.IProgressUpdate;
|
||||
import net.minecraft.src.ISaveHandler;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.SaveFormatComparator;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
|
||||
public class SaveConverterMcRegion extends SaveFormatOld {
|
||||
|
||||
public SaveConverterMcRegion(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public String formatName() {
|
||||
return "Scaevolus' McRegion";
|
||||
}
|
||||
|
||||
public List getWorldList() {
|
||||
ArrayList arraylist = new ArrayList();
|
||||
File afile[] = field_22180_a.listFiles();
|
||||
File afile1[] = afile;
|
||||
int i = afile1.length;
|
||||
for (int j = 0; j < i; j++) {
|
||||
File file = afile1[j];
|
||||
if (!file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
String s = file.getName();
|
||||
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||
if (worldinfo == null) {
|
||||
continue;
|
||||
}
|
||||
boolean flag = worldinfo.getSaveVersion() != 19132;
|
||||
String s1 = worldinfo.getWorldName();
|
||||
if (s1 == null || MathHelper.stringNullOrLengthZero(s1)) {
|
||||
s1 = s;
|
||||
}
|
||||
arraylist.add(new SaveFormatComparator(s, s1, worldinfo.getLastTimePlayed(), worldinfo.getSizeOnDisk(), flag));
|
||||
}
|
||||
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
public void flushCache() {
|
||||
RegionFileCache.func_22192_a();
|
||||
}
|
||||
|
||||
public ISaveHandler getSaveLoader(String s, boolean flag) {
|
||||
return new SaveOldDir(field_22180_a, s, flag);
|
||||
}
|
||||
|
||||
public boolean isOldMapFormat(String s) {
|
||||
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||
return worldinfo != null && worldinfo.getSaveVersion() == 0;
|
||||
}
|
||||
|
||||
public boolean convertMapFormat(String s, IProgressUpdate iprogressupdate) {
|
||||
iprogressupdate.setLoadingProgress(0);
|
||||
ArrayList arraylist = new ArrayList();
|
||||
ArrayList arraylist1 = new ArrayList();
|
||||
ArrayList arraylist2 = new ArrayList();
|
||||
ArrayList arraylist3 = new ArrayList();
|
||||
File file = new File(field_22180_a, s);
|
||||
File file1 = new File(file, "DIM-1");
|
||||
System.out.println("Scanning folders...");
|
||||
func_22183_a(file, arraylist, arraylist1);
|
||||
if (file1.exists()) {
|
||||
func_22183_a(file1, arraylist2, arraylist3);
|
||||
}
|
||||
int i = arraylist.size() + arraylist2.size() + arraylist1.size() + arraylist3.size();
|
||||
System.out.println((new StringBuilder()).append("Total conversion count is ").append(i).toString());
|
||||
func_22181_a(file, arraylist, 0, i, iprogressupdate);
|
||||
func_22181_a(file1, arraylist2, arraylist.size(), i, iprogressupdate);
|
||||
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||
worldinfo.setSaveVersion(19132);
|
||||
ISaveHandler isavehandler = getSaveLoader(s, false);
|
||||
isavehandler.saveWorldInfo(worldinfo);
|
||||
func_22182_a(arraylist1, arraylist.size() + arraylist2.size(), i, iprogressupdate);
|
||||
if (file1.exists()) {
|
||||
func_22182_a(arraylist3, arraylist.size() + arraylist2.size() + arraylist1.size(), i, iprogressupdate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void func_22183_a(File file, ArrayList arraylist, ArrayList arraylist1) {
|
||||
ChunkFolderPattern chunkfolderpattern = new ChunkFolderPattern(null);
|
||||
ChunkFilePattern chunkfilepattern = new ChunkFilePattern(null);
|
||||
File afile[] = file.listFiles(chunkfolderpattern);
|
||||
File afile1[] = afile;
|
||||
int i = afile1.length;
|
||||
for (int j = 0; j < i; j++) {
|
||||
File file1 = afile1[j];
|
||||
arraylist1.add(file1);
|
||||
File afile2[] = file1.listFiles(chunkfolderpattern);
|
||||
File afile3[] = afile2;
|
||||
int k = afile3.length;
|
||||
for (int l = 0; l < k; l++) {
|
||||
File file2 = afile3[l];
|
||||
File afile4[] = file2.listFiles(chunkfilepattern);
|
||||
File afile5[] = afile4;
|
||||
int i1 = afile5.length;
|
||||
for (int j1 = 0; j1 < i1; j1++) {
|
||||
File file3 = afile5[j1];
|
||||
arraylist.add(new FileMatcher(file3));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void func_22181_a(File file, ArrayList arraylist, int i, int j, IProgressUpdate iprogressupdate) {
|
||||
Collections.sort(arraylist);
|
||||
byte abyte0[] = new byte[4096];
|
||||
int i1;
|
||||
for (Iterator iterator = arraylist.iterator(); iterator.hasNext(); iprogressupdate.setLoadingProgress(i1)) {
|
||||
FileMatcher filematcher = (FileMatcher) iterator.next();
|
||||
int k = filematcher.func_22323_b();
|
||||
int l = filematcher.func_22321_c();
|
||||
RegionFile regionfile = RegionFileCache.func_22193_a(file, k, l);
|
||||
if (!regionfile.func_22202_c(k & 0x1f, l & 0x1f)) {
|
||||
try {
|
||||
DataInputStream datainputstream = new DataInputStream(
|
||||
new GZIPInputStream(new FileInputStream(filematcher.func_22324_a())));
|
||||
DataOutputStream dataoutputstream = regionfile.func_22205_b(k & 0x1f, l & 0x1f);
|
||||
for (int j1 = 0; (j1 = datainputstream.read(abyte0)) != -1;) {
|
||||
dataoutputstream.write(abyte0, 0, j1);
|
||||
}
|
||||
|
||||
dataoutputstream.close();
|
||||
datainputstream.close();
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
}
|
||||
}
|
||||
i++;
|
||||
i1 = (int) Math.round((100D * (double) i) / (double) j);
|
||||
}
|
||||
|
||||
RegionFileCache.func_22192_a();
|
||||
}
|
||||
|
||||
private void func_22182_a(ArrayList arraylist, int i, int j, IProgressUpdate iprogressupdate) {
|
||||
int k;
|
||||
for (Iterator iterator = arraylist.iterator(); iterator.hasNext(); iprogressupdate.setLoadingProgress(k)) {
|
||||
File file = (File) iterator.next();
|
||||
File afile[] = file.listFiles();
|
||||
func_22179_a(afile);
|
||||
file.delete();
|
||||
i++;
|
||||
k = (int) Math.round((100D * (double) i) / (double) j);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
118
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/SaveFormatOld.java
Normal file
118
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/SaveFormatOld.java
Normal file
@ -0,0 +1,118 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.CompressedStreamTools;
|
||||
import net.minecraft.src.IProgressUpdate;
|
||||
import net.minecraft.src.ISaveFormat;
|
||||
import net.minecraft.src.ISaveHandler;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.SaveFormatComparator;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
|
||||
public class SaveFormatOld implements ISaveFormat {
|
||||
|
||||
public SaveFormatOld(File file) {
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
field_22180_a = file;
|
||||
}
|
||||
|
||||
public String formatName() {
|
||||
return "Old Format";
|
||||
}
|
||||
|
||||
public List getWorldList() {
|
||||
ArrayList arraylist = new ArrayList();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
String s = (new StringBuilder()).append("World").append(i + 1).toString();
|
||||
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||
if (worldinfo != null) {
|
||||
arraylist.add(new SaveFormatComparator(s, "", worldinfo.getLastTimePlayed(), worldinfo.getSizeOnDisk(), false));
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
public void flushCache() {
|
||||
}
|
||||
|
||||
public WorldInfo getWorldInfoForWorld(String s) {
|
||||
File file = new File(field_22180_a, s);
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
File file1 = new File(file, "level.dat");
|
||||
if (file1.exists()) {
|
||||
try {
|
||||
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
|
||||
return new WorldInfo(nbttagcompound1);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void renameWorldData(String s, String s1) {
|
||||
File file = new File(field_22180_a, s);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
File file1 = new File(file, "level.dat");
|
||||
if (file1.exists()) {
|
||||
try {
|
||||
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
|
||||
nbttagcompound1.setString("LevelName", s1);
|
||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound, new FileOutputStream(file1));
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteWorldByDirectory(String s) {
|
||||
File file = new File(field_22180_a, s);
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
} else {
|
||||
func_22179_a(file.listFiles());
|
||||
file.delete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void func_22179_a(File afile[]) {
|
||||
for (int i = 0; i < afile.length; i++) {
|
||||
if (afile[i].isDirectory()) {
|
||||
func_22179_a(afile[i].listFiles());
|
||||
}
|
||||
afile[i].delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ISaveHandler getSaveLoader(String s, boolean flag) {
|
||||
return new SaveHandler(field_22180_a, s, flag);
|
||||
}
|
||||
|
||||
public boolean isOldMapFormat(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean convertMapFormat(String s, IProgressUpdate iprogressupdate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected final File field_22180_a;
|
||||
}
|
146
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/SaveHandler.java
Normal file
146
src/lwjgl/java/net/lax1dude/eaglercraft/anvil/SaveHandler.java
Normal file
@ -0,0 +1,146 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.src.CompressedStreamTools;
|
||||
import net.minecraft.src.IChunkLoader;
|
||||
import net.minecraft.src.ISaveHandler;
|
||||
import net.minecraft.src.MinecraftException;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
import net.minecraft.src.WorldProvider;
|
||||
import net.minecraft.src.WorldProviderHell;
|
||||
|
||||
public class SaveHandler implements ISaveHandler {
|
||||
|
||||
public SaveHandler(File file, String s, boolean flag) {
|
||||
field_22155_b = new File(file, s);
|
||||
field_22155_b.mkdirs();
|
||||
field_22158_c = new File(field_22155_b, "players");
|
||||
if (flag) {
|
||||
field_22158_c.mkdirs();
|
||||
}
|
||||
func_22154_d();
|
||||
}
|
||||
|
||||
private void func_22154_d() {
|
||||
try {
|
||||
File file = new File(field_22155_b, "session.lock");
|
||||
DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file));
|
||||
try {
|
||||
dataoutputstream.writeLong(field_22157_d);
|
||||
} finally {
|
||||
dataoutputstream.close();
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
ioexception.printStackTrace();
|
||||
throw new RuntimeException("Failed to check session lock, aborting");
|
||||
}
|
||||
}
|
||||
|
||||
protected File func_22153_a() {
|
||||
return field_22155_b;
|
||||
}
|
||||
|
||||
public void checkSessionLock() {
|
||||
try {
|
||||
File file = new File(field_22155_b, "session.lock");
|
||||
DataInputStream datainputstream = new DataInputStream(new FileInputStream(file));
|
||||
try {
|
||||
if (datainputstream.readLong() != field_22157_d) {
|
||||
throw new MinecraftException("The save is being accessed from another location, aborting");
|
||||
}
|
||||
} finally {
|
||||
datainputstream.close();
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
throw new MinecraftException("Failed to check session lock, aborting");
|
||||
}
|
||||
}
|
||||
|
||||
public IChunkLoader getChunkLoader(WorldProvider worldprovider) {
|
||||
if (worldprovider instanceof WorldProviderHell) {
|
||||
File file = new File(field_22155_b, "DIM-1");
|
||||
file.mkdirs();
|
||||
return new ChunkLoader(file, true);
|
||||
} else {
|
||||
return new ChunkLoader(field_22155_b, true);
|
||||
}
|
||||
}
|
||||
|
||||
public WorldInfo loadWorldInfo() {
|
||||
File file = new File(field_22155_b, "level.dat");
|
||||
if (file.exists()) {
|
||||
try {
|
||||
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
|
||||
return new WorldInfo(nbttagcompound1);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveWorldInfoAndPlayer(WorldInfo worldinfo, List list) {
|
||||
NBTTagCompound nbttagcompound = worldinfo.getNBTTagCompoundWithPlayer(list);
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setTag("Data", nbttagcompound);
|
||||
try {
|
||||
File file = new File(field_22155_b, "level.dat_new");
|
||||
File file1 = new File(field_22155_b, "level.dat_old");
|
||||
File file2 = new File(field_22155_b, "level.dat");
|
||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound1, new FileOutputStream(file));
|
||||
if (file1.exists()) {
|
||||
file1.delete();
|
||||
}
|
||||
file2.renameTo(file1);
|
||||
if (file2.exists()) {
|
||||
file2.delete();
|
||||
}
|
||||
file.renameTo(file2);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveWorldInfo(WorldInfo worldinfo) {
|
||||
NBTTagCompound nbttagcompound = worldinfo.getNBTTagCompound();
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setTag("Data", nbttagcompound);
|
||||
try {
|
||||
File file = new File(field_22155_b, "level.dat_new");
|
||||
File file1 = new File(field_22155_b, "level.dat_old");
|
||||
File file2 = new File(field_22155_b, "level.dat");
|
||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(nbttagcompound1, new FileOutputStream(file));
|
||||
if (file1.exists()) {
|
||||
file1.delete();
|
||||
}
|
||||
file2.renameTo(file1);
|
||||
if (file2.exists()) {
|
||||
file2.delete();
|
||||
}
|
||||
file.renameTo(file2);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger field_22156_a = Logger.getLogger("Minecraft");
|
||||
private final File field_22155_b;
|
||||
private final File field_22158_c;
|
||||
private final long field_22157_d = System.currentTimeMillis();
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package net.lax1dude.eaglercraft.anvil;
|
||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3) braces deadcode
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.IChunkLoader;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
import net.minecraft.src.WorldProvider;
|
||||
import net.minecraft.src.WorldProviderHell;
|
||||
|
||||
public class SaveOldDir extends SaveHandler {
|
||||
|
||||
public SaveOldDir(File file, String s, boolean flag) {
|
||||
super(file, s, flag);
|
||||
}
|
||||
|
||||
public IChunkLoader getChunkLoader(WorldProvider worldprovider) {
|
||||
File file = func_22153_a();
|
||||
if (worldprovider instanceof WorldProviderHell) {
|
||||
File file1 = new File(file, "DIM-1");
|
||||
file1.mkdirs();
|
||||
return new McRegionChunkLoader(file1);
|
||||
} else {
|
||||
return new McRegionChunkLoader(file);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveWorldInfoAndPlayer(WorldInfo worldinfo, List list) {
|
||||
worldinfo.setSaveVersion(19132);
|
||||
super.saveWorldInfoAndPlayer(worldinfo, list);
|
||||
}
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
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.Iterator;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.minecraft.src.Chunk;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.EntityList;
|
||||
import net.minecraft.src.IChunkLoader;
|
||||
import net.minecraft.src.NBTBase;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NBTTagList;
|
||||
import net.minecraft.src.NibbleArray;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class EaglercraftChunkLoader implements IChunkLoader {
|
||||
|
||||
public final String directory;
|
||||
|
||||
public EaglercraftChunkLoader(String dir) {
|
||||
this.directory = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk loadChunk(World world, int x, int z) {
|
||||
String name = getChunkPath(x, z);
|
||||
String path = directory + "/" + name;
|
||||
byte[] dat = EaglerAdapter.readFile(path);
|
||||
if(dat != null) {
|
||||
try {
|
||||
NBTTagCompound nbt = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(dat)));
|
||||
int xx = nbt.getInteger("xPos");
|
||||
int zz = nbt.getInteger("zPos");
|
||||
if(x != xx || z != zz) {
|
||||
String name2 = getChunkPath(xx, zz);
|
||||
System.err.println("The chunk file '" + name + "' was supposed to be at [" + x + ", " + z + "], but the file contained a chunk from [" + xx + ", " + zz +
|
||||
"]. It's data will be moved to file '" + name2 + "', and a new empty chunk will be created for file '" + name + "' for [" + x + ", " + z + "]");
|
||||
EaglerAdapter.renameFile(path, directory + "/" + name2);
|
||||
return null;
|
||||
}
|
||||
|
||||
return loadChunkIntoWorldFromCompound(world, nbt);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Corrupt chunk '" + name + "' was found at: [" + x + ", " + z + "]");
|
||||
System.err.println("The file will be deleted");
|
||||
EaglerAdapter.deleteFile(path);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChunk(World world, Chunk chunk) {
|
||||
NBTTagCompound toSave = new NBTTagCompound();
|
||||
storeChunkInCompound(chunk, world, toSave);
|
||||
ByteArrayOutputStream bao = new ByteArrayOutputStream(131072);
|
||||
try {
|
||||
NBTBase.writeTag(toSave, new DataOutputStream(bao));
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to serialize chunk at [" + chunk.xPosition + ", " + chunk.zPosition + "] to byte array");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
EaglerAdapter.writeFile(directory + "/" + getChunkPath(chunk.xPosition, chunk.zPosition), bao.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveExtraChunkData(World world, Chunk chunk) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_814_a() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveExtraData() {
|
||||
}
|
||||
|
||||
public static final String CHUNK_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
public static String getChunkPath(int x, int z) {
|
||||
int unsignedX = x + 30233088;
|
||||
int unsignedZ = z + 30233088;
|
||||
int radix = CHUNK_CHARS.length();
|
||||
char[] path = new char[10];
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
path[i * 2] = CHUNK_CHARS.charAt(unsignedX % radix);
|
||||
unsignedX /= radix;
|
||||
path[i * 2 + 1] = CHUNK_CHARS.charAt(unsignedZ % radix);
|
||||
unsignedZ /= radix;
|
||||
}
|
||||
return new String(path);
|
||||
}
|
||||
|
||||
public static Chunk loadChunkIntoWorldFromCompound(World world, NBTTagCompound nbttagcompound) {
|
||||
int i = nbttagcompound.getInteger("xPos");
|
||||
int j = nbttagcompound.getInteger("zPos");
|
||||
Chunk chunk = new Chunk(world, i, j);
|
||||
chunk.blocks = nbttagcompound.getByteArray("Blocks");
|
||||
chunk.data = new NibbleArray(nbttagcompound.getByteArray("Data"));
|
||||
chunk.skylightMap = new NibbleArray(nbttagcompound.getByteArray("SkyLight"));
|
||||
chunk.blocklightMap = new NibbleArray(nbttagcompound.getByteArray("BlockLight"));
|
||||
chunk.heightMap = nbttagcompound.getByteArray("HeightMap");
|
||||
chunk.isTerrainPopulated = nbttagcompound.getBoolean("TerrainPopulated");
|
||||
if (!chunk.data.isValid()) {
|
||||
chunk.data = new NibbleArray(chunk.blocks.length);
|
||||
}
|
||||
if (chunk.heightMap == null || !chunk.skylightMap.isValid()) {
|
||||
chunk.heightMap = new byte[256];
|
||||
chunk.skylightMap = new NibbleArray(chunk.blocks.length);
|
||||
chunk.func_1024_c();
|
||||
}
|
||||
if (!chunk.blocklightMap.isValid()) {
|
||||
chunk.blocklightMap = new NibbleArray(chunk.blocks.length);
|
||||
chunk.func_1014_a();
|
||||
}
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Entities");
|
||||
if (nbttaglist != null) {
|
||||
for (int k = 0; k < nbttaglist.tagCount(); k++) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(k);
|
||||
Entity entity = EntityList.createEntityFromNBT(nbttagcompound1, world);
|
||||
chunk.hasEntities = true;
|
||||
if (entity != null) {
|
||||
chunk.addEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities");
|
||||
if (nbttaglist1 != null) {
|
||||
for (int l = 0; l < nbttaglist1.tagCount(); l++) {
|
||||
NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
|
||||
TileEntity tileentity = TileEntity.createAndLoadEntity(nbttagcompound2);
|
||||
if (tileentity != null) {
|
||||
chunk.func_1001_a(tileentity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public static void storeChunkInCompound(Chunk chunk, World world, NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("xPos", chunk.xPosition);
|
||||
nbttagcompound.setInteger("zPos", chunk.zPosition);
|
||||
nbttagcompound.setLong("LastUpdate", world.lockTimestamp);
|
||||
nbttagcompound.setByteArray("Blocks", chunk.blocks);
|
||||
nbttagcompound.setByteArray("Data", chunk.data.data);
|
||||
nbttagcompound.setByteArray("SkyLight", chunk.skylightMap.data);
|
||||
nbttagcompound.setByteArray("BlockLight", chunk.blocklightMap.data);
|
||||
nbttagcompound.setByteArray("HeightMap", chunk.heightMap);
|
||||
nbttagcompound.setBoolean("TerrainPopulated", chunk.isTerrainPopulated);
|
||||
chunk.hasEntities = false;
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
label0: for (int i = 0; i < chunk.entities.length; i++) {
|
||||
Iterator iterator = chunk.entities[i].iterator();
|
||||
do {
|
||||
if (!iterator.hasNext()) {
|
||||
continue label0;
|
||||
}
|
||||
Entity entity = (Entity) iterator.next();
|
||||
chunk.hasEntities = true;
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
if (entity.addEntityID(nbttagcompound1)) {
|
||||
nbttaglist.setTag(nbttagcompound1);
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Entities", nbttaglist);
|
||||
NBTTagList nbttaglist1 = new NBTTagList();
|
||||
NBTTagCompound nbttagcompound2;
|
||||
for (Iterator iterator1 = chunk.chunkTileEntityMap.values().iterator(); iterator1.hasNext(); nbttaglist1
|
||||
.setTag(nbttagcompound2)) {
|
||||
TileEntity tileentity = (TileEntity) iterator1.next();
|
||||
nbttagcompound2 = new NBTTagCompound();
|
||||
tileentity.writeToNBT(nbttagcompound2);
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("TileEntities", nbttaglist1);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
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.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.minecraft.src.IChunkLoader;
|
||||
import net.minecraft.src.ISaveHandler;
|
||||
import net.minecraft.src.NBTBase;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
import net.minecraft.src.WorldProvider;
|
||||
import net.minecraft.src.WorldProviderHell;
|
||||
|
||||
public class EaglercraftSaveHandler implements ISaveHandler {
|
||||
|
||||
public final String directory;
|
||||
|
||||
public EaglercraftSaveHandler(String dir) {
|
||||
this.directory = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldInfo loadWorldInfo() {
|
||||
byte[] file = EaglerAdapter.readFile(directory + "/lvl");
|
||||
if(file != null) {
|
||||
try {
|
||||
NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(file)));
|
||||
if(nbt instanceof NBTTagCompound) {
|
||||
return new WorldInfo((NBTTagCompound)nbt);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to load world data for '" + directory + "/lvl'");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkSessionLock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkLoader getChunkLoader(WorldProvider worldprovider) {
|
||||
if(worldprovider instanceof WorldProviderHell) {
|
||||
return new EaglercraftChunkLoader(directory + "/c1");
|
||||
}else {
|
||||
return new EaglercraftChunkLoader(directory + "/c0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorldInfoAndPlayer(WorldInfo worldinfo, List list) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(8192);
|
||||
DataOutputStream ds = new DataOutputStream(out);
|
||||
try {
|
||||
NBTBase.writeTag(worldinfo.getNBTTagCompoundWithPlayer(list), ds);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to serialize world data for '" + directory + "/lvl'");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
EaglerAdapter.writeFile(directory + "/lvl", out.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorldInfo(WorldInfo worldinfo) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(8192);
|
||||
DataOutputStream ds = new DataOutputStream(out);
|
||||
try {
|
||||
NBTBase.writeTag(worldinfo.getNBTTagCompound(), ds);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to serialize world data for '" + directory + "/lvl'");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
EaglerAdapter.writeFile(directory + "/lvl", out.toByteArray());
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
|
||||
import net.minecraft.src.IProgressUpdate;
|
||||
import net.minecraft.src.ISaveFormat;
|
||||
import net.minecraft.src.ISaveHandler;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.NBTBase;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.SaveFormatComparator;
|
||||
import net.minecraft.src.WorldInfo;
|
||||
|
||||
public class EaglercraftSaveManager implements ISaveFormat {
|
||||
|
||||
public final String directory;
|
||||
|
||||
public EaglercraftSaveManager(String dir) {
|
||||
this.directory = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatName() {
|
||||
return "Eaglercraft VFS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISaveHandler getSaveLoader(String s, boolean flag) {
|
||||
return new EaglercraftSaveHandler(directory + "/" + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getWorldList() {
|
||||
//progress.displayLoadingString("Loading Worlds...", "just wait a moment");
|
||||
ArrayList<SaveFormatComparator> lst = new ArrayList<>();
|
||||
EaglerAdapter.listFilesAndDirectories(directory).forEach(new Consumer<FileEntry>() {
|
||||
@Override
|
||||
public void accept(FileEntry t) {
|
||||
if(!t.isDirectory) {
|
||||
return;
|
||||
}
|
||||
String folderName = t.getName();
|
||||
String dir = t.path;
|
||||
byte[] lvl = EaglerAdapter.readFile(dir + "/lvl");
|
||||
if(lvl != null) {
|
||||
try {
|
||||
NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(lvl)));
|
||||
if(nbt instanceof NBTTagCompound) {
|
||||
WorldInfo w = new WorldInfo((NBTTagCompound)nbt);
|
||||
String s1 = w.getWorldName();
|
||||
if (s1 == null || MathHelper.func_22282_a(s1)) {
|
||||
s1 = folderName;
|
||||
}
|
||||
lst.add(new SaveFormatComparator(folderName, s1, w.func_22301_l(), w.func_22306_g(), false));
|
||||
}else {
|
||||
throw new IOException("file '" + dir + "/lvl' does not contain an NBTTagCompound");
|
||||
}
|
||||
}catch(IOException e) {
|
||||
System.err.println("Failed to load world data for '" + directory + "/lvl'");
|
||||
System.err.println("It will be kept for future recovery");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return lst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushCache() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldInfo getWorldInfoForWorld(String s) {
|
||||
byte[] lvl = EaglerAdapter.readFile(directory + "/" + s + "/lvl");
|
||||
if(lvl != null) {
|
||||
try {
|
||||
NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(lvl)));
|
||||
if(nbt instanceof NBTTagCompound) {
|
||||
return new WorldInfo((NBTTagCompound)nbt);
|
||||
}else {
|
||||
throw new IOException("file '" + directory + "/" + s + "/lvl' does not contain an NBTTagCompound");
|
||||
}
|
||||
}catch(IOException e) {
|
||||
System.err.println("Failed to load world data for '" + directory + "/lvl'");
|
||||
System.err.println("It will be kept for future recovery");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deleteWorldByDirectory(String s) {
|
||||
FilesystemUtils.recursiveDeleteDirectoryWithProgress(directory + "/" + s, "Deleting World", "%i chunks");
|
||||
}
|
||||
|
||||
public boolean isOldMapFormat(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean convertMapFormat(String s, IProgressUpdate iprogressupdate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renameWorldData(String s, String s1) {
|
||||
byte[] lvl = EaglerAdapter.readFile(directory + "/" + s + "/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", s1);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(lvl.length + 16 + s1.length() * 2); // should be large enough
|
||||
NBTBase.writeTag(w, new DataOutputStream(out));
|
||||
EaglerAdapter.writeFile(directory + "/" + s + "/lvl", out.toByteArray());
|
||||
}else {
|
||||
throw new IOException("file '" + directory + "/" + s + "/lvl' does not contain an NBTTagCompound");
|
||||
}
|
||||
}catch(IOException e) {
|
||||
System.err.println("Failed to load world data for '" + directory + "/lvl'");
|
||||
System.err.println("It will be kept for future recovery");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package net.minecraft.client;
|
||||
import net.lax1dude.eaglercraft.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.EagUtils;
|
||||
import net.lax1dude.eaglercraft.GuiScreenEditProfile;
|
||||
import net.lax1dude.eaglercraft.beta.EaglercraftSaveManager;
|
||||
import net.lax1dude.eaglercraft.beta.TextureNewClockFX;
|
||||
import net.lax1dude.eaglercraft.beta.TextureNewCompassFX;
|
||||
import net.lax1dude.eaglercraft.internal.EnumPlatformType;
|
||||
@ -138,7 +139,7 @@ public class Minecraft {
|
||||
|
||||
RenderManager.instance.itemRenderer = new ItemRenderer(this);
|
||||
this.mcDataDir = getMinecraftDir();
|
||||
this.saveLoader = new SaveConverterMcRegion(new VFile2("saves"));
|
||||
this.saveLoader = new EaglercraftSaveManager("saves"); // shit better work
|
||||
this.gameSettings = new GameSettings(this, this.mcDataDir);
|
||||
this.scaledResolution = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight);
|
||||
this.texturePackList = new TexturePackList(this, this.mcDataDir);
|
||||
@ -911,8 +912,7 @@ public class Minecraft {
|
||||
this.convertMapFormat(var1, var2);
|
||||
} else {
|
||||
ISaveHandler var5 = this.saveLoader.getSaveLoader(var1, false);
|
||||
World var6 = null;
|
||||
var6 = new World(var5, var2, var3);
|
||||
World var6 = new World(var5, var2, var3);
|
||||
if(var6.isNewWorld) {
|
||||
this.field_25001_G.func_25100_a(StatList.field_25183_f, 1);
|
||||
this.field_25001_G.func_25100_a(StatList.field_25184_e, 1);
|
||||
|
@ -1,168 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.internal.vfs2.VFile2;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class SaveConverterMcRegion extends SaveFormatOld {
|
||||
public SaveConverterMcRegion(VFile2 var1) {
|
||||
super(var1);
|
||||
}
|
||||
|
||||
public String formatName() {
|
||||
return "Scaevolus' McRegion";
|
||||
}
|
||||
|
||||
public List getWorldList() {
|
||||
ArrayList arraylist = new ArrayList();
|
||||
List<String> names = worldFile.listFilenames(true);
|
||||
for (String s : names) {
|
||||
if (!s.contains("level.dat_old")) {
|
||||
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||
if (worldinfo == null) {
|
||||
continue;
|
||||
}
|
||||
boolean flag = worldinfo.getSaveVersion() != 19132;
|
||||
String s1 = worldinfo.getWorldName();
|
||||
if (s1 == null || MathHelper.stringNullOrLengthZero(s1)) {
|
||||
s1 = s;
|
||||
}
|
||||
arraylist.add(new SaveFormatComparator(s, s1, worldinfo.getLastTimePlayed(), worldinfo.getSizeOnDisk(), flag));
|
||||
}
|
||||
}
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
public void flushCache() {
|
||||
RegionFileCache.func_22192_a();
|
||||
}
|
||||
|
||||
public ISaveHandler getSaveLoader(String var1, boolean var2) {
|
||||
return new SaveOldDir(this.worldFile, var1, var2);
|
||||
}
|
||||
|
||||
public boolean isOldMapFormat(String var1) {
|
||||
WorldInfo var2 = this.getWorldInfoForWorld(var1);
|
||||
return var2 != null && var2.getSaveVersion() == 0;
|
||||
}
|
||||
|
||||
public boolean convertMapFormat(String var1, IProgressUpdate var2) {
|
||||
var2.setLoadingProgress(0);
|
||||
ArrayList var3 = new ArrayList();
|
||||
ArrayList var4 = new ArrayList();
|
||||
ArrayList var5 = new ArrayList();
|
||||
ArrayList var6 = new ArrayList();
|
||||
VFile2 var7 = new VFile2(this.worldFile, var1);
|
||||
VFile2 var8 = new VFile2(var7, "DIM-1");
|
||||
System.out.println("Scanning folders...");
|
||||
this.func_22183_a(var7, var3, var4);
|
||||
if(var8.exists()) {
|
||||
this.func_22183_a(var8, var5, var6);
|
||||
}
|
||||
|
||||
int var9 = var3.size() + var5.size() + var4.size() + var6.size();
|
||||
System.out.println("Total conversion count is " + var9);
|
||||
this.func_22181_a(var7, var3, 0, var9, var2);
|
||||
this.func_22181_a(var8, var5, var3.size(), var9, var2);
|
||||
WorldInfo var10 = this.getWorldInfoForWorld(var1);
|
||||
var10.setSaveVersion(19132);
|
||||
ISaveHandler var11 = this.getSaveLoader(var1, false);
|
||||
var11.saveWorldInfo(var10);
|
||||
this.func_22182_a(var4, var3.size() + var5.size(), var9, var2);
|
||||
if(var8.exists()) {
|
||||
this.func_22182_a(var6, var3.size() + var5.size() + var4.size(), var9, var2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void func_22183_a(VFile2 var1, ArrayList var2, ArrayList var3) {
|
||||
ChunkFolderPattern var4 = new ChunkFolderPattern(null);
|
||||
ChunkFilePattern var5 = new ChunkFilePattern(null);
|
||||
VFile2[] var6 = (VFile2[]) var1.listFiles(true).toArray();
|
||||
VFile2[] var7 = var6;
|
||||
int var8 = var6.length;
|
||||
|
||||
for(int var9 = 0; var9 < var8; ++var9) {
|
||||
VFile2 var10 = var7[var9];
|
||||
var3.add(var10);
|
||||
VFile2[] var11 = (VFile2[]) var10.listFiles(true).toArray();
|
||||
VFile2[] var12 = var11;
|
||||
int var13 = var11.length;
|
||||
|
||||
for(int var14 = 0; var14 < var13; ++var14) {
|
||||
VFile2 var15 = var12[var14];
|
||||
VFile2[] var16 = (VFile2[]) var15.listFiles(true).toArray();
|
||||
VFile2[] var17 = var16;
|
||||
int var18 = var16.length;
|
||||
|
||||
for(int var19 = 0; var19 < var18; ++var19) {
|
||||
VFile2 var20 = var17[var19];
|
||||
var2.add(new FileMatcher(var20));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void func_22181_a(VFile2 var1, ArrayList var2, int var3, int var4, IProgressUpdate var5) {
|
||||
Collections.sort(var2);
|
||||
byte[] var6 = new byte[4096];
|
||||
Iterator var7 = var2.iterator();
|
||||
|
||||
while(var7.hasNext()) {
|
||||
FileMatcher var8 = (FileMatcher)var7.next();
|
||||
int var9 = var8.func_22323_b();
|
||||
int var10 = var8.func_22321_c();
|
||||
RegionFile var11 = RegionFileCache.getRegionFile(var1, var9, var10);
|
||||
if(!var11.func_22202_c(var9 & 31, var10 & 31)) {
|
||||
try {
|
||||
DataInputStream var12 = new DataInputStream(new GZIPInputStream(var8.func_22324_a().getInputStream()));
|
||||
DataOutputStream var13 = var11.func_22205_b(var9 & 31, var10 & 31);
|
||||
boolean var14 = false;
|
||||
|
||||
while(true) {
|
||||
int var17 = var12.read(var6);
|
||||
if(var17 == -1) {
|
||||
var13.close();
|
||||
var12.close();
|
||||
break;
|
||||
}
|
||||
|
||||
var13.write(var6, 0, var17);
|
||||
}
|
||||
} catch (IOException var15) {
|
||||
var15.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
++var3;
|
||||
int var16 = (int)Math.round(100.0D * (double)var3 / (double)var4);
|
||||
var5.setLoadingProgress(var16);
|
||||
}
|
||||
|
||||
RegionFileCache.func_22192_a();
|
||||
}
|
||||
|
||||
private void func_22182_a(ArrayList var1, int var2, int var3, IProgressUpdate var4) {
|
||||
Iterator var5 = var1.iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
VFile2 var6 = (VFile2)var5.next();
|
||||
VFile2[] var7 = (VFile2[]) var6.listFiles(true).toArray();
|
||||
deleteWorldFiles(var7);
|
||||
var6.delete();
|
||||
++var2;
|
||||
int var8 = (int)Math.round(100.0D * (double)var2 / (double)var3);
|
||||
var4.setLoadingProgress(var8);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.internal.vfs2.VFile2;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SaveFormatOld implements ISaveFormat {
|
||||
protected final VFile2 worldFile;
|
||||
|
||||
public SaveFormatOld(VFile2 var1) {
|
||||
this.worldFile = var1;
|
||||
}
|
||||
|
||||
public String formatName() {
|
||||
return "Old Format";
|
||||
}
|
||||
|
||||
public List getWorldList() {
|
||||
ArrayList var1 = new ArrayList();
|
||||
|
||||
for(int var2 = 0; var2 < 5; ++var2) {
|
||||
String var3 = "World" + (var2 + 1);
|
||||
WorldInfo var4 = this.getWorldInfoForWorld(var3);
|
||||
if(var4 != null) {
|
||||
var1.add(new SaveFormatComparator(var3, "", var4.getLastTimePlayed(), var4.getSizeOnDisk(), false));
|
||||
}
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
|
||||
public void flushCache() {
|
||||
}
|
||||
|
||||
public WorldInfo getWorldInfoForWorld(String var1) {
|
||||
VFile2 var2 = new VFile2(var1);
|
||||
if (var2.getPath().contains("level.dat")) {
|
||||
try {
|
||||
NBTTagCompound var4 = CompressedStreamTools.readCompressed(var2.getInputStream());
|
||||
NBTTagCompound var5 = var4.getCompoundTag("Data");
|
||||
return new WorldInfo(var5);
|
||||
} catch (Exception var6) {
|
||||
var6.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void renameWorldData(String var1, String var2) {
|
||||
VFile2 var3 = new VFile2(this.worldFile, var1);
|
||||
System.out.println(var3.exists());
|
||||
if(var3.exists()) {
|
||||
VFile2 var4 = new VFile2(var3, "level.dat");
|
||||
if(var4.exists()) {
|
||||
try {
|
||||
NBTTagCompound var5 = CompressedStreamTools.readCompressed(var4.getInputStream());
|
||||
NBTTagCompound var6 = var5.getCompoundTag("Data");
|
||||
var6.setString("LevelName", var2);
|
||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(var5, var4.getOutputStream());
|
||||
} catch (Exception var7) {
|
||||
var7.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteWorldByDirectory(String var1) {
|
||||
VFile2 var3 = new VFile2("saves", var1);
|
||||
System.out.println(var3.getPath());
|
||||
if(var3.dirExists()) {
|
||||
List<VFile2> files = var3.listFiles(true);
|
||||
deleteWorldFiles(files.toArray(new VFile2[0]));
|
||||
var3.delete();
|
||||
}
|
||||
}
|
||||
|
||||
protected static void deleteWorldFiles(VFile2[] var0) {
|
||||
for(int var1 = 0; var1 < var0.length; ++var1) {
|
||||
var0[var1].delete();
|
||||
}
|
||||
}
|
||||
|
||||
public ISaveHandler getSaveLoader(String var1, boolean var2) {
|
||||
return new SaveHandler(this.worldFile, var1, var2);
|
||||
}
|
||||
|
||||
public boolean isOldMapFormat(String var1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean convertMapFormat(String var1, IProgressUpdate var2) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.internal.vfs2.VFile2;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SaveHandler implements ISaveHandler {
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final VFile2 saveDirectory;
|
||||
private final VFile2 playersDirectory;
|
||||
private final long now = System.currentTimeMillis();
|
||||
|
||||
public SaveHandler(VFile2 var1, String var2, boolean var3) {
|
||||
this.saveDirectory = new VFile2(var1.getName(), var2);
|
||||
this.playersDirectory = new VFile2(this.saveDirectory, "players");
|
||||
}
|
||||
|
||||
protected VFile2 getSaveDirectory() {
|
||||
return this.saveDirectory;
|
||||
}
|
||||
|
||||
public IChunkLoader getChunkLoader(WorldProvider var1) {
|
||||
if(var1 instanceof WorldProviderHell) {
|
||||
VFile2 var2 = new VFile2(this.saveDirectory, "DIM-1");
|
||||
// var2.mkdirs();
|
||||
return new ChunkLoader(var2, true);
|
||||
} else {
|
||||
return new ChunkLoader(this.saveDirectory, true);
|
||||
}
|
||||
}
|
||||
|
||||
public WorldInfo loadWorldInfo() {
|
||||
VFile2 var1 = new VFile2(this.saveDirectory, "level.dat");
|
||||
if(var1.exists()) {
|
||||
try {
|
||||
NBTTagCompound var2 = CompressedStreamTools.readCompressed(var1.getInputStream());
|
||||
NBTTagCompound var3 = var2.getCompoundTag("Data");
|
||||
return new WorldInfo(var3);
|
||||
} catch (Exception var4) {
|
||||
var4.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void saveWorldInfoAndPlayer(WorldInfo var1, List var2) {
|
||||
NBTTagCompound var3 = var1.getNBTTagCompoundWithPlayer(var2);
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setTag("Data", var3);
|
||||
|
||||
try {
|
||||
VFile2 var5 = new VFile2(this.saveDirectory, "level.dat_new");
|
||||
VFile2 var6 = new VFile2(this.saveDirectory, "level.dat_old");
|
||||
VFile2 var7 = new VFile2(this.saveDirectory, "level.dat");
|
||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(var4, var5.getOutputStream());
|
||||
if(var6.exists()) {
|
||||
var6.delete();
|
||||
}
|
||||
|
||||
var7.renameTo(var6);
|
||||
if(var7.exists()) {
|
||||
var7.delete();
|
||||
}
|
||||
|
||||
var5.renameTo(var7);
|
||||
if(var5.exists()) {
|
||||
var5.delete();
|
||||
}
|
||||
} catch (Exception var8) {
|
||||
var8.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveWorldInfo(WorldInfo var1) {
|
||||
NBTTagCompound var2 = var1.getNBTTagCompound();
|
||||
NBTTagCompound var3 = new NBTTagCompound();
|
||||
var3.setTag("Data", var2);
|
||||
|
||||
try {
|
||||
VFile2 var4 = new VFile2(this.saveDirectory, "level.dat_new");
|
||||
VFile2 var5 = new VFile2(this.saveDirectory, "level.dat_old");
|
||||
VFile2 var6 = new VFile2(this.saveDirectory, "level.dat");
|
||||
CompressedStreamTools.writeGzippedCompoundToOutputStream(var3, var4.getOutputStream());
|
||||
if(var5.exists()) {
|
||||
var5.delete();
|
||||
}
|
||||
|
||||
var6.renameTo(var5);
|
||||
if(var6.exists()) {
|
||||
var6.delete();
|
||||
}
|
||||
|
||||
var4.renameTo(var6);
|
||||
if(var4.exists()) {
|
||||
var4.delete();
|
||||
}
|
||||
} catch (Exception var7) {
|
||||
var7.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.internal.vfs2.VFile2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SaveOldDir extends SaveHandler {
|
||||
public SaveOldDir(VFile2 var1, String var2, boolean var3) {
|
||||
super(var1, var2, var3);
|
||||
}
|
||||
|
||||
public IChunkLoader getChunkLoader(WorldProvider var1) {
|
||||
VFile2 var2 = this.getSaveDirectory();
|
||||
if(var1 instanceof WorldProviderHell) {
|
||||
VFile2 var3 = new VFile2(var2, "DIM-1");
|
||||
//var3.mkdirs();
|
||||
return new McRegionChunkLoader(var3);
|
||||
} else {
|
||||
return new McRegionChunkLoader(var2);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveWorldInfoAndPlayer(WorldInfo var1, List var2) {
|
||||
var1.setSaveVersion(19132);
|
||||
super.saveWorldInfoAndPlayer(var1, var2);
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ public class World implements IBlockAccess {
|
||||
protected int field_9437_g;
|
||||
protected int field_9436_h;
|
||||
public boolean editingBlocks;
|
||||
private long lockTimestamp;
|
||||
public long lockTimestamp;
|
||||
protected int autosavePeriod;
|
||||
public int difficultySetting;
|
||||
public Random rand;
|
||||
|
Loading…
x
Reference in New Issue
Block a user