reformatted some singleplayer classes

This commit is contained in:
LAX1DUDE 2022-08-03 22:53:10 -07:00
parent 7d0bf17586
commit efcf5f8e77
42 changed files with 525 additions and 478 deletions

View File

@ -1,7 +1,5 @@
package net.lax1dude.eaglercraft.sp;
import org.teavm.classlib.java.util.zip.TChecksum;
import java.util.zip.Checksum;
public class CRC32 implements Checksum {

View File

@ -12,16 +12,39 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import net.minecraft.src.ChunkCoordIntPair;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import net.lax1dude.eaglercraft.sp.ipc.*;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket00StartServer;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket01StopServer;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket02InitWorld;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket03DeleteWorld;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket04RenameWorld;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket05RequestData;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket06RenameWorldNBT;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket07ImportWorld;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket09RequestResponse;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0ASetWorldDifficulty;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0BPause;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0CPlayerChannel;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0EListWorlds;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0FListFiles;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket10FileRead;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket12FileWrite;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket13FileCopyMove;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket15ThrowException;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket16NBTList;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacketBase;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacketFFProcessKeepAlive;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacketManager;
import net.minecraft.src.AchievementList;
import net.minecraft.src.AchievementMap;
import net.minecraft.src.ChunkCoordIntPair;
import net.minecraft.src.CompressedStreamTools;
import net.minecraft.src.EnumGameType;
import net.minecraft.src.ILogAgent;

View File

@ -5,19 +5,20 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import com.jcraft.jzlib.DeflaterOutputStream;
import com.jcraft.jzlib.GZIPInputStream;
import com.jcraft.jzlib.GZIPOutputStream;
import net.minecraft.src.ChunkCoordIntPair;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.InflaterInputStream;
import com.jcraft.jzlib.DeflaterOutputStream;
import com.jcraft.jzlib.GZIPInputStream;
import com.jcraft.jzlib.GZIPOutputStream;
import net.minecraft.src.ChunkCoordIntPair;
public class MCAConverter {
public static void convertFromMCA(VFile dir, byte[] file, String fileName) {
VFile levelDir = new VFile(dir, "level" + (fileName.startsWith("region/") ? "0" : fileName.substring(3, fileName.indexOf('/'))));
VFile levelDir = new VFile(dir,
"level" + (fileName.startsWith("region/") ? "0" : fileName.substring(3, fileName.indexOf('/'))));
String[] xz = fileName.substring(fileName.lastIndexOf('r') + 2, fileName.length() - 4).split("\\.");
int gx = Integer.parseInt(xz[0]);
@ -32,13 +33,16 @@ public class MCAConverter {
if (offset == 0 && file[i + 3] == 0) {
continue;
}
int chunkLen = (((file[offset] & 0xff) << 24) | ((file[offset + 1] & 0xff) << 16) | ((file[offset + 2] & 0xff) << 8) | (file[offset + 3] & 0xff));
if (chunkLen == 0) continue;
int chunkLen = (((file[offset] & 0xff) << 24) | ((file[offset + 1] & 0xff) << 16)
| ((file[offset + 2] & 0xff) << 8) | (file[offset + 3] & 0xff));
if (chunkLen == 0)
continue;
byte compression = file[offset + 4];
byte[] data = new byte[chunkLen - 1];
System.arraycopy(file, offset + 5, data, 0, chunkLen - 1);
if (compression == 0) {
OutputStream os = new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
OutputStream os = new VFile(levelDir,
VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
GZIPOutputStream gos = new GZIPOutputStream(os);
ByteArrayInputStream bais = new ByteArrayInputStream(data);
int len;
@ -49,7 +53,8 @@ public class MCAConverter {
os.close();
bais.close();
} else if (compression == 2) {
OutputStream os = new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
OutputStream os = new VFile(levelDir,
VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").getOutputStream();
GZIPOutputStream gos = new GZIPOutputStream(os);
InflaterInputStream iis = new InflaterInputStream(new ByteArrayInputStream(data));
int len;
@ -60,7 +65,8 @@ public class MCAConverter {
os.close();
iis.close();
} else if (compression == 1) {
new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat").setAllBytes(data);
new VFile(levelDir, VFSChunkLoader.getChunkPath(gx * 32 + x, gz * 32 + z) + ".dat")
.setAllBytes(data);
}
}
}
@ -72,7 +78,8 @@ public class MCAConverter {
public static Map<String, byte[]> convertToMCA(Map<ChunkCoordIntPair, byte[]> regions) {
Map<String, byte[]> regionsOut = new HashMap<>();
if (regions.size() == 0) return regionsOut;
if (regions.size() == 0)
return regionsOut;
byte[] readBuffer = new byte[16000];
@ -85,10 +92,14 @@ public class MCAConverter {
int minZ = Integer.MAX_VALUE;
for (ChunkCoordIntPair coords : regions.keySet()) {
if (maxX < coords.chunkXPos) maxX = coords.chunkXPos;
if (maxZ < coords.chunkZPos) maxZ = coords.chunkZPos;
if (minX > coords.chunkXPos) minX = coords.chunkXPos;
if (minZ > coords.chunkZPos) minZ = coords.chunkZPos;
if (maxX < coords.chunkXPos)
maxX = coords.chunkXPos;
if (maxZ < coords.chunkZPos)
maxZ = coords.chunkZPos;
if (minX > coords.chunkXPos)
minX = coords.chunkXPos;
if (minZ > coords.chunkZPos)
minZ = coords.chunkZPos;
}
for (int z = minZ - (32 + (minZ % 32)); z <= maxZ + (32 + (maxZ % 32)); z += 32) {
@ -139,7 +150,8 @@ public class MCAConverter {
chunksDos.write(zlibbed);
int chunksSizeOff = chunksDos.size() % 4096;
if (chunksSizeOff != 0) chunksDos.write(new byte[4096 - chunksSizeOff]);
if (chunksSizeOff != 0)
chunksDos.write(new byte[4096 - chunksSizeOff]);
}
}
}
@ -148,7 +160,8 @@ public class MCAConverter {
timestampsDos.close();
chunksDos.close();
if (!anyChunks) continue;
if (!anyChunks)
continue;
byte[] offsetsOut = offsets.toByteArray();
byte[] timestampsOut = timestamps.toByteArray();
@ -157,7 +170,8 @@ public class MCAConverter {
byte[] regionFile = new byte[offsetsOut.length + timestampsOut.length + chunksOut.length];
System.arraycopy(offsetsOut, 0, regionFile, 0, offsetsOut.length);
System.arraycopy(timestampsOut, 0, regionFile, offsetsOut.length, timestampsOut.length);
System.arraycopy(chunksOut, 0, regionFile, offsetsOut.length + timestampsOut.length, chunksOut.length);
System.arraycopy(chunksOut, 0, regionFile, offsetsOut.length + timestampsOut.length,
chunksOut.length);
regionsOut.put("r." + (x / 32) + "." + (z / 32), regionFile);
}
}

View File

@ -15,7 +15,6 @@ import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.indexeddb.EventHandler;
import org.teavm.jso.indexeddb.IDBCountRequest;

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.NetHandler;

View File

@ -1,7 +1,7 @@
package net.lax1dude.eaglercraft.sp;
import com.jcraft.jzlib.Deflater;
import com.jcraft.jzlib.DeflaterOutputStream;
import static java.util.zip.Deflater.BEST_COMPRESSION;
import static java.util.zip.Deflater.DEFAULT_COMPRESSION;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -11,8 +11,8 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import static java.util.zip.Deflater.BEST_COMPRESSION;
import static java.util.zip.Deflater.DEFAULT_COMPRESSION;
import com.jcraft.jzlib.Deflater;
import com.jcraft.jzlib.DeflaterOutputStream;
public class ZipOutputStream extends DeflaterOutputStream {
long LOCSIG = 0x4034b50;
@ -168,8 +168,7 @@ public class ZipOutputStream extends DeflaterOutputStream {
if (currentEntry != null) {
closeEntry();
}
if (ze.getMethod() == STORED
|| (compressMethod == STORED && ze.getMethod() == -1)) {
if (ze.getMethod() == STORED || (compressMethod == STORED && ze.getMethod() == -1)) {
if (ze.getCrc() == -1) {
throw new ZipException("Crc mismatch");
}
@ -271,12 +270,10 @@ public class ZipOutputStream extends DeflaterOutputStream {
/**
* Writes data for the current entry to the underlying stream.
*
* @exception IOException
* If an error occurs writing to the stream
* @exception IOException If an error occurs writing to the stream
*/
@Override
public void write(byte[] buffer, int off, int nbytes)
throws IOException {
public void write(byte[] buffer, int off, int nbytes) throws IOException {
// avoid int overflow, check null buf
if ((off < 0 || (nbytes < 0) || off > buffer.length) || (buffer.length - off < nbytes)) {
throw new IndexOutOfBoundsException();

View File

@ -8,9 +8,9 @@ import java.util.List;
import net.lax1dude.eaglercraft.sp.IntegratedServer;
import net.lax1dude.eaglercraft.sp.SYS;
import net.lax1dude.eaglercraft.sp.WorkerListenThread;
import net.lax1dude.eaglercraft.sp.VFSSaveHandler;
import net.lax1dude.eaglercraft.sp.VFile;
import net.lax1dude.eaglercraft.sp.WorkerListenThread;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList;
import net.minecraft.src.AxisAlignedBB;
@ -24,7 +24,6 @@ import net.minecraft.src.ICommandManager;
import net.minecraft.src.ICommandSender;
import net.minecraft.src.ILogAgent;
import net.minecraft.src.IProgressUpdate;
import net.minecraft.src.ISaveFormat;
import net.minecraft.src.ISaveHandler;
import net.minecraft.src.IUpdatePlayerListBox;
import net.minecraft.src.MinecraftException;

View File

@ -1,7 +1,6 @@
package net.minecraft.src;
import java.util.Iterator;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public abstract class CommandBase implements ICommand {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandClearInventory extends CommandBase {

View File

@ -1,10 +1,7 @@
package net.minecraft.src;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandDebug extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandDifficulty extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandEffect extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandEnchant extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandGameMode extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandGameRule extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandGive extends CommandBase {

View File

@ -6,8 +6,8 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
public class CommandHandler implements ICommandManager {
/** Map of Strings to the ICommand objects they represent */

View File

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import net.minecraft.server.MinecraftServer;
public class CommandHelp extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandServerEmote extends CommandBase {

View File

@ -2,6 +2,7 @@ package net.minecraft.src;
import java.util.Arrays;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandServerMessage extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandServerSay extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandServerTp extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandSetSpawnpoint extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandTime extends CommandBase {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class CommandXP extends CommandBase {

View File

@ -10,7 +10,6 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import com.jcraft.jzlib.Deflater;
import com.jcraft.jzlib.GZIPInputStream;

View File

@ -8,8 +8,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class DataWatcher {
/** When isBlank is true the DataWatcher is not watching any objects */

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public abstract class EntityMinecart extends Entity {

View File

@ -9,6 +9,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.server.MinecraftServer;
public class EntityPlayerMP extends EntityPlayer implements ICrafting {

View File

@ -5,7 +5,6 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
public class LowerStringMap implements Map {
private final Map internalMap = new LinkedHashMap();

View File

@ -3,9 +3,6 @@ package net.minecraft.src;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
public class Packet51MapChunk extends Packet {
/** The x-position of the transmitted chunk, in chunk coordinates. */

View File

@ -1,7 +1,9 @@
package net.minecraft.src;
import java.util.Vector;
import javax.swing.JList;
import net.minecraft.server.MinecraftServer;
public class PlayerListBox extends JList implements IUpdatePlayerListBox {

View File

@ -2,7 +2,6 @@ package net.minecraft.src;
import java.util.ArrayList;
import java.util.List;
import java.util.UnknownFormatConversionException;
public class PlayerManager {
private final WorldServer theWorldServer;

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.server.MinecraftServer;
public class PlayerSelector {

View File

@ -2,6 +2,7 @@ package net.minecraft.src;
import java.util.Collection;
import java.util.Iterator;
import net.minecraft.server.MinecraftServer;
public class ScoreboardSaveData extends WorldSavedData {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.Iterator;
import net.minecraft.server.MinecraftServer;
public class ServerCommandManager extends CommandHandler implements IAdminCommand {

View File

@ -7,6 +7,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.minecraft.server.MinecraftServer;
public class ServerCommandScoreboard extends CommandBase {

View File

@ -7,8 +7,9 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import net.minecraft.server.MinecraftServer;
public class ServerConfigurationManager {

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.minecraft.server.MinecraftServer;
public class ServerScoreboard extends Scoreboard {

View File

@ -2,6 +2,7 @@ package net.minecraft.src;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.server.MinecraftServer;
public class TileEntity {

View File

@ -1,6 +1,7 @@
package net.minecraft.src;
import java.util.Iterator;
import net.minecraft.server.MinecraftServer;
public class WorldManager implements IWorldAccess {