server compiles and loads correctly and generates the world

This commit is contained in:
LAX1DUDE 2022-02-21 13:18:30 -08:00
parent 63889aa632
commit 395e167728
454 changed files with 306245 additions and 13245 deletions

2
javascript/bootstrap.js vendored Normal file
View File

@ -0,0 +1,2 @@
importScripts("classes_server.js");
main();

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1278,69 +1278,3 @@ advMode.allPlayers=Use "@a" to target all players
advMode.notEnabled=Command blocks are not enabled on this server
advMode.notAllowed=Must be an opped player in creative mode
mco.title=Minecraft Realms
mco.selectServer.select=Join World
mco.selectServer.configure=Configure
mco.selectServer.create=Create World
mco.selectServer.moreinfo=More Info
mco.configure.world.edit.title=Edit World
mco.configure.world.title=Configure World
mco.configure.world.name=Name
mco.configure.world.seed=World Seed (Optional)
mco.configure.world.description=Description
mco.configure.world.owner=Owner
mco.configure.world.status=Status
mco.configure.world.location=Location
mco.configure.world.invited=Invited
mco.configure.world.buttons.edit=Edit
mco.configure.world.buttons.reset=Reset World
mco.configure.world.buttons.done=Done
mco.configure.world.buttons.delete=Delete
mco.configure.world.buttons.open=Open World
mco.configure.world.buttons.close=Close World
mco.configure.world.buttons.invite=Invite
mco.configure.world.buttons.uninvite=Uninvite
mco.configure.world.buttons.subscription=Subscription
mco.configure.world.buttons.save=Save
mco.configure.world.buttons.settings=Settings...
mco.configure.world.invite.profile.name=Name
mco.configure.world.uninvite.question=Are you sure that you want to uninvite
mco.configure.world.settings.title=Settings
mco.configure.world.subscription.title=Subscription Info
mco.configure.world.subscription.daysleft=Days Left
mco.configure.world.subscription.start=Start Date
mco.configure.world.subscription.extend=Extend
mco.create.world.location.title=Locations
mco.create.world.location.warning=You may not get the exact location you select
mco.create.world.wait=Creating the world...
mco.reset.world.title=Reset World
mco.reset.world.warning=This will permanently delete your world!
mco.reset.world.seed=World Seed (Optional)
mco.reset.world.resetting.screen.title=Resetting World...
mco.configure.world.close.question.line1=Your world will become unavailable.
mco.configure.world.close.question.line2=Are you sure you want to do that?
mco.connect.connecting=Connecting to the online server...
mco.connect.authorizing=Logging in...
mco.connect.failed=Failed to connect to the online server
mco.create.world=Create
mco.gameMode=Game Mode
mco.gameMode.survival=Survival
mco.gameMode.survival.line1=Search for resources, crafting, gain
mco.gameMode.survival.line2=levels, health and hunger
mco.gameMode.creative=Creative
mco.gameMode.creative.line1=Unlimited resources, free flying and
mco.gameMode.creative.line2=destroy blocks instantly
mco.gameMode.adventure=Adventure
mco.gameMode.adventure.line1=Same as survival mode, but blocks can't
mco.gameMode.adventure.line2=be added or removed

View File

@ -6,7 +6,12 @@
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/ipc/java"/>
<classpathentry kind="src" output="bin/main" path="src/ipc/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>

View File

