rewrote chunk storage to use single files (anvil still available via args[])
This commit is contained in:
parent
699997d652
commit
d39e81ff72
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -7,6 +7,7 @@ bin
|
||||||
/epkcompiler/bin
|
/epkcompiler/bin
|
||||||
/eaglercraftbungee/rundir
|
/eaglercraftbungee/rundir
|
||||||
/lwjgl-rundir/_eagstorage*
|
/lwjgl-rundir/_eagstorage*
|
||||||
/lwjgl-rundir/saves
|
/lwjgl-rundir/lwjgl_saves
|
||||||
|
/lwjgl-rundir/filesystem
|
||||||
/lwjgl-rundir/texturepacks
|
/lwjgl-rundir/texturepacks
|
||||||
/lwjgl-rundir/options.txt
|
/lwjgl-rundir/options.txt
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package net.lax1dude.eaglercraft;
|
package net.lax1dude.eaglercraft;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import net.lax1dude.eaglercraft.anvil.SaveConverterMcRegion;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class MinecraftMain {
|
public class MinecraftMain {
|
||||||
|
@ -12,6 +15,13 @@ public class MinecraftMain {
|
||||||
JOptionPane.PLAIN_MESSAGE);
|
JOptionPane.PLAIN_MESSAGE);
|
||||||
EaglerAdapter.initializeContext();
|
EaglerAdapter.initializeContext();
|
||||||
|
|
||||||
|
for(int i = 0; i < par0ArrayOfStr.length; ++i) {
|
||||||
|
String arg = par0ArrayOfStr[i];
|
||||||
|
if("--anvilSaveFormat".equalsIgnoreCase(arg)) {
|
||||||
|
EaglerAdapter.configureSaveFormat(new SaveConverterMcRegion(new File("lwjgl_saves")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LocalStorageManager.loadStorage(); byte[] b =
|
* LocalStorageManager.loadStorage(); byte[] b =
|
||||||
* EaglerAdapter.loadLocalStorage("forced"); if(b != null) {
|
* EaglerAdapter.loadLocalStorage("forced"); if(b != null) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -29,6 +30,8 @@ import java.nio.ByteOrder;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -65,9 +68,8 @@ import org.lwjgl.util.glu.GLU;
|
||||||
import de.cuina.fireandfuel.CodecJLayerMP3;
|
import de.cuina.fireandfuel.CodecJLayerMP3;
|
||||||
import net.lax1dude.eaglercraft.AssetRepository;
|
import net.lax1dude.eaglercraft.AssetRepository;
|
||||||
import net.lax1dude.eaglercraft.EarlyLoadScreen;
|
import net.lax1dude.eaglercraft.EarlyLoadScreen;
|
||||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.ProgramGL;
|
|
||||||
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.RateLimit;
|
|
||||||
import net.lax1dude.eaglercraft.adapter.lwjgl.GameWindowListener;
|
import net.lax1dude.eaglercraft.adapter.lwjgl.GameWindowListener;
|
||||||
|
import net.minecraft.src.ISaveFormat;
|
||||||
import net.minecraft.src.MathHelper;
|
import net.minecraft.src.MathHelper;
|
||||||
import paulscode.sound.SoundSystem;
|
import paulscode.sound.SoundSystem;
|
||||||
import paulscode.sound.SoundSystemConfig;
|
import paulscode.sound.SoundSystemConfig;
|
||||||
|
@ -1550,6 +1552,215 @@ public class EaglerAdapterImpl2 {
|
||||||
return serverToJoinOnLaunch;
|
return serverToJoinOnLaunch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final File filesystemBaseDirectory = new File("./filesystem");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filesystemBaseDirectory.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======== Virtual Filesystem Functions =============
|
||||||
|
|
||||||
|
public static final boolean fileExists(String path) {
|
||||||
|
return (new File(filesystemBaseDirectory, stripPath(path))).isFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final boolean directoryExists(String path) {
|
||||||
|
return (new File(filesystemBaseDirectory, stripPath(path))).isDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void writeFile(String path, byte[] data) {
|
||||||
|
try {
|
||||||
|
File f = new File(filesystemBaseDirectory, stripPath(path));
|
||||||
|
File p = f.getParentFile();
|
||||||
|
if(p != null) {
|
||||||
|
p.mkdirs();
|
||||||
|
}
|
||||||
|
FileOutputStream os = new FileOutputStream(f);
|
||||||
|
os.write(data);
|
||||||
|
os.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final byte[] readFile(String path) {
|
||||||
|
File f = new File(filesystemBaseDirectory, stripPath(path));
|
||||||
|
if(!f.isFile()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
byte[] ret = new byte[(int)f.length()];
|
||||||
|
FileInputStream in = new FileInputStream(f);
|
||||||
|
in.read(ret);
|
||||||
|
in.close();
|
||||||
|
return ret;
|
||||||
|
}catch(IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final long getLastModified(String path) {
|
||||||
|
return (new File(filesystemBaseDirectory, stripPath(path))).lastModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void setLastModified(String path, long t) {
|
||||||
|
(new File(filesystemBaseDirectory, stripPath(path))).setLastModified(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void touchFile(String path) {
|
||||||
|
(new File(filesystemBaseDirectory, stripPath(path))).setLastModified(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int getFileSize(String path) {
|
||||||
|
return (int)(new File(filesystemBaseDirectory, stripPath(path))).length();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void renameFile(String oldPath, String newPath) {
|
||||||
|
File f1 = new File(filesystemBaseDirectory, stripPath(oldPath));
|
||||||
|
File f2 = new File(filesystemBaseDirectory, stripPath(newPath));
|
||||||
|
if(f1.exists()) {
|
||||||
|
if(f2.exists()) {
|
||||||
|
try {
|
||||||
|
FileInputStream fs1 = new FileInputStream(f1);
|
||||||
|
FileOutputStream fs2 = new FileOutputStream(f2);
|
||||||
|
byte[] buffer = new byte[1024 * 64];
|
||||||
|
int a;
|
||||||
|
while((a = fs1.read(buffer)) > 0) {
|
||||||
|
fs2.write(buffer, 0, a);
|
||||||
|
}
|
||||||
|
fs1.close();
|
||||||
|
fs2.close();
|
||||||
|
f1.delete();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Copy from '" + oldPath + "' to '" + newPath + "' failed");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
File p = f2.getParentFile();
|
||||||
|
if(p != null) {
|
||||||
|
p.mkdirs();
|
||||||
|
}
|
||||||
|
f1.renameTo(f2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void copyFile(String oldPath, String newPath) {
|
||||||
|
try {
|
||||||
|
File ff2 = new File(filesystemBaseDirectory, stripPath(newPath));
|
||||||
|
File p = ff2.getParentFile();
|
||||||
|
if(p != null) {
|
||||||
|
p.mkdirs();
|
||||||
|
}
|
||||||
|
FileInputStream f1 = new FileInputStream(new File(filesystemBaseDirectory, stripPath(oldPath)));
|
||||||
|
FileOutputStream f2 = new FileOutputStream(ff2);
|
||||||
|
byte[] buffer = new byte[1024 * 64];
|
||||||
|
int a;
|
||||||
|
while((a = f1.read(buffer)) > 0) {
|
||||||
|
f2.write(buffer, 0, a);
|
||||||
|
}
|
||||||
|
f1.close();
|
||||||
|
f2.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Copy from '" + oldPath + "' to '" + newPath + "' failed");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void deleteFile(String path) {
|
||||||
|
(new File(filesystemBaseDirectory, stripPath(path))).delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFiles(String path, boolean listDirs, boolean recursiveDirs) {
|
||||||
|
path = stripPath(path);
|
||||||
|
ArrayList<FileEntry> ret = new ArrayList<>();
|
||||||
|
File f = new File(filesystemBaseDirectory, path);
|
||||||
|
if(f.isFile()) {
|
||||||
|
ret.add(new FileEntry(path, false, f.lastModified(), (int)f.length()));
|
||||||
|
}else if(f.isDirectory()) {
|
||||||
|
for(File ff : f.listFiles()) {
|
||||||
|
if(ff.isDirectory()) {
|
||||||
|
if(listDirs && !recursiveDirs) {
|
||||||
|
ret.add(new FileEntry(path + "/" + ff.getName(), true, -1l, -1));
|
||||||
|
}
|
||||||
|
if(recursiveDirs) {
|
||||||
|
recursiveListing(path + "/" + ff.getName(), ff, ret, listDirs, recursiveDirs);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
ret.add(new FileEntry(path + "/" + ff.getName(), false, ff.lastModified(), (int)ff.length()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void recursiveListing(String path, File f, Collection<FileEntry> lst, boolean listDirs, boolean recursiveDirs) {
|
||||||
|
if(f.isFile()) {
|
||||||
|
lst.add(new FileEntry(path, false, f.lastModified(), (int)f.length()));
|
||||||
|
}else if(f.isDirectory()) {
|
||||||
|
if(listDirs) {
|
||||||
|
lst.add(new FileEntry(path, true, -1l, -1));
|
||||||
|
}
|
||||||
|
if(recursiveDirs) {
|
||||||
|
for(File ff : f.listFiles()) {
|
||||||
|
recursiveListing(path + "/" + ff.getName(), ff, lst, listDirs, recursiveDirs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFilesAndDirectories(String path) {
|
||||||
|
return listFiles(path, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Collection<FileEntry> listFilesRecursive(String path) {
|
||||||
|
return listFiles(path, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FileEntry {
|
||||||
|
|
||||||
|
public final String path;
|
||||||
|
public final boolean isDirectory;
|
||||||
|
public final long lastModified;
|
||||||
|
public final int fileSize;
|
||||||
|
|
||||||
|
protected FileEntry(String path, boolean isDirectory, long lastModified, int fileSize) {
|
||||||
|
this.path = path;
|
||||||
|
this.isDirectory = isDirectory;
|
||||||
|
this.lastModified = lastModified;
|
||||||
|
this.fileSize = fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
int i = path.indexOf('/');
|
||||||
|
if(i >= 0) {
|
||||||
|
return path.substring(i + 1);
|
||||||
|
}else {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String stripPath(String str) {
|
||||||
|
if(str.startsWith("/")) {
|
||||||
|
str = str.substring(1);
|
||||||
|
}
|
||||||
|
if(str.endsWith("/")) {
|
||||||
|
str = str.substring(0, str.length() - 1);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ISaveFormat svformat = null;
|
||||||
|
|
||||||
|
public static final void configureSaveFormat(ISaveFormat fmt) {
|
||||||
|
svformat = fmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final ISaveFormat getConfiguredSaveFormat() {
|
||||||
|
return svformat;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
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.func_1138_a(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.func_22297_b(worldinfo.func_22306_g() - 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.func_22297_b(worldinfo1.func_22306_g() + 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;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
||||||
|
@ -6,6 +6,14 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.io.*;
|
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 class McRegionChunkLoader implements IChunkLoader {
|
||||||
|
|
||||||
public McRegionChunkLoader(File file) {
|
public McRegionChunkLoader(File file) {
|
||||||
|
@ -36,7 +44,7 @@ public class McRegionChunkLoader implements IChunkLoader {
|
||||||
.append(" is missing block data, skipping").toString());
|
.append(" is missing block data, skipping").toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Chunk chunk = ChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
Chunk chunk = EaglercraftChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
||||||
if (!chunk.isAtLocation(i, j)) {
|
if (!chunk.isAtLocation(i, j)) {
|
||||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(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(" is in the wrong location; relocating. (Expected ").append(i).append(", ").append(j)
|
||||||
|
@ -44,7 +52,7 @@ public class McRegionChunkLoader implements IChunkLoader {
|
||||||
.toString());
|
.toString());
|
||||||
nbttagcompound.setInteger("xPos", i);
|
nbttagcompound.setInteger("xPos", i);
|
||||||
nbttagcompound.setInteger("zPos", j);
|
nbttagcompound.setInteger("zPos", j);
|
||||||
chunk = ChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
chunk = EaglercraftChunkLoader.loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
||||||
}
|
}
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +65,7 @@ public class McRegionChunkLoader implements IChunkLoader {
|
||||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||||
nbttagcompound.setTag("Level", nbttagcompound1);
|
nbttagcompound.setTag("Level", nbttagcompound1);
|
||||||
ChunkLoader.storeChunkInCompound(chunk, world, nbttagcompound1);
|
EaglercraftChunkLoader.storeChunkInCompound(chunk, world, nbttagcompound1);
|
||||||
CompressedStreamTools.func_1139_a(nbttagcompound, dataoutputstream);
|
CompressedStreamTools.func_1139_a(nbttagcompound, dataoutputstream);
|
||||||
dataoutputstream.close();
|
dataoutputstream.close();
|
||||||
WorldInfo worldinfo = world.func_22144_v();
|
WorldInfo worldinfo = world.func_22144_v();
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
||||||
|
@ -8,17 +8,23 @@ import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.zip.GZIPInputStream;
|
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 class SaveConverterMcRegion extends SaveFormatOld {
|
||||||
|
|
||||||
public SaveConverterMcRegion(File file) {
|
public SaveConverterMcRegion(File file) {
|
||||||
super(file);
|
super(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String func_22178_a() {
|
public String formatName() {
|
||||||
return "Scaevolus' McRegion";
|
return "Scaevolus' McRegion";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List func_22176_b() {
|
public List getWorldList() {
|
||||||
ArrayList arraylist = new ArrayList();
|
ArrayList arraylist = new ArrayList();
|
||||||
File afile[] = field_22180_a.listFiles();
|
File afile[] = field_22180_a.listFiles();
|
||||||
File afile1[] = afile;
|
File afile1[] = afile;
|
||||||
|
@ -29,7 +35,7 @@ public class SaveConverterMcRegion extends SaveFormatOld {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String s = file.getName();
|
String s = file.getName();
|
||||||
WorldInfo worldinfo = func_22173_b(s);
|
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||||
if (worldinfo == null) {
|
if (worldinfo == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -44,20 +50,20 @@ public class SaveConverterMcRegion extends SaveFormatOld {
|
||||||
return arraylist;
|
return arraylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22177_c() {
|
public void flushCache() {
|
||||||
RegionFileCache.func_22192_a();
|
RegionFileCache.func_22192_a();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISaveHandler func_22174_a(String s, boolean flag) {
|
public ISaveHandler loadWorldHandler(String s, boolean flag) {
|
||||||
return new SaveOldDir(field_22180_a, s, flag);
|
return new SaveOldDir(field_22180_a, s, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_22175_a(String s) {
|
public boolean worldNeedsConvert_maybe(String s) {
|
||||||
WorldInfo worldinfo = func_22173_b(s);
|
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||||
return worldinfo != null && worldinfo.func_22296_k() == 0;
|
return worldinfo != null && worldinfo.func_22296_k() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_22171_a(String s, IProgressUpdate iprogressupdate) {
|
public boolean convertSave(String s, IProgressUpdate iprogressupdate) {
|
||||||
iprogressupdate.setLoadingProgress(0);
|
iprogressupdate.setLoadingProgress(0);
|
||||||
ArrayList arraylist = new ArrayList();
|
ArrayList arraylist = new ArrayList();
|
||||||
ArrayList arraylist1 = new ArrayList();
|
ArrayList arraylist1 = new ArrayList();
|
||||||
|
@ -74,10 +80,10 @@ public class SaveConverterMcRegion extends SaveFormatOld {
|
||||||
System.out.println((new StringBuilder()).append("Total conversion count is ").append(i).toString());
|
System.out.println((new StringBuilder()).append("Total conversion count is ").append(i).toString());
|
||||||
func_22181_a(file, arraylist, 0, i, iprogressupdate);
|
func_22181_a(file, arraylist, 0, i, iprogressupdate);
|
||||||
func_22181_a(file1, arraylist2, arraylist.size(), i, iprogressupdate);
|
func_22181_a(file1, arraylist2, arraylist.size(), i, iprogressupdate);
|
||||||
WorldInfo worldinfo = func_22173_b(s);
|
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||||
worldinfo.func_22289_d(19132);
|
worldinfo.func_22289_d(19132);
|
||||||
ISaveHandler isavehandler = func_22174_a(s, false);
|
ISaveHandler isavehandler = loadWorldHandler(s, false);
|
||||||
isavehandler.func_22152_a(worldinfo);
|
isavehandler.saveWorldInfo(worldinfo);
|
||||||
func_22182_a(arraylist1, arraylist.size() + arraylist2.size(), i, iprogressupdate);
|
func_22182_a(arraylist1, arraylist.size() + arraylist2.size(), i, iprogressupdate);
|
||||||
if (file1.exists()) {
|
if (file1.exists()) {
|
||||||
func_22182_a(arraylist3, arraylist.size() + arraylist2.size() + arraylist1.size(), i, iprogressupdate);
|
func_22182_a(arraylist3, arraylist.size() + arraylist2.size() + arraylist1.size(), i, iprogressupdate);
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
||||||
|
@ -8,6 +8,14 @@ import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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 class SaveFormatOld implements ISaveFormat {
|
||||||
|
|
||||||
public SaveFormatOld(File file) {
|
public SaveFormatOld(File file) {
|
||||||
|
@ -17,15 +25,15 @@ public class SaveFormatOld implements ISaveFormat {
|
||||||
field_22180_a = file;
|
field_22180_a = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String func_22178_a() {
|
public String formatName() {
|
||||||
return "Old Format";
|
return "Old Format";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List func_22176_b() {
|
public List getWorldList() {
|
||||||
ArrayList arraylist = new ArrayList();
|
ArrayList arraylist = new ArrayList();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
String s = (new StringBuilder()).append("World").append(i + 1).toString();
|
String s = (new StringBuilder()).append("World").append(i + 1).toString();
|
||||||
WorldInfo worldinfo = func_22173_b(s);
|
WorldInfo worldinfo = getWorldInfoForWorld(s);
|
||||||
if (worldinfo != null) {
|
if (worldinfo != null) {
|
||||||
arraylist.add(
|
arraylist.add(
|
||||||
new SaveFormatComparator(s, "", worldinfo.func_22301_l(), worldinfo.func_22306_g(), false));
|
new SaveFormatComparator(s, "", worldinfo.func_22301_l(), worldinfo.func_22306_g(), false));
|
||||||
|
@ -35,10 +43,10 @@ public class SaveFormatOld implements ISaveFormat {
|
||||||
return arraylist;
|
return arraylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22177_c() {
|
public void flushCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldInfo func_22173_b(String s) {
|
public WorldInfo getWorldInfoForWorld(String s) {
|
||||||
File file = new File(field_22180_a, s);
|
File file = new File(field_22180_a, s);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -56,7 +64,7 @@ public class SaveFormatOld implements ISaveFormat {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22170_a(String s, String s1) {
|
public void renameWorldData(String s, String s1) {
|
||||||
File file = new File(field_22180_a, s);
|
File file = new File(field_22180_a, s);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return;
|
return;
|
||||||
|
@ -74,7 +82,7 @@ public class SaveFormatOld implements ISaveFormat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22172_c(String s) {
|
public void deleteWorldByDirectory(String s) {
|
||||||
File file = new File(field_22180_a, s);
|
File file = new File(field_22180_a, s);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return;
|
return;
|
||||||
|
@ -95,15 +103,15 @@ public class SaveFormatOld implements ISaveFormat {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISaveHandler func_22174_a(String s, boolean flag) {
|
public ISaveHandler loadWorldHandler(String s, boolean flag) {
|
||||||
return new SaveHandler(field_22180_a, s, flag);
|
return new SaveHandler(field_22180_a, s, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_22175_a(String s) {
|
public boolean worldNeedsConvert_maybe(String s) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_22171_a(String s, IProgressUpdate iprogressupdate) {
|
public boolean convertSave(String s, IProgressUpdate iprogressupdate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
||||||
|
@ -8,6 +8,15 @@ import java.io.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
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 class SaveHandler implements ISaveHandler {
|
||||||
|
|
||||||
public SaveHandler(File file, String s, boolean flag) {
|
public SaveHandler(File file, String s, boolean flag) {
|
||||||
|
@ -39,7 +48,7 @@ public class SaveHandler implements ISaveHandler {
|
||||||
return field_22155_b;
|
return field_22155_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22150_b() {
|
public void checkSessionLock() {
|
||||||
try {
|
try {
|
||||||
File file = new File(field_22155_b, "session.lock");
|
File file = new File(field_22155_b, "session.lock");
|
||||||
DataInputStream datainputstream = new DataInputStream(new FileInputStream(file));
|
DataInputStream datainputstream = new DataInputStream(new FileInputStream(file));
|
||||||
|
@ -55,7 +64,7 @@ public class SaveHandler implements ISaveHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IChunkLoader func_22149_a(WorldProvider worldprovider) {
|
public IChunkLoader getChunkLoader(WorldProvider worldprovider) {
|
||||||
if (worldprovider instanceof WorldProviderHell) {
|
if (worldprovider instanceof WorldProviderHell) {
|
||||||
File file = new File(field_22155_b, "DIM-1");
|
File file = new File(field_22155_b, "DIM-1");
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
|
@ -65,7 +74,7 @@ public class SaveHandler implements ISaveHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldInfo func_22151_c() {
|
public WorldInfo getWorldInfo() {
|
||||||
File file = new File(field_22155_b, "level.dat");
|
File file = new File(field_22155_b, "level.dat");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
try {
|
try {
|
||||||
|
@ -79,7 +88,7 @@ public class SaveHandler implements ISaveHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22148_a(WorldInfo worldinfo, List list) {
|
public void saveWorldAndPlayer(WorldInfo worldinfo, List list) {
|
||||||
NBTTagCompound nbttagcompound = worldinfo.func_22305_a(list);
|
NBTTagCompound nbttagcompound = worldinfo.func_22305_a(list);
|
||||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||||
nbttagcompound1.setTag("Data", nbttagcompound);
|
nbttagcompound1.setTag("Data", nbttagcompound);
|
||||||
|
@ -104,7 +113,7 @@ public class SaveHandler implements ISaveHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22152_a(WorldInfo worldinfo) {
|
public void saveWorldInfo(WorldInfo worldinfo) {
|
||||||
NBTTagCompound nbttagcompound = worldinfo.func_22299_a();
|
NBTTagCompound nbttagcompound = worldinfo.func_22299_a();
|
||||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||||
nbttagcompound1.setTag("Data", nbttagcompound);
|
nbttagcompound1.setTag("Data", nbttagcompound);
|
|
@ -0,0 +1,35 @@
|
||||||
|
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.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.src.IChunkLoader;
|
||||||
|
import net.minecraft.src.ISaveHandler;
|
||||||
|
import net.minecraft.src.WorldInfo;
|
||||||
|
import net.minecraft.src.WorldProvider;
|
||||||
|
|
||||||
|
public class SaveHandlerMP implements ISaveHandler {
|
||||||
|
|
||||||
|
public SaveHandlerMP() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldInfo getWorldInfo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkSessionLock() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public IChunkLoader getChunkLoader(WorldProvider worldprovider) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveWorldAndPlayer(WorldInfo worldinfo, List list) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveWorldInfo(WorldInfo worldinfo) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.anvil;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
// Jad home page: http://www.kpdus.com/jad.html
|
||||||
|
@ -7,13 +7,18 @@ package net.minecraft.src;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
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 class SaveOldDir extends SaveHandler {
|
||||||
|
|
||||||
public SaveOldDir(File file, String s, boolean flag) {
|
public SaveOldDir(File file, String s, boolean flag) {
|
||||||
super(file, s, flag);
|
super(file, s, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IChunkLoader func_22149_a(WorldProvider worldprovider) {
|
public IChunkLoader getChunkLoader(WorldProvider worldprovider) {
|
||||||
File file = func_22153_a();
|
File file = func_22153_a();
|
||||||
if (worldprovider instanceof WorldProviderHell) {
|
if (worldprovider instanceof WorldProviderHell) {
|
||||||
File file1 = new File(file, "DIM-1");
|
File file1 = new File(file, "DIM-1");
|
||||||
|
@ -24,8 +29,8 @@ public class SaveOldDir extends SaveHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_22148_a(WorldInfo worldinfo, List list) {
|
public void saveWorldAndPlayer(WorldInfo worldinfo, List list) {
|
||||||
worldinfo.func_22289_d(19132);
|
worldinfo.func_22289_d(19132);
|
||||||
super.func_22148_a(worldinfo, list);
|
super.saveWorldAndPlayer(worldinfo, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
60
src/main/java/net/lax1dude/eaglercraft/beta/EPKCompiler.java
Normal file
60
src/main/java/net/lax1dude/eaglercraft/beta/EPKCompiler.java
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
package net.lax1dude.eaglercraft.beta;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
import com.jcraft.jzlib.Deflater;
|
||||||
|
import com.jcraft.jzlib.DeflaterOutputStream;
|
||||||
|
|
||||||
|
import net.lax1dude.eaglercraft.SHA1Digest;
|
||||||
|
|
||||||
|
public class EPKCompiler {
|
||||||
|
|
||||||
|
private final ByteArrayOutputStream osb = new ByteArrayOutputStream();
|
||||||
|
private DataOutputStream os;
|
||||||
|
private Deflater d;
|
||||||
|
private final SHA1Digest dig = new SHA1Digest();
|
||||||
|
|
||||||
|
public EPKCompiler(String name) {
|
||||||
|
try {
|
||||||
|
d = new Deflater(9);
|
||||||
|
os = new DataOutputStream(osb);
|
||||||
|
os.write("EAGPKG!!".getBytes(Charset.forName("UTF-8")));
|
||||||
|
os.writeUTF("\n\n # eaglercraft package file - " + name + "\n # eagler eagler eagler eagler eagler eagler eagler\n\n");
|
||||||
|
d = new Deflater(9);
|
||||||
|
os = new DataOutputStream(new DeflaterOutputStream(osb, d));
|
||||||
|
}catch(Throwable t) {
|
||||||
|
throw new RuntimeException("this happened somehow", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void append(String name, byte[] dat) {
|
||||||
|
try {
|
||||||
|
os.writeUTF("<file>");
|
||||||
|
os.writeUTF(name);
|
||||||
|
byte[] v = dat;
|
||||||
|
dig.update(v, 0, v.length);
|
||||||
|
byte[] final_ = new byte[20];
|
||||||
|
dig.doFinal(final_, 0);
|
||||||
|
os.write(final_);
|
||||||
|
os.writeInt(v.length);
|
||||||
|
os.write(v);
|
||||||
|
os.writeUTF("</file>");
|
||||||
|
}catch(Throwable t) {
|
||||||
|
throw new RuntimeException("this happened somehow", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] complete() {
|
||||||
|
try {
|
||||||
|
os.writeUTF(" end");
|
||||||
|
os.flush();
|
||||||
|
os.close();
|
||||||
|
return osb.toByteArray();
|
||||||
|
}catch(Throwable t) {
|
||||||
|
throw new RuntimeException("this happened somehow", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package net.lax1dude.eaglercraft.beta;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.jcraft.jzlib.InflaterInputStream;
|
||||||
|
|
||||||
|
import net.lax1dude.eaglercraft.SHA1Digest;
|
||||||
|
|
||||||
|
public class EPKDecompiler {
|
||||||
|
|
||||||
|
public static class FileEntry {
|
||||||
|
public final String name;
|
||||||
|
public final byte[] data;
|
||||||
|
protected FileEntry(String name, byte[] data) {
|
||||||
|
this.name = name;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final ByteArrayInputStream in2;
|
||||||
|
private DataInputStream in;
|
||||||
|
private SHA1Digest dg = new SHA1Digest();
|
||||||
|
private boolean isFinished = false;
|
||||||
|
|
||||||
|
public EPKDecompiler(byte[] data) throws IOException {
|
||||||
|
in2 = new ByteArrayInputStream(data);
|
||||||
|
in = new DataInputStream(in2);
|
||||||
|
byte[] header = new byte[8];
|
||||||
|
in.read(header);
|
||||||
|
if(!"EAGPKG!!".equals(new String(header, Charset.forName("UTF-8")))) throw new IOException("invalid epk file");
|
||||||
|
in.readUTF();
|
||||||
|
in = new DataInputStream(new InflaterInputStream(in2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileEntry readFile() throws IOException {
|
||||||
|
if(isFinished) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String s = in.readUTF();
|
||||||
|
if(s.equals(" end")) {
|
||||||
|
isFinished = true;
|
||||||
|
return null;
|
||||||
|
}else if(!s.equals("<file>")) {
|
||||||
|
throw new IOException("invalid epk file");
|
||||||
|
}
|
||||||
|
String path = in.readUTF();
|
||||||
|
byte[] digest = new byte[20];
|
||||||
|
byte[] digest2 = new byte[20];
|
||||||
|
in.read(digest);
|
||||||
|
int len = in.readInt();
|
||||||
|
byte[] file = new byte[len];
|
||||||
|
in.read(file);
|
||||||
|
dg.update(file, 0, len); dg.doFinal(digest2, 0);
|
||||||
|
if(!Arrays.equals(digest, digest2)) throw new IOException("invalid file hash for "+path);
|
||||||
|
if(!"</file>".equals(in.readUTF())) throw new IOException("invalid epk file");
|
||||||
|
return new FileEntry(path, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,148 +1,104 @@
|
||||||
package net.minecraft.src;
|
package net.lax1dude.eaglercraft.beta;
|
||||||
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
|
||||||
|
|
||||||
// Jad home page: http://www.kpdus.com/jad.html
|
import java.io.ByteArrayInputStream;
|
||||||
// Decompiler options: packimports(3) braces deadcode
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import java.io.*;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
import java.util.*;
|
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 ChunkLoader implements IChunkLoader {
|
public class EaglercraftChunkLoader implements IChunkLoader {
|
||||||
|
|
||||||
public ChunkLoader(File file, boolean flag) {
|
public final String directory;
|
||||||
saveDir = file;
|
|
||||||
createIfNecessary = flag;
|
public EaglercraftChunkLoader(String dir) {
|
||||||
|
this.directory = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private File chunkFileForXZ(int i, int j) {
|
@Override
|
||||||
String s = (new StringBuilder()).append("c.").append(Integer.toString(i, 36)).append(".")
|
public Chunk loadChunk(World world, int x, int z) {
|
||||||
.append(Integer.toString(j, 36)).append(".dat").toString();
|
String name = getChunkPath(x, z);
|
||||||
String s1 = Integer.toString(i & 0x3f, 36);
|
String path = directory + "/" + name;
|
||||||
String s2 = Integer.toString(j & 0x3f, 36);
|
byte[] dat = EaglerAdapter.readFile(path);
|
||||||
File file = new File(saveDir, s1);
|
if(dat != null) {
|
||||||
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 {
|
try {
|
||||||
FileInputStream fileinputstream = new FileInputStream(file);
|
NBTTagCompound nbt = (NBTTagCompound) NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(dat)));
|
||||||
NBTTagCompound nbttagcompound = CompressedStreamTools.func_1138_a(fileinputstream);
|
int xx = nbt.getInteger("xPos");
|
||||||
if (!nbttagcompound.hasKey("Level")) {
|
int zz = nbt.getInteger("zPos");
|
||||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
if(x != xx || z != zz) {
|
||||||
.append(" is missing level data, skipping").toString());
|
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 null;
|
||||||
}
|
}
|
||||||
if (!nbttagcompound.getCompoundTag("Level").hasKey("Blocks")) {
|
|
||||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
return loadChunkIntoWorldFromCompound(world, nbt);
|
||||||
.append(" is missing block data, skipping").toString());
|
} catch (IOException e) {
|
||||||
return null;
|
System.err.println("Corrupt chunk '" + name + "' was found at: [" + x + ", " + z + "]");
|
||||||
}
|
System.err.println("The file will be deleted");
|
||||||
Chunk chunk = loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
EaglerAdapter.deleteFile(path);
|
||||||
if (!chunk.isAtLocation(i, j)) {
|
e.printStackTrace();
|
||||||
System.out.println((new StringBuilder()).append("Chunk file at ").append(i).append(",").append(j)
|
return null;
|
||||||
.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 = loadChunkIntoWorldFromCompound(world, nbttagcompound.getCompoundTag("Level"));
|
|
||||||
}
|
|
||||||
return chunk;
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void saveChunk(World world, Chunk chunk) {
|
public void saveChunk(World world, Chunk chunk) {
|
||||||
world.checkSessionLock();
|
NBTTagCompound toSave = new NBTTagCompound();
|
||||||
File file = chunkFileForXZ(chunk.xPosition, chunk.zPosition);
|
storeChunkInCompound(chunk, world, toSave);
|
||||||
if (file.exists()) {
|
ByteArrayOutputStream bao = new ByteArrayOutputStream(98304);
|
||||||
WorldInfo worldinfo = world.func_22144_v();
|
|
||||||
worldinfo.func_22297_b(worldinfo.func_22306_g() - file.length());
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
File file1 = new File(saveDir, "tmp_chunk.dat");
|
NBTBase.writeTag(toSave, new DataOutputStream(bao));
|
||||||
FileOutputStream fileoutputstream = new FileOutputStream(file1);
|
} catch (IOException e) {
|
||||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
System.err.println("Failed to serialize chunk at [" + chunk.xPosition + ", " + chunk.zPosition + "] to byte array");
|
||||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
e.printStackTrace();
|
||||||
nbttagcompound.setTag("Level", nbttagcompound1);
|
return;
|
||||||
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.func_22297_b(worldinfo1.func_22306_g() + file.length());
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
EaglerAdapter.writeFile(directory + "/" + getChunkPath(chunk.xPosition, chunk.zPosition), bao.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeChunkInCompound(Chunk chunk, World world, NBTTagCompound nbttagcompound) {
|
@Override
|
||||||
world.checkSessionLock();
|
public void saveExtraChunkData(World world, Chunk chunk) {
|
||||||
nbttagcompound.setInteger("xPos", chunk.xPosition);
|
}
|
||||||
nbttagcompound.setInteger("zPos", chunk.zPosition);
|
|
||||||
nbttagcompound.setLong("LastUpdate", world.func_22139_r());
|
|
||||||
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);
|
@Override
|
||||||
NBTTagList nbttaglist1 = new NBTTagList();
|
public void func_814_a() {
|
||||||
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);
|
@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) {
|
public static Chunk loadChunkIntoWorldFromCompound(World world, NBTTagCompound nbttagcompound) {
|
||||||
|
@ -177,7 +133,7 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
chunk.addEntity(entity);
|
chunk.addEntity(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities");
|
NBTTagList nbttaglist1 = nbttagcompound.getTagList("TileEntities");
|
||||||
if (nbttaglist1 != null) {
|
if (nbttaglist1 != null) {
|
||||||
|
@ -188,20 +144,49 @@ public class ChunkLoader implements IChunkLoader {
|
||||||
chunk.func_1001_a(tileentity);
|
chunk.func_1001_a(tileentity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void func_814_a() {
|
public static void storeChunkInCompound(Chunk chunk, World world, NBTTagCompound nbttagcompound) {
|
||||||
|
nbttagcompound.setInteger("xPos", chunk.xPosition);
|
||||||
|
nbttagcompound.setInteger("zPos", chunk.zPosition);
|
||||||
|
nbttagcompound.setLong("LastUpdate", world.func_22139_r());
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveExtraData() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveExtraChunkData(World world, Chunk chunk) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private File saveDir;
|
|
||||||
private boolean createIfNecessary;
|
|
||||||
}
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
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 getWorldInfo() {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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 saveWorldAndPlayer(WorldInfo worldinfo, List list) {
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(8192);
|
||||||
|
DataOutputStream ds = new DataOutputStream(out);
|
||||||
|
try {
|
||||||
|
NBTBase.writeTag(worldinfo.func_22305_a(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.func_22299_a(), 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,140 @@
|
||||||
|
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 loadWorldHandler(String s, boolean flag) {
|
||||||
|
return new EaglercraftSaveHandler(directory + "/" + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List getWorldList() {
|
||||||
|
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;
|
||||||
|
System.out.println(dir);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteWorldByDirectory(String s) {
|
||||||
|
FilesystemUtils.recursiveDeleteDirectory(directory + "/" + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean worldNeedsConvert_maybe(String s) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean convertSave(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package net.lax1dude.eaglercraft.beta;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
|
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry;
|
||||||
|
|
||||||
|
public class FilesystemUtils {
|
||||||
|
|
||||||
|
public static void recursiveDeleteDirectory(String dir) {
|
||||||
|
EaglerAdapter.listFiles(dir, true, true).forEach(new Consumer<FileEntry>() {
|
||||||
|
@Override
|
||||||
|
public void accept(FileEntry t) {
|
||||||
|
EaglerAdapter.deleteFile(t.path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
EaglerAdapter.deleteFile(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import java.io.*;
|
||||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||||
import net.lax1dude.eaglercraft.TextureLocation;
|
import net.lax1dude.eaglercraft.TextureLocation;
|
||||||
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
||||||
|
import net.lax1dude.eaglercraft.beta.EaglercraftSaveManager;
|
||||||
import net.lax1dude.eaglercraft.beta.SingleplayerCommands;
|
import net.lax1dude.eaglercraft.beta.SingleplayerCommands;
|
||||||
import net.minecraft.src.*;
|
import net.minecraft.src.*;
|
||||||
|
|
||||||
|
@ -59,7 +60,12 @@ public class Minecraft implements Runnable {
|
||||||
public void startGame() {
|
public void startGame() {
|
||||||
RenderManager.instance.itemRenderer = new ItemRenderer(this);
|
RenderManager.instance.itemRenderer = new ItemRenderer(this);
|
||||||
mcDataDir = getMinecraftDir();
|
mcDataDir = getMinecraftDir();
|
||||||
field_22008_V = new SaveConverterMcRegion(new File(mcDataDir, "saves"));
|
|
||||||
|
field_22008_V = EaglerAdapter.getConfiguredSaveFormat();
|
||||||
|
if(field_22008_V == null) {
|
||||||
|
field_22008_V = new EaglercraftSaveManager("saves");
|
||||||
|
}
|
||||||
|
|
||||||
gameSettings = new GameSettings(this, mcDataDir);
|
gameSettings = new GameSettings(this, mcDataDir);
|
||||||
texturePackList = new TexturePackList(this);
|
texturePackList = new TexturePackList(this);
|
||||||
renderEngine = new RenderEngine(texturePackList, gameSettings);
|
renderEngine = new RenderEngine(texturePackList, gameSettings);
|
||||||
|
@ -767,10 +773,10 @@ public class Minecraft implements Runnable {
|
||||||
public void startWorld(String s, String s1, long l) {
|
public void startWorld(String s, String s1, long l) {
|
||||||
changeWorld1(null);
|
changeWorld1(null);
|
||||||
System.gc();
|
System.gc();
|
||||||
if (field_22008_V.func_22175_a(s)) {
|
if (field_22008_V.worldNeedsConvert_maybe(s)) {
|
||||||
func_22002_b(s, s1);
|
func_22002_b(s, s1);
|
||||||
} else {
|
} else {
|
||||||
ISaveHandler isavehandler = field_22008_V.func_22174_a(s, false);
|
ISaveHandler isavehandler = field_22008_V.loadWorldHandler(s, false);
|
||||||
World world = new World(isavehandler, s1, l);
|
World world = new World(isavehandler, s1, l);
|
||||||
if (world.isNewWorld) {
|
if (world.isNewWorld) {
|
||||||
changeWorld2(world, "Generating level");
|
changeWorld2(world, "Generating level");
|
||||||
|
@ -881,9 +887,9 @@ public class Minecraft implements Runnable {
|
||||||
|
|
||||||
private void func_22002_b(String s, String s1) {
|
private void func_22002_b(String s, String s1) {
|
||||||
loadingScreen.printText(
|
loadingScreen.printText(
|
||||||
(new StringBuilder()).append("Converting World to ").append(field_22008_V.func_22178_a()).toString());
|
(new StringBuilder()).append("Converting World to ").append(field_22008_V.formatName()).toString());
|
||||||
loadingScreen.displayLoadingString("This may take a while :)");
|
loadingScreen.displayLoadingString("This may take a while :)");
|
||||||
field_22008_V.func_22171_a(s, loadingScreen);
|
field_22008_V.convertSave(s, loadingScreen);
|
||||||
startWorld(s, s1, 0L);
|
startWorld(s, s1, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package net.minecraft.src;
|
|
||||||
// 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 Empty1 {
|
|
||||||
}
|
|
|
@ -50,7 +50,7 @@ public class GuiCreateWorld extends GuiScreen {
|
||||||
field_22132_k = "World";
|
field_22132_k = "World";
|
||||||
}
|
}
|
||||||
for (ISaveFormat isaveformat = mc.func_22004_c(); isaveformat
|
for (ISaveFormat isaveformat = mc.func_22004_c(); isaveformat
|
||||||
.func_22173_b(field_22132_k) != null; field_22132_k = (new StringBuilder()).append(field_22132_k)
|
.getWorldInfoForWorld(field_22132_k) != null; field_22132_k = (new StringBuilder()).append(field_22132_k)
|
||||||
.append("-").toString()) {
|
.append("-").toString()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class GuiRenameWorld extends GuiScreen {
|
||||||
controlList.add(
|
controlList.add(
|
||||||
new GuiButton(1, width / 2 - 100, height / 4 + 120 + 12, stringtranslate.translateKey("gui.cancel")));
|
new GuiButton(1, width / 2 - 100, height / 4 + 120 + 12, stringtranslate.translateKey("gui.cancel")));
|
||||||
ISaveFormat isaveformat = mc.func_22004_c();
|
ISaveFormat isaveformat = mc.func_22004_c();
|
||||||
WorldInfo worldinfo = isaveformat.func_22173_b(field_22113_i);
|
WorldInfo worldinfo = isaveformat.getWorldInfoForWorld(field_22113_i);
|
||||||
String s = worldinfo.getWorldName();
|
String s = worldinfo.getWorldName();
|
||||||
field_22114_h = new GuiDisableButton(fontRenderer, width / 2 - 100, 60, 200, 20, s);
|
field_22114_h = new GuiDisableButton(fontRenderer, width / 2 - 100, 60, 200, 20, s);
|
||||||
field_22114_h.field_22082_a = true;
|
field_22114_h.field_22082_a = true;
|
||||||
|
@ -48,7 +48,7 @@ public class GuiRenameWorld extends GuiScreen {
|
||||||
mc.displayGuiScreen(field_22112_a);
|
mc.displayGuiScreen(field_22112_a);
|
||||||
} else if (guibutton.id == 0) {
|
} else if (guibutton.id == 0) {
|
||||||
ISaveFormat isaveformat = mc.func_22004_c();
|
ISaveFormat isaveformat = mc.func_22004_c();
|
||||||
isaveformat.func_22170_a(field_22113_i, field_22114_h.func_22071_a().trim());
|
isaveformat.renameWorldData(field_22113_i, field_22114_h.func_22071_a().trim());
|
||||||
mc.displayGuiScreen(field_22112_a);
|
mc.displayGuiScreen(field_22112_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class GuiSelectWorld extends GuiScreen {
|
||||||
|
|
||||||
private void func_22084_k() {
|
private void func_22084_k() {
|
||||||
ISaveFormat isaveformat = mc.func_22004_c();
|
ISaveFormat isaveformat = mc.func_22004_c();
|
||||||
field_22100_m = isaveformat.func_22176_b();
|
field_22100_m = isaveformat.getWorldList();
|
||||||
Collections.sort(field_22100_m);
|
Collections.sort(field_22100_m);
|
||||||
field_22101_l = -1;
|
field_22101_l = -1;
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,8 @@ public class GuiSelectWorld extends GuiScreen {
|
||||||
field_22096_q = false;
|
field_22096_q = false;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
ISaveFormat isaveformat = mc.func_22004_c();
|
ISaveFormat isaveformat = mc.func_22004_c();
|
||||||
isaveformat.func_22177_c();
|
isaveformat.flushCache();
|
||||||
isaveformat.func_22172_c(func_22091_c(i));
|
isaveformat.deleteWorldByDirectory(func_22091_c(i));
|
||||||
func_22084_k();
|
func_22084_k();
|
||||||
}
|
}
|
||||||
mc.displayGuiScreen(this);
|
mc.displayGuiScreen(this);
|
||||||
|
|
|
@ -8,21 +8,21 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ISaveFormat {
|
public interface ISaveFormat {
|
||||||
|
|
||||||
public abstract String func_22178_a();
|
public abstract String formatName();
|
||||||
|
|
||||||
public abstract ISaveHandler func_22174_a(String s, boolean flag);
|
public abstract ISaveHandler loadWorldHandler(String s, boolean flag);
|
||||||
|
|
||||||
public abstract List func_22176_b();
|
public abstract List getWorldList();
|
||||||
|
|
||||||
public abstract void func_22177_c();
|
public abstract void flushCache();
|
||||||
|
|
||||||
public abstract WorldInfo func_22173_b(String s);
|
public abstract WorldInfo getWorldInfoForWorld(String s);
|
||||||
|
|
||||||
public abstract void func_22172_c(String s);
|
public abstract void deleteWorldByDirectory(String s);
|
||||||
|
|
||||||
public abstract void func_22170_a(String s, String s1);
|
public abstract void renameWorldData(String s, String s1);
|
||||||
|
|
||||||
public abstract boolean func_22175_a(String s);
|
public abstract boolean worldNeedsConvert_maybe(String s);
|
||||||
|
|
||||||
public abstract boolean func_22171_a(String s, IProgressUpdate iprogressupdate);
|
public abstract boolean convertSave(String s, IProgressUpdate iprogressupdate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,13 @@ import java.util.List;
|
||||||
|
|
||||||
public interface ISaveHandler {
|
public interface ISaveHandler {
|
||||||
|
|
||||||
public abstract WorldInfo func_22151_c();
|
public abstract WorldInfo getWorldInfo();
|
||||||
|
|
||||||
public abstract void func_22150_b();
|
public abstract void checkSessionLock();
|
||||||
|
|
||||||
public abstract IChunkLoader func_22149_a(WorldProvider worldprovider);
|
public abstract IChunkLoader getChunkLoader(WorldProvider worldprovider);
|
||||||
|
|
||||||
public abstract void func_22148_a(WorldInfo worldinfo, List list);
|
public abstract void saveWorldAndPlayer(WorldInfo worldinfo, List list);
|
||||||
|
|
||||||
public abstract void func_22152_a(WorldInfo worldinfo);
|
public abstract void saveWorldInfo(WorldInfo worldinfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,8 @@ class PacketCounter {
|
||||||
field_22238_a++;
|
field_22238_a++;
|
||||||
field_22237_b += i;
|
field_22237_b += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketCounter(Empty1 empty1) {
|
public PacketCounter(Object wtf) {
|
||||||
this();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int field_22238_a;
|
private int field_22238_a;
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package net.minecraft.src;
|
|
||||||
// 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.util.List;
|
|
||||||
|
|
||||||
public class SaveHandlerMP implements ISaveHandler {
|
|
||||||
|
|
||||||
public SaveHandlerMP() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldInfo func_22151_c() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void func_22150_b() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public IChunkLoader func_22149_a(WorldProvider worldprovider) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void func_22148_a(WorldInfo worldinfo, List list) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void func_22152_a(WorldInfo worldinfo) {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package net.minecraft.src;
|
|
||||||
// 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.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class SoundPool {
|
|
||||||
|
|
||||||
public SoundPool() {
|
|
||||||
rand = new Random();
|
|
||||||
nameToSoundPoolEntriesMapping = new HashMap();
|
|
||||||
allSoundPoolEntries = new ArrayList();
|
|
||||||
numberOfSoundPoolEntries = 0;
|
|
||||||
field_1657_b = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoundPoolEntry addSound(String s, File file) {
|
|
||||||
try {
|
|
||||||
String s1 = s;
|
|
||||||
s = s.substring(0, s.indexOf("."));
|
|
||||||
if (field_1657_b) {
|
|
||||||
for (; Character.isDigit(s.charAt(s.length() - 1)); s = s.substring(0, s.length() - 1)) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s = s.replaceAll("/", ".");
|
|
||||||
if (!nameToSoundPoolEntriesMapping.containsKey(s)) {
|
|
||||||
nameToSoundPoolEntriesMapping.put(s, new ArrayList());
|
|
||||||
}
|
|
||||||
SoundPoolEntry soundpoolentry = new SoundPoolEntry(s1, file.toURI().toURL());
|
|
||||||
((List) nameToSoundPoolEntriesMapping.get(s)).add(soundpoolentry);
|
|
||||||
allSoundPoolEntries.add(soundpoolentry);
|
|
||||||
numberOfSoundPoolEntries++;
|
|
||||||
return soundpoolentry;
|
|
||||||
} catch (MalformedURLException malformedurlexception) {
|
|
||||||
malformedurlexception.printStackTrace();
|
|
||||||
throw new RuntimeException(malformedurlexception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoundPoolEntry getRandomSoundFromSoundPool(String s) {
|
|
||||||
List list = (List) nameToSoundPoolEntriesMapping.get(s);
|
|
||||||
if (list == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return (SoundPoolEntry) list.get(rand.nextInt(list.size()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoundPoolEntry getRandomSound() {
|
|
||||||
if (allSoundPoolEntries.size() == 0) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return (SoundPoolEntry) allSoundPoolEntries.get(rand.nextInt(allSoundPoolEntries.size()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Random rand;
|
|
||||||
private Map nameToSoundPoolEntriesMapping;
|
|
||||||
private List allSoundPoolEntries;
|
|
||||||
public int numberOfSoundPoolEntries;
|
|
||||||
public boolean field_1657_b;
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package net.minecraft.src;
|
|
||||||
// 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.net.URL;
|
|
||||||
|
|
||||||
public class SoundPoolEntry {
|
|
||||||
|
|
||||||
public SoundPoolEntry(String s, URL url) {
|
|
||||||
soundName = s;
|
|
||||||
soundUrl = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String soundName;
|
|
||||||
public URL soundUrl;
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package net.minecraft.src;
|
|
||||||
// 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 net.minecraft.client.Minecraft;
|
|
||||||
|
|
||||||
public class ThreadSleepForever extends Thread {
|
|
||||||
|
|
||||||
public ThreadSleepForever(Minecraft minecraft, String s) {
|
|
||||||
super(s);
|
|
||||||
mc = minecraft;
|
|
||||||
setDaemon(true);
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
while (mc.running) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(0x7fffffffL);
|
|
||||||
} catch (InterruptedException interruptedexception) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Minecraft mc; /* synthetic field */
|
|
||||||
}
|
|
|
@ -116,7 +116,7 @@ public class World implements IBlockAccess {
|
||||||
field_1012_M = new ArrayList();
|
field_1012_M = new ArrayList();
|
||||||
multiplayerWorld = false;
|
multiplayerWorld = false;
|
||||||
field_22147_p = isavehandler;
|
field_22147_p = isavehandler;
|
||||||
worldinfo = isavehandler.func_22151_c();
|
worldinfo = isavehandler.getWorldInfo();
|
||||||
isNewWorld = worldinfo == null;
|
isNewWorld = worldinfo == null;
|
||||||
if (worldprovider != null) {
|
if (worldprovider != null) {
|
||||||
worldProvider = worldprovider;
|
worldProvider = worldprovider;
|
||||||
|
@ -150,7 +150,7 @@ public class World implements IBlockAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IChunkProvider getChunkProvider() {
|
protected IChunkProvider getChunkProvider() {
|
||||||
IChunkLoader ichunkloader = field_22147_p.func_22149_a(worldProvider);
|
IChunkLoader ichunkloader = field_22147_p.getChunkLoader(worldProvider);
|
||||||
return new ChunkProviderLoadOrGenerate(this, ichunkloader, worldProvider.getChunkProvider());
|
return new ChunkProviderLoadOrGenerate(this, ichunkloader, worldProvider.getChunkProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public class World implements IBlockAccess {
|
||||||
|
|
||||||
private void saveLevel() {
|
private void saveLevel() {
|
||||||
checkSessionLock();
|
checkSessionLock();
|
||||||
field_22147_p.func_22148_a(worldinfo, playerEntities);
|
field_22147_p.saveWorldAndPlayer(worldinfo, playerEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_650_a(int i) {
|
public boolean func_650_a(int i) {
|
||||||
|
@ -1817,7 +1817,7 @@ public class World implements IBlockAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkSessionLock() {
|
public void checkSessionLock() {
|
||||||
field_22147_p.func_22150_b();
|
field_22147_p.checkSessionLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorldTime(long l) {
|
public void setWorldTime(long l) {
|
||||||
|
|
|
@ -6,6 +6,8 @@ package net.minecraft.src;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import net.lax1dude.eaglercraft.anvil.SaveHandlerMP;
|
||||||
|
|
||||||
public class WorldClient extends World {
|
public class WorldClient extends World {
|
||||||
|
|
||||||
public WorldClient(NetClientHandler netclienthandler, long l, int i) {
|
public WorldClient(NetClientHandler netclienthandler, long l, int i) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user