Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 8db26f74b12cd7c115e3b49c40a953f15001cde5 Mon Sep 17 00:00:00 2001
- From: REDACTED
- Date: Fri, 1 Dec 2017 02:41:40 +0100
- Subject: [PATCH] Added tick/timetime display in the player list.
- ---
- .../net/minecraft/server/MinecraftServer.java | 34 ++++++++++++++++++++++
- 1 file changed, 34 insertions(+)
- diff --git a/src/minecraft_server/net/minecraft/server/MinecraftServer.java b/src/minecraft_server/net/minecraft/server/MinecraftServer.java
- index 8fefd31..023d2d5 100644
- --- a/src/minecraft_server/net/minecraft/server/MinecraftServer.java
- +++ b/src/minecraft_server/net/minecraft/server/MinecraftServer.java
- @@ -18,6 +18,7 @@ import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- +import java.lang.reflect.Field;
- import java.net.Proxy;
- import java.net.URLEncoder;
- import java.nio.charset.StandardCharsets;
- @@ -49,6 +50,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
- import net.minecraft.init.Bootstrap;
- import net.minecraft.network.NetworkSystem;
- import net.minecraft.network.ServerStatusResponse;
- +import net.minecraft.network.play.server.SPacketPlayerListHeaderFooter;
- import net.minecraft.network.play.server.SPacketTimeUpdate;
- import net.minecraft.profiler.ISnooperInfo;
- import net.minecraft.profiler.Profiler;
- @@ -67,6 +69,7 @@ import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.util.text.ITextComponent;
- import net.minecraft.util.text.TextComponentString;
- +import net.minecraft.util.text.TextFormatting;
- import net.minecraft.world.EnumDifficulty;
- import net.minecraft.world.GameType;
- import net.minecraft.world.MinecraftException;
- @@ -626,6 +629,37 @@ public abstract class MinecraftServer implements ICommandSender, Runnable, IThre
- this.saveAllWorlds(true);
- this.profiler.endSection();
- }
- +
- + //QC - fancy TPS display
- + if(this.tickCounter % 20 == 0)
- + {
- + this.profiler.startSection("qc_tps_display");
- + double MSPT = MathHelper.average(this.tickTimeArray) * 1.0E-6D;
- + double TPS = 1000.0D / Math.max(50.0D, MSPT);
- +
- + String tps_display = TextFormatting.GRAY + "TPS: " +
- + (TPS > 16.0D ? TextFormatting.YELLOW : TextFormatting.RED) +
- + String.format("%.1f", TPS) +
- + TextFormatting.GRAY + " MSPT: " +
- + (TPS > 16.0D ? TextFormatting.YELLOW : TextFormatting.RED) +
- + String.format("%.1f", MSPT);
- +
- + SPacketPlayerListHeaderFooter packet = new SPacketPlayerListHeaderFooter();
- + Field header = packet.getClass().getDeclaredFields()[0];
- + Field footer = packet.getClass().getDeclaredFields()[1];
- + header.setAccessible(true);
- + footer.setAccessible(true);
- + try {
- + header.set(packet, new TextComponentString(""));
- + footer.set(packet, new TextComponentString(tps_display));
- + } catch (IllegalArgumentException e) {
- + e.printStackTrace();
- + } catch (IllegalAccessException e) {
- + e.printStackTrace();
- + }
- + this.getPlayerList().sendPacketToAllPlayers(packet);
- + this.profiler.endSection();
- + }
- this.profiler.startSection("tallying");
- this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i;
- --
- 2.7.4.1.g5468f9e
Advertisement
Add Comment
Please, Sign In to add comment