@ -68,7 +68,7 @@ teavm {
maxTopLevelNames = 10000;
properties = null;
debugInformationGenerated = false;
sourceMapsGenerated = false;
sourceMapsGenerated = true;
sourceFilesCopied = false;
incremental = false;
transformers = null;

View File

@ -3,42 +3,67 @@ package net.lax1dude.eaglercraft.sp.ipc;
import java.io.IOException;
import java.io.InputStream;
class IPCInputStream extends InputStream {
public class IPCInputStream extends InputStream {
private byte[] currentBuffer = null;
private int idx = 0;
private int markIDX = 0;
private String errorName = null;
void feedBuffer(byte[] b) {
public void feedBuffer(byte[] b) {
currentBuffer = b;
idx = 0;
errorName = null;
markIDX = 0;
}
void nameBuffer(String str) {
public void nameBuffer(String str) {
errorName = str;
}
@Override
public int read() throws IOException {
try {
return ((int)currentBuffer[++idx]) & 0xFF;
return ((int)currentBuffer[idx++]) & 0xFF;
}catch(ArrayIndexOutOfBoundsException a) {
throw new IOException("IPCInputStream buffer underflow" + (errorName == null ? "" : (" while deserializing '" + errorName + "'")), a);
throw new IOException("IPCInputStream buffer underflow" + (errorName == null ? "," : (" (while deserializing '" + errorName + "')")) + " no bytes remaining", a);
}
}
@Override
public int read(byte b[], int off, int len) throws IOException {
if(idx + len > currentBuffer.length) {
throw new IOException("IPCInputStream buffer underflow" + (errorName == null ? "" : (" while deserializing '" + errorName + "'")), new ArrayIndexOutOfBoundsException(idx + len - 1));
throw new IOException("IPCInputStream buffer underflow" + (errorName == null ? "," : (" (while deserializing '" + errorName + "')")) + " tried to read " + len + " when there are only " + (currentBuffer.length - idx) + " bytes remaining", new ArrayIndexOutOfBoundsException(idx + len - 1));
}
if(off + len > b.length) {
throw new ArrayIndexOutOfBoundsException(off + len - 1);
}
System.arraycopy(b, off, currentBuffer, idx, len);
System.arraycopy(currentBuffer, idx, b, off, len);
idx += len;
return 0;
return len;
}
public void markIndex() {
markIDX = idx;
}
public void rewindIndex() {
idx = markIDX;
}
public byte[] getLeftover() {
if(currentBuffer.length - idx <= 0) {
return null;
}
byte[] buf = new byte[currentBuffer.length - idx];
System.arraycopy(currentBuffer, idx, buf, 0, currentBuffer.length - idx);
return buf;
}
public int getLeftoverCount() {
return currentBuffer.length - idx;
}
}

View File

@ -3,21 +3,21 @@ package net.lax1dude.eaglercraft.sp.ipc;
import java.io.IOException;
import java.io.OutputStream;
class IPCOutputStream extends OutputStream {
public class IPCOutputStream extends OutputStream {
private String className = null;
private byte[] currentBuffer = null;
private int idx = 0;
private int originalSize = 0;
void feedBuffer(byte[] buf, String clazzName) {
public void feedBuffer(byte[] buf, String clazzName) {
currentBuffer = buf;
idx = 0;
originalSize = buf.length;
className = clazzName;
}
byte[] returnBuffer() {
public byte[] returnBuffer() {
if(className != null && currentBuffer.length != originalSize) {
System.err.println("WARNING: Packet '" + className + "' was supposed to be " + originalSize + " bytes but buffer has grown by " + (currentBuffer.length - originalSize) + " to " + currentBuffer.length + " bytes");
}
@ -39,8 +39,7 @@ class IPCOutputStream extends OutputStream {
if(idx >= currentBuffer.length) {
growBuffer(idx + 1);
}
currentBuffer[idx] = (byte) b;
++idx;
currentBuffer[idx++] = (byte) b;
}
@Override

View File

@ -9,22 +9,30 @@ public class IPCPacket00StartServer implements IPCPacketBase {
public static final int ID = 0x00;
public String worldName;
public String ownerName;
public int initialDifficulty;
public IPCPacket00StartServer() {
}
public IPCPacket00StartServer(String worldName) {
public IPCPacket00StartServer(String worldName, String ownerName, int initialDifficulty) {
this.worldName = worldName;
this.ownerName = ownerName;
this.initialDifficulty = initialDifficulty;
}
@Override
public void deserialize(DataInput bin) throws IOException {
worldName = bin.readUTF();
ownerName = bin.readUTF();
initialDifficulty = bin.readByte();
}
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeUTF(worldName);
bin.writeUTF(ownerName);
bin.writeByte(initialDifficulty);
}
@Override
@ -34,7 +42,7 @@ public class IPCPacket00StartServer implements IPCPacketBase {
@Override
public int size() {
return IPCPacketBase.strLen(worldName);
return IPCPacketBase.strLen(worldName) + IPCPacketBase.strLen(ownerName) + 1;
}
}

View File

@ -20,10 +20,10 @@ public class IPCPacket02InitWorld implements IPCPacketBase {
public IPCPacket02InitWorld() {
}
public IPCPacket02InitWorld(String worldName, byte gamemode, byte worldType, String worldArgs, long seed, boolean cheats, boolean structures, boolean bonusChest) {
public IPCPacket02InitWorld(String worldName, int gamemode, int worldType, String worldArgs, long seed, boolean cheats, boolean structures, boolean bonusChest) {
this.worldName = worldName;
this.gamemode = gamemode;
this.worldType = worldType;
this.gamemode = (byte)gamemode;
this.worldType = (byte)worldType;
this.worldArgs = worldArgs;
this.seed = seed;
this.cheats = cheats;

View File

@ -10,6 +10,7 @@ public class IPCPacket04RenameWorld implements IPCPacketBase {
public String worldOldName;
public String worldNewName;
public String displayName;
public boolean copy;
public IPCPacket04RenameWorld() {
@ -25,6 +26,7 @@ public class IPCPacket04RenameWorld implements IPCPacketBase {
public void deserialize(DataInput bin) throws IOException {
worldOldName = bin.readUTF();
worldNewName = bin.readUTF();
displayName = bin.readUTF();
copy = bin.readBoolean();
}
@ -32,6 +34,7 @@ public class IPCPacket04RenameWorld implements IPCPacketBase {
public void serialize(DataOutput bin) throws IOException {
bin.writeUTF(worldOldName);
bin.writeUTF(worldNewName);
bin.writeUTF(displayName);
bin.writeBoolean(copy);
}
@ -42,7 +45,7 @@ public class IPCPacket04RenameWorld implements IPCPacketBase {
@Override
public int size() {
return IPCPacketBase.strLen(worldOldName) + IPCPacketBase.strLen(worldNewName) + 1;
return IPCPacketBase.strLen(worldOldName) + IPCPacketBase.strLen(worldNewName) + IPCPacketBase.strLen(displayName) + 1;
}
}

View File

@ -0,0 +1,44 @@
package net.lax1dude.eaglercraft.sp.ipc;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class IPCPacket06RenameWorldNBT implements IPCPacketBase {
public static final int ID = 0x06;
public String worldName;
public String displayName;
public IPCPacket06RenameWorldNBT() {
}
public IPCPacket06RenameWorldNBT(String worldName, String displayName) {
this.worldName = worldName;
this.displayName = displayName;
}
@Override
public void deserialize(DataInput bin) throws IOException {
this.worldName = bin.readUTF();
this.displayName = bin.readUTF();
}
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeUTF(worldName);
bin.writeUTF(displayName);
}
@Override
public int id() {
return ID;
}
@Override
public int size() {
return IPCPacketBase.strLen(worldName) + IPCPacketBase.strLen(displayName);
}
}

View File

@ -4,30 +4,49 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class IPCPacket14StringList implements IPCPacketBase {
public static final int ID = 0x14;
public static final int FILE_LIST = 0x0;
public static final int LOCALE = 0x1;
public static final int STAT_GUID = 0x2;
public int opCode;
public final List<String> stringList;
public IPCPacket14StringList() {
stringList = new ArrayList();
}
public IPCPacket14StringList(String[] list) {
stringList = Arrays.asList(list);
public IPCPacket14StringList(int opcode, String[] list) {
stringList = new ArrayList();
for(String s : list) {
s = s.trim();
if(s.length() > 0) {
stringList.add(s);
}
}
this.opCode = opcode;
}
public IPCPacket14StringList(List<String> list) {
stringList = list;
public IPCPacket14StringList(int opcode, List<String> list) {
stringList = new ArrayList();
for(String s : list) {
s = s.trim();
if(s.length() > 0) {
stringList.add(s);
}
}
this.opCode = opcode;
}
@Override
public void deserialize(DataInput bin) throws IOException {
stringList.clear();
opCode = bin.readByte();
int len = bin.readInt();
for(int i = 0; i < len; ++i) {
stringList.add(bin.readUTF());
@ -36,6 +55,7 @@ public class IPCPacket14StringList implements IPCPacketBase {
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeByte(opCode);
bin.writeInt(stringList.size());
for(String str : stringList) {
bin.writeUTF(str);
@ -49,7 +69,7 @@ public class IPCPacket14StringList implements IPCPacketBase {
@Override
public int size() {
int len = 4;
int len = 5;
for(String str : stringList) {
len += IPCPacketBase.strLen(str);
}

View File

@ -0,0 +1,64 @@
package net.lax1dude.eaglercraft.sp.ipc;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class IPCPacket15ThrowException implements IPCPacketBase {
public static final int ID = 0x15;
public String errorMessage;
public final List<String> stackTrace;
public IPCPacket15ThrowException() {
stackTrace = new ArrayList();
}
public IPCPacket15ThrowException(String errorMessage, String[] list) {
stackTrace = new ArrayList(Arrays.asList(list));
this.errorMessage = errorMessage;
}
public IPCPacket15ThrowException(String errorMessage, List<String> list) {
stackTrace = list;
this.errorMessage = errorMessage;
}
@Override
public void deserialize(DataInput bin) throws IOException {
stackTrace.clear();
errorMessage = bin.readUTF();
int len = bin.readInt();
for(int i = 0; i < len; ++i) {
stackTrace.add(bin.readUTF());
}
}
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeUTF(errorMessage);
bin.writeInt(stackTrace.size());
for(String str : stackTrace) {
bin.writeUTF(str);
}
}
@Override
public int id() {
return ID;
}
@Override
public int size() {
int len = 4 + IPCPacketBase.strLen(errorMessage);
for(String str : stackTrace) {
len += IPCPacketBase.strLen(str);
}
return len;
}
}

View File

@ -0,0 +1,95 @@
package net.lax1dude.eaglercraft.sp.ipc;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.src.CompressedStreamTools;
import net.minecraft.src.NBTTagCompound;
public class IPCPacket16NBTList implements IPCPacketBase {
public static final int ID = 0x16;
public static final int WORLD_LIST = 0x0;
public int opCode;
public final List<byte[]> tagList;
public final List<NBTTagCompound> nbtTagList;
public IPCPacket16NBTList() {
tagList = new LinkedList();
nbtTagList = new LinkedList();
}
public IPCPacket16NBTList(int opcode, NBTTagCompound[] list) {
this(opcode, Arrays.asList(list));
}
public IPCPacket16NBTList(int opcode, List<NBTTagCompound> list) {
tagList = new LinkedList();
nbtTagList = list;
for(int i = 0, size = list.size(); i < size; ++i) {
NBTTagCompound tag = list.get(i);
try {
ByteArrayOutputStream bao = new ByteArrayOutputStream();
CompressedStreamTools.write(tag, new DataOutputStream(bao));
tagList.add(bao.toByteArray());
}catch(IOException e) {
System.err.println("Failed to write tag '" + tag.getName() + "' (#" + i + ") in IPCPacket16NBTList");
}
}
opCode = opcode;
}
@Override
public void deserialize(DataInput bin) throws IOException {
tagList.clear();
nbtTagList.clear();
opCode = bin.readInt();
int count = bin.readInt();
for(int i = 0; i < count; ++i) {
byte[] toRead = new byte[bin.readInt()];
bin.readFully(toRead);
tagList.add(toRead);
try {
nbtTagList.add(CompressedStreamTools.read(new DataInputStream(new ByteArrayInputStream(toRead))));
}catch(IOException e) {
System.err.println("Failed to read tag #" + i + " in IPCPacket16NBTList");
}
}
}
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeInt(opCode);
bin.writeInt(tagList.size());
for(byte[] str : tagList) {
bin.writeInt(str.length);
bin.write(str);
}
}
@Override
public int id() {
return ID;
}
@Override
public int size() {
int len = 8;
for(byte[] str : tagList) {
len += 4;
len += str.length;
}
return len;
}
}

View File

@ -12,21 +12,22 @@ public interface IPCPacketBase {
public int size();
public static int strLen(String s) {
int count = 0;
for (int i = 0, len = s.length(); i < len; i++) {
char ch = s.charAt(i);
if (ch <= 0x7F) {
count++;
} else if (ch <= 0x7FF) {
count += 2;
} else if (Character.isHighSurrogate(ch)) {
count += 4;
++i;
int strlen = s.length();
int utflen = 2;
int c;
for (int i = 0; i < strlen; ++i) {
c = s.charAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
++utflen;
} else if (c > 0x07FF) {
utflen += 3;
} else {
count += 3;
utflen += 2;
}
}
return count + 2;
return utflen;
}
}

View File

@ -3,7 +3,6 @@ package net.lax1dude.eaglercraft.sp.ipc;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
public class IPCPacketManager {
@ -23,6 +22,7 @@ public class IPCPacketManager {
mappings.put(IPCPacket03DeleteWorld.ID, IPCPacket03DeleteWorld.class);
mappings.put(IPCPacket04RenameWorld.ID, IPCPacket04RenameWorld.class);
mappings.put(IPCPacket05RequestData.ID, IPCPacket05RequestData.class);
mappings.put(IPCPacket06RenameWorldNBT.ID, IPCPacket06RenameWorldNBT.class);
mappings.put(IPCPacket07ImportWorld.ID, IPCPacket07ImportWorld.class);
mappings.put(IPCPacket09RequestResponse.ID, IPCPacket09RequestResponse.class);
mappings.put(IPCPacket0ASetWorldDifficulty.ID, IPCPacket0ASetWorldDifficulty.class);
@ -35,12 +35,14 @@ public class IPCPacketManager {
mappings.put(IPCPacket12FileWrite.ID, IPCPacket12FileWrite.class);
mappings.put(IPCPacket13FileCopyMove.ID, IPCPacket13FileCopyMove.class);
mappings.put(IPCPacket14StringList.ID, IPCPacket14StringList.class);
mappings.put(IPCPacket15ThrowException.ID, IPCPacket15ThrowException.class);
mappings.put(IPCPacket16NBTList.ID, IPCPacket16NBTList.class);
mappings.put(IPCPacketFFProcessKeepAlive.ID, IPCPacketFFProcessKeepAlive.class);
}
public static byte[] IPCSerialize(IPCPacketBase pkt) throws IOException {
IPC_OUTPUT_STREAM.feedBuffer(new byte[1 + pkt.size()], pkt.getClass().getSimpleName());
IPC_OUTPUT_STREAM.feedBuffer(new byte[pkt.size() + 1], pkt.getClass().getSimpleName());
IPC_OUTPUT_STREAM.write(pkt.id());
pkt.serialize(IPC_DATA_OUTPUT_STREAM);
@ -59,16 +61,20 @@ public class IPCPacketManager {
IPCPacketBase p;
try {
p = pk.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
throw new RuntimeException("Packet type '" + pk.getSimpleName() + "' could not be constructed", e);
p = pk.newInstance();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | SecurityException e) {
throw new RuntimeException("Packet type 0x" + Integer.toHexString(i) + " class '" + pk.getSimpleName() + "' could not be constructed", e);
}
IPC_INPUT_STREAM.nameBuffer(pk.getSimpleName());
p.deserialize(IPC_DATA_INPUT_STREAM);
int lo = IPC_INPUT_STREAM.getLeftoverCount();
if(lo > 0) {
System.err.println("Packet type 0x" + Integer.toHexString(i) + " class '" + pk.getSimpleName() + "' was size " + (pkt.length - 1) + " but only " + (pkt.length - 1 - lo) + " bytes were read");
}
return p;
}

View File

@ -0,0 +1,40 @@
package net.lax1dude.eaglercraft.sp;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.src.ILogAgent;
public class EAGLogAgent implements ILogAgent {
private final Logger logger = Logger.getLogger("IntegratedServer");
public Logger getServerLogger() {
return this.logger;
}
public void func_98233_a(String par1Str) {
this.logger.log(Level.INFO, par1Str);
}
public void func_98236_b(String par1Str) {
this.logger.log(Level.WARNING, par1Str);
}
public void logWarningFormatted(String par1Str, Object... par2ArrayOfObj) {
this.logger.log(Level.WARNING, par1Str, par2ArrayOfObj);
}
public void logWarningException(String par1Str, Throwable par2Throwable) {
this.logger.log(Level.WARNING, par1Str, par2Throwable);
}
public void logSevere(String par1Str) {
this.logger.log(Level.SEVERE, par1Str);
}
public void logSevereException(String par1Str, Throwable par2Throwable) {
this.logger.log(Level.SEVERE, par1Str, par2Throwable);
}
}

View File

@ -1,78 +1,124 @@
package net.lax1dude.eaglercraft.sp;
import java.io.File;
import java.io.IOException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.EnumGameType;
import net.minecraft.src.ILogAgent;
import net.minecraft.src.NetworkListenThread;
import net.minecraft.src.WorldSettings;
public class EAGMinecraftServer extends MinecraftServer {
protected int difficulty;
protected EnumGameType gamemode;
protected long lastTick;
protected WorkerListenThread listenThreadImpl;
protected WorldSettings newWorldSettings;
protected boolean paused;
public EAGMinecraftServer(File par1File) {
super(par1File);
// TODO Auto-generated constructor stub
public EAGMinecraftServer(String world, String owner, WorldSettings currentWorldSettings) {
super(world);
this.setServerOwner(owner);
this.setConfigurationManager(new EAGPlayerList(this));
this.listenThreadImpl = new WorkerListenThread(this);
this.newWorldSettings = currentWorldSettings;
}
public void setBaseServerProperties(int difficulty, EnumGameType gamemode) {
this.difficulty = difficulty;
this.gamemode = gamemode;
}
public void mainLoop() {
if(paused) {
return;
}
long ctm = System.currentTimeMillis();
long delta = ctm - lastTick;
if (delta > 2000L && ctm - this.timeOfLastWarning >= 15000L) {
this.getLogAgent().func_98236_b("Can\'t keep up! Did the system time change, or is the server overloaded? Skipping " + ((delta - 2000l) / 50l) + " ticks");
delta = 2000L;
this.timeOfLastWarning = ctm;
}
if (delta < 0L) {
this.getLogAgent().func_98236_b("Time ran backwards! Did the fucking system time change?");
delta = 0L;
}
if (this.worldServers[0].areAllPlayersAsleep()) {
this.tick();
lastTick = ctm;
} else {
while (delta > 50L) {
delta -= 50L;
this.tick();
}
lastTick = System.currentTimeMillis();
}
}
public void setPaused(boolean p) {
paused = p;
}
public boolean getPaused() {
return paused;
}
@Override
protected boolean startServer() throws IOException {
// TODO Auto-generated method stub
return false;
this.loadAllWorlds(folderName, "world", difficulty, newWorldSettings);
this.lastTick = System.currentTimeMillis();
return true;
}
@Override
public boolean canStructuresSpawn() {
// TODO Auto-generated method stub
return false;
}
@Override
public EnumGameType getGameType() {
// TODO Auto-generated method stub
return null;
return gamemode;
}
@Override
public int getDifficulty() {
// TODO Auto-generated method stub
return 0;
return difficulty;
}
@Override
public boolean isHardcore() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isDedicatedServer() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isCommandBlockEnabled() {
// TODO Auto-generated method stub
return false;
return true;
}
@Override
public NetworkListenThread getNetworkThread() {
// TODO Auto-generated method stub
return null;
public WorkerListenThread getNetworkThread() {
return listenThreadImpl;
}
@Override
public String shareToLAN(EnumGameType var1, boolean var2) {
// TODO Auto-generated method stub
return null;
}
@Override
public ILogAgent getLogAgent() {
// TODO Auto-generated method stub
return null;
return IntegratedServer.logger;
}
}

View File

@ -0,0 +1,31 @@
package net.lax1dude.eaglercraft.sp;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.EntityPlayerMP;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.ServerConfigurationManager;
public class EAGPlayerList extends ServerConfigurationManager {
private NBTTagCompound hostPlayerNBT = null;
public EAGPlayerList(MinecraftServer par1MinecraftServer) {
super(par1MinecraftServer);
this.viewDistance = 15;
}
protected void writePlayerData(EntityPlayerMP par1EntityPlayerMP) {
if (par1EntityPlayerMP.getCommandSenderName().equals(this.getServerInstance().getServerOwner())) {
this.hostPlayerNBT = new NBTTagCompound();
par1EntityPlayerMP.writeToNBT(hostPlayerNBT);
}
}
public String allowUserToConnect(String par2Str) {
return par2Str.equalsIgnoreCase(this.getServerInstance().getServerOwner()) ? "fuck off don't hack your friends" : super.allowUserToConnect(par2Str);
}
public NBTTagCompound getHostPlayerData() {
return this.hostPlayerNBT;
}
}

View File

@ -0,0 +1,189 @@
package net.lax1dude.eaglercraft.sp;
public class EaglerUUID {
private final long mostSigBits;
private final long leastSigBits;
private EaglerUUID(byte[] data) {
long msb = 0;
long lsb = 0;
assert data.length == 16 : "data must be 16 bytes in length";
for (int i=0; i<8; i++)
msb = (msb << 8) | (data[i] & 0xff);
for (int i=8; i<16; i++)
lsb = (lsb << 8) | (data[i] & 0xff);
this.mostSigBits = msb;
this.leastSigBits = lsb;
}
public EaglerUUID(long mostSigBits, long leastSigBits) {
this.mostSigBits = mostSigBits;
this.leastSigBits = leastSigBits;
}
private static final EaglercraftRandom random = new EaglercraftRandom();
public static EaglerUUID randomUUID() {
byte[] randomBytes = new byte[16];
random.nextBytes(randomBytes);
randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */
return new EaglerUUID(randomBytes);
}
private static final SHA1Digest yee = new SHA1Digest();
public static EaglerUUID nameUUIDFromBytes(byte[] name) {
yee.update(name, 0, name.length);
byte[] md5Bytes = new byte[20];
yee.doFinal(md5Bytes, 0);
md5Bytes[6] &= 0x0f; /* clear version */
md5Bytes[6] |= 0x30; /* set to version 3 */
md5Bytes[8] &= 0x3f; /* clear variant */
md5Bytes[8] |= 0x80; /* set to IETF variant */
return new EaglerUUID(md5Bytes);
}
public static EaglerUUID fromString(String name) {
String[] components = name.split("-");
if (components.length != 5)
throw new IllegalArgumentException("Invalid UUID string: "+name);
for (int i=0; i<5; i++)
components[i] = "0x"+components[i];
long mostSigBits = Long.decode(components[0]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
long leastSigBits = Long.decode(components[3]).longValue();
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
return new EaglerUUID(mostSigBits, leastSigBits);
}
public long getLeastSignificantBits() {
return leastSigBits;
}
public long getMostSignificantBits() {
return mostSigBits;
}
/**
* The version number associated with this {@code UUID}. The version
* number describes how this {@code UUID} was generated.
*
* The version number has the following meaning:
* <ul>
* <li>1 Time-based UUID
* <li>2 DCE security UUID
* <li>3 Name-based UUID
* <li>4 Randomly generated UUID
* </ul>
*
* @return The version number of this {@code UUID}
*/
public int version() {
// Version is bits masked by 0x000000000000F000 in MS long
return (int)((mostSigBits >> 12) & 0x0f);
}
/**
* The variant number associated with this {@code UUID}. The variant
* number describes the layout of the {@code UUID}.
*
* The variant number has the following meaning:
* <ul>
* <li>0 Reserved for NCS backward compatibility
* <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF&nbsp;RFC&nbsp;4122</a>
* (Leach-Salz), used by this class
* <li>6 Reserved, Microsoft Corporation backward compatibility
* <li>7 Reserved for future definition
* </ul>
*
* @return The variant number of this {@code UUID}
*/
public int variant() {
// This field is composed of a varying number of bits.
// 0 - - Reserved for NCS backward compatibility
// 1 0 - The IETF aka Leach-Salz variant (used by this class)
// 1 1 0 Reserved, Microsoft backward compatibility
// 1 1 1 Reserved for future definition.
return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62)))
& (leastSigBits >> 63));
}
public long timestamp() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
return (mostSigBits & 0x0FFFL) << 48
| ((mostSigBits >> 16) & 0x0FFFFL) << 32
| mostSigBits >>> 32;
}
/**
* The clock sequence value associated with this UUID.
*
* <p> The 14 bit clock sequence value is constructed from the clock
* sequence field of this UUID. The clock sequence field is used to
* guarantee temporal uniqueness in a time-based UUID.
*
* <p> The {@code clockSequence} value is only meaningful in a time-based
* UUID, which has version type 1. If this UUID is not a time-based UUID
* then this method throws UnsupportedOperationException.
*
* @return The clock sequence of this {@code UUID}
*
* @throws UnsupportedOperationException
* If this UUID is not a version 1 UUID
*/
public int clockSequence() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
return (int)((leastSigBits & 0x3FFF000000000000L) >>> 48);
}
public String toString() {
return (digits(mostSigBits >> 32, 8) + "-" +
digits(mostSigBits >> 16, 4) + "-" +
digits(mostSigBits, 4) + "-" +
digits(leastSigBits >> 48, 4) + "-" +
digits(leastSigBits, 12));
}
private static String digits(long val, int digits) {
long hi = 1L << (digits * 4);
return Long.toHexString(hi | (val & (hi - 1))).substring(1);
}
public int hashCode() {
long hilo = mostSigBits ^ leastSigBits;
return ((int)(hilo >> 32)) ^ (int) hilo;
}
public boolean equals(Object obj) {
if ((null == obj) || !(obj instanceof EaglerUUID))
return false;
EaglerUUID id = (EaglerUUID)obj;
return (mostSigBits == id.mostSigBits &&
leastSigBits == id.leastSigBits);
}
public int compareTo(EaglerUUID val) {
return (this.mostSigBits < val.mostSigBits ? -1 :
(this.mostSigBits > val.mostSigBits ? 1 :
(this.leastSigBits < val.leastSigBits ? -1 :
(this.leastSigBits > val.leastSigBits ? 1 :
0))));
}
}

View File

@ -0,0 +1,84 @@
package net.lax1dude.eaglercraft.sp;
public class EaglercraftRandom {
private static final long multiplier = 0x5DEECE66DL;
private static final long addend = 0xBL;
private static final long mask = (1L << 48) - 1;
private static final double DOUBLE_UNIT = 0x1.0p-53;
private long seed = 69;
public EaglercraftRandom() {
this(System.nanoTime());
}
public EaglercraftRandom(long seed) {
setSeed(seed);
}
public void setSeed(long yeed) {
seed = yeed;
}
protected int next(int bits) {
seed = (seed * multiplier + addend) & mask;
return (int)(seed >>> (48 - bits));
}
public void nextBytes(byte[] bytes) {
for (int i = 0, len = bytes.length; i < len; )
for (int rnd = nextInt(),
n = Math.min(len - i, Integer.SIZE/Byte.SIZE);
n-- > 0; rnd >>= Byte.SIZE)
bytes[i++] = (byte)rnd;
}
public int nextInt() {
return next(32);
}
public int nextInt(int bound) {
int r = next(31);
int m = bound - 1;
if ((bound & m) == 0) // i.e., bound is a power of 2
r = (int)((bound * (long)r) >> 31);
else {
for (int u = r;
u - (r = u % bound) + m < 0;
u = next(31))
;
}
return r;
}
public long nextLong() {
return ((long)(next(32)) << 32) + next(32);
}
public boolean nextBoolean() {
return next(1) != 0;
}
public float nextFloat() {
return next(24) / ((float)(1 << 24));
}
public double nextDouble() {
return (((long)(next(26)) << 27) + next(27)) * DOUBLE_UNIT;
}
private double nextNextGaussian;
private boolean haveNextNextGaussian = false;
public double nextGaussian() {
// See Knuth, ACP, Section 3.4.1 Algorithm C.
if (haveNextNextGaussian) {
haveNextNextGaussian = false;
return nextNextGaussian;
} else {
double v1, v2, s;
do {
v1 = 2 * nextDouble() - 1; // between -1 and 1
v2 = 2 * nextDouble() - 1; // between -1 and 1
s = v1 * v1 + v2 * v2;
} while (s >= 1 || s == 0);
double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s);
nextNextGaussian = v2 * multiplier;
haveNextNextGaussian = true;
return v1 * multiplier;
}
}
}

View File

@ -0,0 +1,124 @@
package net.lax1dude.eaglercraft.sp;
/**
* base implementation of MD4 family style digest as outlined in
* "Handbook of Applied Cryptography", pages 344 - 347.
*/
public abstract class GeneralDigest {
private byte[] xBuf;
private int xBufOff;
private long byteCount;
/**
* Standard constructor
*/
protected GeneralDigest()
{
xBuf = new byte[4];
xBufOff = 0;
}
/**
* Copy constructor. We are using copy constructors in place
* of the Object.clone() interface as this interface is not
* supported by J2ME.
*/
protected GeneralDigest(GeneralDigest t)
{
xBuf = new byte[t.xBuf.length];
System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length);
xBufOff = t.xBufOff;
byteCount = t.byteCount;
}
public void update(
byte in)
{
xBuf[xBufOff++] = in;
if (xBufOff == xBuf.length)
{
processWord(xBuf, 0);
xBufOff = 0;
}
byteCount++;
}
public void update(
byte[] in,
int inOff,
int len)
{
//
// fill the current word
//
while ((xBufOff != 0) && (len > 0))
{
update(in[inOff]);
inOff++;
len--;
}
//
// process whole words.
//
while (len > xBuf.length)
{
processWord(in, inOff);
inOff += xBuf.length;
len -= xBuf.length;
byteCount += xBuf.length;
}
//
// load in the remainder.
//
while (len > 0)
{
update(in[inOff]);
inOff++;
len--;
}
}
public void finish()
{
long bitLength = (byteCount << 3);
//
// add the pad bytes.
//
update((byte)128);
while (xBufOff != 0)
{
update((byte)0);
}
processLength(bitLength);
processBlock();
}
public void reset()
{
byteCount = 0;
xBufOff = 0;
for ( int i = 0; i < xBuf.length; i++ ) {
xBuf[i] = 0;
}
}
protected abstract void processWord(byte[] in, int inOff);
protected abstract void processLength(long bitLength);
protected abstract void processBlock();
}

View File

@ -2,13 +2,24 @@ package net.lax1dude.eaglercraft.sp;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
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.minecraft.src.AchievementList;
import net.minecraft.src.AchievementMap;
import net.minecraft.src.CompressedStreamTools;
import net.minecraft.src.EnumGameType;
import net.minecraft.src.ILogAgent;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.StringTranslate;
import net.minecraft.src.WorldSettings;
import net.minecraft.src.WorldType;
public class IntegratedServer {
@ -23,11 +34,23 @@ public class IntegratedServer {
}
}
private static EAGMinecraftServer currentProcess = null;
private static WorldSettings newWorldSettings = null;
public static EAGMinecraftServer getServer() {
return currentProcess;
}
public static final ILogAgent logger = new EAGLogAgent();
@JSFunctor
private static class WorkerBinaryPacketHandler {
private static interface WorkerBinaryPacketHandler extends JSObject {
public void onMessage(String channel, ArrayBuffer buf);
}
private static class WorkerBinaryPacketHandlerImpl implements WorkerBinaryPacketHandler {
@SuppressWarnings("unused")
private void onMessage(String channel, ArrayBuffer buf) {
public void onMessage(String channel, ArrayBuffer buf) {
if(channel == null) {
System.err.println("Recieved IPC packet with null channel");
return;
@ -40,7 +63,7 @@ public class IntegratedServer {
Uint8Array a = Uint8Array.create(buf);
byte[] pkt = new byte[a.getLength()];
for(int i = 0; i < a.getLength(); ++i) {
for(int i = 0; i < pkt.length; ++i) {
pkt[i] = (byte) a.get(i);
}
@ -49,6 +72,34 @@ public class IntegratedServer {
}
private static void tryStopServer() {
if(currentProcess != null) {
try {
currentProcess.stopServer();
currentProcess = null;
}catch(Throwable t) {
System.err.println("Failed to stop server!");
throwExceptionToClient("Failed to stop server!", t);
}
}
}
private static boolean isServerStopped() {
return currentProcess == null || currentProcess.isServerRunning();
}
public static void throwExceptionToClient(String msg, Throwable t) {
String str = t.toString();
System.err.println("Exception was raised to client: " + str);
List<String> arr = new LinkedList();
for(StackTraceElement e : t.getStackTrace()) {
String st = e.toString();
arr.add(st);
System.err.println(" " + st);
}
sendIPCPacket(new IPCPacket15ThrowException(str, arr));
}
private static void processAsyncMessageQueue() {
while(messageQueue.size() > 0) {
PKT msg = messageQueue.remove(0);
@ -65,70 +116,246 @@ public class IntegratedServer {
}
int id = packet.id();
switch(id) {
case IPCPacket00StartServer.ID:
break;
case IPCPacket01StopServer.ID:
break;
case IPCPacket02InitWorld.ID:
break;
case IPCPacket03DeleteWorld.ID:
break;
case IPCPacket04RenameWorld.ID:
break;
case IPCPacket05RequestData.ID:
break;
case IPCPacket07ImportWorld.ID:
break;
case IPCPacket09RequestResponse.ID:
break;
case IPCPacket0ASetWorldDifficulty.ID:
break;
case IPCPacket0BPause.ID:
break;
case IPCPacket0CPlayerChannel.ID:
break;
case IPCPacket0EListWorlds.ID:
break;
case IPCPacket0FListFiles.ID:
break;
case IPCPacket10FileRead.ID:
break;
case IPCPacket12FileWrite.ID:
break;
case IPCPacket13FileCopyMove.ID:
break;
case IPCPacket14StringList.ID:
break;
default:
System.err.println("IPC packet type 0x" + Integer.toHexString(id) + " class '" + packet.getClass().getSimpleName() + "' was not handled");
break;
try {
switch(id) {
case IPCPacket00StartServer.ID: {
IPCPacket00StartServer pkt = (IPCPacket00StartServer)packet;
if(!isServerStopped()) {
currentProcess.stopServer();
}
currentProcess = new EAGMinecraftServer("worlds/" + pkt.worldName, pkt.ownerName, newWorldSettings);
currentProcess.setBaseServerProperties(pkt.initialDifficulty, newWorldSettings == null ? EnumGameType.SURVIVAL : newWorldSettings.getGameType());
currentProcess.startServer();
}
break;
case IPCPacket01StopServer.ID: {
if(!isServerStopped()) {
try {
currentProcess.stopServer();
currentProcess = null;
}catch(Throwable t) {
throwExceptionToClient("Failed to stop server!", t);
}
}else {
System.err.println("Client tried to stop server while it was running for some reason");
}
}
break;
case IPCPacket02InitWorld.ID: {
tryStopServer();
IPCPacket02InitWorld pkt = (IPCPacket02InitWorld)packet;
newWorldSettings = new WorldSettings(pkt.seed, pkt.gamemode == 1 ? EnumGameType.CREATIVE : EnumGameType.SURVIVAL, pkt.structures,
pkt.gamemode == 2, pkt.worldType == 1 ? WorldType.FLAT : (pkt.worldType == 2 ? WorldType.LARGE_BIOMES : WorldType.DEFAULT_1_1));
newWorldSettings.func_82750_a(pkt.worldArgs);
if(pkt.bonusChest) {
newWorldSettings.enableBonusChest();
}
if(pkt.cheats) {
newWorldSettings.enableCheats();
}
}
break;
case IPCPacket03DeleteWorld.ID: {
tryStopServer();
IPCPacket03DeleteWorld pkt = (IPCPacket03DeleteWorld)packet;
if(SYS.VFS.deleteFiles("worlds/" + pkt.worldName) <= 0) {
throwExceptionToClient("Failed to delete world!", new RuntimeException("VFS did not delete directory 'worlds/" + pkt.worldName + "' correctly"));
}
}
break;
case IPCPacket04RenameWorld.ID: {
tryStopServer();
IPCPacket04RenameWorld pkt = (IPCPacket04RenameWorld)packet;
if(SYS.VFS.renameFiles("worlds/" + pkt.worldOldName, "worlds/" + pkt.worldNewName, pkt.copy) <= 0) {
throwExceptionToClient("Failed to copy/rename server!", new RuntimeException("VFS did not copy/rename directory 'worlds/" + pkt.worldOldName + "' correctly"));
}else {
VFile worldDat = new VFile("worlds", pkt.worldNewName, "level.dat");
if(worldDat.canRead()) {
NBTTagCompound worldDatNBT = CompressedStreamTools.decompress(worldDat.getAllBytes());
worldDatNBT.setString("LevelName", pkt.displayName);
worldDat.setAllBytes(CompressedStreamTools.compress(worldDatNBT));
}else {
throwExceptionToClient("Failed to copy/rename world!", new RuntimeException("Failed to change level.dat world '" + pkt.worldNewName + "' display name to '" + pkt.displayName + "' because level.dat was missing"));
}
}
}
break;
case IPCPacket05RequestData.ID:
break;
case IPCPacket06RenameWorldNBT.ID: {
IPCPacket06RenameWorldNBT pkt = (IPCPacket06RenameWorldNBT)packet;
if(isServerStopped()) {
VFile worldDat = new VFile("worlds", pkt.worldName, "level.dat");
if(worldDat.canRead()) {
NBTTagCompound worldDatNBT = CompressedStreamTools.decompress(worldDat.getAllBytes());
worldDatNBT.setString("LevelName", pkt.displayName);
worldDat.setAllBytes(CompressedStreamTools.compress(worldDatNBT));
}else {
throwExceptionToClient("Failed to rename world!", new RuntimeException("Failed to change level.dat world '" + pkt.worldName + "' display name to '" + pkt.displayName + "' because level.dat was missing"));
}
}else {
System.err.println("Client tried to rename a world '" + pkt.worldName + "' to have name '" + pkt.displayName + "' while the server is running");
}
}
break;
case IPCPacket07ImportWorld.ID:
break;
case IPCPacket09RequestResponse.ID:
break;
case IPCPacket0ASetWorldDifficulty.ID: {
IPCPacket0ASetWorldDifficulty pkt = (IPCPacket0ASetWorldDifficulty)packet;
if(!isServerStopped()) {
currentProcess.setDifficultyForAllWorlds(pkt.difficulty);
}else {
System.err.println("Client tried to set difficulty '" + pkt.difficulty + "' while server was stopped");
}
}
break;
case IPCPacket0BPause.ID: {
IPCPacket0BPause pkt = (IPCPacket0BPause)packet;
if(!isServerStopped()) {
currentProcess.setPaused(pkt.pause);
}else {
System.err.println("Client tried to " + (pkt.pause ? "pause" : "unpause") + " while server was stopped");
}
}
break;
case IPCPacket0CPlayerChannel.ID: {
IPCPacket0CPlayerChannel pkt = (IPCPacket0CPlayerChannel)packet;
if(!isServerStopped()) {
if(pkt.open) {
if(!currentProcess.getNetworkThread().openChannel(pkt.channel)) {
System.err.println("Client tried to open a duplicate channel '" + pkt.channel + "'");
}
}else {
if(!currentProcess.getNetworkThread().closeChannel(pkt.channel)) {
System.err.println("Client tried to close a null channel '" + pkt.channel + "'");
}
}
}else {
System.err.println("Client tried to " + (pkt.open ? "open" : "close") + " channel '" + pkt.channel + "' while server was stopped");
}
}
break;
case IPCPacket0EListWorlds.ID: {
IPCPacket0EListWorlds pkt = (IPCPacket0EListWorlds)packet;
if(isServerStopped()) {
String[] worlds = SYS.VFS.getFile("worlds.txt").getAllLines();
LinkedList<String> updatedList = new LinkedList();
LinkedList<NBTTagCompound> sendListNBT = new LinkedList();
boolean rewrite = false;
for(String w : worlds) {
VFile lvl = new VFile("worlds", w, "level.dat");
if(!lvl.canRead()) {
rewrite = true;
System.err.println("World level.dat for '" + w + "' was not found, attempting to delete 'worlds/" + w + "/*'");
if(SYS.VFS.deleteFiles("worlds/" + w) <= 0) {
System.err.println("No files were deleted in 'worlds/" + w + "/*', this may be corruption but '" + w + "' will still be removed from worlds.txt");
}
}else {
NBTTagCompound worldDatNBT;
try {
sendListNBT.add(CompressedStreamTools.decompress(lvl.getAllBytes()));
updatedList.add(w);
}catch(IOException e) {
rewrite = true;
System.err.println("World level.dat for '" + w + "' was corrupt, attempting to delete 'worlds/" + w + "/*'");
if(SYS.VFS.deleteFiles("worlds/" + w) <= 0) {
System.err.println("No files were deleted in 'worlds/" + w + "/*', this may be corruption but '" + w + "' will still be removed from worlds.txt");
}
}
}
}
if(rewrite) {
SYS.VFS.getFile("worlds.txt").setAllChars(String.join("\n", updatedList));
}
sendIPCPacket(new IPCPacket16NBTList(IPCPacket16NBTList.WORLD_LIST, sendListNBT));
}else {
System.err.println("Client tried to list worlds while server was running");
}
}
break;
case IPCPacket0FListFiles.ID:
break;
case IPCPacket10FileRead.ID:
break;
case IPCPacket12FileWrite.ID:
break;
case IPCPacket13FileCopyMove.ID:
break;
case IPCPacket14StringList.ID: {
IPCPacket14StringList pkt = (IPCPacket14StringList)packet;
switch(pkt.opCode) {
case IPCPacket14StringList.LOCALE:
StringTranslate.init(pkt.stringList);
break;
case IPCPacket14StringList.STAT_GUID:
AchievementMap.init(pkt.stringList);
AchievementList.init();
break;
default:
System.err.println("Strange string list 0x" + Integer.toHexString(pkt.opCode) + " with length " + pkt.stringList.size() + " recieved");
break;
}
}
break;
default:
System.err.println("IPC packet type 0x" + Integer.toHexString(id) + " class '" + packet.getClass().getSimpleName() + "' was not handled");
break;
}
}catch(Throwable t) {
System.err.println("IPC packet 0x" + Integer.toHexString(id) + " class '" + packet.getClass().getSimpleName() + "' was not processed correctly");
t.printStackTrace();
}
return;
}else if(msg.channel.startsWith("NET|")) {
String u = msg.channel.substring(4);
currentProcess.getNetworkThread().recievePacket(u, msg.data);
}
System.err.println("Unknown IPC channel: " + msg.channel);
}
}
@JSBody(params = { "ch", "dat" }, script = "postMessage({ ch: ch, dat : dat });")
private static native void sendWorkerPacket(String channel, ArrayBuffer arr);
public static void sendIPCPacket(IPCPacketBase pkt) {
byte[] serialized;
try {
serialized = IPCPacketManager.IPCSerialize(pkt);
} catch (IOException e) {
System.err.println("Could not serialize IPC packet 0x" + Integer.toHexString(pkt.id()) + " class '" + pkt.getClass().getSimpleName() + "'");
e.printStackTrace();
return;
}
ArrayBuffer arb = ArrayBuffer.create(serialized.length);
Uint8Array ar = Uint8Array.create(arb);
ar.set(serialized);
sendWorkerPacket("IPC", arb);
}
public static void sendPlayerPacket(String channel, byte[] buf) {
ArrayBuffer arb = ArrayBuffer.create(buf.length);
Uint8Array ar = Uint8Array.create(arb);
ar.set(buf);
sendWorkerPacket("NET|" + channel, arb);
}
private static boolean isRunning = false;
public static void halt() {
@ -137,17 +364,33 @@ public class IntegratedServer {
private static void mainLoop() {
processAsyncMessageQueue();
if(currentProcess != null) {
currentProcess.mainLoop();
}
}
@JSBody(params = { "wb" }, script = "onmessage = function(o) { wb(o.ch, o.dat); };")
@JSBody(params = { "wb" }, script = "onmessage = function(o) { wb(o.data.ch, o.data.dat); };")
private static native void registerPacketHandler(WorkerBinaryPacketHandler wb);
@JSBody(script = "return (((typeof window) !== \"undefined\") && ((typeof window.testScript) !== \"undefined\")) ? window.testScript : null;")
private static native String shouldLaunchTest();
public static void main(String[] args) {
registerPacketHandler(new WorkerBinaryPacketHandler());
String test = shouldLaunchTest();
if(test != null) {
WorkerTest.init(test);
return;
}
registerPacketHandler(new WorkerBinaryPacketHandlerImpl());
isRunning = true;
sendIPCPacket(new IPCPacketFFProcessKeepAlive());
while(isRunning) {
mainLoop();

View File

@ -0,0 +1,258 @@
package net.lax1dude.eaglercraft.sp;
/**
* implementation of SHA-1 as outlined in "Handbook of Applied Cryptography", pages 346 - 349.
*
* It is interesting to ponder why the, apart from the extra IV, the other difference here from MD5
* is the "endienness" of the word processing!
*/
public class SHA1Digest
extends GeneralDigest
{
private static final int DIGEST_LENGTH = 20;
private int H1, H2, H3, H4, H5;
private int[] X = new int[80];
private int xOff;
/**
* Standard constructor
*/
public SHA1Digest()
{
reset();
}
/**
* Copy constructor. This will copy the state of the provided
* message digest.
*/
public SHA1Digest(SHA1Digest t)
{
super(t);
H1 = t.H1;
H2 = t.H2;
H3 = t.H3;
H4 = t.H4;
H5 = t.H5;
System.arraycopy(t.X, 0, X, 0, t.X.length);
xOff = t.xOff;
}
public String getAlgorithmName()
{
return "SHA-1";
}
public int getDigestSize()
{
return DIGEST_LENGTH;
}
protected void processWord(
byte[] in,
int inOff)
{
X[xOff++] = ((in[inOff] & 0xff) << 24) | ((in[inOff + 1] & 0xff) << 16)
| ((in[inOff + 2] & 0xff) << 8) | ((in[inOff + 3] & 0xff));
if (xOff == 16)
{
processBlock();
}
}
private void unpackWord(
int word,
byte[] out,
int outOff)
{
out[outOff] = (byte)(word >>> 24);
out[outOff + 1] = (byte)(word >>> 16);
out[outOff + 2] = (byte)(word >>> 8);
out[outOff + 3] = (byte)word;
}
protected void processLength(
long bitLength)
{
if (xOff > 14)
{
processBlock();
}
X[14] = (int)(bitLength >>> 32);
X[15] = (int)(bitLength & 0xffffffff);
}
public int doFinal(
byte[] out,
int outOff)
{
finish();
unpackWord(H1, out, outOff);
unpackWord(H2, out, outOff + 4);
unpackWord(H3, out, outOff + 8);
unpackWord(H4, out, outOff + 12);
unpackWord(H5, out, outOff + 16);
reset();
return DIGEST_LENGTH;
}
/**
* reset the chaining variables
*/
public void reset()
{
super.reset();
H1 = 0x67452301;
H2 = 0xefcdab89;
H3 = 0x98badcfe;
H4 = 0x10325476;
H5 = 0xc3d2e1f0;
xOff = 0;
for (int i = 0; i != X.length; i++)
{
X[i] = 0;
}
}
//
// Additive constants
//
private static final int Y1 = 0x5a827999;
private static final int Y2 = 0x6ed9eba1;
private static final int Y3 = 0x8f1bbcdc;
private static final int Y4 = 0xca62c1d6;
private int f(
int u,
int v,
int w)
{
return ((u & v) | ((~u) & w));
}
private int h(
int u,
int v,
int w)
{
return (u ^ v ^ w);
}
private int g(
int u,
int v,
int w)
{
return ((u & v) | (u & w) | (v & w));
}
private int rotateLeft(
int x,
int n)
{
return (x << n) | (x >>> (32 - n));
}
protected void processBlock()
{
//
// expand 16 word block into 80 word block.
//
for (int i = 16; i <= 79; i++)
{
X[i] = rotateLeft((X[i - 3] ^ X[i - 8] ^ X[i - 14] ^ X[i - 16]), 1);
}
//
// set up working variables.
//
int A = H1;
int B = H2;
int C = H3;
int D = H4;
int E = H5;
//
// round 1
//
for (int j = 0; j <= 19; j++)
{
int t = rotateLeft(A, 5) + f(B, C, D) + E + X[j] + Y1;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
//
// round 2
//
for (int j = 20; j <= 39; j++)
{
int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y2;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
//
// round 3
//
for (int j = 40; j <= 59; j++)
{
int t = rotateLeft(A, 5) + g(B, C, D) + E + X[j] + Y3;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
//
// round 4
//
for (int j = 60; j <= 79; j++)
{
int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y4;
E = D;
D = C;
C = rotateLeft(B, 30);
B = A;
A = t;
}
H1 += A;
H2 += B;
H3 += C;
H4 += D;
H5 += E;
//
// reset the offset and clean out the word buffer.
//
xOff = 0;
for (int i = 0; i != X.length; i++)
{
X[i] = 0;
}
}
}

View File

@ -1,19 +1,13 @@
package net.lax1dude.eaglercraft.sp;
import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject;
import org.teavm.jso.browser.Window;
import net.lax1dude.eaglercraft.sp.VirtualFilesystem.VFSHandle;
public class SYS {
public static final boolean PERSIST;
//public static final boolean PERSIST;
public static final VirtualFilesystem VFS;
/*
@JSFunctor
private interface PromiseHandler extends JSObject {
void complete(JSObject result);
@ -30,19 +24,21 @@ public class SYS {
+ "navigator.storage.persist().then(function(persistent) {callback(persistent ? {p:true} : null);});"
+ "}else{callback(null);}")
private static native void requestPersist0(PromiseHandler callback);
*/
static {
PERSIST = requestPersist().bool;
//PERSIST = requestPersist().bool;
if(!PERSIST) {
Window.alert("PERSISTENT STORAGE NOT AVAILABLE, YOUR BROWSER MAY DELETE YOUR WORLDS!");
}
//if(!PERSIST) {
// Window.alert("PERSISTENT STORAGE NOT AVAILABLE, YOUR BROWSER MAY DELETE YOUR WORLDS!");
//}
VFSHandle vh = VirtualFilesystem.openVFS("_net_lax1dude_eaglercraft_sp_VirtualFilesystem_1_5_2");
if(vh.vfs == null) {
Window.alert("COULD NOT INIT FILESYSTEM: " + vh.toString());
System.err.println("Could not init filesystem!");
IntegratedServer.throwExceptionToClient("Could not init filesystem!", new RuntimeException("VFSHandle.vfs was null"));
}
VFS = vh.vfs;

View File

@ -0,0 +1,291 @@
package net.lax1dude.eaglercraft.sp;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import net.minecraft.src.Chunk;
import net.minecraft.src.CompressedStreamTools;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityList;
import net.minecraft.src.ExtendedBlockStorage;
import net.minecraft.src.IChunkLoader;
import net.minecraft.src.MinecraftException;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.NextTickListEntry;
import net.minecraft.src.NibbleArray;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class VFSChunkLoader implements IChunkLoader {
public final VFile chunkDirectory;
private static final String hex = "0123456789ABCDEF";
public static String getChunkPath(int x, int z) {
int unsignedX = x + 1900000;
int unsignedZ = z + 1900000;
char[] path = new char[12];
for(int i = 5; i >= 0; --i) {
path[i] = hex.charAt((unsignedX >> (i * 4)) & 0xF);
path[i + 6] = hex.charAt((unsignedZ >> (i * 4)) & 0xF);
}
return new String(path);
}
public VFSChunkLoader(VFile chunkDirectory) {
this.chunkDirectory = chunkDirectory;
}
@Override
public Chunk loadChunk(World var1, int var2, int var3) throws IOException {
VFile file = new VFile(chunkDirectory, getChunkPath(var2, var3), ".dat");
byte[] bytes = file.getAllBytes();
if(bytes == null) {
return null;
}
try {
NBTTagCompound nbt = CompressedStreamTools.decompress(bytes);
nbt = nbt.getCompoundTag("Level");
return readChunkFromNBT(var1, nbt, var2, var3);
}catch(Throwable t) {
file.delete();
System.err.println("Corrupted chunk has been deleted: [" + var2 + ", " + var3 + "]");
t.printStackTrace();
return null;
}
}
@Override
public void saveChunk(World var1, Chunk var2) throws MinecraftException, IOException {
NBTTagCompound chunkFile = new NBTTagCompound();
this.writeChunkToNBT(var2, var1, chunkFile);
byte[] save;
try {
NBTTagCompound chunkFileSave = new NBTTagCompound();
chunkFileSave.setCompoundTag("Level", chunkFileSave);
save = CompressedStreamTools.compress(chunkFileSave);
}catch(IOException e) {
System.err.println("Corrupted chunk could not be serialized: [" + var2.xPosition + ", " + var2.zPosition + "]");
return;
}
VFile file = new VFile(chunkDirectory, getChunkPath(var2.xPosition, var2.zPosition) + ".dat");
if(!file.setAllBytes(save)) {
System.err.println("Corrupted chunk could not be written: [" + var2.xPosition + ", " + var2.zPosition + "] to file \"" + file.toString() + "\")");
}
}
@Override
public void saveExtraChunkData(World var1, Chunk var2) {
// ?
}
@Override
public void chunkTick() {
// TODO Auto-generated method stub
}
@Override
public void saveExtraData() {
// unused
}
private Chunk readChunkFromNBT(World par1World, NBTTagCompound par2NBTTagCompound, int x, int z) {
int var3 = x; //par2NBTTagCompound.getInteger("xPos");
int var4 = z; //par2NBTTagCompound.getInteger("zPos");
Chunk var5 = new Chunk(par1World, var3, var4);
var5.heightMap = par2NBTTagCompound.getIntArray("HeightMap");
var5.isTerrainPopulated = par2NBTTagCompound.getBoolean("TerrainPopulated");
NBTTagList var6 = par2NBTTagCompound.getTagList("Sections");
byte var7 = 16;
ExtendedBlockStorage[] var8 = new ExtendedBlockStorage[var7];
boolean var9 = !par1World.provider.hasNoSky;
for (int var10 = 0; var10 < var6.tagCount(); ++var10) {
NBTTagCompound var11 = (NBTTagCompound) var6.tagAt(var10);
byte var12 = var11.getByte("Y");
ExtendedBlockStorage var13 = new ExtendedBlockStorage(var12 << 4, var9);
var13.setBlockLSBArray(var11.getByteArray("Blocks"));
if (var11.hasKey("Add")) {
var13.setBlockMSBArray(new NibbleArray(var11.getByteArray("Add"), 4));
}
var13.setBlockMetadataArray(new NibbleArray(var11.getByteArray("Data"), 4));
var13.setBlocklightArray(new NibbleArray(var11.getByteArray("BlockLight"), 4));
if (var9) {
var13.setSkylightArray(new NibbleArray(var11.getByteArray("SkyLight"), 4));
}
var13.removeInvalidBlocks();
var8[var12] = var13;
}
var5.setStorageArrays(var8);
if (par2NBTTagCompound.hasKey("Biomes")) {
var5.setBiomeArray(par2NBTTagCompound.getByteArray("Biomes"));
}
NBTTagList var17 = par2NBTTagCompound.getTagList("Entities");
if (var17 != null) {
for (int var18 = 0; var18 < var17.tagCount(); ++var18) {
NBTTagCompound var20 = (NBTTagCompound) var17.tagAt(var18);
Entity var22 = EntityList.createEntityFromNBT(var20, par1World);
var5.hasEntities = true;
if (var22 != null) {
var5.addEntity(var22);
Entity var14 = var22;
for (NBTTagCompound var15 = var20; var15.hasKey("Riding"); var15 = var15.getCompoundTag("Riding")) {
Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), par1World);
if (var16 != null) {
var5.addEntity(var16);
var14.mountEntity(var16);
}
var14 = var16;
}
}
}
}
NBTTagList var19 = par2NBTTagCompound.getTagList("TileEntities");
if (var19 != null) {
for (int var21 = 0; var21 < var19.tagCount(); ++var21) {
NBTTagCompound var24 = (NBTTagCompound) var19.tagAt(var21);
TileEntity var26 = TileEntity.createAndLoadEntity(var24);
if (var26 != null) {
var5.addTileEntity(var26);
}
}
}
if (par2NBTTagCompound.hasKey("TileTicks")) {
NBTTagList var23 = par2NBTTagCompound.getTagList("TileTicks");
if (var23 != null) {
for (int var25 = 0; var25 < var23.tagCount(); ++var25) {
NBTTagCompound var27 = (NBTTagCompound) var23.tagAt(var25);
par1World.scheduleBlockUpdateFromLoad(var27.getInteger("x"), var27.getInteger("y"),
var27.getInteger("z"), var27.getInteger("i"), var27.getInteger("t"), var27.getInteger("p"));
}
}
}
return var5;
}
private void writeChunkToNBT(Chunk par1Chunk, World par2World, NBTTagCompound par3NBTTagCompound) {
par3NBTTagCompound.setInteger("xPos", par1Chunk.xPosition);
par3NBTTagCompound.setInteger("zPos", par1Chunk.zPosition);
par3NBTTagCompound.setLong("LastUpdate", par2World.getTotalWorldTime());
par3NBTTagCompound.setIntArray("HeightMap", par1Chunk.heightMap);
par3NBTTagCompound.setBoolean("TerrainPopulated", par1Chunk.isTerrainPopulated);
ExtendedBlockStorage[] var4 = par1Chunk.getBlockStorageArray();
NBTTagList var5 = new NBTTagList("Sections");
boolean var6 = !par2World.provider.hasNoSky;
ExtendedBlockStorage[] var7 = var4;
int var8 = var4.length;
NBTTagCompound var11;
for (int var9 = 0; var9 < var8; ++var9) {
ExtendedBlockStorage var10 = var7[var9];
if (var10 != null) {
var11 = new NBTTagCompound();
var11.setByte("Y", (byte) (var10.getYLocation() >> 4 & 255));
var11.setByteArray("Blocks", var10.getBlockLSBArray());
if (var10.getBlockMSBArray() != null) {
var11.setByteArray("Add", var10.getBlockMSBArray().data);
}
var11.setByteArray("Data", var10.getMetadataArray().data);
var11.setByteArray("BlockLight", var10.getBlocklightArray().data);
if (var6) {
var11.setByteArray("SkyLight", var10.getSkylightArray().data);
} else {
var11.setByteArray("SkyLight", new byte[var10.getBlocklightArray().data.length]);
}
var5.appendTag(var11);
}
}
par3NBTTagCompound.setTag("Sections", var5);
par3NBTTagCompound.setByteArray("Biomes", par1Chunk.getBiomeArray());
par1Chunk.hasEntities = false;
NBTTagList var16 = new NBTTagList();
Iterator var18;
for (var8 = 0; var8 < par1Chunk.entityLists.length; ++var8) {
var18 = par1Chunk.entityLists[var8].iterator();
while (var18.hasNext()) {
Entity var20 = (Entity) var18.next();
var11 = new NBTTagCompound();
if (var20.addEntityID(var11)) {
par1Chunk.hasEntities = true;
var16.appendTag(var11);
}
}
}
par3NBTTagCompound.setTag("Entities", var16);
NBTTagList var17 = new NBTTagList();
var18 = par1Chunk.chunkTileEntityMap.values().iterator();
while (var18.hasNext()) {
TileEntity var21 = (TileEntity) var18.next();
var11 = new NBTTagCompound();
var21.writeToNBT(var11);
var17.appendTag(var11);
}
par3NBTTagCompound.setTag("TileEntities", var17);
List var19 = par2World.getPendingBlockUpdates(par1Chunk, false);
if (var19 != null) {
long var22 = par2World.getTotalWorldTime();
NBTTagList var12 = new NBTTagList();
Iterator var13 = var19.iterator();
while (var13.hasNext()) {
NextTickListEntry var14 = (NextTickListEntry) var13.next();
NBTTagCompound var15 = new NBTTagCompound();
var15.setInteger("i", var14.blockID);
var15.setInteger("x", var14.xCoord);
var15.setInteger("y", var14.yCoord);
var15.setInteger("z", var14.zCoord);
var15.setInteger("t", (int) (var14.scheduledTime - var22));
var15.setInteger("p", var14.field_82754_f);
var12.appendTag(var15);
}
par3NBTTagCompound.setTag("TileTicks", var12);
}
}
}

View File

@ -0,0 +1,17 @@
package net.lax1dude.eaglercraft.sp;
public interface VFSIterator {
public static class BreakLoop extends RuntimeException {
public BreakLoop() {
super("iterator loop break request");
}
}
public default void end() {
throw new BreakLoop();
}
public void next(VIteratorFile entry);
}

View File

@ -0,0 +1,39 @@
package net.lax1dude.eaglercraft.sp;
import net.minecraft.src.IProgressUpdate;
import net.minecraft.src.ISaveFormat;
import net.minecraft.src.ISaveHandler;
public class VFSSaveFormat implements ISaveFormat {
private VFSSaveHandler folder;
public VFSSaveFormat(VFSSaveHandler dir) {
folder = dir;
}
@Override
public ISaveHandler getSaveLoader(String var1, boolean var2) {
return folder;
}
@Override
public void flushCache() {
}
@Override
public boolean deleteWorldDirectory(String var1) {
return true;
}
@Override
public boolean isOldMapFormat(String var1) {
return false;
}
@Override
public boolean convertMapFormat(String var1, IProgressUpdate var2) {
return false;
}
}

View File

@ -0,0 +1,158 @@
package net.lax1dude.eaglercraft.sp;
import java.io.IOException;
import java.util.HashMap;
import net.minecraft.src.CompressedStreamTools;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IChunkLoader;
import net.minecraft.src.IPlayerFileData;
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;
public class VFSSaveHandler implements ISaveHandler, IPlayerFileData {
public final VFile worldDirectory;
private final HashMap<Integer, VFSChunkLoader> chunkLoaders = new HashMap();
public VFSSaveHandler(VFile worldDirectory) {
this.worldDirectory = worldDirectory;
}
@Override
public WorldInfo loadWorldInfo() {
byte[] level_dat_bin = (new VFile(worldDirectory, "level.dat")).getAllBytes();
if(level_dat_bin == null) {
return null;
}
try {
NBTTagCompound level_dat = CompressedStreamTools.decompress(level_dat_bin);
return new WorldInfo(level_dat);
}catch(Throwable t) {
System.err.println("Could not parse level.dat!");
t.printStackTrace();
}
return null;
}
@Override
public void checkSessionLock() throws MinecraftException {
// no
}
@Override
public IChunkLoader getChunkLoader(WorldProvider var1) {
VFSChunkLoader loader = chunkLoaders.get(var1.dimensionId);
if(loader == null) {
loader = new VFSChunkLoader(new VFile(worldDirectory, "level" + var1.dimensionId));
chunkLoaders.put(var1.dimensionId, loader);
}
return loader;
}
@Override
public void saveWorldInfoWithPlayer(WorldInfo var1, NBTTagCompound var2) {
NBTTagCompound var3 = var2 != null ? var1.cloneNBTCompound(var2) : var1.getNBTTagCompound();
NBTTagCompound var4 = new NBTTagCompound();
var4.setTag("Data", var3);
VFile level_dat = new VFile(worldDirectory, "level.dat");
byte[] compressed;
try {
compressed = CompressedStreamTools.compress(var4);
}catch(IOException e) {
System.err.println("Could not serialize \"" + level_dat + "\"");
e.printStackTrace();
return;
}
if(!level_dat.setAllBytes(compressed)) {
System.err.println("Could not save \"" + level_dat + "\" to filesystem");
}
}
@Override
public void saveWorldInfo(WorldInfo var1) {
saveWorldInfoWithPlayer(var1, null);
}
@Override
public IPlayerFileData getPlayerNBTManager() {
return this;
}
@Override
public void flush() {
}
@Override
public VFile getMapFileFromName(String var1) {
return new VFile(worldDirectory, "data", var1 + ".dat");
}
@Override
public String getWorldDirectoryName() {
return worldDirectory.toString();
}
@Override
public void writePlayerData(EntityPlayer var1) {
NBTTagCompound var2 = new NBTTagCompound();
var1.writeToNBT(var2);
byte[] bin;
try {
bin = CompressedStreamTools.compress(var2);
}catch(Throwable t) {
System.err.println("Could not serialize player data for \"" + var1.username + "\"");
t.printStackTrace();
return;
}
VFile playerData = new VFile(worldDirectory, "player", var1.username.toLowerCase() + ".dat");
if(!playerData.setAllBytes(bin)) {
System.err.println("Could not write player data for \"" + var1.username + "\" to file \"" + playerData.toString() + "\"");
}
}
@Override
public NBTTagCompound readPlayerData(EntityPlayer var1) {
VFile playerData = new VFile(worldDirectory, "player", var1.username.toLowerCase() + ".dat");
NBTTagCompound ret = null;
byte[] playerBin = playerData.getAllBytes();
if(playerBin != null) {
try {
ret = CompressedStreamTools.decompress(playerBin);
var1.readFromNBT(ret);
}catch(IOException e) {
System.err.println("Could not deserialize player data for \"" + var1.username + "\"");
e.printStackTrace();
}
}
return ret;
}
@Override
public String[] getAvailablePlayerDat() {
return null;
}
}

View File

@ -3,6 +3,8 @@ package net.lax1dude.eaglercraft.sp;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class VFile {
@ -14,7 +16,7 @@ public class VFile {
p = p.replace(altPathSeperator[i], pathSeperator);
}
if(p.startsWith(pathSeperator)) {
p = p.substring(pathSeperator.length());
p = p.substring(1);
}
if(p.endsWith(pathSeperator)) {
p = p.substring(0, p.length() - pathSeperator.length());
@ -30,7 +32,7 @@ public class VFile {
return pth;
}
private String path;
protected String path;
public static String createPath(Object... p) {
ArrayList<String> r = new ArrayList();
@ -136,8 +138,8 @@ public class VFile {
return !isRelative() && SYS.VFS.deleteFile(path);
}
public boolean renameTo(String p) {
if(!isRelative() && SYS.VFS.renameFile(path, p)) {
public boolean renameTo(String p, boolean copy) {
if(!isRelative() && SYS.VFS.renameFile(path, p, copy)) {
path = p;
return true;
}
@ -210,4 +212,16 @@ public class VFile {
}
return SYS.VFS.getFile(path).setAllBytes(bytes, copy);
}
public List<String> list() {
if(isRelative()) {
return Arrays.asList(path);
}
return SYS.VFS.listFiles(path);
}
public int deleteAll() {
return isRelative() ? 0 : SYS.VFS.deleteFiles(path);
}
}

View File

@ -0,0 +1,289 @@
package net.lax1dude.eaglercraft.sp;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
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.IDBCursor;
import org.teavm.jso.indexeddb.IDBRequest;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
/**
* Do not use an instance of this class outside of the VFSIterator.next() method
*/
public class VIteratorFile extends VFile {
static final VIteratorFile instance = new VIteratorFile();
private VIteratorFile() {
super("");
this.idx = -1;
this.cur = null;
this.vfs = null;
}
private static class VirtualIteratorOutputStream extends ByteArrayOutputStream {
private final VIteratorFile itr;
protected VirtualIteratorOutputStream(VIteratorFile itr) {
this.itr = itr;
}
public void close() throws IOException {
if(!itr.setAllBytes(super.toByteArray(), false)) {
throw new IOException("Could not close stream and write to \"" + itr.path + "\" on VFS \"" + itr.vfs.database + "\" (the file was probably deleted)");
}
}
}
private int idx;
private IDBCursor cur;
private VirtualFilesystem vfs;
private boolean wasDeleted;
@JSBody(params = { "k" }, script = "return ((typeof k) === \"string\") ? k : (((typeof k) === \"undefined\") ? null : (((typeof k[0]) === \"string\") ? k[0] : null));")
private static native String readKey(JSObject k);
static VIteratorFile create(int idx, VirtualFilesystem vfs, IDBCursor cur) {
String k = readKey(cur.getKey());
if(k == null) {
return null;
}
instance.update(idx, k, vfs, cur);
return instance;
}
public VFile makeVFile() {
return new VFile(path);
}
private void update(int idx, String path, VirtualFilesystem vfs, IDBCursor cur) {
this.idx = idx;
this.path = path;
this.vfs = vfs;
this.cur = cur;
this.wasDeleted = false;
}
public InputStream getInputStream() {
return !wasDeleted ? new ByteArrayInputStream(getAllBytes()) : null;
}
public OutputStream getOutputStream() {
return !wasDeleted ? new VirtualIteratorOutputStream(this) : null;
}
public String toString() {
return path;
}
public boolean isRelative() {
return false;
}
public boolean canRead() {
return !wasDeleted;
}
public String getPath() {
return path;
}
public String getName() {
if(path == null) {
return null;
}
int i = path.indexOf(pathSeperator);
return i == -1 ? path : path.substring(i + 1);
}
public boolean canWrite() {
return !wasDeleted;
}
public String getParent() {
if(path == null) {
return null;
}
int i = path.indexOf(pathSeperator);
return i == -1 ? ".." : path.substring(0, i);
}
public int hashCode() {
return path == null ? 0 : path.hashCode();
}
public boolean equals(Object o) {
return path != null && o != null && (o instanceof VFile) && path.equals(((VFile)o).path);
}
public boolean exists() {
return !wasDeleted;
}
public boolean delete() {
return wasDeleted = AsyncHandlers.awaitRequest(cur.delete()).bool;
}
public boolean renameTo(String p) {
byte[] data = getAllBytes();
String op = path;
path = p;
if(!setAllBytes(data)) {
path = op;
return false;
}
path = op;
if(!delete()) {
return false;
}
path = p;
return true;
}
public int length() {
JSObject obj = cur.getValue();
if(obj == null) {
throw new RuntimeException("Value of entry is missing");
}
ArrayBuffer arr = readRow(obj);
if(arr == null) {
throw new RuntimeException("Value of the fucking value of the entry is missing");
}
return arr.getByteLength();
}
public void getBytes(int fileOffset, byte[] array, int offset, int length) {
JSObject obj = cur.getValue();
if(obj == null) {
throw new ArrayIndexOutOfBoundsException("Value of entry is missing");
}
ArrayBuffer arr = readRow(obj);
if(arr == null) {
throw new ArrayIndexOutOfBoundsException("Value of the fucking value of the entry is missing");
}
Uint8Array a = Uint8Array.create(arr);
if(a.getLength() < fileOffset + length) {
throw new ArrayIndexOutOfBoundsException("file '" + path + "' size was "+a.getLength()+" but user tried to read index "+(fileOffset + length - 1));
}
for(int i = 0; i < length; ++i) {
array[i + offset] = (byte)a.get(i + fileOffset);
}
}
public void setCacheEnabled() {
// no
}
@JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? null : ((typeof obj.data === 'undefined') ? null : obj.data);")
private static native ArrayBuffer readRow(JSObject obj);
public byte[] getAllBytes() {
JSObject obj = cur.getValue();
if(obj == null) {
return null;
}
ArrayBuffer arr = readRow(obj);
if(arr == null) {
return null;
}
Uint8Array a = Uint8Array.create(arr);
int ii = a.getByteLength();
byte[] array = new byte[ii];
for(int i = 0; i < ii; ++i) {
array[i] = (byte)a.get(i);
}
return array;
}
public String getAllChars() {
return VirtualFilesystem.utf8(getAllBytes());
}
public String[] getAllLines() {
return VirtualFilesystem.lines(VirtualFilesystem.utf8(getAllBytes()));
}
public byte[] getAllBytes(boolean copy) {
return getAllBytes();
}
public boolean setAllChars(String bytes) {
return setAllBytes(VirtualFilesystem.utf8(bytes));
}
public List<String> list() {
throw new RuntimeException("Cannot perform list all in VFS callback");
}
public int deleteAll() {
throw new RuntimeException("Cannot perform delete all in VFS callback");
}
@JSBody(params = { "pat", "dat" }, script = "return { path: pat, data: dat };")
private static native JSObject writeRow(String name, ArrayBuffer data);
public boolean setAllBytes(byte[] bytes) {
ArrayBuffer a = ArrayBuffer.create(bytes.length);
Uint8Array ar = Uint8Array.create(a);
ar.set(bytes);
JSObject obj = writeRow(path, a);
BooleanResult r = AsyncHandlers.awaitRequest(cur.update(obj));
return r.bool;
}
public boolean setAllBytes(byte[] bytes, boolean copy) {
return setAllBytes(bytes);
}
public static class AsyncHandlers {
@Async
public static native BooleanResult awaitRequest(IDBRequest r);
private static void awaitRequest(IDBRequest r, final AsyncCallback<BooleanResult> cb) {
r.addEventListener("success", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
cb.complete(BooleanResult._new(true));
}
});
r.addEventListener("error", new EventListener<Event>() {
@Override
public void handleEvent(Event evt) {
cb.complete(BooleanResult._new(false));
}
});
}
}
}

View File

@ -6,8 +6,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.teavm.interop.Async;
import org.teavm.interop.AsyncCallback;
@ -17,9 +19,12 @@ 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;
import org.teavm.jso.indexeddb.IDBCursor;
import org.teavm.jso.indexeddb.IDBCursorRequest;
import org.teavm.jso.indexeddb.IDBDatabase;
import org.teavm.jso.indexeddb.IDBFactory;
import org.teavm.jso.indexeddb.IDBGetRequest;
import org.teavm.jso.indexeddb.IDBObjectStore;
import org.teavm.jso.indexeddb.IDBObjectStoreParameters;
import org.teavm.jso.indexeddb.IDBOpenDBRequest;
import org.teavm.jso.indexeddb.IDBRequest;
@ -265,7 +270,7 @@ public class VirtualFilesystem {
return false;
}
public boolean rename(String newName) {
public boolean rename(String newName, boolean copy) {
if(!hasBeenDeleted && !(hasBeenAccessed && !exists)) {
cacheHit = System.currentTimeMillis();
ArrayBuffer arr = AsyncHandlers.readWholeFile(virtualFilesystem.indexeddb, filePath);
@ -377,8 +382,8 @@ public class VirtualFilesystem {
return f;
}
public boolean renameFile(String oldName, String newName) {
return getFile(oldName).rename(newName);
public boolean renameFile(String oldName, String newName, boolean copy) {
return getFile(oldName).rename(newName, copy);
}
public boolean deleteFile(String path) {
@ -389,6 +394,36 @@ public class VirtualFilesystem {
return getFile(path).exists();
}
public List<String> listFiles(String prefix) {
final ArrayList<String> list = new ArrayList();
AsyncHandlers.iterateFiles(indexeddb, this, prefix, false, (v) -> {
list.add(v.getPath());
});
return list;
}
public int deleteFiles(String prefix) {
return AsyncHandlers.deleteFiles(indexeddb, prefix);
}
public int iterateFiles(String prefix, boolean rw, VFSIterator itr) {
return AsyncHandlers.iterateFiles(indexeddb, this, prefix, rw, itr);
}
public int renameFiles(String oldPrefix, String newPrefix, boolean copy) {
List<String> filesToCopy = listFiles(oldPrefix);
int i = 0;
for(String str : filesToCopy) {
String f = VFile.createPath(newPrefix, str.substring(oldPrefix.length()));
if(!renameFile(str, f, copy)) {
System.err.println("Could not " + (copy ? "copy" : "rename") + " file \"" + str + "\" to \"" + f + "\" for some reason");
}else {
++i;
}
}
return i;
}
public void flushCache(long age) {
long curr = System.currentTimeMillis();
Iterator<VFSFile> files = fileMap.values().iterator();
@ -416,17 +451,19 @@ public class VirtualFilesystem {
}
@JSBody(script = "return ((typeof indexedDB) !== 'undefined') ? indexedDB : null;")
protected static native IDBFactory createIDBFactory();
protected static class AsyncHandlers {
@Async
protected static native DatabaseOpen openDB(String name);
private static void openDB(String name, final AsyncCallback<DatabaseOpen> cb) {
IDBFactory i = null;
try {
i = IDBFactory.getInstance();
}catch(Throwable t) {
cb.complete(new DatabaseOpen(true, false, t.toString(), null));
IDBFactory i = createIDBFactory();
if(i == null) {
cb.complete(new DatabaseOpen(false, false, "window.indexedDB was null or undefined", null));
return;
}
final IDBOpenDBRequest f = i.open(name, 1);
f.setOnBlocked(new EventHandler() {
@ -462,15 +499,15 @@ public class VirtualFilesystem {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBRequest r = tx.objectStore("filesystem").delete(makeTheFuckingKeyWork(name));
r.addEventListener("success", new EventListener<Event>() {
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(BooleanResult._new(true));
}
});
r.addEventListener("error", new EventListener<Event>() {
r.setOnError(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
@ -488,36 +525,110 @@ public class VirtualFilesystem {
private static void readWholeFile(IDBDatabase db, String name, final AsyncCallback<ArrayBuffer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBGetRequest r = tx.objectStore("filesystem").get(makeTheFuckingKeyWork(name));
r.addEventListener("success", new EventListener<Event>() {
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(readRow(r.getResult()));
}
});
r.addEventListener("error", new EventListener<Event>() {
r.setOnError(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(null);
}
});
}
@JSBody(params = { "k" }, script = "return ((typeof k) === \"string\") ? k : (((typeof k) === \"undefined\") ? null : (((typeof k[0]) === \"string\") ? k[0] : null));")
private static native String readKey(JSObject k);
@JSBody(params = { "k" }, script = "return ((typeof k) === \"undefined\") ? null : (((typeof k.path) === \"undefined\") ? null : (((typeof k.path) === \"string\") ? k[0] : null));")
private static native String readRowKey(JSObject r);
@Async
protected static native Integer iterateFiles(IDBDatabase db, final VirtualFilesystem vfs, final String prefix, boolean rw, final VFSIterator itr);
private static void iterateFiles(IDBDatabase db, final VirtualFilesystem vfs, final String prefix, boolean rw, final VFSIterator itr, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", rw ? "readwrite" : "readonly");
final IDBCursorRequest r = tx.objectStore("filesystem").openCursor();
final int[] res = new int[1];
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
IDBCursor c = r.getResult();
if(c == null) {
cb.complete(res[0]);
}
String k = readKey(c.getKey());
if(k != null) {
if(k.startsWith(prefix)) {
int ci = res[0]++;
try {
itr.next(VIteratorFile.create(ci, vfs, c));
}catch(VFSIterator.BreakLoop ex) {
cb.complete(res[0]);
}
}
}
c.doContinue();
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(res[0] > 0 ? res[0] : -1);
}
});
}
@Async
protected static native Integer deleteFiles(IDBDatabase db, final String prefix);
private static void deleteFiles(IDBDatabase db, final String prefix, final AsyncCallback<Integer> cb) {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBCursorRequest r = tx.objectStore("filesystem").openCursor();
final int[] res = new int[1];
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent() {
IDBCursor c = r.getResult();
if(c == null) {
cb.complete(res[0]);
}
String k = readKey(c.getKey());
if(k != null) {
if(k.startsWith(prefix)) {
c.delete();
++res[0];
}
}
c.doContinue();
}
});
r.setOnError(new EventHandler() {
@Override
public void handleEvent() {
cb.complete(res[0] > 0 ? res[0] : -1);
}
});
}
@Async
protected static native BooleanResult fileExists(IDBDatabase db, String name);
private static void fileExists(IDBDatabase db, String name, final AsyncCallback<BooleanResult> cb) {
IDBTransaction tx = db.transaction("filesystem", "readonly");
final IDBCountRequest r = tx.objectStore("filesystem").count(makeTheFuckingKeyWork(name));
r.addEventListener("success", new EventListener<Event>() {
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(BooleanResult._new(r.getResult() > 0));
}
});
r.addEventListener("error", new EventListener<Event>() {
r.setOnError(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
@ -533,15 +644,15 @@ public class VirtualFilesystem {
IDBTransaction tx = db.transaction("filesystem", "readwrite");
final IDBRequest r = tx.objectStore("filesystem").put(writeRow(name, data));
r.addEventListener("success", new EventListener<Event>() {
r.setOnSuccess(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(BooleanResult._new(true));
}
});
r.addEventListener("error", new EventListener<Event>() {
r.setOnError(new EventHandler() {
@Override
public void handleEvent(Event evt) {
public void handleEvent() {
cb.complete(BooleanResult._new(false));
}
});
@ -561,7 +672,15 @@ public class VirtualFilesystem {
public static String CRLFtoLF(String str) {
if(str == null) return null;
return str.indexOf('\r') != -1 ? str.replace("\r", "") : str;
str = str.indexOf('\r') != -1 ? str.replace("\r", "") : str;
str = str.trim();
if(str.endsWith("\n")) {
str = str.substring(0, str.length() - 1);
}
if(str.startsWith("\n")) {
str = str.substring(1);
}
return str;
}
public static String[] lines(String str) {

View File

@ -0,0 +1,72 @@
package net.lax1dude.eaglercraft.sp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.NetServerHandler;
public class WorkerListenThread {
/** Reference to the MinecraftServer object. */
private final MinecraftServer mcServer;
private final List connections = new ArrayList();
private final HashMap<String, WorkerNetworkManager> channels = new HashMap();
/** Whether the network listener object is listening. */
public volatile boolean isListening = false;
public WorkerListenThread(MinecraftServer par1MinecraftServer) {
this.mcServer = par1MinecraftServer;
this.isListening = true;
}
/**
* adds this connection to the list of currently connected players
*/
public void addPlayer(NetServerHandler par1NetServerHandler) {
this.connections.add(par1NetServerHandler);
}
public void stopListening() {
this.isListening = false;
}
public boolean openChannel(String player) {
return channels.put(player, new WorkerNetworkManager(player, mcServer, this)) == null;
}
public void recievePacket(String player, byte[] data) {
WorkerNetworkManager channel = channels.get(player);
if(channel == null) {
return;
}
channel.addToRecieveQueue(data);
}
public boolean closeChannel(String player) {
WorkerNetworkManager channel = channels.get(player);
if(channel == null) {
return false;
}
channel.networkShutdown(null, null, null);
channels.remove(player);
return true;
}
/**
* Handles all incoming connections and packets
*/
public void handleNetworkListenThread() {
for(WorkerNetworkManager mgr : channels.values()) {
mgr.processReadPackets();
}
for (int var1 = 0; var1 < this.connections.size(); ++var1) {
NetServerHandler var2 = (NetServerHandler) this.connections.get(var1);
var2.handlePackets();
}
}
public MinecraftServer getServer() {
return this.mcServer;
}
}

View File

@ -0,0 +1,165 @@
package net.lax1dude.eaglercraft.sp;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import net.lax1dude.eaglercraft.sp.ipc.IPCInputStream;
import net.lax1dude.eaglercraft.sp.ipc.IPCOutputStream;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0CPlayerChannel;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.INetworkManager;
import net.minecraft.src.NetHandler;
import net.minecraft.src.NetLoginHandler;
import net.minecraft.src.Packet;
public class WorkerNetworkManager implements INetworkManager {
public static final IPCInputStream NET_INPUT_STREAM = new IPCInputStream();
public static final IPCOutputStream NET_OUTPUT_STREAM = new IPCOutputStream();
public static final DataInputStream NET_DATA_INPUT_STREAM = new DataInputStream(NET_INPUT_STREAM);
public static final DataOutputStream NET_DATA_OUTPUT_STREAM = new DataOutputStream(NET_OUTPUT_STREAM);
private NetHandler theNetHandler;
private String ipcChannel;
private boolean isAlive;
private WorkerListenThread listenThread;
private LinkedList<byte[]> frags = new LinkedList();
public WorkerNetworkManager(String ipcChannel, MinecraftServer srv, WorkerListenThread th) {
this.ipcChannel = ipcChannel;
this.theNetHandler = new NetLoginHandler(srv, this);
this.isAlive = true;
this.listenThread = th;
}
@Override
public void setNetHandler(NetHandler var1) {
theNetHandler = var1;
}
@Override
public void addToSendQueue(Packet var1) {
if(!isAlive) {
return;
}
NET_OUTPUT_STREAM.feedBuffer(new byte[var1.getPacketSize() + 1], "[MC]" + var1.getClass().getSimpleName());
try {
Packet.writePacket(var1, NET_DATA_OUTPUT_STREAM);
}catch(IOException e) {
System.err.println("Failed to serialize minecraft packet '" + var1.getPacketId() + "' for IPC channel 'NET|" + ipcChannel + "'");
e.printStackTrace();
}
IntegratedServer.sendPlayerPacket(ipcChannel, NET_OUTPUT_STREAM.returnBuffer());
}
public void addToRecieveQueue(byte[] fragment) {
if(!isAlive) {
return;
}
frags.add(fragment);
}
@Override
public void wakeThreads() {
// no
}
@Override
public void processReadPackets() {
if(!isAlive) {
return;
}
if(frags.size() <= 0) {
return;
}
int blockSize = 0;
for(byte[] pkt : frags) {
blockSize += pkt.length;
}
int idx = 0;
byte[] block = new byte[blockSize];
for(byte[] pkt : frags) {
System.arraycopy(pkt, 0, block, idx, pkt.length);
idx += pkt.length;
}
LinkedList<Packet> readPackets = new LinkedList();
NET_INPUT_STREAM.feedBuffer(block);
while(true) {
try {
int pktId = NET_INPUT_STREAM.read();
if(pktId == -1) {
System.err.println("Recieved invalid '-1' packet");
NET_INPUT_STREAM.markIndex();
break;
}
Packet pkt = Packet.getNewPacket(IntegratedServer.logger, idx);
if(pkt == null) {
NET_INPUT_STREAM.markIndex();
break;
}
pkt.field_98193_m = IntegratedServer.logger;
pkt.readPacketData(NET_DATA_INPUT_STREAM);
readPackets.add(pkt);
NET_INPUT_STREAM.markIndex();
}catch(IOException ex) {
// end
break;
}
}
NET_INPUT_STREAM.rewindIndex();
frags.clear();
frags.add(NET_INPUT_STREAM.getLeftover());
for(Packet p : readPackets) {
try {
p.processPacket(theNetHandler);
}catch(Throwable t) {
System.err.println("Could not process minecraft packet 0x" + Integer.toHexString(p.getPacketId()) + " class '" + p.getClass().getSimpleName() + "' on channel 'NET|" + ipcChannel + "'");
t.printStackTrace();
}
}
}
@Override
public void serverShutdown() {
if(isAlive) {
listenThread.closeChannel(ipcChannel);
IntegratedServer.sendIPCPacket(new IPCPacket0CPlayerChannel(ipcChannel, false));
}
isAlive = false;
}
@Override
public int getNumChunkDataPackets() { // why is this a thing, it limits map (the item) updates
return 0;
}
@Override
public void networkShutdown(String var1, Object... var2) {
if(isAlive) {
listenThread.closeChannel(ipcChannel);
IntegratedServer.sendIPCPacket(new IPCPacket0CPlayerChannel(ipcChannel, false));
}
isAlive = false;
}
}

View File

@ -0,0 +1,169 @@
package net.lax1dude.eaglercraft.sp;
import java.io.IOException;
import java.util.LinkedList;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSFunctor;
import org.teavm.jso.JSObject;
import org.teavm.jso.browser.Window;
import org.teavm.jso.dom.events.ErrorEvent;
import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.html.HTMLDocument;
import org.teavm.jso.typedarrays.ArrayBuffer;
import org.teavm.jso.typedarrays.Uint8Array;
import org.teavm.jso.workers.Worker;
import net.lax1dude.eaglercraft.sp.ipc.*;
public class WorkerTest {
private static final LinkedList<PKT> messageQueue = new LinkedList();
private static boolean isAlive = false;
private static boolean isLoading = false;
protected static class PKT {
protected final String channel;
protected final byte[] data;
protected PKT(String channel, byte[] data) {
this.channel = channel;
this.data = data;
}
}
public static Worker server = null;
@JSFunctor
private static interface WorkerBinaryPacketHandler extends JSObject {
public void onMessage(String channel, ArrayBuffer buf);
}
private static class WorkerBinaryPacketHandlerImpl implements WorkerBinaryPacketHandler {
public void onMessage(String channel, ArrayBuffer buf) {
if(channel == null) {
System.err.println("Recieved IPC packet with null channel");
return;
}
if(buf == null) {
System.err.println("Recieved IPC packet with null buffer");
return;
}
Uint8Array a = Uint8Array.create(buf);
byte[] pkt = new byte[a.getLength()];
for(int i = 0; i < pkt.length; ++i) {
pkt[i] = (byte) a.get(i);
}
messageQueue.add(new PKT(channel, pkt));
}
}
@JSBody(params = { "w", "wb" }, script = "w.onmessage = function(o) { wb(o.data.ch, o.data.dat); };")
private static native void registerPacketHandler(Worker w, WorkerBinaryPacketHandler wb);
@JSBody(params = { "w", "ch", "dat" }, script = "w.postMessage({ ch: ch, dat : dat });")
private static native void sendWorkerPacket(Worker w, String channel, ArrayBuffer arr);
public static void sendIPCPacket(IPCPacketBase pkt) {
byte[] serialized;
try {
serialized = IPCPacketManager.IPCSerialize(pkt);
} catch (IOException e) {
System.err.println("Could not serialize IPC packet 0x" + Integer.toHexString(pkt.id()) + " class '" + pkt.getClass().getSimpleName() + "'");
e.printStackTrace();
return;
}
ArrayBuffer arb = ArrayBuffer.create(serialized.length);
Uint8Array ar = Uint8Array.create(arb);
ar.set(serialized);
sendWorkerPacket(server, "IPC", arb);
}
public static void init(String path) {
server = Worker.create(path);
server.onError(new EventListener<ErrorEvent>() {
@Override
public void handleEvent(ErrorEvent evt) {
System.err.println("Worker Error: " + evt.getError());
}
});
registerPacketHandler(server, new WorkerBinaryPacketHandlerImpl());
while(true) {
while(messageQueue.size() > 0) {
PKT p = messageQueue.remove(0);
if(p.channel.equals("IPC")) {
IPCPacketBase packet;
try {
packet = IPCPacketManager.IPCDeserialize(p.data);
}catch(IOException e) {
System.err.print("Failed to deserialize IPC packet: ");
e.printStackTrace();
return;
}
int id = packet.id();
try {
switch(id) {
case IPCPacketFFProcessKeepAlive.ID: {
isAlive = true;
}
break;
case IPCPacket15ThrowException.ID: {
IPCPacket15ThrowException pkt = (IPCPacket15ThrowException)packet;
System.err.println("Server Exception: " + pkt.errorMessage);
for(String s : pkt.stackTrace) {
System.err.println(" " + s);
}
}
break;
case IPCPacket0DProgressUpdate.ID: {
IPCPacket0DProgressUpdate pkt = (IPCPacket0DProgressUpdate)packet;
System.out.println("Progress: " + pkt.updateMessage + " (" + (int)(100 * pkt.updateProgress) + "/100)");
}
break;
default:
System.err.println("IPC packet type 0x" + Integer.toHexString(id) + " class '" + packet.getClass().getSimpleName() + "' was not handled");
break;
}
}catch(Throwable t) {
System.err.println("fuck");
t.printStackTrace();
}
}
}
if(isAlive && !isLoading) {
isLoading = true;
HTMLDocument doc = Window.current().getDocument();
String[] stat = doc.getElementById("str_STAT_GUID").getInnerText().split("\n");
String[] lang = doc.getElementById("str_LOCALE").getInnerText().split("\n");
sendIPCPacket(new IPCPacket14StringList(IPCPacket14StringList.STAT_GUID, stat));
sendIPCPacket(new IPCPacket14StringList(IPCPacket14StringList.LOCALE, lang));
sendIPCPacket(new IPCPacket02InitWorld("eagler", 1, 0, "", 6969696969696969l, true, true, true));
sendIPCPacket(new IPCPacket00StartServer("eagler", "LAX1DUDE", 0));
}
try {
Thread.sleep(1l); // allow some async to occur
}catch(InterruptedException e) {
System.err.println("you eagler");
}
}
}
}

View File

@ -1,131 +1,107 @@
package net.minecraft.server;
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.IOException;
import java.security.KeyPair;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.src.AnvilSaveConverter;
import net.lax1dude.eaglercraft.sp.IntegratedServer;
import net.lax1dude.eaglercraft.sp.WorkerListenThread;
import net.lax1dude.eaglercraft.sp.VFSSaveHandler;
import net.lax1dude.eaglercraft.sp.VFile;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.CallableIsServerModded;
import net.minecraft.src.CallableServerMemoryStats;
import net.minecraft.src.CallableServerProfiler;
import net.minecraft.src.ChunkCoordinates;
import net.minecraft.src.CommandBase;
import net.minecraft.src.ConvertingProgressUpdate;
import net.minecraft.src.CrashReport;
import net.minecraft.src.DedicatedServer;
import net.minecraft.src.DemoWorldServer;
import net.minecraft.src.DispenserBehaviors;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EnumGameType;
import net.minecraft.src.ICommandManager;
import net.minecraft.src.ICommandSender;
import net.minecraft.src.ILogAgent;
import net.minecraft.src.IPlayerUsage;
import net.minecraft.src.IProgressUpdate;
import net.minecraft.src.ISaveFormat;
import net.minecraft.src.ISaveHandler;
import net.minecraft.src.IUpdatePlayerListBox;
import net.minecraft.src.MathHelper;
import net.minecraft.src.MinecraftException;
import net.minecraft.src.NetworkListenThread;
import net.minecraft.src.Packet;
import net.minecraft.src.Packet4UpdateTime;
import net.minecraft.src.PlayerUsageSnooper;
import net.minecraft.src.Profiler;
import net.minecraft.src.RConConsoleSource;
import net.minecraft.src.ReportedException;
import net.minecraft.src.ServerCommandManager;
import net.minecraft.src.ServerConfigurationManager;
import net.minecraft.src.StatList;
import net.minecraft.src.StringTranslate;
import net.minecraft.src.StringUtils;
import net.minecraft.src.ThreadDedicatedServer;
import net.minecraft.src.ThreadMinecraftServer;
import net.minecraft.src.World;
import net.minecraft.src.WorldInfo;
import net.minecraft.src.WorldManager;
import net.minecraft.src.WorldServer;
import net.minecraft.src.WorldServerMulti;
import net.minecraft.src.WorldSettings;
import net.minecraft.src.WorldType;
public abstract class MinecraftServer implements ICommandSender, Runnable, IPlayerUsage {
public abstract class MinecraftServer implements ICommandSender, Runnable {
/** Instance of Minecraft Server. */
private static MinecraftServer mcServer = null;
private final ISaveFormat anvilConverterForAnvilFile;
/** The PlayerUsageSnooper instance. */
private final PlayerUsageSnooper usageSnooper = new PlayerUsageSnooper("server", this);
private final File anvilFile;
protected static MinecraftServer mcServer = null;
/** List of names of players who are online. */
private final List playersOnline = new ArrayList();
private final ICommandManager commandManager;
protected final List playersOnline = new ArrayList();
protected final ICommandManager commandManager;
public final Profiler theProfiler = new Profiler();
/** The server's hostname. */
private String hostname;
protected String hostname;
/** The server's port. */
private int serverPort = -1;
protected int serverPort = -1;
/** The server world instances. */
public WorldServer[] worldServers;
/** The ServerConfigurationManager instance. */
private ServerConfigurationManager serverConfigManager;
protected ServerConfigurationManager serverConfigManager;
/**
* Indicates whether the server is running or not. Set to false to initiate a
* shutdown.
*/
private boolean serverRunning = true;
protected boolean serverRunning = true;
/** Indicates to other classes that the server is safely stopped. */
private boolean serverStopped = false;
protected boolean serverStopped = false;
/** Incremented every tick. */
private int tickCounter = 0;
protected int tickCounter = 0;
/**
* The task the server is currently working on(and will output on
* outputPercentRemaining).
*/
public String currentTask;
protected String currentTask;
/** The percentage of the current task finished so far. */
public int percentDone;
protected int percentDone;
/** True if the server is in online mode. */
private boolean onlineMode;
protected boolean onlineMode;
/** True if the server has animals turned on. */
private boolean canSpawnAnimals;
private boolean canSpawnNPCs;
protected boolean canSpawnAnimals;
protected boolean canSpawnNPCs;
/** Indicates whether PvP is active on the server or not. */
private boolean pvpEnabled;
protected boolean pvpEnabled;
/** Determines if flight is allowed or not. */
private boolean allowFlight;
protected boolean allowFlight;
/** The server MOTD string. */
private String motd;
protected String motd;
/** Maximum build height. */
private int buildLimit;
private long lastSentPacketID;
private long lastSentPacketSize;
private long lastReceivedID;
private long lastReceivedSize;
protected int buildLimit;
protected long lastSentPacketID;
protected long lastSentPacketSize;
protected long lastReceivedID;
protected long lastReceivedSize;
public final long[] sentPacketCountArray = new long[100];
public final long[] sentPacketSizeArray = new long[100];
public final long[] receivedPacketCountArray = new long[100];
@ -134,35 +110,33 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
/** Stats are [dimension][tick%100] system.nanoTime is stored. */
public long[][] timeOfLastDimensionTick;
private KeyPair serverKeyPair;
/** Username of the server owner (for integrated servers) */
private String serverOwner;
private String folderName;
private boolean isDemo;
private boolean enableBonusChest;
protected String serverOwner;
protected String folderName;
protected boolean isDemo;
protected boolean enableBonusChest;
/**
* If true, there is no need to save chunks or stop the server, because that is
* already being done.
*/
private boolean worldIsBeingDeleted;
private String texturePack = "";
private boolean serverIsRunning = false;
protected boolean worldIsBeingDeleted;
protected String texturePack = "";
protected boolean serverIsRunning = false;
/**
* Set when warned for "Can't keep up", which triggers again after 15 seconds.
*/
private long timeOfLastWarning;
private String userMessage;
private boolean startProfiling;
private boolean field_104057_T = false;
protected long timeOfLastWarning;
protected String userMessage;
protected boolean startProfiling;
protected boolean field_104057_T = false;
public MinecraftServer(File par1File) {
public MinecraftServer(String folder) {
mcServer = this;
this.anvilFile = par1File;
this.folderName = folder;
this.commandManager = new ServerCommandManager();
this.anvilConverterForAnvilFile = new AnvilSaveConverter(par1File);
this.registerDispenseBehaviors();
}
@ -179,33 +153,31 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
protected abstract boolean startServer() throws IOException;
protected void convertMapIfNeeded(String par1Str) {
if (this.getActiveAnvilConverter().isOldMapFormat(par1Str)) {
this.getLogAgent().func_98233_a("Converting map!");
this.setUserMessage("menu.convertingLevel");
this.getActiveAnvilConverter().convertMapFormat(par1Str, new ConvertingProgressUpdate(this));
}
// no
}
/**
* Typically "menu.convertingLevel", "menu.loadingLevel" or others.
*/
protected synchronized void setUserMessage(String par1Str) {
IntegratedServer.sendIPCPacket(new IPCPacket0DProgressUpdate(par1Str, 0.0f));
this.userMessage = par1Str;
}
protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str) {
protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldSettings par5WorldType) {
this.convertMapIfNeeded(par1Str);
this.setUserMessage("menu.loadingLevel");
this.worldServers = new WorldServer[3];
this.timeOfLastDimensionTick = new long[this.worldServers.length][100];
ISaveHandler var7 = this.anvilConverterForAnvilFile.getSaveLoader(par1Str, true);
ISaveHandler var7 = new VFSSaveHandler(new VFile(par1Str));
WorldInfo var9 = var7.loadWorldInfo();
WorldSettings var8;
if (var9 == null) {
var8 = new WorldSettings(par3, this.getGameType(), this.canStructuresSpawn(), this.isHardcore(),
par5WorldType);
var8.func_82750_a(par6Str);
if(par5WorldType == null) {
throw new IllegalArgumentException("World '" + par1Str + "/" + par2Str + "' does not exist and WorldSettings is null");
}
var8 = par5WorldType;
} else {
var8 = new WorldSettings(var9);
}
@ -226,13 +198,7 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
}
if (var10 == 0) {
if (this.isDemo()) {
this.worldServers[var10] = new DemoWorldServer(this, var7, par2Str, var11, this.theProfiler,
this.getLogAgent());
} else {
this.worldServers[var10] = new WorldServer(this, var7, par2Str, var11, var8, this.theProfiler,
this.getLogAgent());
}
this.worldServers[var10] = new WorldServer(this, var7, par2Str, var11, var8, this.theProfiler, this.getLogAgent());
} else {
this.worldServers[var10] = new WorldServerMulti(this, var7, par2Str, var11, var8, this.worldServers[0],
this.theProfiler, this.getLogAgent());
@ -360,10 +326,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
WorldServer var2 = this.worldServers[var1];
var2.flush();
}
if (this.usageSnooper != null && this.usageSnooper.isSnooperRunning()) {
this.usageSnooper.stopSnooper();
}
}
}
@ -427,30 +389,12 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
Thread.sleep(1L);
}
} else {
this.finalTick((CrashReport) null);
throw new RuntimeException("Server did not init correctly");
}
} catch (Throwable var48) {
var48.printStackTrace();
this.getLogAgent().logSevereException(
"Encountered an unexpected exception " + var48.getClass().getSimpleName(), var48);
CrashReport var2 = null;
if (var48 instanceof ReportedException) {
var2 = this.addServerInfoToCrashReport(((ReportedException) var48).getCrashReport());
} else {
var2 = this.addServerInfoToCrashReport(new CrashReport("Exception in server tick loop", var48));
}
File var3 = new File(new File(this.getDataDirectory(), "crash-reports"),
"crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
if (var2.saveToFile(var3, this.getLogAgent())) {
this.getLogAgent().logSevere("This crash report has been saved to: " + var3.getAbsolutePath());
} else {
this.getLogAgent().logSevere("We were unable to save this crash report to disk.");
}
this.finalTick(var2);
var48.printStackTrace();
} finally {
try {
this.stopServer();
@ -463,14 +407,8 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
}
}
protected File getDataDirectory() {
return new File(".");
}
/**
* Called on exit from the main run() loop.
*/
protected void finalTick(CrashReport par1CrashReport) {
protected VFile getDataDirectory() {
return new VFile(".");
}
/**
@ -513,17 +451,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
this.lastReceivedID = Packet.receivedID;
this.receivedPacketSizeArray[this.tickCounter % 100] = Packet.receivedSize - this.lastReceivedSize;
this.lastReceivedSize = Packet.receivedSize;
this.theProfiler.endSection();
this.theProfiler.startSection("snooper");
if (!this.usageSnooper.isSnooperRunning() && this.tickCounter > 100) {
this.usageSnooper.startSnooper();
}
if (this.tickCounter % 6000 == 0) {
this.usageSnooper.addMemoryStatsToSnooper();
}
this.theProfiler.endSection();
this.theProfiler.endSection();
}
@ -551,24 +478,10 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
}
this.theProfiler.startSection("tick");
CrashReport var6;
try {
var4.tick();
} catch (Throwable var8) {
var6 = CrashReport.makeCrashReport(var8, "Exception ticking world");
var4.addWorldInfoToCrashReport(var6);
throw new ReportedException(var6);
}
try {
var4.updateEntities();
} catch (Throwable var7) {
var6 = CrashReport.makeCrashReport(var7, "Exception ticking world entities");
var4.addWorldInfoToCrashReport(var6);
throw new ReportedException(var6);
}
var4.tick();
var4.updateEntities();
this.theProfiler.endSection();
this.theProfiler.startSection("tracker");
var4.getEntityTracker().updateTrackedEntities();
@ -599,104 +512,12 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
public void func_82010_a(IUpdatePlayerListBox par1IUpdatePlayerListBox) {
this.playersOnline.add(par1IUpdatePlayerListBox);
}
public static void main(String[] par0ArrayOfStr) {
StatList.nopInit();
ILogAgent var1 = null;
try {
boolean var2 = !GraphicsEnvironment.isHeadless();
String var3 = null;
String var4 = ".";
String var5 = null;
boolean var6 = false;
boolean var7 = false;
int var8 = -1;
for (int var9 = 0; var9 < par0ArrayOfStr.length; ++var9) {
String var10 = par0ArrayOfStr[var9];
String var11 = var9 == par0ArrayOfStr.length - 1 ? null : par0ArrayOfStr[var9 + 1];
boolean var12 = false;
if (!var10.equals("nogui") && !var10.equals("--nogui")) {
if (var10.equals("--port") && var11 != null) {
var12 = true;
try {
var8 = Integer.parseInt(var11);
} catch (NumberFormatException var14) {
;
}
} else if (var10.equals("--singleplayer") && var11 != null) {
var12 = true;
var3 = var11;
} else if (var10.equals("--universe") && var11 != null) {
var12 = true;
var4 = var11;
} else if (var10.equals("--world") && var11 != null) {
var12 = true;
var5 = var11;
} else if (var10.equals("--demo")) {
var6 = true;
} else if (var10.equals("--bonusChest")) {
var7 = true;
}
} else {
var2 = false;
}
if (var12) {
++var9;
}
}
DedicatedServer var16 = new DedicatedServer(new File(var4));
var1 = var16.getLogAgent();
if (var3 != null) {
var16.setServerOwner(var3);
}
if (var5 != null) {
var16.setFolderName(var5);
}
if (var8 >= 0) {
var16.setServerPort(var8);
}
if (var6) {
var16.setDemo(true);
}
if (var7) {
var16.canCreateBonusChest(true);
}
if (var2) {
var16.enableGui();
}
var16.startServerThread();
Runtime.getRuntime().addShutdownHook(new ThreadDedicatedServer(var16));
} catch (Exception var15) {
if (var1 != null) {
var1.logSevereException("Failed to start the minecraft server", var15);
} else {
Logger.getAnonymousLogger().log(Level.SEVERE, "Failed to start the minecraft server", var15);
}
}
}
public void startServerThread() {
(new ThreadMinecraftServer(this, "Server thread")).start();
}
/**
* Returns a File object from the specified string.
*/
public File getFile(String par1Str) {
return new File(this.getDataDirectory(), par1Str);
public VFile getFile(String par1Str) {
return new VFile(folderName, par1Str);
}
/**
@ -781,9 +602,7 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
* Handle a command received by an RCon instance
*/
public String handleRConCommand(String par1Str) {
RConConsoleSource.instance.resetLog();
this.commandManager.executeCommand(RConConsoleSource.instance, par1Str);
return RConConsoleSource.instance.getLogContents();
return "fuck off";
}
/**
@ -813,23 +632,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
return "vanilla";
}
/**
* Adds the server info, including from theWorldServer, to the crash report.
*/
public CrashReport addServerInfoToCrashReport(CrashReport par1CrashReport) {
par1CrashReport.func_85056_g().addCrashSectionCallable("Profiler Position", new CallableIsServerModded(this));
if (this.worldServers != null && this.worldServers.length > 0 && this.worldServers[0] != null) {
par1CrashReport.func_85056_g().addCrashSectionCallable("Vec3 Pool Size", new CallableServerProfiler(this));
}
if (this.serverConfigManager != null) {
par1CrashReport.func_85056_g().addCrashSectionCallable("Player Count", new CallableServerMemoryStats(this));
}
return par1CrashReport;
}
/**
* If par2Str begins with /, then it searches for commands, otherwise it returns
* players.
@ -911,13 +713,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
return this.commandManager;
}
/**
* Gets KeyPair instanced in MinecraftServer.
*/
public KeyPair getKeyPair() {
return this.serverKeyPair;
}
/**
* Gets serverPort.
*/
@ -956,10 +751,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
this.folderName = par1Str;
}
public void setKeyPair(KeyPair par1KeyPair) {
this.serverKeyPair = par1KeyPair;
}
public void setDifficultyForAllWorlds(int par1) {
for (int var2 = 0; var2 < this.worldServers.length; ++var2) {
WorldServer var3 = this.worldServers[var2];
@ -1002,7 +793,7 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
}
public ISaveFormat getActiveAnvilConverter() {
return this.anvilConverterForAnvilFile;
return null;
}
/**
@ -1034,66 +825,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
this.texturePack = par1Str;
}
public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) {
par1PlayerUsageSnooper.addData("whitelist_enabled", Boolean.valueOf(false));
par1PlayerUsageSnooper.addData("whitelist_count", Integer.valueOf(0));
par1PlayerUsageSnooper.addData("players_current", Integer.valueOf(this.getCurrentPlayerCount()));
par1PlayerUsageSnooper.addData("players_max", Integer.valueOf(this.getMaxPlayers()));
par1PlayerUsageSnooper.addData("players_seen",
Integer.valueOf(this.serverConfigManager.getAvailablePlayerDat().length));
par1PlayerUsageSnooper.addData("uses_auth", Boolean.valueOf(this.onlineMode));
par1PlayerUsageSnooper.addData("gui_state", this.getGuiEnabled() ? "enabled" : "disabled");
par1PlayerUsageSnooper.addData("avg_tick_ms",
Integer.valueOf((int) (MathHelper.average(this.tickTimeArray) * 1.0E-6D)));
par1PlayerUsageSnooper.addData("avg_sent_packet_count",
Integer.valueOf((int) MathHelper.average(this.sentPacketCountArray)));
par1PlayerUsageSnooper.addData("avg_sent_packet_size",
Integer.valueOf((int) MathHelper.average(this.sentPacketSizeArray)));
par1PlayerUsageSnooper.addData("avg_rec_packet_count",
Integer.valueOf((int) MathHelper.average(this.receivedPacketCountArray)));
par1PlayerUsageSnooper.addData("avg_rec_packet_size",
Integer.valueOf((int) MathHelper.average(this.receivedPacketSizeArray)));
int var2 = 0;
for (int var3 = 0; var3 < this.worldServers.length; ++var3) {
if (this.worldServers[var3] != null) {
WorldServer var4 = this.worldServers[var3];
WorldInfo var5 = var4.getWorldInfo();
par1PlayerUsageSnooper.addData("world[" + var2 + "][dimension]",
Integer.valueOf(var4.provider.dimensionId));
par1PlayerUsageSnooper.addData("world[" + var2 + "][mode]", var5.getGameType());
par1PlayerUsageSnooper.addData("world[" + var2 + "][difficulty]",
Integer.valueOf(var4.difficultySetting));
par1PlayerUsageSnooper.addData("world[" + var2 + "][hardcore]",
Boolean.valueOf(var5.isHardcoreModeEnabled()));
par1PlayerUsageSnooper.addData("world[" + var2 + "][generator_name]",
var5.getTerrainType().getWorldTypeName());
par1PlayerUsageSnooper.addData("world[" + var2 + "][generator_version]",
Integer.valueOf(var5.getTerrainType().getGeneratorVersion()));
par1PlayerUsageSnooper.addData("world[" + var2 + "][height]", Integer.valueOf(this.buildLimit));
par1PlayerUsageSnooper.addData("world[" + var2 + "][chunks_loaded]",
Integer.valueOf(var4.getChunkProvider().getLoadedChunkCount()));
++var2;
}
}
par1PlayerUsageSnooper.addData("worlds", Integer.valueOf(var2));
}
public void addServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) {
par1PlayerUsageSnooper.addData("singleplayer", Boolean.valueOf(this.isSinglePlayer()));
par1PlayerUsageSnooper.addData("server_brand", this.getServerModName());
par1PlayerUsageSnooper.addData("gui_supported", GraphicsEnvironment.isHeadless() ? "headless" : "supported");
par1PlayerUsageSnooper.addData("dedicated", Boolean.valueOf(this.isDedicatedServer()));
}
/**
* Returns whether snooping is enabled or not.
*/
public boolean isSnooperEnabled() {
return true;
}
/**
* This is checked to be 16 upon receiving the packet, otherwise the packet is
* ignored.
@ -1186,7 +917,7 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IPlay
}
}
public abstract NetworkListenThread getNetworkThread();
public abstract WorkerListenThread getNetworkThread();
public boolean getGuiEnabled() {
return false;

View File

@ -1,11 +0,0 @@
package net.minecraft.src;
final class AABBLocalPool extends ThreadLocal {
protected AABBPool createNewDefaultPool() {
return new AABBPool(300, 2000);
}
protected Object initialValue() {
return this.createNewDefaultPool();
}
}

View File

@ -129,8 +129,9 @@ public class AchievementList {
* A stub functions called to make the static initializer for this class run.
*/
public static void init() {
System.out.println("yee");
}
static {
System.out.println(achievementList.size() + " achievements");
}

View File

@ -1,32 +1,25 @@
package net.minecraft.src;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AchievementMap {
/** Holds the singleton instance of AchievementMap. */
public static AchievementMap instance = new AchievementMap();
public static AchievementMap instance = null;
public static void init(List<String> guid) {
instance = new AchievementMap(guid);
}
/** Maps a achievement id with it's unique GUID. */
private Map guidMap = new HashMap();
private AchievementMap() {
try {
BufferedReader var1 = new BufferedReader(
new InputStreamReader(AchievementMap.class.getResourceAsStream("/achievement/map.txt")));
String var2;
while ((var2 = var1.readLine()) != null) {
String[] var3 = var2.split(",");
int var4 = Integer.parseInt(var3[0]);
this.guidMap.put(Integer.valueOf(var4), var3[1]);
}
var1.close();
} catch (Exception var5) {
var5.printStackTrace();
private AchievementMap(List<String> guid) {
for (String var2 : guid) {
String[] var3 = var2.split(",");
int var4 = Integer.parseInt(var3[0]);
this.guidMap.put(Integer.valueOf(var4), var3[1]);
}
}

View File

@ -2,7 +2,7 @@ package net.minecraft.src;
public class AxisAlignedBB {
/** ThreadLocal AABBPool */
private static final ThreadLocal theAABBLocalPool = new AABBLocalPool();
private static final AABBPool theAABBLocalPool = new AABBPool(300, 2000);
public double minX;
public double minY;
public double minZ;
@ -23,7 +23,7 @@ public class AxisAlignedBB {
* Gets the ThreadLocal AABBPool
*/
public static AABBPool getAABBPool() {
return (AABBPool) theAABBLocalPool.get();
return theAABBLocalPool;
}
protected AxisAlignedBB(double par1, double par3, double par5, double par7, double par9, double par11) {

View File

@ -1,140 +0,0 @@
package net.minecraft.src;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;
import net.minecraft.server.MinecraftServer;
public class BanEntry {
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
private final String username;
private Date banStartDate = new Date();
private String bannedBy = "(Unknown)";
private Date banEndDate = null;
private String reason = "Banned by an operator.";
public BanEntry(String par1Str) {
this.username = par1Str;
}
public String getBannedUsername() {
return this.username;
}
public Date getBanStartDate() {
return this.banStartDate;
}
/**
* null == start ban now
*/
public void setBanStartDate(Date par1Date) {
this.banStartDate = par1Date != null ? par1Date : new Date();
}
public String getBannedBy() {
return this.bannedBy;
}
public void setBannedBy(String par1Str) {
this.bannedBy = par1Str;
}
public Date getBanEndDate() {
return this.banEndDate;
}
public void setBanEndDate(Date par1Date) {
this.banEndDate = par1Date;
}
public boolean hasBanExpired() {
return this.banEndDate == null ? false : this.banEndDate.before(new Date());
}
public String getBanReason() {
return this.reason;
}
public void setBanReason(String par1Str) {
this.reason = par1Str;
}
public String buildBanString() {
StringBuilder var1 = new StringBuilder();
var1.append(this.getBannedUsername());
var1.append("|");
var1.append(dateFormat.format(this.getBanStartDate()));
var1.append("|");
var1.append(this.getBannedBy());
var1.append("|");
var1.append(this.getBanEndDate() == null ? "Forever" : dateFormat.format(this.getBanEndDate()));
var1.append("|");
var1.append(this.getBanReason());
return var1.toString();
}
public static BanEntry parse(String par0Str) {
if (par0Str.trim().length() < 2) {
return null;
} else {
String[] var1 = par0Str.trim().split(Pattern.quote("|"), 5);
BanEntry var2 = new BanEntry(var1[0].trim());
byte var3 = 0;
int var10000 = var1.length;
int var7 = var3 + 1;
if (var10000 <= var7) {
return var2;
} else {
try {
var2.setBanStartDate(dateFormat.parse(var1[var7].trim()));
} catch (ParseException var6) {
MinecraftServer.getServer().getLogAgent()
.logWarningException("Could not read creation date format for ban entry \'"
+ var2.getBannedUsername() + "\' (was: \'" + var1[var7] + "\')", var6);
}
var10000 = var1.length;
++var7;
if (var10000 <= var7) {
return var2;
} else {
var2.setBannedBy(var1[var7].trim());
var10000 = var1.length;
++var7;
if (var10000 <= var7) {
return var2;
} else {
try {
String var4 = var1[var7].trim();
if (!var4.equalsIgnoreCase("Forever") && var4.length() > 0) {
var2.setBanEndDate(dateFormat.parse(var4));
}
} catch (ParseException var5) {
MinecraftServer.getServer().getLogAgent()
.logWarningException(
"Could not read expiry date format for ban entry \'"
+ var2.getBannedUsername() + "\' (was: \'" + var1[var7] + "\')",
var5);
}
var10000 = var1.length;
++var7;
if (var10000 <= var7) {
return var2;
} else {
var2.setBanReason(var1[var7].trim());
return var2;
}
}
}
}
}
}
}

View File

@ -1,137 +0,0 @@
package net.minecraft.src;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import net.minecraft.server.MinecraftServer;
public class BanList {
private final LowerStringMap theBanList = new LowerStringMap();
private final File fileName;
/** set to true if not singlePlayer */
private boolean listActive = true;
public BanList(File par1File) {
this.fileName = par1File;
}
public boolean isListActive() {
return this.listActive;
}
public void setListActive(boolean par1) {
this.listActive = par1;
}
/**
* removes expired Bans before returning
*/
public Map getBannedList() {
this.removeExpiredBans();
return this.theBanList;
}
public boolean isBanned(String par1Str) {
if (!this.isListActive()) {
return false;
} else {
this.removeExpiredBans();
return this.theBanList.containsKey(par1Str);
}
}
public void put(BanEntry par1BanEntry) {
this.theBanList.putLower(par1BanEntry.getBannedUsername(), par1BanEntry);
this.saveToFileWithHeader();
}
public void remove(String par1Str) {
this.theBanList.remove(par1Str);
this.saveToFileWithHeader();
}
public void removeExpiredBans() {
Iterator var1 = this.theBanList.values().iterator();
while (var1.hasNext()) {
BanEntry var2 = (BanEntry) var1.next();
if (var2.hasBanExpired()) {
var1.remove();
}
}
}
/**
* Loads the ban list from the file (adds every entry, does not clear the
* current list).
*/
public void loadBanList() {
if (this.fileName.isFile()) {
BufferedReader var1;
try {
var1 = new BufferedReader(new FileReader(this.fileName));
} catch (FileNotFoundException var4) {
throw new Error();
}
String var2;
try {
while ((var2 = var1.readLine()) != null) {
if (!var2.startsWith("#")) {
BanEntry var3 = BanEntry.parse(var2);
if (var3 != null) {
this.theBanList.putLower(var3.getBannedUsername(), var3);
}
}
}
} catch (IOException var5) {
MinecraftServer.getServer().getLogAgent().logSevereException("Could not load ban list", var5);
}
}
}
public void saveToFileWithHeader() {
this.saveToFile(true);
}
/**
* par1: include header
*/
public void saveToFile(boolean par1) {
this.removeExpiredBans();
try {
PrintWriter var2 = new PrintWriter(new FileWriter(this.fileName, false));
if (par1) {
var2.println("# Updated " + (new SimpleDateFormat()).format(new Date()) + " by Minecraft " + "1.5.2");
var2.println("# victim name | ban date | banned by | banned until | reason");
var2.println();
}
Iterator var3 = this.theBanList.values().iterator();
while (var3.hasNext()) {
BanEntry var4 = (BanEntry) var3.next();
var2.println(var4.buildBanString());
}
var2.close();
} catch (IOException var5) {
MinecraftServer.getServer().getLogAgent().logSevereException("Could not save ban list", var5);
}
}
}

View File

@ -1,13 +1,13 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BiomeDecorator {
/** The world the BiomeDecorator is currently decorating */
protected World currentWorld;
/** The Biome Decorator's random number generator. */
protected Random randomGenerator;
protected EaglercraftRandom randomGenerator;
/** The X-coordinate of the chunk currently being decorated */
protected int chunk_X;
@ -175,7 +175,7 @@ public class BiomeDecorator {
* Decorates the world. Calls code that was formerly (pre-1.8) in
* ChunkProviderGenerate.populate
*/
public void decorate(World par1World, Random par2Random, int par3, int par4) {
public void decorate(World par1World, EaglercraftRandom par2Random, int par3, int par4) {
if (this.currentWorld != null) {
throw new RuntimeException("Already decorating!!");
} else {

View File

@ -2,7 +2,8 @@ package net.minecraft.src;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public abstract class BiomeGenBase {
/** An array of all the biomes, indexed by biome id. */
@ -162,18 +163,18 @@ public abstract class BiomeGenBase {
this.biomeID = par1;
biomeList[par1] = this;
this.theBiomeDecorator = this.createBiomeDecorator();
this.spawnableCreatureList.add(new SpawnListEntry(EntitySheep.class, 12, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 10, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 10, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 8, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntitySpider.class, 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntityZombie.class, 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntitySkeleton.class, 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntityCreeper.class, 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntitySlime.class, 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntityEnderman.class, 1, 1, 4));
this.spawnableWaterCreatureList.add(new SpawnListEntry(EntitySquid.class, 10, 4, 4));
this.spawnableCaveCreatureList.add(new SpawnListEntry(EntityBat.class, 10, 8, 8));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntitySheep(w), 12, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntityPig(w), 10, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntityChicken(w), 10, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntityCow(w), 8, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntitySpider(w), 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityZombie(w), 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntitySkeleton(w), 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityCreeper(w), 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntitySlime(w), 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityEnderman(w), 1, 1, 4));
this.spawnableWaterCreatureList.add(new SpawnListEntry((w) -> new EntitySquid(w), 10, 4, 4));
this.spawnableCaveCreatureList.add(new SpawnListEntry((w) -> new EntityBat(w), 10, 8, 8));
}
/**
@ -217,14 +218,14 @@ public abstract class BiomeGenBase {
/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForTrees(Random par1Random) {
public WorldGenerator getRandomWorldGenForTrees(EaglercraftRandom par1Random) {
return (WorldGenerator) (par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees);
}
/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForGrass(Random par1Random) {
public WorldGenerator getRandomWorldGenForGrass(EaglercraftRandom par1Random) {
return new WorldGenTallGrass(Block.tallGrass.blockID, 1);
}
@ -312,7 +313,7 @@ public abstract class BiomeGenBase {
return this.temperature;
}
public void decorate(World par1World, Random par2Random, int par3, int par4) {
public void decorate(World par1World, EaglercraftRandom par2Random, int par3, int par4) {
this.theBiomeDecorator.decorate(par1World, par2Random, par3, par4);
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BiomeGenDesert extends BiomeGenBase {
public BiomeGenDesert(int par1) {
@ -14,7 +14,7 @@ public class BiomeGenDesert extends BiomeGenBase {
this.theBiomeDecorator.cactiPerChunk = 10;
}
public void decorate(World par1World, Random par2Random, int par3, int par4) {
public void decorate(World par1World, EaglercraftRandom par2Random, int par3, int par4) {
super.decorate(par1World, par2Random, par3, par4);
if (par2Random.nextInt(1000) == 0) {

View File

@ -7,7 +7,7 @@ public class BiomeGenEnd extends BiomeGenBase {
this.spawnableCreatureList.clear();
this.spawnableWaterCreatureList.clear();
this.spawnableCaveCreatureList.clear();
this.spawnableMonsterList.add(new SpawnListEntry(EntityEnderman.class, 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityEnderman(w), 10, 4, 4));
this.topBlock = (byte) Block.dirt.blockID;
this.fillerBlock = (byte) Block.dirt.blockID;
this.theBiomeDecorator = new BiomeEndDecorator(this);

View File

@ -1,11 +1,11 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BiomeGenForest extends BiomeGenBase {
public BiomeGenForest(int par1) {
super(par1);
this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 5, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntityWolf(w), 5, 4, 4));
this.theBiomeDecorator.treesPerChunk = 10;
this.theBiomeDecorator.grassPerChunk = 2;
}
@ -13,7 +13,7 @@ public class BiomeGenForest extends BiomeGenBase {
/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForTrees(Random par1Random) {
public WorldGenerator getRandomWorldGenForTrees(EaglercraftRandom par1Random) {
return (WorldGenerator) (par1Random.nextInt(5) == 0 ? this.worldGeneratorForest
: (par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees));
}

View File

@ -7,8 +7,8 @@ public class BiomeGenHell extends BiomeGenBase {
this.spawnableCreatureList.clear();
this.spawnableWaterCreatureList.clear();
this.spawnableCaveCreatureList.clear();
this.spawnableMonsterList.add(new SpawnListEntry(EntityGhast.class, 50, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntityPigZombie.class, 100, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry(EntityMagmaCube.class, 1, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityGhast(w), 50, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityPigZombie(w), 100, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityMagmaCube(w), 1, 4, 4));
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BiomeGenHills extends BiomeGenBase {
private WorldGenerator theWorldGenerator;
@ -10,7 +10,7 @@ public class BiomeGenHills extends BiomeGenBase {
this.theWorldGenerator = new WorldGenMinable(Block.silverfish.blockID, 8);
}
public void decorate(World par1World, Random par2Random, int par3, int par4) {
public void decorate(World par1World, EaglercraftRandom par2Random, int par3, int par4) {
super.decorate(par1World, par2Random, par3, par4);
int var5 = 3 + par2Random.nextInt(6);
int var6;

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BiomeGenJungle extends BiomeGenBase {
public BiomeGenJungle(int par1) {
@ -8,14 +8,14 @@ public class BiomeGenJungle extends BiomeGenBase {
this.theBiomeDecorator.treesPerChunk = 50;
this.theBiomeDecorator.grassPerChunk = 25;
this.theBiomeDecorator.flowersPerChunk = 4;
this.spawnableMonsterList.add(new SpawnListEntry(EntityOcelot.class, 2, 1, 1));
this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 10, 4, 4));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntityOcelot(w), 2, 1, 1));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntityChicken(w), 10, 4, 4));
}
/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForTrees(Random par1Random) {
public WorldGenerator getRandomWorldGenForTrees(EaglercraftRandom par1Random) {
return (WorldGenerator) (par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree
: (par1Random.nextInt(2) == 0 ? new WorldGenShrub(3, 0)
: (par1Random.nextInt(3) == 0 ? new WorldGenHugeTrees(false, 10 + par1Random.nextInt(20), 3, 3)
@ -25,12 +25,12 @@ public class BiomeGenJungle extends BiomeGenBase {
/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForGrass(Random par1Random) {
public WorldGenerator getRandomWorldGenForGrass(EaglercraftRandom par1Random) {
return par1Random.nextInt(4) == 0 ? new WorldGenTallGrass(Block.tallGrass.blockID, 2)
: new WorldGenTallGrass(Block.tallGrass.blockID, 1);
}
public void decorate(World par1World, Random par2Random, int par3, int par4) {
public void decorate(World par1World, EaglercraftRandom par2Random, int par3, int par4) {
super.decorate(par1World, par2Random, par3, par4);
WorldGenVines var5 = new WorldGenVines();

View File

@ -12,6 +12,6 @@ public class BiomeGenMushroomIsland extends BiomeGenBase {
this.spawnableMonsterList.clear();
this.spawnableCreatureList.clear();
this.spawnableWaterCreatureList.clear();
this.spawnableCreatureList.add(new SpawnListEntry(EntityMooshroom.class, 8, 4, 8));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntityMooshroom(w), 8, 4, 8));
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BiomeGenSwamp extends BiomeGenBase {
protected BiomeGenSwamp(int par1) {
@ -13,13 +13,13 @@ public class BiomeGenSwamp extends BiomeGenBase {
this.theBiomeDecorator.clayPerChunk = 1;
this.theBiomeDecorator.waterlilyPerChunk = 4;
this.waterColorMultiplier = 14745518;
this.spawnableMonsterList.add(new SpawnListEntry(EntitySlime.class, 1, 1, 1));
this.spawnableMonsterList.add(new SpawnListEntry((w) -> new EntitySlime(w), 1, 1, 1));
}
/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForTrees(Random par1Random) {
public WorldGenerator getRandomWorldGenForTrees(EaglercraftRandom par1Random) {
return this.worldGeneratorSwamp;
}
}

View File

@ -1,11 +1,11 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BiomeGenTaiga extends BiomeGenBase {
public BiomeGenTaiga(int par1) {
super(par1);
this.spawnableCreatureList.add(new SpawnListEntry(EntityWolf.class, 8, 4, 4));
this.spawnableCreatureList.add(new SpawnListEntry((w) -> new EntityWolf(w), 8, 4, 4));
this.theBiomeDecorator.treesPerChunk = 10;
this.theBiomeDecorator.grassPerChunk = 1;
}
@ -13,7 +13,7 @@ public class BiomeGenTaiga extends BiomeGenBase {
/**
* Gets a WorldGen appropriate for this biome.
*/
public WorldGenerator getRandomWorldGenForTrees(Random par1Random) {
public WorldGenerator getRandomWorldGenForTrees(EaglercraftRandom par1Random) {
return (WorldGenerator) (par1Random.nextInt(3) == 0 ? new WorldGenTaiga1() : new WorldGenTaiga2(false));
}
}

View File

@ -1,7 +1,8 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class Block {
/**
@ -637,7 +638,7 @@ public class Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
}
/**
@ -678,14 +679,14 @@ public class Block {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 1;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return this.blockID;
}
@ -1104,7 +1105,7 @@ public class Block {
* Returns the usual quantity dropped by the block plus a bonus of 1 to 'i'
* (inclusive).
*/
public int quantityDroppedWithBonus(int par1, Random par2Random) {
public int quantityDroppedWithBonus(int par1, EaglercraftRandom par2Random) {
return this.quantityDropped(par2Random);
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public abstract class BlockBasePressurePlate extends Block {
private String pressurePlateIconName;
@ -98,7 +98,7 @@ public abstract class BlockBasePressurePlate extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!par1World.isRemote) {
int var6 = this.getPowerSupply(par1World.getBlockMetadata(par2, par3, par4));

View File

@ -3,6 +3,8 @@ package net.minecraft.src;
import java.util.Iterator;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockBed extends BlockDirectional {
/** Maps the foot-of-bed block to the head-of-bed block. */
public static final int[][] footBlockToHeadBlockMap = new int[][] { { 0, 1 }, { -1, 0 }, { 0, -1 }, { 1, 0 } };
@ -155,7 +157,7 @@ public class BlockBed extends BlockDirectional {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return isBlockHeadOfBed(par1) ? 0 : Item.bed.itemID;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockBookshelf extends Block {
public BlockBookshelf(int par1) {
@ -11,14 +11,14 @@ public class BlockBookshelf extends Block {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 3;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.book.itemID;
}
}

View File

@ -1,10 +1,11 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockBrewingStand extends BlockContainer {
private Random rand = new Random();
private EaglercraftRandom rand = new EaglercraftRandom();
public BlockBrewingStand(int par1) {
super(par1, Material.iron);
@ -136,7 +137,7 @@ public class BlockBrewingStand extends BlockContainer {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.brewingStand.itemID;
}

View File

@ -1,7 +1,8 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public abstract class BlockButton extends Block {
/** Whether this button is sensible to arrows, used by wooden buttons. */
@ -262,7 +263,7 @@ public abstract class BlockButton extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!par1World.isRemote) {
int var6 = par1World.getBlockMetadata(par2, par3, par4);

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockCactus extends Block {
protected BlockCactus(int par1) {
@ -12,7 +12,7 @@ public class BlockCactus extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (par1World.isAirBlock(par2, par3 + 1, par4)) {
int var6;

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockCake extends Block {
protected BlockCake(int par1) {
@ -122,14 +122,14 @@ public class BlockCake extends Block {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 0;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return 0;
}
}

View File

@ -1,7 +1,8 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockCauldron extends Block {
public BlockCauldron(int par1) {
@ -138,7 +139,7 @@ public class BlockCauldron extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.cauldron.itemID;
}
}

View File

@ -1,10 +1,11 @@
package net.minecraft.src;
import java.util.Iterator;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockChest extends BlockContainer {
private final Random random = new Random();
private final EaglercraftRandom random = new EaglercraftRandom();
/** Determines whether of not the chest is trapped. */
public final int isTrapped;

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockClay extends Block {
public BlockClay(int par1) {
@ -11,14 +11,14 @@ public class BlockClay extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.clay.itemID;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 4;
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockCocoa extends BlockDirectional {
public static final String[] cocoaIcons = new String[] { "cocoa_0", "cocoa_1", "cocoa_2" };
@ -13,7 +13,7 @@ public class BlockCocoa extends BlockDirectional {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!this.canBlockStay(par1World, par2, par3, par4)) {
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(par2, par3, par4);

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockCommandBlock extends BlockContainer {
public BlockCommandBlock(int par1) {
@ -38,7 +38,7 @@ public class BlockCommandBlock extends BlockContainer {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4);
if (var6 != null && var6 instanceof TileEntityCommandBlock) {

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockComparator extends BlockRedstoneLogic implements ITileEntityProvider {
public BlockComparator(int par1, boolean par2) {
@ -11,7 +11,7 @@ public class BlockComparator extends BlockRedstoneLogic implements ITileEntityPr
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.comparator.itemID;
}
@ -135,7 +135,7 @@ public class BlockComparator extends BlockRedstoneLogic implements ITileEntityPr
}
}
private void func_96476_c(World par1World, int par2, int par3, int par4, Random par5Random) {
private void func_96476_c(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
int var6 = par1World.getBlockMetadata(par2, par3, par4);
int var7 = this.func_94491_m(par1World, par2, par3, par4, var6);
int var8 = this.getTileEntityComparator(par1World, par2, par3, par4).func_96100_a();
@ -158,7 +158,7 @@ public class BlockComparator extends BlockRedstoneLogic implements ITileEntityPr
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (this.isRepeaterPowered) {
int var6 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlock(par2, par3, par4, this.func_94484_i().blockID, var6 | 8, 4);

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockCrops extends BlockFlower {
protected BlockCrops(int par1) {
@ -25,7 +25,7 @@ public class BlockCrops extends BlockFlower {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9) {
@ -149,14 +149,14 @@ public class BlockCrops extends BlockFlower {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return par1 == 7 ? this.getCropItem() : this.getSeedItem();
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 1;
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockDaylightDetector extends BlockContainer {
private Icon[] iconArray = new Icon[2];
@ -32,7 +32,7 @@ public class BlockDaylightDetector extends BlockContainer {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
}
/**

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockDeadBush extends BlockFlower {
protected BlockDeadBush(int par1) {
@ -20,7 +20,7 @@ public class BlockDeadBush extends BlockFlower {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return -1;
}

View File

@ -1,7 +1,8 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockDetectorRail extends BlockRailBase {
public BlockDetectorRail(int par1) {
@ -41,7 +42,7 @@ public class BlockDetectorRail extends BlockRailBase {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!par1World.isRemote) {
int var6 = par1World.getBlockMetadata(par2, par3, par4);

View File

@ -1,11 +1,11 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockDispenser extends BlockContainer {
/** Registry for all dispense behaviors. */
public static final IRegistry dispenseBehaviorRegistry = new RegistryDefaulted(new BehaviorDefaultDispenseItem());
protected Random random = new Random();
protected EaglercraftRandom random = new EaglercraftRandom();
protected BlockDispenser(int par1) {
super(par1, Material.rock);
@ -127,7 +127,7 @@ public class BlockDispenser extends BlockContainer {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!par1World.isRemote) {
this.dispense(par1World, par2, par3, par4);
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockDoor extends Block {
private static final String[] doorIconNames = new String[] { "doorWood_lower", "doorWood_upper", "doorIron_lower",
@ -234,7 +234,7 @@ public class BlockDoor extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return (par1 & 8) != 0 ? 0
: (this.blockMaterial == Material.iron ? Item.doorIron.itemID : Item.doorWood.itemID);
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockDragonEgg extends Block {
public BlockDragonEgg(int par1) {
@ -27,7 +27,7 @@ public class BlockDragonEgg extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
this.fallIfPossible(par1World, par2, par3, par4);
}

View File

@ -1,7 +1,8 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockEndPortal extends BlockContainer {
/**
@ -60,7 +61,7 @@ public class BlockEndPortal extends BlockContainer {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 0;
}

View File

@ -1,7 +1,8 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockEndPortalFrame extends Block {
public BlockEndPortalFrame(int par1) {
@ -61,7 +62,7 @@ public class BlockEndPortalFrame extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return 0;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockEnderChest extends BlockContainer {
protected BlockEnderChest(int par1) {
@ -36,14 +36,14 @@ public class BlockEnderChest extends BlockContainer {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Block.obsidian.blockID;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 8;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockFarmland extends Block {
protected BlockFarmland(int par1) {
@ -39,7 +39,7 @@ public class BlockFarmland extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!this.isWaterNearby(par1World, par2, par3, par4) && !par1World.canLightningStrikeAt(par2, par3 + 1, par4)) {
int var6 = par1World.getBlockMetadata(par2, par3, par4);
@ -122,7 +122,7 @@ public class BlockFarmland extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Block.dirt.idDropped(0, par2Random, par3);
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockFire extends Block {
/** The chance this block will encourage nearby blocks to catch on fire */
@ -86,7 +86,7 @@ public class BlockFire extends Block {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 0;
}
@ -100,7 +100,7 @@ public class BlockFire extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (par1World.getGameRules().getGameRuleBooleanValue("doFireTick")) {
boolean var6 = par1World.getBlockId(par2, par3 - 1, par4) == Block.netherrack.blockID;
@ -201,7 +201,7 @@ public class BlockFire extends Block {
return false;
}
private void tryToCatchBlockOnFire(World par1World, int par2, int par3, int par4, int par5, Random par6Random,
private void tryToCatchBlockOnFire(World par1World, int par2, int par3, int par4, int par5, EaglercraftRandom par6Random,
int par7) {
int var8 = this.abilityToCatchFire[par1World.getBlockId(par2, par3, par4)];

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockFlower extends Block {
protected BlockFlower(int par1, Material par2Material) {
@ -45,7 +45,7 @@ public class BlockFlower extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
this.checkFlowerChange(par1World, par2, par3, par4);
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockFlowerPot extends Block {
public BlockFlowerPot(int par1) {
@ -118,7 +118,7 @@ public class BlockFlowerPot extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.flowerPot.itemID;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockFlowing extends BlockFluid {
/**
@ -41,7 +41,7 @@ public class BlockFlowing extends BlockFluid {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
int var6 = this.getFlowDecay(par1World, par2, par3, par4);
byte var7 = 1;

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public abstract class BlockFluid extends Block {
protected BlockFluid(int par1, Material par2Material) {
@ -111,14 +111,14 @@ public abstract class BlockFluid extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return 0;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 0;
}

View File

@ -1,13 +1,13 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockFurnace extends BlockContainer {
/**
* Is the random generator used by furnace to drop the inventory contents in
* random directions.
*/
private final Random furnaceRand = new Random();
private final EaglercraftRandom furnaceRand = new EaglercraftRandom();
/** True if this is an active furnace, false if idle */
private final boolean isActive;
@ -27,7 +27,7 @@ public class BlockFurnace extends BlockContainer {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Block.furnaceIdle.blockID;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockGlass extends BlockBreakable {
public BlockGlass(int par1, Material par2Material, boolean par3) {
@ -11,7 +11,7 @@ public class BlockGlass extends BlockBreakable {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 0;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockGlowStone extends Block {
public BlockGlowStone(int par1, Material par2Material) {
@ -12,21 +12,21 @@ public class BlockGlowStone extends Block {
* Returns the usual quantity dropped by the block plus a bonus of 1 to 'i'
* (inclusive).
*/
public int quantityDroppedWithBonus(int par1, Random par2Random) {
public int quantityDroppedWithBonus(int par1, EaglercraftRandom par2Random) {
return MathHelper.clamp_int(this.quantityDropped(par2Random) + par2Random.nextInt(par1 + 1), 1, 4);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 2 + par1Random.nextInt(3);
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.lightStoneDust.itemID;
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockGrass extends Block {
protected BlockGrass(int par1) {
@ -12,7 +12,7 @@ public class BlockGrass extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!par1World.isRemote) {
if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4
&& Block.lightOpacity[par1World.getBlockId(par2, par3 + 1, par4)] > 2) {
@ -37,7 +37,7 @@ public class BlockGrass extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Block.dirt.idDropped(0, par2Random, par3);
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockGravel extends BlockSand {
public BlockGravel(int par1) {
@ -10,7 +10,7 @@ public class BlockGravel extends BlockSand {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
if (par3 > 3) {
par3 = 3;
}

View File

@ -1,7 +1,8 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public abstract class BlockHalfSlab extends Block {
protected final boolean isDoubleSlab;
@ -79,7 +80,7 @@ public abstract class BlockHalfSlab extends Block {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return this.isDoubleSlab ? 2 : 1;
}

View File

@ -1,10 +1,11 @@
package net.minecraft.src;
import java.util.List;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockHopper extends BlockContainer {
private final Random field_94457_a = new Random();
private final EaglercraftRandom field_94457_a = new EaglercraftRandom();
public BlockHopper(int par1) {
super(par1, Material.iron);

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockIce extends BlockBreakable {
public BlockIce(int par1) {
@ -43,14 +43,14 @@ public class BlockIce extends BlockBreakable {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 0;
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (par1World.getSavedLightValue(EnumSkyBlock.Block, par2, par3, par4) > 11
- Block.lightOpacity[this.blockID]) {
if (par1World.provider.isHellWorld) {

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockLadder extends Block {
protected BlockLadder(int par1) {
@ -145,7 +145,7 @@ public class BlockLadder extends Block {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 1;
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockLeaves extends BlockLeavesBase {
public static final String[] LEAF_TYPES = new String[] { "oak", "spruce", "birch", "jungle" };
@ -43,7 +43,7 @@ public class BlockLeaves extends BlockLeavesBase {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (!par1World.isRemote) {
int var6 = par1World.getBlockMetadata(par2, par3, par4);
@ -152,14 +152,14 @@ public class BlockLeaves extends BlockLeavesBase {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return par1Random.nextInt(20) == 0 ? 1 : 0;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Block.sapling.blockID;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockLockedChest extends Block {
protected BlockLockedChest(int par1) {
@ -18,7 +18,7 @@ public class BlockLockedChest extends Block {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
par1World.setBlockToAir(par2, par3, par4);
}
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockLog extends Block {
/** The type of tree this log came from. */
@ -23,14 +23,14 @@ public class BlockLog extends Block {
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 1;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Block.wood.blockID;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockMelon extends Block {
protected BlockMelon(int par1) {
@ -11,14 +11,14 @@ public class BlockMelon extends Block {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return Item.melon.itemID;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 3 + par1Random.nextInt(5);
}
@ -26,7 +26,7 @@ public class BlockMelon extends Block {
* Returns the usual quantity dropped by the block plus a bonus of 1 to 'i'
* (inclusive).
*/
public int quantityDroppedWithBonus(int par1, Random par2Random) {
public int quantityDroppedWithBonus(int par1, EaglercraftRandom par2Random) {
int var3 = this.quantityDropped(par2Random) + par2Random.nextInt(1 + par1);
if (var3 > 9) {

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockMobSpawner extends BlockContainer {
protected BlockMobSpawner(int par1) {
@ -18,14 +18,14 @@ public class BlockMobSpawner extends BlockContainer {
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3) {
public int idDropped(int par1, EaglercraftRandom par2Random, int par3) {
return 0;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random par1Random) {
public int quantityDropped(EaglercraftRandom par1Random) {
return 0;
}

View File

@ -1,6 +1,6 @@
package net.minecraft.src;
import java.util.Random;
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
public class BlockMushroom extends BlockFlower {
private final String field_94374_a;
@ -16,7 +16,7 @@ public class BlockMushroom extends BlockFlower {
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
public void updateTick(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
if (par5Random.nextInt(25) == 0) {
byte var6 = 4;
int var7 = 5;
@ -93,7 +93,7 @@ public class BlockMushroom extends BlockFlower {
/**
* Fertilize the mushroom.
*/
public boolean fertilizeMushroom(World par1World, int par2, int par3, int par4, Random par5Random) {
public boolean fertilizeMushroom(World par1World, int par2, int par3, int par4, EaglercraftRandom par5Random) {
int var6 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockToAir(par2, par3, par4);
WorldGenBigMushroom var7 = null;

Some files were not shown because too many files have changed in this diff Show More