fixed chunk memory leak, added statistics to ingame gui

This commit is contained in:
LAX1DUDE 2022-03-06 17:14:07 -08:00
parent a1a25e12d3
commit f18d793896
21 changed files with 32068 additions and 425811 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -64,7 +64,7 @@ dependencies {
teavm {
compileScopes = null;
minifying = false;
minifying = true;
maxTopLevelNames = 10000;
properties = null;
debugInformationGenerated = false;

View File

@ -13,6 +13,7 @@ public class IPCPacket14StringList implements IPCPacketBase {
public static final int FILE_LIST = 0x0;
public static final int LOCALE = 0x1;
public static final int STAT_GUID = 0x2;
public static final int SERVER_TPS = 0x3;
public int opCode;
public final List<String> stringList;

View File

@ -51,13 +51,13 @@ public class EAGMinecraftServer extends MinecraftServer {
this.getLogAgent().func_98236_b("Time ran backwards! Did the fucking system time change?");
delta = 0L;
}
if (this.worldServers[0].areAllPlayersAsleep()) {
this.tick();
lastTick = System.currentTimeMillis();
} else {
boolean mustYield = false;
while (delta > 50L) {
while (delta >= 50L) {
if(mustYield) {
try {
Thread.sleep(1l); // allow some async

View File

@ -121,18 +121,9 @@ public class IntegratedServer {
cur = new ArrayList<PKT>(messageQueue);
messageQueue.clear();
}
long watchDog = System.currentTimeMillis();
Iterator<PKT> itr = cur.iterator();
int overflow = 0;
while(itr.hasNext()) {
PKT msg = itr.next();
if(System.currentTimeMillis() - watchDog > 150l && !msg.channel.equals("IPC")) {
++overflow;
continue;
}
if(msg.channel.equals("IPC")) {
IPCPacketBase packet;
@ -492,13 +483,25 @@ public class IntegratedServer {
}
continue;
}else if(msg.channel.startsWith("NET|")) {
}
}
long watchDog = System.currentTimeMillis();
itr = cur.iterator();
int overflow = 0;
while(itr.hasNext()) {
PKT msg = itr.next();
if(!msg.channel.equals("IPC")) {
if(System.currentTimeMillis() - watchDog > 500l) {
++overflow;
continue;
}
if(!msg.channel.startsWith("NET|") || currentProcess == null) {
System.err.println("Unknown ICP channel: '" + msg.channel + "' passed " + msg.data.length + " bytes");
continue;
}
String u = msg.channel.substring(4);
currentProcess.getNetworkThread().recievePacket(u, msg.data);
continue;
}
System.err.println("Unknown IPC channel: " + msg.channel);
}
if(overflow > 0) {
System.err.println("Async ICP queue is overloaded, server dropped " + overflow + " player packets");

View File

@ -10,11 +10,13 @@ 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.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.ChunkCoordinates;
import net.minecraft.src.CommandBase;
import net.minecraft.src.DispenserBehaviors;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EntityPlayerMP;
import net.minecraft.src.EnumGameType;
import net.minecraft.src.ICommandManager;
import net.minecraft.src.ICommandSender;
@ -122,6 +124,10 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
protected boolean startProfiling;
protected boolean field_104057_T = false;
private int tpsCounter = 0;
private int tpsMeasure = 0;
private long tpsTimer = 0l;
public MinecraftServer(String folder) {
mcServer = this;
this.folderName = folder;
@ -441,6 +447,53 @@ public abstract class MinecraftServer implements ICommandSender, Runnable {
this.lastReceivedSize = Packet.receivedSize;
this.theProfiler.endSection();
this.theProfiler.endSection();
++tpsCounter;
long millis = System.currentTimeMillis();
if(millis - tpsTimer >= 1000l) {
tpsTimer = millis;
tpsMeasure = tpsCounter;
IntegratedServer.sendIPCPacket(new IPCPacket14StringList(IPCPacket14StringList.SERVER_TPS, getTPSAndChunkBuffer()));
tpsCounter = 0;
}
}
public List<String> getTPSAndChunkBuffer() {
ArrayList<String> strs = new ArrayList();
strs.add("Ticks/Second: " + tpsCounter + "/20");
int c = 0;
int oc = 0;
int e = 0;
int te = 0;
int r = 0;
int w = 0;
int g = 0;
int tu = 0;
int lu = 0;
for(int i = 0; i < worldServers.length; ++i) {
c += worldServers[i].getChunkProvider().getLoadedChunkCount();
e += worldServers[i].loadedEntityList.size();
te += worldServers[i].loadedTileEntityList.size();
r += worldServers[i].getR();
w += worldServers[i].getW();
g += worldServers[i].getG();
lu += worldServers[i].getLU();
tu += worldServers[i].getTU();
}
for(EntityPlayerMP p : (List<EntityPlayerMP>)this.playersOnline) {
oc += p.loadedChunks.size();
}
strs.add("Chunks: " + c + "/" + (c + oc));
strs.add("Entities: " + e + "+" + te);
strs.add("R: " + r + ", G: " + g + ", W: " + w);
strs.add("TU: " + tu + " LU: " + lu);
int pp = this.playersOnline.size();
if(pp > 1) {
strs.add("Players: " + pp);
}
return strs;
}
public void updateTimeLightAndEntities() {

View File

@ -1,8 +1,5 @@
package net.minecraft.src;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ChatAllowedCharacters {
/**
* This String have the characters allowed in any text drawing of minecraft.
@ -21,25 +18,10 @@ public class ChatAllowedCharacters {
* the characters that minecraft can render Strings on screen.
*/
private static String getAllowedCharacters() {
String var0 = "";
try {
BufferedReader var1 = new BufferedReader(
new InputStreamReader(ChatAllowedCharacters.class.getResourceAsStream("/font.txt"), "UTF-8"));
String var2 = "";
while ((var2 = var1.readLine()) != null) {
if (!var2.startsWith("#")) {
var0 = var0 + var2;
}
}
var1.close();
} catch (Exception var3) {
;
}
return var0;
return "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'abcdefghijklmnopqrstuvwxyz{|}~\u2302" +
"\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5" +
"\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192" +
"\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb";
}
public static final boolean isAllowedCharacter(char par0) {

View File

@ -259,7 +259,7 @@ public class Chunk {
/**
* Runs delayed skylight updates.
*/
private void updateSkylight_do() {
private boolean updateSkylight_do() {
this.worldObj.theProfiler.startSection("recheckGaps");
if (this.worldObj.doChunksNearChunkExist(this.xPosition * 16 + 8, 0, this.zPosition * 16 + 8, 16)) {
@ -300,6 +300,8 @@ public class Chunk {
}
this.worldObj.theProfiler.endSection();
return !this.isGapLightingUpdated;
}
/**
@ -325,6 +327,8 @@ public class Chunk {
this.isModified = true;
}
}
public static int totalBlockLightUpdates = 0;
/**
* Initiates the recalculation of both the block-light and sky-light for a given
@ -419,7 +423,9 @@ public class Chunk {
this.updateSkylightNeighborHeight(var6, var7 + 1, var12, var13);
this.updateSkylightNeighborHeight(var6, var7, var12, var13);
}
++totalBlockLightUpdates;
this.isModified = true;
}
}
@ -991,10 +997,11 @@ public class Chunk {
/**
* Checks whether skylight needs updated; if it does, calls updateSkylight_do
*/
public void updateSkylight() {
public boolean updateSkylight() {
if (this.isGapLightingUpdated && !this.worldObj.provider.hasNoSky) {
this.updateSkylight_do();
return this.updateSkylight_do();
}
return false;
}
/**

View File

@ -47,6 +47,7 @@ public class ChunkProviderServer implements IChunkProvider {
}
public void dropChunk(int par1, int par2) {
/*
if (this.worldObj.provider.canRespawnHere()) {
ChunkCoordinates var3 = this.worldObj.getSpawnPoint();
int var4 = par1 * 16 + 8 - var3.posX;
@ -57,8 +58,9 @@ public class ChunkProviderServer implements IChunkProvider {
this.droppedChunksSet.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(par1, par2)));
}
} else {
*/
this.droppedChunksSet.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(par1, par2)));
}
//}
}
/**
@ -88,8 +90,11 @@ public class ChunkProviderServer implements IChunkProvider {
if (this.serverChunkGenerator == null) {
var5 = this.dummyChunk;
} else {
++_g;
var5 = this.serverChunkGenerator.provideChunk(par1, par2);
}
}else {
++_r;
}
this.id2ChunkMap.add(var3, var5);
@ -151,6 +156,7 @@ public class ChunkProviderServer implements IChunkProvider {
private void saveChunkData(Chunk par1Chunk) {
if (this.chunkLoader != null) {
++_w;
try {
par1Chunk.lastSaveTime = this.worldObj.getTotalWorldTime();
this.chunkLoader.saveChunk(this.worldObj, par1Chunk);
@ -211,6 +217,8 @@ public class ChunkProviderServer implements IChunkProvider {
this.chunkLoader.saveExtraData();
}
}
private long fixTheFuckingMemoryLeak = 0l;
/**
* Unloads chunks that are marked to be unloaded. This is not guaranteed to
@ -218,6 +226,20 @@ public class ChunkProviderServer implements IChunkProvider {
*/
public boolean unloadQueuedChunks() {
if (!this.worldObj.levelSaving) {
long millis = System.currentTimeMillis();
if(millis - fixTheFuckingMemoryLeak > 10000l) { // FUCK OFF SUCK MY FUCKING COCK
fixTheFuckingMemoryLeak = millis;
this.id2ChunkMap.iterate((l,o) -> {
Chunk id = (Chunk) o;
PlayerInstance ii = this.worldObj.getPlayerManager().getPlayerInstance(id.xPosition, id.zPosition, false);
if((ii == null || ii.isEmpty()) && !droppedChunksSet.contains(l)) {
this.droppedChunksSet.add(l);
//System.out.println("Leaked: " + id);
}
});
}
for (int var1 = 0; var1 < 100; ++var1) {
if (!this.droppedChunksSet.isEmpty()) {
Long var2 = (Long) this.droppedChunksSet.iterator().next();
@ -225,9 +247,11 @@ public class ChunkProviderServer implements IChunkProvider {
var3.onChunkUnload();
this.saveChunkData(var3);
this.saveChunkExtraData(var3);
this.worldObj.getPlayerManager().freePlayerInstance(var2);
this.droppedChunksSet.remove(var2);
this.id2ChunkMap.remove(var2.longValue());
this.loadedChunks.remove(var3);
//System.out.println("" + this.droppedChunksSet.size() + ", " + this.id2ChunkMap.getNumHashElements());
}
}
@ -275,4 +299,26 @@ public class ChunkProviderServer implements IChunkProvider {
public void recreateStructures(int par1, int par2) {
}
private int _r = 0;
private int _w = 0;
private int _g = 0;
public int statR() {
int r = _r;
_r = 0;
return r;
}
public int statW() {
int w = _w;
_w = 0;
return w;
}
public int statG() {
int g = _g;
_g = 0;
return g;
}
}

View File

@ -54,8 +54,9 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
private int ticksOfInvuln = 60;
/** must be between 3>x>15 (strictly between) */
private int renderDistance = 0;
private int chatVisibility = 0;
public int renderDistance = 0;
public int lastRenderDistance = 0;
public int chatVisibility = 0;
private boolean chatColours = true;
/**
@ -81,7 +82,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
super(par2World);
par4ItemInWorldManager.thisPlayerMP = this;
this.theItemInWorldManager = par4ItemInWorldManager;
this.renderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
this.renderDistance = this.lastRenderDistance = par1MinecraftServer.getConfigurationManager().getViewDistance();
ChunkCoordinates var5 = par2World.getSpawnPoint();
int var6 = var5.posX;
int var7 = var5.posZ;
@ -180,7 +181,7 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
Iterator var7 = this.loadedChunks.iterator();
ArrayList var8 = new ArrayList();
while (var7.hasNext() && var6.size() < 5) {
while (var7.hasNext() && var6.size() < this.renderDistance / 2) {
ChunkCoordIntPair var9 = (ChunkCoordIntPair) var7.next();
var7.remove();
@ -806,11 +807,18 @@ public class EntityPlayerMP extends EntityPlayer implements ICrafting {
//if (this.translator.getLanguageList().containsKey(par1Packet204ClientInfo.getLanguage())) {
// this.translator.setLanguage(par1Packet204ClientInfo.getLanguage(), false);
//}
int var2 = 256 >> par1Packet204ClientInfo.getRenderDistance();
int var2 = 64 << 3 - par1Packet204ClientInfo.getRenderDistance();
if(var2 > 400) {
var2 = 400;
}
var2 = (var2 >> 5) + 2;
if (var2 > 3 && var2 < 15) {
this.renderDistance = var2;
if(this.lastRenderDistance != this.renderDistance) {
((WorldServer)this.worldObj).getPlayerManager().cycleRenderDistance(this);
}
}
this.chatVisibility = par1Packet204ClientInfo.getChatVisibility();

View File

@ -1,5 +1,7 @@
package net.minecraft.src;
import java.util.function.BiConsumer;
public class LongHashMap {
/** the array of all elements in the hash */
private transient LongHashMapEntry[] hashArray = new LongHashMapEntry[16];
@ -179,6 +181,19 @@ public class LongHashMap {
return var6;
}
public void iterate(BiConsumer<Long, Object> con) {
for(int i = 0; i < this.hashArray.length; ++i) {
LongHashMapEntry var5 = this.hashArray[i];
LongHashMapEntry var6;
LongHashMapEntry var7;
for (var6 = var5; var6 != null; var6 = var7) {
var7 = var6.nextEntry;
con.accept(var6.key, var6.value);
}
}
}
/**
* creates the key in the hash table

View File

@ -40,6 +40,14 @@ class PlayerInstance {
par1EntityPlayerMP.loadedChunks.add(this.currentChunk);
}
}
public boolean hasPlayer(EntityPlayerMP player) {
return this.players.contains(player);
}
public boolean isEmpty() {
return this.players.size() <= 0;
}
/**
* remove player from this instance
@ -53,8 +61,8 @@ class PlayerInstance {
par1EntityPlayerMP.loadedChunks.remove(this.currentChunk);
if (this.players.isEmpty()) {
long var2 = (long) this.currentChunk.chunkXPos + 2147483647L
| (long) this.currentChunk.chunkZPos + 2147483647L << 32;
long var2 = ((long) this.currentChunk.chunkXPos + 2147483647L)
| (((long) this.currentChunk.chunkZPos + 2147483647L) << 32);
PlayerManager.getChunkWatchers(this.thePlayerManager).remove(var2);
if (this.numBlocksToUpdate > 0) {

View File

@ -2,6 +2,7 @@ package net.minecraft.src;
import java.util.ArrayList;
import java.util.List;
import java.util.UnknownFormatConversionException;
public class PlayerManager {
private final WorldServer theWorldServer;
@ -15,12 +16,6 @@ public class PlayerManager {
/** the playerInstances(chunks) that need to be updated */
private final List playerInstancesToUpdate = new ArrayList();
/**
* Number of chunks the server sends to the client. Valid 3<=x<=15. In
* server.properties.
*/
private final int playerViewRadius;
/** x, z direction vectors: east, south, west, north */
private final int[][] xzDirectionsConst = new int[][] { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
@ -30,7 +25,7 @@ public class PlayerManager {
} else if (par2 < 3) {
throw new IllegalArgumentException("Too small view radius!");
} else {
this.playerViewRadius = par2;
//this.playerViewRadius = par2;
this.theWorldServer = par1WorldServer;
}
}
@ -65,8 +60,8 @@ public class PlayerManager {
* passi n the chunk x and y and a flag as to whether or not the instance should
* be made if it doesnt exist
*/
private PlayerInstance getPlayerInstance(int par1, int par2, boolean par3) {
long var4 = (long) par1 + 2147483647L | (long) par2 + 2147483647L << 32;
public PlayerInstance getPlayerInstance(int par1, int par2, boolean par3) {
long var4 = ((long) par1 + 2147483647L) | (((long) par2 + 2147483647L) << 32);
PlayerInstance var6 = (PlayerInstance) this.playerInstances.getValueByKey(var4);
if (var6 == null && par3) {
@ -76,6 +71,11 @@ public class PlayerManager {
return var6;
}
public void freePlayerInstance(long l) {
this.playerInstances.remove(l);
this.playerInstancesToUpdate.remove(l);
}
public void markBlockNeedsUpdate(int par1, int par2, int par3) {
int var4 = par1 >> 4;
@ -86,6 +86,12 @@ public class PlayerManager {
var6.markBlockNeedsUpdate(par1 & 15, par2, par3 & 15);
}
}
public void cycleRenderDistance(EntityPlayerMP player) {
//System.out.println("" + player.lastRenderDistance + " => " + player.renderDistance);
removePlayer(player);
addPlayer(player);
}
/**
* Adds an EntityPlayerMP to the PlayerManager.
@ -95,9 +101,10 @@ public class PlayerManager {
int var3 = (int) par1EntityPlayerMP.posZ >> 4;
par1EntityPlayerMP.managedPosX = par1EntityPlayerMP.posX;
par1EntityPlayerMP.managedPosZ = par1EntityPlayerMP.posZ;
for (int var4 = var2 - this.playerViewRadius; var4 <= var2 + this.playerViewRadius; ++var4) {
for (int var5 = var3 - this.playerViewRadius; var5 <= var3 + this.playerViewRadius; ++var5) {
int rd = par1EntityPlayerMP.lastRenderDistance = par1EntityPlayerMP.renderDistance;
for (int var4 = var2 - rd; var4 <= var2 + rd; ++var4) {
for (int var5 = var3 - rd; var5 <= var3 + rd; ++var5) {
this.getPlayerInstance(var4, var5, true).addPlayer(par1EntityPlayerMP);
}
}
@ -111,9 +118,12 @@ public class PlayerManager {
* viewing range of the player.
*/
public void filterChunkLoadQueue(EntityPlayerMP par1EntityPlayerMP) {
if(par1EntityPlayerMP.lastRenderDistance != par1EntityPlayerMP.renderDistance) {
cycleRenderDistance(par1EntityPlayerMP);
}
ArrayList var2 = new ArrayList(par1EntityPlayerMP.loadedChunks);
int var3 = 0;
int var4 = this.playerViewRadius;
int var4 = par1EntityPlayerMP.renderDistance;
int var5 = (int) par1EntityPlayerMP.posX >> 4;
int var6 = (int) par1EntityPlayerMP.posZ >> 4;
int var7 = 0;
@ -162,9 +172,10 @@ public class PlayerManager {
public void removePlayer(EntityPlayerMP par1EntityPlayerMP) {
int var2 = (int) par1EntityPlayerMP.managedPosX >> 4;
int var3 = (int) par1EntityPlayerMP.managedPosZ >> 4;
for (int var4 = var2 - this.playerViewRadius; var4 <= var2 + this.playerViewRadius; ++var4) {
for (int var5 = var3 - this.playerViewRadius; var5 <= var3 + this.playerViewRadius; ++var5) {
int rd = par1EntityPlayerMP.lastRenderDistance;
for (int var4 = var2 - rd; var4 <= var2 + rd; ++var4) {
for (int var5 = var3 - rd; var5 <= var3 + rd; ++var5) {
PlayerInstance var6 = this.getPlayerInstance(var4, var5, false);
if (var6 != null) {
@ -172,6 +183,7 @@ public class PlayerManager {
}
}
}
par1EntityPlayerMP.lastRenderDistance = par1EntityPlayerMP.renderDistance;
this.players.remove(par1EntityPlayerMP);
}
@ -185,7 +197,10 @@ public class PlayerManager {
/**
* update chunks around a player being moved by server logic (e.g. cart, boat)
*/
public void updateMountedMovingPlayer(EntityPlayerMP par1EntityPlayerMP) {
public void updateMountedMovingPlayer(final EntityPlayerMP par1EntityPlayerMP) {
if(par1EntityPlayerMP.renderDistance != par1EntityPlayerMP.lastRenderDistance) {
cycleRenderDistance(par1EntityPlayerMP);
}
int var2 = (int) par1EntityPlayerMP.posX >> 4;
int var3 = (int) par1EntityPlayerMP.posZ >> 4;
double var4 = par1EntityPlayerMP.managedPosX - par1EntityPlayerMP.posX;
@ -195,7 +210,7 @@ public class PlayerManager {
if (var8 >= 64.0D) {
int var10 = (int) par1EntityPlayerMP.managedPosX >> 4;
int var11 = (int) par1EntityPlayerMP.managedPosZ >> 4;
int var12 = this.playerViewRadius;
int var12 = par1EntityPlayerMP.renderDistance;
int var13 = var2 - var10;
int var14 = var3 - var11;

View File

@ -28,6 +28,20 @@ public class WorldServer extends World {
private int updateEntityTick = 0;
private final Teleporter field_85177_Q;
private int r = 0;
private int w = 0;
private int g = 0;
private int tu = 0;
private int lu = 0;
private int _r = 0;
private int _w = 0;
private int _g = 0;
private int _tu = 0;
private int _lu = 0;
private long rwgtuluTimer = 0l;
/**
* Double buffer of ServerBlockEventList[] for holding pending BlockEventData's
*/
@ -145,6 +159,43 @@ public class WorldServer extends World {
this.field_85177_Q.removeStalePortalLocations(this.getTotalWorldTime());
this.theProfiler.endSection();
this.sendAndApplyBlockEvents();
_r += this.theChunkProviderServer.statR();
_w += this.theChunkProviderServer.statW();
_g += this.theChunkProviderServer.statG();
_lu += Chunk.totalBlockLightUpdates;
Chunk.totalBlockLightUpdates = 0;
long millis = System.currentTimeMillis();
if(millis - rwgtuluTimer >= 1000l) {
rwgtuluTimer = millis;
r = _r; _r = 0;
w = _w; _w = 0;
g = _g; _g = 0;
tu = _tu; _tu = 0;
lu = _lu; _lu = 0;
}
}
public int getR() {
return r;
}
public int getW() {
return w;
}
public int getG() {
return g;
}
public int getTU() {
return tu;
}
public int getLU() {
return lu;
}
/**
@ -232,7 +283,9 @@ public class WorldServer extends World {
Chunk var7 = this.getChunkFromChunkCoords(var4.chunkXPos, var4.chunkZPos);
this.moodSoundAndLightCheck(var5, var6, var7);
this.theProfiler.endStartSection("tickChunk");
var7.updateSkylight();
if(var7.updateSkylight()) {
++_lu;
}
this.theProfiler.endStartSection("thunder");
int var8;
int var9;
@ -303,6 +356,7 @@ public class WorldServer extends World {
if (var18 != null && var18.getTickRandomly()) {
++var1;
var18.updateTick(this, var14 + var5, var16 + var20.getYLocation(), var15 + var6, this.rand);
++_tu;
}
}
}
@ -340,6 +394,7 @@ public class WorldServer extends World {
if (var9 == var7.blockID && var9 > 0) {
Block.blocksList[var9].updateTick(this, var7.xCoord, var7.yCoord, var7.zCoord, this.rand);
++_tu;
}
}
@ -445,6 +500,7 @@ public class WorldServer extends World {
if (var6 > 0 && Block.isAssociatedBlockID(var6, var4.blockID)) {
Block.blocksList[var6].updateTick(this, var4.xCoord, var4.yCoord, var4.zCoord, this.rand);
++_tu;
}
} else {
this.scheduleBlockUpdate(var4.xCoord, var4.yCoord, var4.zCoord, var4.blockID, 0);

View File

@ -26,6 +26,15 @@ public class IntegratedServer {
private static String[] loadLocale = null;
private static String[] loadStats = null;
private static boolean isPaused = false;
private static List<String> integratedServerTPS = new LinkedList();
public static List<String> getTPS() {
return integratedServerTPS;
}
public static void clearTPS() {
integratedServerTPS.clear();
}
public static void begin() {
if(!isWorkerAlive()) {
@ -42,6 +51,7 @@ public class IntegratedServer {
isPaused = false;
loadLocale = locale;
loadStats = stats;
clearTPS();
EaglerAdapter.beginLoadingIntegratedServer();
}
}
@ -78,6 +88,7 @@ public class IntegratedServer {
public static void loadWorld(String name, int difficulty, WorldSettings gen) {
ensureReady();
clearTPS();
statusState = IntegratedState.WORLD_LOADING;
isPaused = false;
@ -305,6 +316,11 @@ public class IntegratedServer {
case IPCPacket14StringList.ID: {
IPCPacket14StringList pkt = (IPCPacket14StringList)packet;
if(pkt.opCode == IPCPacket14StringList.SERVER_TPS) {
integratedServerTPS.clear();
integratedServerTPS.addAll(pkt.stringList);
}
// file path list for file browser
break;

View File

@ -178,6 +178,10 @@ public class Minecraft implements Runnable {
private void startTimerHackThread() {
}
public boolean isSingleplayerOrLAN() {
return IntegratedServer.isWorldRunning();
}
public void setServer(String par1Str, int par2) {
this.serverName = par1Str;
@ -1502,7 +1506,7 @@ public class Minecraft implements Runnable {
if (this.texturePackList.getIsDownloading()) {
this.texturePackList.onDownloadFinished();
}
IntegratedServer.unloadWorld();
this.setServerData((ServerData) null);
this.integratedServerIsRunning = false;
}

View File

@ -246,6 +246,9 @@ public class GameSettings {
if (par1EnumOptions == EnumOptions.RENDER_DISTANCE) {
this.renderDistance = this.renderDistance + par2 & 3;
if(this.mc.isSingleplayerOrLAN()) {
Minecraft.getMinecraft().displayEaglercraftText("changing render distance in singleplayer may take a few seconds, this is not a glitch plz don't report");
}
}
if (par1EnumOptions == EnumOptions.GUI_SCALE) {

View File

@ -7,6 +7,7 @@ import java.util.List;
import net.minecraft.client.Minecraft;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.EaglercraftRandom;
import net.lax1dude.eaglercraft.IntegratedServer;
import net.lax1dude.eaglercraft.TextureLocation;
import net.lax1dude.eaglercraft.adapter.Tessellator;
import net.lax1dude.eaglercraft.glemu.EffectPipeline;
@ -416,6 +417,14 @@ public class GuiIngame extends Gui {
var24 = MathHelper.floor_double((double) (this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
this.drawString(var8, "f: " + var24 + " (" + Direction.directions[var24] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 88, 14737632);
if(IntegratedServer.isWorldRunning()) {
this.drawString(var8, "IntegratedServer is running", 2, 106, 14737632);
List<String> info = IntegratedServer.getTPS();
for(int i = 0, size = info.size(); i < size; ++i) {
this.drawString(var8, info.get(i), 2, 122 + i * 8, 14737632);
}
}
//this.drawString(var8, String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", new Object[] { Float.valueOf(this.mc.thePlayer.capabilities.getWalkSpeed()), Float.valueOf(this.mc.thePlayer.capabilities.getFlySpeed()),
// Boolean.valueOf(this.mc.thePlayer.onGround), Integer.valueOf(this.mc.theWorld.getHeightValue(var47, var23)) }), 2, 104, 14737632);
var45 = "opengl emulator status - v1.0";
@ -445,6 +454,14 @@ public class GuiIngame extends Gui {
EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
var8.drawStringWithShadow(this.mc.renderGlobal.getDebugInfoShort(), 2, 2, 16777215);
var8.drawStringWithShadow("x: "+MathHelper.floor_double(this.mc.thePlayer.posX)+", y: "+MathHelper.floor_double(this.mc.thePlayer.posY)+", z: "+MathHelper.floor_double(this.mc.thePlayer.posZ), 2, 12, 16777215);
if(IntegratedServer.isWorldRunning()) {
String strr = "Playing Singleplayer";
var8.drawStringWithShadow(strr, (int)(var6 / 0.75f) - var8.getStringWidth(strr) - 2, 2, 0xFFFFAA);
List<String> info = IntegratedServer.getTPS();
for(int i = 0, size = info.size(); i < size; ++i) {
var8.drawStringWithShadow(info.get(i), (int)(var6 / 0.75f) - var8.getStringWidth(info.get(i)) - 2, 12 + i * 10, 14737632);
}
}
EaglerAdapter.glPopMatrix();
}