Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .tps command #979

Closed
4 tasks done
ZXMushroom63 opened this issue Apr 8, 2024 · 2 comments
Closed
4 tasks done

Add .tps command #979

ZXMushroom63 opened this issue Apr 8, 2024 · 2 comments
Labels
status:stale status:unconfirmed New issue. Needs triage. type:enhancement New feature or request

Comments

@ZXMushroom63
Copy link

ZXMushroom63 commented Apr 8, 2024

Pre-suggestion checklist

  • I have searched existing issues and didn't find any previous issues with the same suggestion.
    I did find one oither issue with the same suggestion, but it was closed as stale, and didn't have much detail on how the feature would be implemented
  • This is only one suggestion. I understand that GitHub issues don't work well with lists.
  • This feature doesn't already exist in the latest version of Wurst. I've made sure my installation is up to date.
  • I have looked at the code and am reasonably confident that this suggestion is possible to implement.

What type of improvement are you suggesting?

Adding a new chat command.

What type of player would find this improvement useful?

Griefers, PVPers

Description

The improvement would be a chat command that when run would output the estimated server tps. It does this by calculating the delay between PacketTimeUpdates. This is useful because you can get a profile of how laggy the server is, which is useful when testing lag machines.

Here is a sample implementation (not build in wurst codebase):

import java.util.Timer;
import java.util.TimerTask;

import net.minecraft.hacks.HackClient;
import net.minecraft.hacks.module.Category;
import net.minecraft.hacks.module.Module;
import net.minecraft.network.play.server.S03PacketTimeUpdate;

public class TPS extends Module {
    private double lastTime;
    private double lastAge = -1d;
    public double currentTps = 0;

    public TPS() {
        super("TPS", -1, Category.NONE);
    }

    @Override
    public void onEventCommand(String command, String[] args) {
        if (command.equalsIgnoreCase("tps")) {
            displayToChat("Current server TPS is ~" + currentTps);
        }
    }

    @Override
    public void onTimeUpdatePacket(S03PacketTimeUpdate packet) {
        double age = packet.getTotalWorldTime();
        double time = System.currentTimeMillis();

        if (lastAge == -1L) {
            lastTime = time;
            lastAge = age;
            return;
        }

        double diffAge = age - lastAge;
        double diffTime = time - lastTime;

        lastAge = age;
        lastTime = time;

        double tps = diffAge / (diffTime / 1000.0);
        currentTps = Math.round(tps * 100) / 100.0;
    }
}
@ZXMushroom63 ZXMushroom63 added status:unconfirmed New issue. Needs triage. type:enhancement New feature or request labels Apr 8, 2024
@Cyclopropinon
Copy link

a small window would be also nice (like in the style of radar)
it could display the current tps and mspt, also the time since the last packet received
Maybe also add carpet-support to get server-side much more accurate data if the server has it installed

Copy link

This issue has been open for a while with no recent activity. If this issue is still important to you, please add a comment within the next 7 days to keep it open. Otherwise, the issue will be automatically closed to free up time for other tasks.

Issues should be closed if:

  • They are duplicates of other issues
  • There is not enough demand
  • They are no longer relevant
  • There are not enough details

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:stale status:unconfirmed New issue. Needs triage. type:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants