mirror of
https://git.zelz.net/catfoolyou/Project164.git
synced 2025-12-14 12:47:41 +00:00
Clean up client source
This commit is contained in:
@@ -6,14 +6,8 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.sp.IntegratedServer;
|
||||
import net.lax1dude.eaglercraft.sp.SYS;
|
||||
import net.lax1dude.eaglercraft.sp.SysUtil;
|
||||
import net.lax1dude.eaglercraft.sp.VFSSaveHandler;
|
||||
import net.lax1dude.eaglercraft.sp.VFile;
|
||||
import net.lax1dude.eaglercraft.sp.WorkerListenThread;
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate;
|
||||
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList;
|
||||
import net.minecraft.src.AxisAlignedBB;
|
||||
import net.minecraft.src.ChunkCoordinates;
|
||||
import net.minecraft.src.CommandBase;
|
||||
@@ -146,95 +140,14 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
* Typically "menu.convertingLevel", "menu.loadingLevel" or others.
|
||||
*/
|
||||
protected void setUserMessage(String par1Str) {
|
||||
IntegratedServer.sendIPCPacket(new IPCPacket0DProgressUpdate(par1Str, 0.0f));
|
||||
this.logInfo(par1Str);
|
||||
this.userMessage = par1Str;
|
||||
}
|
||||
|
||||
protected void setUserMessage(String par1Str, float prog) {
|
||||
IntegratedServer.sendIPCPacket(new IPCPacket0DProgressUpdate(par1Str, prog));
|
||||
this.logInfo(par1Str + ": " + (prog > 1.0f ? "" + (int)prog : "" + (int)(prog * 100.0f) + "%"));
|
||||
this.userMessage = par1Str;
|
||||
}
|
||||
|
||||
protected void loadAllWorlds(String par1Str, long par3, WorldSettings par5WorldType) {
|
||||
this.setUserMessage("menu.loadingLevel");
|
||||
this.worldServers = new WorldServer[3];
|
||||
this.timeOfLastDimensionTick = new long[this.worldServers.length][100];
|
||||
ISaveHandler var7 = new VFSSaveHandler(new VFile("worlds", par1Str));
|
||||
WorldInfo var9 = var7.loadWorldInfo();
|
||||
WorldSettings var8;
|
||||
|
||||
if (var9 == null) {
|
||||
if(par5WorldType == null) {
|
||||
throw new IllegalArgumentException("World '" + par1Str + "' does not exist and WorldSettings is null");
|
||||
}
|
||||
var8 = par5WorldType;
|
||||
} else {
|
||||
var8 = new WorldSettings(var9);
|
||||
}
|
||||
|
||||
for (int var10 = 0; var10 < this.worldServers.length; ++var10) {
|
||||
byte var11 = 0;
|
||||
|
||||
if (var10 == 1) {
|
||||
var11 = -1;
|
||||
}
|
||||
|
||||
if (var10 == 2) {
|
||||
var11 = 1;
|
||||
}
|
||||
|
||||
if (var10 == 0) {
|
||||
this.worldServers[var10] = new WorldServer(this, var7, par1Str, var11, var8, this.getLogAgent());
|
||||
} else {
|
||||
this.worldServers[var10] = new WorldServerMulti(this, var7, par1Str, var11, var8, this.worldServers[0], this.getLogAgent());
|
||||
}
|
||||
|
||||
this.worldServers[var10].addWorldAccess(new WorldManager(this, this.worldServers[var10]));
|
||||
this.worldServers[var10].getWorldInfo().setGameType(this.getGameType());
|
||||
|
||||
this.serverConfigManager.setPlayerManager(this.worldServers);
|
||||
}
|
||||
|
||||
this.setDifficultyForAllWorlds(this.getDifficulty());
|
||||
this.setGameType(var8.getGameType());
|
||||
this.initialWorldChunkLoad();
|
||||
}
|
||||
|
||||
protected void initialWorldChunkLoad() {
|
||||
int var5 = 0;
|
||||
//this.setUserMessage("menu.generatingTerrain");
|
||||
byte var6 = 0;
|
||||
this.setUserMessage("Preparing start region for level " + var6);
|
||||
|
||||
// Removed 'spawn chunks' for performance, they are unnecessary
|
||||
|
||||
/*
|
||||
WorldServer var7 = this.worldServers[var6];
|
||||
ChunkCoordinates var8 = var7.getSpawnPoint();
|
||||
long var9 = System.currentTimeMillis();
|
||||
|
||||
int prepareRadius = 64;
|
||||
|
||||
for (int var11 = -prepareRadius; var11 <= prepareRadius && this.isServerRunning(); var11 += 16) {
|
||||
for (int var12 = -prepareRadius; var12 <= prepareRadius && this.isServerRunning(); var12 += 16) {
|
||||
long var13 = System.currentTimeMillis();
|
||||
|
||||
if (var13 - var9 > 1000L) {
|
||||
setUserMessage("Preparing spawn area", Math.min(var5 / 64.0f, 0.99f));
|
||||
var9 = var13;
|
||||
}
|
||||
|
||||
++var5;
|
||||
var7.theChunkProviderServer.loadChunk(var8.posX + var11 >> 4, var8.posZ + var12 >> 4);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
this.clearCurrentTask();
|
||||
}
|
||||
|
||||
public abstract boolean canStructuresSpawn();
|
||||
|
||||
public abstract EnumGameType getGameType();
|
||||
@@ -298,10 +211,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
if (!this.worldIsBeingDeleted) {
|
||||
setUserMessage("Stopping server");
|
||||
|
||||
if (this.getNetworkThread() != null) {
|
||||
this.getNetworkThread().stopListening();
|
||||
}
|
||||
|
||||
if (this.serverConfigManager != null) {
|
||||
this.getLogAgent().logInfo("Saving players");
|
||||
this.serverConfigManager.saveAllPlayerData();
|
||||
@@ -344,10 +253,10 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
public void run() {
|
||||
try {
|
||||
if (this.startServer()) {
|
||||
long var1 = SysUtil.steadyTimeMillis();
|
||||
long var1 = EaglerAdapter.steadyTimeMillis();
|
||||
|
||||
for (long var50 = 0L; this.serverRunning; this.serverIsRunning = true) {
|
||||
long var5 = SysUtil.steadyTimeMillis();
|
||||
long var5 = EaglerAdapter.steadyTimeMillis();
|
||||
long var7 = var5 - var1;
|
||||
|
||||
if (var7 > 2000L && var1 - this.timeOfLastWarning >= 15000L) {
|
||||
@@ -375,7 +284,7 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
SysUtil.sleep(1);
|
||||
EaglerAdapter.sleep(1);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("Server did not init correctly");
|
||||
@@ -384,7 +293,7 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
this.getLogAgent().logSevereException(
|
||||
"Encountered an unexpected exception " + var48.getClass().getSimpleName(), var48);
|
||||
var48.printStackTrace();
|
||||
IntegratedServer.throwExceptionToClient("Encountered an unexpected exception", var48);
|
||||
//IntegratedServer.throwExceptionToClient("Encountered an unexpected exception", var48);
|
||||
} finally {
|
||||
try {
|
||||
this.stopServer();
|
||||
@@ -397,10 +306,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
protected VFile getDataDirectory() {
|
||||
return new VFile(".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly calls System.exit(0), instantly killing the program.
|
||||
*/
|
||||
@@ -496,7 +401,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
this.timeOfLastDimensionTick[var1][this.tickCounter % 100] = System.nanoTime() - var2;
|
||||
}
|
||||
|
||||
this.getNetworkThread().handleNetworkListenThread();
|
||||
this.serverConfigManager.sendPlayerInfoToAllPlayers();
|
||||
|
||||
for (var1 = 0; var1 < this.playersOnline.size(); ++var1) {
|
||||
@@ -511,13 +415,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
public void func_82010_a(IUpdatePlayerListBox par1IUpdatePlayerListBox) {
|
||||
this.playersOnline.add(par1IUpdatePlayerListBox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a File object from the specified string.
|
||||
*/
|
||||
public VFile getFile(String par1Str) {
|
||||
return new VFile(folderName, par1Str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the message with a level of INFO.
|
||||
@@ -540,34 +437,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
return par1 == -1 ? this.worldServers[1] : (par1 == 1 ? this.worldServers[2] : this.worldServers[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's hostname.
|
||||
*/
|
||||
public String getHostname() {
|
||||
return this.getServerHostname();
|
||||
}
|
||||
|
||||
/**
|
||||
* Never used, but "getServerPort" is already taken.
|
||||
*/
|
||||
public int getPort() {
|
||||
return this.getServerPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server message of the day
|
||||
*/
|
||||
public String getMotd() {
|
||||
return this.motd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's Minecraft version as string.
|
||||
*/
|
||||
public String getMinecraftVersion() {
|
||||
return "1.5.2";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of players currently on the server.
|
||||
*/
|
||||
@@ -589,47 +458,7 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
return this.serverConfigManager.getAllUsernames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by RCon's Query in the form of "MajorServerMod 1.2.3: MyPlugin 1.3;
|
||||
* AnotherPlugin 2.1; AndSoForth 1.0".
|
||||
*/
|
||||
public String getPlugins() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a command received by an RCon instance
|
||||
*/
|
||||
public String handleRConCommand(String par1Str) {
|
||||
return "fuck off";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if debugging is enabled, false otherwise.
|
||||
*/
|
||||
public boolean isDebuggingEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the error message with a level of SEVERE.
|
||||
*/
|
||||
public void logSevere(String par1Str) {
|
||||
this.getLogAgent().logSevere(par1Str);
|
||||
}
|
||||
|
||||
/**
|
||||
* If isDebuggingEnabled(), logs the message with a level of INFO.
|
||||
*/
|
||||
public void logDebug(String par1Str) {
|
||||
if (this.isDebuggingEnabled()) {
|
||||
this.getLogAgent().logInfo(par1Str);
|
||||
}
|
||||
}
|
||||
|
||||
public String getServerModName() {
|
||||
return "eaglercraft";
|
||||
}
|
||||
|
||||
/**
|
||||
* If par2Str begins with /, then it searches for commands, otherwise it returns
|
||||
@@ -701,13 +530,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
return par2Str.equals(this.getServerOwner());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates and formats the given string key with the given arguments.
|
||||
*/
|
||||
public String translateString(String par1Str, Object... par2ArrayOfObj) {
|
||||
return StringTranslate.getInstance().translateKeyFormat(par1Str, par2ArrayOfObj);
|
||||
}
|
||||
|
||||
public ICommandManager getCommandManager() {
|
||||
return this.commandManager;
|
||||
}
|
||||
@@ -719,10 +541,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void setServerPort(int par1) {
|
||||
throw new IllegalArgumentException("variable removed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username of the server owner (for integrated servers)
|
||||
*/
|
||||
@@ -730,25 +548,11 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
return this.serverOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username of the owner of this server (in the case of an integrated
|
||||
* server)
|
||||
*/
|
||||
public void setServerOwner(String par1Str) {
|
||||
this.serverOwner = par1Str;
|
||||
}
|
||||
|
||||
public boolean isSinglePlayer() {
|
||||
return this.serverOwner != null;
|
||||
}
|
||||
|
||||
public String getFolderName() {
|
||||
return this.folderName;
|
||||
}
|
||||
|
||||
public void setFolderName(String par1Str) {
|
||||
this.folderName = par1Str;
|
||||
}
|
||||
|
||||
public void setDifficultyForAllWorlds(int par1) {
|
||||
for (int var2 = 0; var2 < this.worldServers.length; ++var2) {
|
||||
@@ -773,23 +577,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this is a demo or not.
|
||||
*/
|
||||
public boolean isDemo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this is a demo or not.
|
||||
*/
|
||||
public void setDemo(boolean par1) {
|
||||
throw new IllegalArgumentException("variable removed");
|
||||
}
|
||||
|
||||
public void canCreateBonusChest(boolean par1) {
|
||||
throw new IllegalArgumentException("variable removed");
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING : directly calls
|
||||
@@ -807,17 +594,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
}
|
||||
|
||||
String dir = this.worldServers[0].getSaveHandler().getWorldDirectoryName();
|
||||
SYS.VFS.deleteFiles(dir);
|
||||
String[] worldsTxt = SYS.VFS.getFile("worlds.txt").getAllLines();
|
||||
if(worldsTxt != null) {
|
||||
LinkedList<String> newWorlds = new LinkedList();
|
||||
for(String str : worldsTxt) {
|
||||
if(!str.equalsIgnoreCase(dir)) {
|
||||
newWorlds.add(str);
|
||||
}
|
||||
}
|
||||
SYS.VFS.getFile("worlds.txt").setAllChars(String.join("\n", newWorlds));
|
||||
}
|
||||
|
||||
this.initiateShutdown();
|
||||
}
|
||||
@@ -826,9 +602,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setTexturePack(String par1Str) {
|
||||
throw new IllegalArgumentException("variable removed");
|
||||
}
|
||||
|
||||
/**
|
||||
* This is checked to be 16 upon receiving the packet, otherwise the packet is
|
||||
@@ -840,71 +613,41 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
|
||||
public abstract boolean isDedicatedServer();
|
||||
|
||||
public boolean isServerInOnlineMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setOnlineMode(boolean par1) {
|
||||
throw new IllegalArgumentException("variable removed");
|
||||
}
|
||||
|
||||
public boolean getCanSpawnAnimals() {
|
||||
return this.canSpawnAnimals;
|
||||
}
|
||||
|
||||
public void setCanSpawnAnimals(boolean par1) {
|
||||
this.canSpawnAnimals = par1;
|
||||
}
|
||||
|
||||
|
||||
public boolean getCanSpawnNPCs() {
|
||||
return this.canSpawnNPCs;
|
||||
}
|
||||
|
||||
public void setCanSpawnNPCs(boolean par1) {
|
||||
this.canSpawnNPCs = par1;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPVPEnabled() {
|
||||
return this.pvpEnabled;
|
||||
}
|
||||
|
||||
public void setAllowPvp(boolean par1) {
|
||||
this.pvpEnabled = par1;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFlightAllowed() {
|
||||
return this.allowFlight;
|
||||
}
|
||||
|
||||
public void setAllowFlight(boolean par1) {
|
||||
this.allowFlight = par1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether command blocks are enabled.
|
||||
*/
|
||||
public abstract boolean isCommandBlockEnabled();
|
||||
|
||||
public String getMOTD() {
|
||||
return this.motd;
|
||||
}
|
||||
|
||||
public void setMOTD(String par1Str) {
|
||||
this.motd = par1Str;
|
||||
}
|
||||
|
||||
public int getBuildLimit() {
|
||||
return 256;
|
||||
}
|
||||
|
||||
public void setBuildLimit(int par1) {
|
||||
throw new IllegalArgumentException("variable removed");
|
||||
}
|
||||
|
||||
public boolean isServerStopped() {
|
||||
return this.serverStopped;
|
||||
}
|
||||
|
||||
public ServerConfigurationManager getConfigurationManager() {
|
||||
return this.serverConfigManager;
|
||||
}
|
||||
@@ -922,8 +665,6 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract WorkerListenThread getNetworkThread();
|
||||
|
||||
public boolean getGuiEnabled() {
|
||||
return false;
|
||||
}
|
||||
@@ -958,18 +699,4 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
|
||||
|
||||
public abstract ILogAgent getLogAgent();
|
||||
|
||||
public void func_104055_i(boolean par1) {
|
||||
this.field_104057_T = par1;
|
||||
}
|
||||
|
||||
public boolean func_104056_am() {
|
||||
return this.field_104057_T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current player count, maximum player count, and player entity list.
|
||||
*/
|
||||
public static ServerConfigurationManager getServerConfigurationManager(MinecraftServer par0MinecraftServer) {
|
||||
return par0MinecraftServer.serverConfigManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.sp.VFile;
|
||||
|
||||
public interface ISaveHandler
|
||||
{
|
||||
/**
|
||||
@@ -39,11 +37,6 @@ public interface ISaveHandler
|
||||
*/
|
||||
void flush();
|
||||
|
||||
/**
|
||||
* Gets the file location of the given map
|
||||
*/
|
||||
VFile getMapFileFromName(String var1);
|
||||
|
||||
/**
|
||||
* Returns the name of the directory where world information is saved.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ItemMap extends ItemMapBase
|
||||
public static MapData getMPMapData(short par0, World par1World)
|
||||
{
|
||||
String var2 = "map_" + par0;
|
||||
MapData var3 = (MapData)par1World.loadItemData((s) -> new MapData(s), var2);
|
||||
MapData var3 = (MapData)par1World.loadItemData(MapData.class, var2);
|
||||
|
||||
if (var3 == null)
|
||||
{
|
||||
@@ -27,7 +27,7 @@ public class ItemMap extends ItemMapBase
|
||||
public MapData getMapData(ItemStack par1ItemStack, World par2World)
|
||||
{
|
||||
String var3 = "map_" + par1ItemStack.getItemDamage();
|
||||
MapData var4 = (MapData)par2World.loadItemData((s) -> new MapData(s), var3);
|
||||
MapData var4 = (MapData)par2World.loadItemData(MapData.class, var3);
|
||||
|
||||
if (var4 == null && !par2World.isRemote)
|
||||
{
|
||||
|
||||
@@ -219,7 +219,7 @@ public abstract class MapGenStructure extends MapGenBase
|
||||
{
|
||||
if (this.field_143029_e == null)
|
||||
{
|
||||
this.field_143029_e = (MapGenStructureData)par1World.loadItemData((s) -> new MapGenStructureData(s), this.func_143025_a());
|
||||
this.field_143029_e = (MapGenStructureData)par1World.loadItemData(MapGenStructure.class, this.func_143025_a());
|
||||
|
||||
if (this.field_143029_e == null)
|
||||
{
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.sp.VFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class MapStorage
|
||||
{
|
||||
private ISaveHandler saveHandler;
|
||||
public class MapStorage {
|
||||
|
||||
/** Map of item data String id to loaded MapDataBases */
|
||||
private Map loadedDataMap = new HashMap();
|
||||
@@ -17,73 +14,33 @@ public class MapStorage
|
||||
private List loadedDataList = new ArrayList();
|
||||
|
||||
/**
|
||||
* Map of MapDataBase id String prefixes ('map' etc) to max known unique Short id (the 0 part etc) for that prefix
|
||||
* Map of MapDataBase id String prefixes ('map' etc) to max known unique Short
|
||||
* id (the 0 part etc) for that prefix
|
||||
*/
|
||||
private Map idCounts = new HashMap();
|
||||
|
||||
public MapStorage(ISaveHandler par1ISaveHandler)
|
||||
{
|
||||
this.saveHandler = par1ISaveHandler;
|
||||
this.loadIdCounts();
|
||||
}
|
||||
|
||||
public MapStorage() // FIX THIS SHIT
|
||||
{
|
||||
this.saveHandler = null;
|
||||
public MapStorage() {
|
||||
this.loadIdCounts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an existing MapDataBase corresponding to the given String id from disk, instantiating the given Class, or
|
||||
* returns null if none such file exists. args: Class to instantiate, String dataid
|
||||
* Loads an existing MapDataBase corresponding to the given String id from disk,
|
||||
* instantiating the given Class, or returns null if none such file exists.
|
||||
* args: Class to instantiate, String dataid
|
||||
*/
|
||||
public WorldSavedData loadData(Function<String, WorldSavedData> par1Class, String par2Str) {
|
||||
WorldSavedData var3 = (WorldSavedData) this.loadedDataMap.get(par2Str);
|
||||
|
||||
if (var3 != null) {
|
||||
return var3;
|
||||
} else {
|
||||
if (this.saveHandler != null) {
|
||||
try {
|
||||
VFile var4 = this.saveHandler.getMapFileFromName(par2Str);
|
||||
|
||||
if (var4 != null && var4.exists()) {
|
||||
try {
|
||||
var3 = (WorldSavedData) par1Class.apply(par2Str);
|
||||
} catch (Exception var7) {
|
||||
throw new RuntimeException("Failed to instantiate " + par1Class.toString(), var7);
|
||||
}
|
||||
|
||||
NBTTagCompound var6 = CompressedStreamTools.readCompressed(var4.getInputStream());
|
||||
var3.readFromNBT(var6.getCompoundTag("data"));
|
||||
}
|
||||
} catch (Exception var8) {
|
||||
var8.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (var3 != null) {
|
||||
this.loadedDataMap.put(par2Str, var3);
|
||||
this.loadedDataList.add(var3);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
public WorldSavedData loadData(Class par1Class, String par2Str) {
|
||||
return (WorldSavedData) this.loadedDataMap.get(par2Str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns the given String id to the given MapDataBase, removing any existing ones of the same id.
|
||||
* Assigns the given String id to the given MapDataBase, removing any existing
|
||||
* ones of the same id.
|
||||
*/
|
||||
public void setData(String par1Str, WorldSavedData par2WorldSavedData)
|
||||
{
|
||||
if (par2WorldSavedData == null)
|
||||
{
|
||||
public void setData(String par1Str, WorldSavedData par2WorldSavedData) {
|
||||
if (par2WorldSavedData == null) {
|
||||
throw new RuntimeException("Can\'t set null data");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.loadedDataMap.containsKey(par1Str))
|
||||
{
|
||||
} else {
|
||||
if (this.loadedDataMap.containsKey(par1Str)) {
|
||||
this.loadedDataList.remove(this.loadedDataMap.remove(par1Str));
|
||||
}
|
||||
|
||||
@@ -95,14 +52,11 @@ public class MapStorage
|
||||
/**
|
||||
* Saves all dirty loaded MapDataBases to disk.
|
||||
*/
|
||||
public void saveAllData()
|
||||
{
|
||||
for (int var1 = 0; var1 < this.loadedDataList.size(); ++var1)
|
||||
{
|
||||
WorldSavedData var2 = (WorldSavedData)this.loadedDataList.get(var1);
|
||||
public void saveAllData() {
|
||||
for (int var1 = 0; var1 < this.loadedDataList.size(); ++var1) {
|
||||
WorldSavedData var2 = (WorldSavedData) this.loadedDataList.get(var1);
|
||||
|
||||
if (var2.isDirty())
|
||||
{
|
||||
if (var2.isDirty()) {
|
||||
this.saveData(var2);
|
||||
var2.setDirty(false);
|
||||
}
|
||||
@@ -113,23 +67,7 @@ public class MapStorage
|
||||
* Saves the given MapDataBase to disk.
|
||||
*/
|
||||
private void saveData(WorldSavedData par1WorldSavedData) {
|
||||
if (this.saveHandler != null) {
|
||||
try {
|
||||
VFile var2 = this.saveHandler.getMapFileFromName(par1WorldSavedData.mapName);
|
||||
|
||||
if (var2 != null) {
|
||||
NBTTagCompound var3 = new NBTTagCompound();
|
||||
par1WorldSavedData.writeToNBT(var3);
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setCompoundTag("data", var3);
|
||||
OutputStream st = var2.getOutputStream();
|
||||
CompressedStreamTools.writeCompressed(var4, st);
|
||||
st.close();
|
||||
}
|
||||
} catch (Exception var6) {
|
||||
var6.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,37 +76,14 @@ public class MapStorage
|
||||
private void loadIdCounts() {
|
||||
try {
|
||||
this.idCounts.clear();
|
||||
|
||||
if (this.saveHandler == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
VFile var1 = this.saveHandler.getMapFileFromName("idcounts");
|
||||
|
||||
if (var1 != null && var1.exists()) {
|
||||
DataInputStream var2 = new DataInputStream(var1.getInputStream());
|
||||
NBTTagCompound var3 = CompressedStreamTools.read(var2);
|
||||
var2.close();
|
||||
Iterator var4 = var3.getTags().iterator();
|
||||
|
||||
while (var4.hasNext()) {
|
||||
NBTBase var5 = (NBTBase) var4.next();
|
||||
|
||||
if (var5 instanceof NBTTagShort) {
|
||||
NBTTagShort var6 = (NBTTagShort) var5;
|
||||
String var7 = var6.getName();
|
||||
short var8 = var6.data;
|
||||
this.idCounts.put(var7, Short.valueOf(var8));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception var9) {
|
||||
var9.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unique new data id for the given prefix and saves the idCounts map to the 'idcounts' file.
|
||||
* Returns an unique new data id for the given prefix and saves the idCounts map
|
||||
* to the 'idcounts' file.
|
||||
*/
|
||||
public int getUniqueDataId(String par1Str) {
|
||||
Short var2 = (Short) this.idCounts.get(par1Str);
|
||||
@@ -181,32 +96,6 @@ public class MapStorage
|
||||
|
||||
this.idCounts.put(par1Str, var2);
|
||||
|
||||
if (this.saveHandler == null) {
|
||||
return var2.shortValue();
|
||||
} else {
|
||||
try {
|
||||
VFile var3 = this.saveHandler.getMapFileFromName("idcounts");
|
||||
|
||||
if (var3 != null) {
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
Iterator var5 = this.idCounts.keySet().iterator();
|
||||
|
||||
while (var5.hasNext()) {
|
||||
String var6 = (String) var5.next();
|
||||
short var7 = ((Short) this.idCounts.get(var6)).shortValue();
|
||||
var4.setShort(var6, var7);
|
||||
}
|
||||
|
||||
OutputStream os = var3.getOutputStream();
|
||||
DataOutputStream var9 = new DataOutputStream(os);
|
||||
CompressedStreamTools.write(var4, var9);
|
||||
os.close();
|
||||
}
|
||||
} catch (Exception var8) {
|
||||
var8.printStackTrace();
|
||||
}
|
||||
|
||||
return var2.shortValue();
|
||||
}
|
||||
return var2.shortValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.sp.EaglercraftRandom;
|
||||
import net.lax1dude.eaglercraft.sp.WorkerNetworkManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class NetLoginHandler extends NetHandler {
|
||||
/** The Random object used to generate serverId hex strings. */
|
||||
private static EaglercraftRandom rand = new EaglercraftRandom();
|
||||
|
||||
/** Reference to the MinecraftServer object. */
|
||||
private final MinecraftServer mcServer;
|
||||
public final WorkerNetworkManager myTCPConnection;
|
||||
|
||||
/**
|
||||
* Returns if the login handler is finished and can be removed. It is set to
|
||||
* true on either error or successful login.
|
||||
*/
|
||||
public boolean finishedProcessing = false;
|
||||
|
||||
/** While waiting to login, if this field ++'s to 600 it will kick you. */
|
||||
private int loginTimer = 0;
|
||||
private String clientUsername = null;
|
||||
private volatile boolean field_72544_i = false;
|
||||
|
||||
private boolean field_92079_k = false;
|
||||
|
||||
private int hash = 0;
|
||||
private static int hashBase = 69696969;
|
||||
|
||||
private int viewDistance = 2;
|
||||
|
||||
public NetLoginHandler(MinecraftServer par1MinecraftServer, WorkerNetworkManager par2Socket) {
|
||||
this.mcServer = par1MinecraftServer;
|
||||
this.myTCPConnection = par2Socket;
|
||||
hash = ++hashBase;
|
||||
}
|
||||
|
||||
public boolean shouldBeRemoved() {
|
||||
return this.finishedProcessing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the user in if a login packet is found, otherwise keeps processing
|
||||
* network packets unless the timeout has occurred.
|
||||
*/
|
||||
public void handlePackets() {
|
||||
System.out.println("[Server][LOGIN][HANDLE][" + clientUsername + "]");
|
||||
if (this.field_72544_i) {
|
||||
this.initializePlayerConnection();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.loginTimer++ == 600) {
|
||||
this.kickUser("Took too long to log in");
|
||||
} else {
|
||||
this.myTCPConnection.processReadPackets();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return (o instanceof NetLoginHandler) && ((NetLoginHandler)o).hash == hash;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects the user with the given reason.
|
||||
*/
|
||||
public void kickUser(String par1Str) {
|
||||
try {
|
||||
this.mcServer.getLogAgent().logInfo("Disconnecting " + this.getUsernameAndAddress() + ": " + par1Str);
|
||||
this.myTCPConnection.addToSendQueue(new Packet255KickDisconnect(par1Str));
|
||||
this.myTCPConnection.serverShutdown();
|
||||
this.finishedProcessing = true;
|
||||
} catch (Exception var3) {
|
||||
var3.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void handleClientProtocol(Packet2ClientProtocol par1Packet2ClientProtocol) {
|
||||
this.clientUsername = par1Packet2ClientProtocol.getUsername();
|
||||
int var2 = 64 << 3 - par1Packet2ClientProtocol.getViewDistance();
|
||||
if(var2 > 400) {
|
||||
var2 = 400;
|
||||
}
|
||||
var2 = (var2 >> 5) + 2;
|
||||
this.viewDistance = var2;
|
||||
System.out.println("[Server][HANDSHAKE][" + this.clientUsername + "]");
|
||||
|
||||
if (!this.clientUsername.equals(StringUtils.stripControlCodes(this.clientUsername))) {
|
||||
this.kickUser("Invalid username!");
|
||||
} else {
|
||||
if (par1Packet2ClientProtocol.getProtocolVersion() != 61) {
|
||||
if (par1Packet2ClientProtocol.getProtocolVersion() > 61) {
|
||||
this.kickUser("Outdated server!");
|
||||
} else {
|
||||
this.kickUser("Outdated client!");
|
||||
}
|
||||
}else {
|
||||
this.initializePlayerConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleClientCommand(Packet205ClientCommand par1Packet205ClientCommand) {
|
||||
if (par1Packet205ClientCommand.forceRespawn == 0) {
|
||||
if (this.field_92079_k) {
|
||||
this.kickUser("Duplicate login");
|
||||
return;
|
||||
}
|
||||
|
||||
this.field_92079_k = true;
|
||||
this.field_72544_i = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleLogin(Packet1Login par1Packet1Login) {
|
||||
}
|
||||
|
||||
/**
|
||||
* on success the specified username is connected to the minecraftInstance,
|
||||
* otherwise they are packet255'd
|
||||
*/
|
||||
public void initializePlayerConnection() {
|
||||
String var1 = this.mcServer.getConfigurationManager().allowUserToConnect(this.clientUsername);
|
||||
|
||||
if (var1 != null) {
|
||||
this.kickUser(var1);
|
||||
} else {
|
||||
EntityPlayerMP var2 = this.mcServer.getConfigurationManager().createPlayerForUser(this.clientUsername);
|
||||
if (var2 != null) {
|
||||
if (this.mcServer.getServerOwner().equals(this.clientUsername)) {
|
||||
var2.renderDistance = this.viewDistance;
|
||||
} else {
|
||||
EntityPlayerMP fard = this.mcServer.getConfigurationManager().getPlayerForUsername(this.mcServer.getServerOwner());
|
||||
int maxRenderDistance = fard == null ? 10 : (fard.renderDistance > 10 ? 10 : fard.renderDistance);
|
||||
var2.renderDistance = this.viewDistance > maxRenderDistance ? maxRenderDistance : this.viewDistance;
|
||||
}
|
||||
this.mcServer.getConfigurationManager().initializeConnectionToPlayer(this.myTCPConnection, var2);
|
||||
}else {
|
||||
this.kickUser("Could not construct EntityPlayerMP for '" + var1 + "'");
|
||||
}
|
||||
}
|
||||
|
||||
this.finishedProcessing = true;
|
||||
}
|
||||
|
||||
public void handleErrorMessage(String par1Str, Object[] par2ArrayOfObj) {
|
||||
this.mcServer.getLogAgent().logInfo(this.getUsernameAndAddress() + " lost connection");
|
||||
this.finishedProcessing = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a server ping packet.
|
||||
*/
|
||||
public void handleServerPing(Packet254ServerPing par1Packet254ServerPing) {
|
||||
try {
|
||||
ServerConfigurationManager var2 = this.mcServer.getConfigurationManager();
|
||||
String var3 = null;
|
||||
|
||||
if (par1Packet254ServerPing.readSuccessfully == 1) {
|
||||
List var4 = Arrays.asList(new Serializable[] { Integer.valueOf(1), Integer.valueOf(61),
|
||||
this.mcServer.getMinecraftVersion(), this.mcServer.getMOTD(),
|
||||
Integer.valueOf(var2.getCurrentPlayerCount()), Integer.valueOf(var2.getMaxPlayers()) });
|
||||
Object var6;
|
||||
|
||||
for (Iterator var5 = var4.iterator(); var5
|
||||
.hasNext(); var3 = var3 + var6.toString().replaceAll("\u0000", "")) {
|
||||
var6 = var5.next();
|
||||
|
||||
if (var3 == null) {
|
||||
var3 = "\u00a7";
|
||||
} else {
|
||||
var3 = var3 + "\u0000";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var3 = this.mcServer.getMOTD() + "\u00a7" + var2.getCurrentPlayerCount() + "\u00a7"
|
||||
+ var2.getMaxPlayers();
|
||||
}
|
||||
|
||||
this.myTCPConnection.addToSendQueue(new Packet255KickDisconnect(var3));
|
||||
this.myTCPConnection.serverShutdown();
|
||||
|
||||
this.finishedProcessing = true;
|
||||
} catch (Exception var7) {
|
||||
var7.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default handler called for packets that don't have their own handlers in
|
||||
* NetServerHandler; kicks player from the server.
|
||||
*/
|
||||
public void unexpectedPacket(Packet par1Packet) {
|
||||
this.kickUser("Protocol error");
|
||||
}
|
||||
|
||||
public String getUsernameAndAddress() {
|
||||
return this.clientUsername + "[EAG]";
|
||||
}
|
||||
|
||||
/**
|
||||
* determine if it is a server handler
|
||||
*/
|
||||
public boolean isServerHandler() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server Id randomly generated by this login handler.
|
||||
*/
|
||||
static String getServerId(NetLoginHandler par0NetLoginHandler) {
|
||||
return "you eagler";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reference to Minecraft Server.
|
||||
*/
|
||||
static MinecraftServer getLoginMinecraftServer(NetLoginHandler par0NetLoginHandler) {
|
||||
return par0NetLoginHandler.mcServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connecting client username.
|
||||
*/
|
||||
static String getClientUsername(NetLoginHandler par0NetLoginHandler) {
|
||||
return par0NetLoginHandler.clientUsername;
|
||||
}
|
||||
|
||||
static boolean func_72531_a(NetLoginHandler par0NetLoginHandler, boolean par1) {
|
||||
return par0NetLoginHandler.field_72544_i = par1;
|
||||
}
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.sp.RandomAccessMemoryFile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
public class RegionFile
|
||||
{
|
||||
private static final byte[] emptySector = new byte[4096];
|
||||
private RandomAccessMemoryFile dataFile;
|
||||
private final int[] offsets = new int[1024];
|
||||
private final int[] chunkTimestamps = new int[1024];
|
||||
private ArrayList sectorFree;
|
||||
|
||||
/** McRegion sizeDelta */
|
||||
private int sizeDelta;
|
||||
private long lastModified;
|
||||
|
||||
public RegionFile(RandomAccessMemoryFile par1File)
|
||||
{
|
||||
this.sizeDelta = 0;
|
||||
|
||||
try
|
||||
{
|
||||
this.dataFile = par1File;
|
||||
int var2;
|
||||
|
||||
if (this.dataFile.getLength() < 4096L)
|
||||
{
|
||||
for (var2 = 0; var2 < 1024; ++var2)
|
||||
{
|
||||
this.dataFile.writeInt(0);
|
||||
}
|
||||
|
||||
for (var2 = 0; var2 < 1024; ++var2)
|
||||
{
|
||||
this.dataFile.writeInt(0);
|
||||
}
|
||||
|
||||
this.sizeDelta += 8192;
|
||||
}
|
||||
|
||||
if ((this.dataFile.getLength() & 4095L) != 0L)
|
||||
{
|
||||
for (var2 = 0; (long)var2 < (this.dataFile.getLength() & 4095L); ++var2)
|
||||
{
|
||||
this.dataFile.write(0);
|
||||
}
|
||||
}
|
||||
|
||||
var2 = (int)this.dataFile.getLength() / 4096;
|
||||
this.sectorFree = new ArrayList(var2);
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < var2; ++var3)
|
||||
{
|
||||
this.sectorFree.add(Boolean.valueOf(true));
|
||||
}
|
||||
|
||||
this.sectorFree.set(0, Boolean.valueOf(false));
|
||||
this.sectorFree.set(1, Boolean.valueOf(false));
|
||||
this.dataFile.seek(0);
|
||||
int var4;
|
||||
|
||||
for (var3 = 0; var3 < 1024; ++var3)
|
||||
{
|
||||
var4 = this.dataFile.readInt();
|
||||
this.offsets[var3] = var4;
|
||||
|
||||
if (var4 != 0 && (var4 >> 8) + (var4 & 255) <= this.sectorFree.size())
|
||||
{
|
||||
for (int var5 = 0; var5 < (var4 & 255); ++var5)
|
||||
{
|
||||
this.sectorFree.set((var4 >> 8) + var5, Boolean.valueOf(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 1024; ++var3)
|
||||
{
|
||||
var4 = this.dataFile.readInt();
|
||||
this.chunkTimestamps[var3] = var4;
|
||||
}
|
||||
}
|
||||
catch (IOException var6)
|
||||
{
|
||||
var6.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, y - get uncompressed chunk stream from the region file
|
||||
*/
|
||||
public synchronized DataInputStream getChunkDataInputStream(int par1, int par2) {
|
||||
if (this.outOfBounds(par1, par2)) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
int var3 = this.getOffset(par1, par2);
|
||||
|
||||
if (var3 == 0) {
|
||||
return null;
|
||||
} else {
|
||||
int var4 = var3 >> 8;
|
||||
int var5 = var3 & 255;
|
||||
|
||||
if (var4 + var5 > this.sectorFree.size()) {
|
||||
return null;
|
||||
} else {
|
||||
this.dataFile.seek(var4 * 4096);
|
||||
int var6 = this.dataFile.readInt();
|
||||
|
||||
if (var6 > 4096 * var5) {
|
||||
return null;
|
||||
} else if (var6 <= 0) {
|
||||
return null;
|
||||
} else {
|
||||
byte var7 = this.dataFile.readByte();
|
||||
byte[] var8;
|
||||
|
||||
if (var7 == 1) {
|
||||
var8 = new byte[var6 - 1];
|
||||
this.dataFile.read(var8);
|
||||
return new DataInputStream(
|
||||
new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(var8))));
|
||||
} else if (var7 == 2) {
|
||||
var8 = new byte[var6 - 1];
|
||||
this.dataFile.read(var8);
|
||||
return new DataInputStream(new BufferedInputStream(
|
||||
new InflaterInputStream(new ByteArrayInputStream(var8))));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException var9) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, z - get an output stream used to write chunk data, data is on disk when the returned stream is closed
|
||||
*/
|
||||
public DataOutputStream getChunkDataOutputStream(int par1, int par2)
|
||||
{
|
||||
return this.outOfBounds(par1, par2) ? null : new DataOutputStream(new DeflaterOutputStream(new RegionFileChunkBuffer(this, par1, par2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, z, data, length - write chunk data at (x, z) to disk
|
||||
*/
|
||||
protected synchronized void write(int par1, int par2, byte[] par3ArrayOfByte, int par4)
|
||||
{
|
||||
try
|
||||
{
|
||||
int var5 = this.getOffset(par1, par2);
|
||||
int var6 = var5 >> 8;
|
||||
int var7 = var5 & 255;
|
||||
int var8 = (par4 + 5) / 4096 + 1;
|
||||
|
||||
if (var8 >= 256)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (var6 != 0 && var7 == var8)
|
||||
{
|
||||
this.write(var6, par3ArrayOfByte, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
int var9;
|
||||
|
||||
for (var9 = 0; var9 < var7; ++var9)
|
||||
{
|
||||
this.sectorFree.set(var6 + var9, Boolean.valueOf(true));
|
||||
}
|
||||
|
||||
var9 = this.sectorFree.indexOf(Boolean.valueOf(true));
|
||||
int var10 = 0;
|
||||
int var11;
|
||||
|
||||
if (var9 != -1)
|
||||
{
|
||||
for (var11 = var9; var11 < this.sectorFree.size(); ++var11)
|
||||
{
|
||||
if (var10 != 0)
|
||||
{
|
||||
if (((Boolean)this.sectorFree.get(var11)).booleanValue())
|
||||
{
|
||||
++var10;
|
||||
}
|
||||
else
|
||||
{
|
||||
var10 = 0;
|
||||
}
|
||||
}
|
||||
else if (((Boolean)this.sectorFree.get(var11)).booleanValue())
|
||||
{
|
||||
var9 = var11;
|
||||
var10 = 1;
|
||||
}
|
||||
|
||||
if (var10 >= var8)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var10 >= var8)
|
||||
{
|
||||
var6 = var9;
|
||||
this.setOffset(par1, par2, var9 << 8 | var8);
|
||||
|
||||
for (var11 = 0; var11 < var8; ++var11)
|
||||
{
|
||||
this.sectorFree.set(var6 + var11, Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
this.write(var6, par3ArrayOfByte, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dataFile.seek(this.dataFile.getLength());
|
||||
var6 = this.sectorFree.size();
|
||||
|
||||
for (var11 = 0; var11 < var8; ++var11)
|
||||
{
|
||||
this.dataFile.write(emptySector);
|
||||
this.sectorFree.add(Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
this.sizeDelta += 4096 * var8;
|
||||
this.write(var6, par3ArrayOfByte, par4);
|
||||
this.setOffset(par1, par2, var6 << 8 | var8);
|
||||
}
|
||||
}
|
||||
|
||||
this.setChunkTimestamp(par1, par2, (int)(EaglerAdapter.steadyTimeMillis() / 1000L));
|
||||
}
|
||||
catch (IOException var12)
|
||||
{
|
||||
var12.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* args: sectorNumber, data, length - write the chunk data to this RegionFile
|
||||
*/
|
||||
private void write(int par1, byte[] par2ArrayOfByte, int par3) throws IOException
|
||||
{
|
||||
this.dataFile.seek(par1 * 4096);
|
||||
this.dataFile.writeInt(par3 + 1);
|
||||
this.dataFile.writeByte(2);
|
||||
this.dataFile.write(par2ArrayOfByte, 0, par3);
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, z - check region bounds
|
||||
*/
|
||||
private boolean outOfBounds(int par1, int par2)
|
||||
{
|
||||
return par1 < 0 || par1 >= 32 || par2 < 0 || par2 >= 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, y - get chunk's offset in region file
|
||||
*/
|
||||
private int getOffset(int par1, int par2)
|
||||
{
|
||||
return this.offsets[par1 + par2 * 32];
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, z, - true if chunk has been saved / converted
|
||||
*/
|
||||
public boolean isChunkSaved(int par1, int par2)
|
||||
{
|
||||
return this.getOffset(par1, par2) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, z, offset - sets the chunk's offset in the region file
|
||||
*/
|
||||
private void setOffset(int par1, int par2, int par3) throws IOException
|
||||
{
|
||||
this.offsets[par1 + par2 * 32] = par3;
|
||||
this.dataFile.seek((par1 + par2 * 32) * 4);
|
||||
this.dataFile.writeInt(par3);
|
||||
}
|
||||
|
||||
/**
|
||||
* args: x, z, timestamp - sets the chunk's write timestamp
|
||||
*/
|
||||
private void setChunkTimestamp(int par1, int par2, int par3) throws IOException
|
||||
{
|
||||
this.chunkTimestamps[par1 + par2 * 32] = par3;
|
||||
this.dataFile.seek(4096 + (par1 + par2 * 32) * 4);
|
||||
this.dataFile.writeInt(par3);
|
||||
}
|
||||
|
||||
public RandomAccessMemoryFile getFile() {
|
||||
return dataFile;
|
||||
}
|
||||
|
||||
class ChunkBuffer extends ByteArrayOutputStream {
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
|
||||
public ChunkBuffer(int x, int z) {
|
||||
super(8096);
|
||||
this.chunkX = x;
|
||||
this.chunkZ = z;
|
||||
}
|
||||
|
||||
/**+
|
||||
* close this RegionFile and prevent further writes
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
RegionFile.this.write(this.chunkX, this.chunkZ, this.buf, this.count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
class RegionFileChunkBuffer extends ByteArrayOutputStream
|
||||
{
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
|
||||
final RegionFile regionFile;
|
||||
|
||||
public RegionFileChunkBuffer(RegionFile par1RegionFile, int par2, int par3)
|
||||
{
|
||||
super(8096);
|
||||
this.regionFile = par1RegionFile;
|
||||
this.chunkX = par2;
|
||||
this.chunkZ = par3;
|
||||
}
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
this.regionFile.write(this.chunkX, this.chunkZ, this.buf, this.count);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.sp.VFile;
|
||||
|
||||
public class SaveHandlerMP implements ISaveHandler
|
||||
{
|
||||
/**
|
||||
* Loads and returns the world info
|
||||
*/
|
||||
public WorldInfo loadWorldInfo()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the session lock to prevent save collisions
|
||||
*/
|
||||
public void checkSessionLock() throws MinecraftException {}
|
||||
|
||||
/**
|
||||
* Returns the chunk loader with the provided world provider
|
||||
*/
|
||||
public IChunkLoader getChunkLoader(WorldProvider par1WorldProvider)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the given World Info with the given NBTTagCompound as the Player.
|
||||
*/
|
||||
public void saveWorldInfoWithPlayer(WorldInfo par1WorldInfo, NBTTagCompound par2NBTTagCompound) {}
|
||||
|
||||
/**
|
||||
* Saves the passed in world info.
|
||||
*/
|
||||
public void saveWorldInfo(WorldInfo par1WorldInfo) {}
|
||||
|
||||
/**
|
||||
* returns null if no saveHandler is relevent (eg. SMP)
|
||||
*/
|
||||
public IPlayerFileData getSaveHandler()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to flush all changes to disk, waiting for them to complete.
|
||||
*/
|
||||
public void flush() {}
|
||||
|
||||
/**
|
||||
* Gets the file location of the given map
|
||||
*/
|
||||
public VFile getMapFileFromName(String par1Str)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the directory where world information is saved.
|
||||
*/
|
||||
public String getWorldDirectoryName()
|
||||
{
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
@@ -143,8 +143,8 @@ public abstract class World implements IBlockAccess
|
||||
this.saveHandler = par1ISaveHandler;
|
||||
this.worldInfo = new WorldInfo(par4WorldSettings, par2Str);
|
||||
this.provider = par3WorldProvider;
|
||||
this.mapStorage = new MapStorage(par1ISaveHandler);
|
||||
VillageCollection var7 = (VillageCollection) this.mapStorage.loadData((s) -> new VillageCollection(s), "villages");
|
||||
this.mapStorage = new MapStorage();
|
||||
VillageCollection var7 = (VillageCollection) this.mapStorage.loadData(VillageCollection.class, "villages");
|
||||
|
||||
if (var7 == null)
|
||||
{
|
||||
@@ -168,7 +168,7 @@ public abstract class World implements IBlockAccess
|
||||
this.ambientTickCountdown = this.rand.nextInt(12000);
|
||||
this.lightUpdateBlockList = new int[32768];
|
||||
this.saveHandler = par1ISaveHandler;
|
||||
this.mapStorage = new MapStorage(par1ISaveHandler);
|
||||
this.mapStorage = new MapStorage();
|
||||
this.worldInfo = par1ISaveHandler.loadWorldInfo();
|
||||
|
||||
if (par4WorldProvider != null)
|
||||
@@ -203,7 +203,7 @@ public abstract class World implements IBlockAccess
|
||||
this.worldInfo.setServerInitialized(true);
|
||||
}
|
||||
|
||||
VillageCollection var7 = (VillageCollection) this.mapStorage.loadData((s) -> new VillageCollection(s), "villages");
|
||||
VillageCollection var7 = (VillageCollection) this.mapStorage.loadData(VillageCollection.class, "villages");
|
||||
|
||||
if (var7 == null)
|
||||
{
|
||||
@@ -3899,7 +3899,7 @@ public abstract class World implements IBlockAccess
|
||||
* Loads an existing MapDataBase corresponding to the given String id from disk using the MapStorage, instantiating
|
||||
* the given Class, or returns null if none such file exists. args: Class to instantiate, String dataid
|
||||
*/
|
||||
public WorldSavedData loadItemData(Function<String, WorldSavedData> par1Class, String par2Str) {
|
||||
public WorldSavedData loadItemData(Class par1Class, String par2Str) {
|
||||
return this.mapStorage.loadData(par1Class, par2Str);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class WorldClient extends World
|
||||
|
||||
public WorldClient(NetClientHandler par1NetClientHandler, WorldSettings par2WorldSettings, int par3, int par4)
|
||||
{
|
||||
super(new SaveHandlerMP(), "MpServer", WorldProvider.getProviderForDimension(par3), par2WorldSettings);
|
||||
super(null, "MpServer", WorldProvider.getProviderForDimension(par3), par2WorldSettings);
|
||||
this.sendQueue = par1NetClientHandler;
|
||||
this.difficultySetting = par4;
|
||||
this.setSpawnLocation(8, 64, 8);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.EaglercraftRandom;
|
||||
import net.lax1dude.eaglercraft.sp.SysUtil;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.util.*;
|
||||
@@ -84,7 +84,7 @@ public class WorldServer extends World
|
||||
|
||||
this.worldTeleporter = new Teleporter(this);
|
||||
this.worldScoreboard = new ServerScoreboard(par1MinecraftServer);
|
||||
ScoreboardSaveData var8 = (ScoreboardSaveData) this.mapStorage.loadData((s) -> new ScoreboardSaveData(s), "scoreboard");
|
||||
ScoreboardSaveData var8 = (ScoreboardSaveData) this.mapStorage.loadData(ScoreboardSaveData.class, "scoreboard");
|
||||
|
||||
if (var8 == null)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ public class WorldServer extends World
|
||||
_lu += Chunk.totalBlockLightUpdates;
|
||||
Chunk.totalBlockLightUpdates = 0;
|
||||
|
||||
long millis = SysUtil.steadyTimeMillis();
|
||||
long millis = EaglerAdapter.steadyTimeMillis();
|
||||
if(millis - rwgtuluTimer >= 1000l) {
|
||||
rwgtuluTimer = millis;
|
||||
r = _r; _r = 0;
|
||||
|
||||
Reference in New Issue
Block a user