master
mckuhei 2 years ago
parent b378ab2ca4
commit 1b646ee787

@ -9,6 +9,9 @@ import java.awt.Frame;
import java.awt.Graphics;
import java.io.File;
import java.io.IOException;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import org.mcmodule.math.BigInteger;
import java.nio.ByteBuffer;
import java.text.DecimalFormat;
@ -272,6 +275,7 @@ public abstract class Minecraft implements Runnable, IPlayerUsage
/** holds the current fps */
int fpsCounter = 0;
long prevFrameTime = -1L;
private long lastUpdateGCCollectedObjects, lastUpdateGCUsedTime;
public Minecraft(Canvas par1Canvas, MinecraftApplet par2MinecraftApplet, int par3, int par4, boolean par5)
{
@ -866,6 +870,8 @@ public abstract class Minecraft implements Runnable, IPlayerUsage
this.toggleFullscreen();
}
if (this.gameSettings.showDebugInfo && this.gameSettings.field_74329_Q)
{
if (!this.mcProfiler.profilingEnabled)
@ -890,6 +896,18 @@ public abstract class Minecraft implements Runnable, IPlayerUsage
this.guiAchievement.updateAchievementWindow();
this.mcProfiler.startSection("root");
long gcUsedTime = 0;
for(GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
long time = gc.getCollectionTime();
if(time > 0) gcUsedTime += time;
}
long time = gcUsedTime - lastUpdateGCUsedTime;
if(gcUsedTime > 0) {
this.mcProfiler.startSection("gc");
this.mcProfiler.endSectionWithTime(time * 1000000);
}
lastUpdateGCUsedTime = gcUsedTime;
Thread.yield();
if (Keyboard.isKeyDown(65))
@ -929,9 +947,16 @@ public abstract class Minecraft implements Runnable, IPlayerUsage
while (getSystemTime() >= this.debugUpdateTime + 1000L)
{
long gcCollectedObjects = 0;
for(GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
long count = gc.getCollectionCount();
if(count > 0) gcCollectedObjects += count;
}
long collectedObjects = gcCollectedObjects - lastUpdateGCCollectedObjects;
lastUpdateGCCollectedObjects = gcCollectedObjects;
field_71470_ab = this.fpsCounter;
this.debug = field_71470_ab + " fps, " + WorldRenderer.chunksUpdated + " chunk updates";
this.extraDebug = String.format("BC: %d, BR: %d", BigInteger.getAndClearCreateCounter(), BigInteger.getAndClearFreeCounter());
this.extraDebug = String.format("BC: %d, OR: %d", BigInteger.getAndClearCreateCounter(), collectedObjects);
WorldRenderer.chunksUpdated = 0;
this.debugUpdateTime += 1000L;
this.fpsCounter = 0;

@ -937,7 +937,7 @@ public class EntityRenderer
this.mc.mcProfiler.endStartSection("pick");
this.getMouseOver(par1);
EntityLiving var4 = this.mc.renderViewEntity;
EntityPlayer var4 = (EntityPlayer) this.mc.renderViewEntity;
RenderGlobal var5 = this.mc.renderGlobal;
EffectRenderer var6 = this.mc.effectRenderer;
double var7 = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par1;

@ -430,7 +430,7 @@ public class GuiIngame extends Gui
}
this.drawString(var8, String.format("ws: %.3f, fs: %.3f, g: %b", new Object[] {Float.valueOf(this.mc.thePlayer.capabilities.getWalkSpeed()), Float.valueOf(this.mc.thePlayer.capabilities.getFlySpeed()), Boolean.valueOf(this.mc.thePlayer.onGround)}), 2, 104, 14737632);
int maxBit = mc.thePlayer.posXBig.max(mc.thePlayer.posZBig).toBigInteger().bitLength();
int maxBit = mc.thePlayer.posXBig.abs().max(mc.thePlayer.posZBig.abs()).toBigInteger().bitLength();
double doublePrecision = Math.pow(2, (maxBit - 53)),
floatPrecision = Math.pow(2, (maxBit - 24));

@ -1,6 +1,8 @@
package net.minecraft.src;
import java.math.BigDecimal;
import java.math.RoundingMode;
import org.mcmodule.math.BigInteger;
import java.util.Random;
@ -76,6 +78,10 @@ public class MathHelper
return new BigInteger(String.format("%.0f", Math.floor(normalize(val))));
}
public static BigInteger floor_double_BigInteger(BigDecimal val) {
return new BigInteger(val.setScale(0, RoundingMode.FLOOR).toBigInteger().toByteArray());
}
public static BigInteger toBigInteger(double val) {
val = normalize(val);
val = val < 0 ? Math.floor(val) + 1 : Math.floor(val);

@ -66,6 +66,20 @@ public class Profiler
this.sectionList.remove(this.sectionList.size() - 1);
long var5 = var1 - var3;
endSection(var5);
}
}
public void endSectionWithTime(long time) {
if (this.profilingEnabled)
{
this.timestampList.remove(this.timestampList.size() - 1);
this.sectionList.remove(this.sectionList.size() - 1);
endSection(time);
}
}
private void endSection(long var5) {
if (this.profilingMap.containsKey(this.profilingSection))
{
this.profilingMap.put(this.profilingSection, Long.valueOf(((Long)this.profilingMap.get(this.profilingSection)).longValue() + var5));
@ -82,7 +96,6 @@ public class Profiler
this.profilingSection = !this.sectionList.isEmpty() ? (String)this.sectionList.get(this.sectionList.size() - 1) : "";
}
}
/**
* Get profiling data

@ -564,7 +564,7 @@ public class RenderGlobal implements IWorldAccess
/**
* Sorts all renderers based on the passed in entity. Args: entityLiving, renderPass, partialTickTime
*/
public int sortAndRender(EntityLiving par1EntityLiving, int par2, double par3)
public int sortAndRender(EntityPlayer par1EntityLiving, int par2, double par3)
{
this.theWorld.theProfiler.startSection("sortchunks");
@ -606,7 +606,7 @@ public class RenderGlobal implements IWorldAccess
this.prevSortX = par1EntityLiving.posX;
this.prevSortY = par1EntityLiving.posY;
this.prevSortZ = par1EntityLiving.posZ;
this.markRenderersForNewPosition(MathHelper.floor_double_BigInteger(par1EntityLiving.posX), MathHelper.floor_double(par1EntityLiving.posY), MathHelper.floor_double_BigInteger(par1EntityLiving.posZ));
this.markRenderersForNewPosition(MathHelper.floor_double_BigInteger(par1EntityLiving.posXBig), MathHelper.floor_double(par1EntityLiving.posY), MathHelper.floor_double_BigInteger(par1EntityLiving.posZBig));
Arrays.sort(this.sortedWorldRenderers, new EntitySorter(par1EntityLiving));
}
@ -817,7 +817,7 @@ public class RenderGlobal implements IWorldAccess
var18.func_78421_b();
}
WorldRenderer var22;
WorldRenderer var22 = null;
for (Iterator var21 = this.glRenderLists.iterator(); var21.hasNext(); this.allRenderLists[var17].func_78420_a(var22.getGLCallListForPass(par3)))
{

@ -1344,6 +1344,7 @@ public abstract class World implements IBlockAccess
public List getCollidingBoundingBoxes(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB)
{
this.collidingBoundingBoxes.clear();
if(Double.isInfinite(par2AxisAlignedBB.minX) || Double.isInfinite(par2AxisAlignedBB.maxX) || Double.isInfinite(par2AxisAlignedBB.minZ) || Double.isInfinite(par2AxisAlignedBB.maxZ)) return this.collidingBoundingBoxes;
BigInteger var3 = MathHelper.floor_double_BigInteger(par2AxisAlignedBB.minX);
BigInteger var4 = MathHelper.floor_double_BigInteger(par2AxisAlignedBB.maxX + 1.0D);
int var5 = MathHelper.floor_double(par2AxisAlignedBB.minY);

Loading…
Cancel
Save