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 a CPS variable to Meteor Starscript #4057

Merged
merged 3 commits into from
Sep 10, 2023
Merged

Add a CPS variable to Meteor Starscript #4057

merged 3 commits into from
Sep 10, 2023

Conversation

panpanpro888
Copy link
Contributor

Type of change

  • Bug fix
  • New feature

Description

Added a CPS variable to the Meteor Starscript that counts the player's clicks per second.

Related issues

None

How Has This Been Tested?

As just a Starscript variable, the only form of testing that i can do is open up the game and see if it counts correctly, which it does.

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.

@hexadecimal233
Copy link
Contributor

This can be done by a cps checker thread?

@MineGame159
Copy link
Member

This can be done by a cps checker thread?

Creating a new thread is absolutely not necessary and wasteful.

And to reply to the original PR. It looks like you forgot to commit some changes since I dont see a way for the cps to ever change. Also I have some things to change. It would be best to move this to a separate class, use our static initialization system (look at some other static class) and subscribe to the tick event (possible more events) there. Then there should be a method to get the average CPS instead of doing that manually where the CPS is needed and exposing implementation details. Another thing is that using a list of integer objects is very wasteful since Java doesnt have a proper support for generics, it would be better if you just have a normal int array with the size of 20 (since 20 ticks = one second) and just cycle through it.

@panpanpro888
Copy link
Contributor Author

Sorry for the late reply.
I will look into it and do the refactors you said. I will get to working on the commit right now.

@panpanpro888
Copy link
Contributor Author

Hi, I am working on it, and while transferring the events from the Minecraft Client Mixin to its own class with event handlers I am having trouble finding an event with the equivalent of the minecraft client's doAttack function to listen for when the player clicks. Is it okay to add a function to increment the cps directly into the mixin? Or if there is actually an event for that can you please tell it to me?

@MineGame159
Copy link
Member

There is an AttackEntityEvent but that will also count attacks made through modules like Kill Aura. If it shouldnt count those (which in my opinion it shouldnt) then its fine to just directly call the static method from the mixin.

@panpanpro888
Copy link
Contributor Author

I can't understand how to make an int array with the size of 20 since the original code had a new array element for every second and then got the average of those elements. Can you please help with this, by the way all the other things are finished.

@MineGame159
Copy link
Member

Ah well I couldnt really make out how the list was supposed to work since a) the cps was never incremented and b) the list was never cleared / removed from so it would just fill up your entire memory after a while.
Basically what I meant is that lets say you want the average of the last 5 seconds. Then you would create an array of size 5 and fill it up in circles (0, 1, 2, 3, 4 and then back to 0, etc). This is to not create a billion Integer objects and stress the GC.

@panpanpro888
Copy link
Contributor Author

I fixed the previous issues and instead of creating an array of integers, I made it store the total clicks and the seconds the players has been clicking. Already committed and pushed the fixes, code is ready.

@hexadecimal233
Copy link
Contributor

now cps will be affected by client tick rate?

@panpanpro888
Copy link
Contributor Author

The only thing done in the onTick event is checking if a second has passed. This was also done in the previous commit but directly from the minecraft client mixin.

Copy link
Member

@MineGame159 MineGame159 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise looks good.

));
}

public static void cpsChecker() {
Copy link
Member

@MineGame159 MineGame159 Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesnt need to be a method, and a public one at that. You can just move the body to the onTick handler.

CPSUtils.cps++;
}

public static Value getCpsAverage() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return an int in case something also wants to get the value.

@@ -72,7 +72,6 @@ public class Utils {
public static double frameTime;
public static Screen screenToOpen;
public static VertexSorter vertexSorter;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why. If you want to cleanup then move the 2 constants to the top of the file and with a new line to separate constants and static variables.

@panpanpro888
Copy link
Contributor Author

I added the requested changes, can you please review it again?

@MineGame159 MineGame159 merged commit e5b64cc into MeteorDevelopment:master Sep 10, 2023
RacoonDog added a commit to RacoonDog/meteor-client that referenced this pull request Sep 11, 2023
commit 52595d0
Author: RacoonDog <[email protected]>
Date:   Sun Sep 10 15:33:51 2023 -0400

    Fix ChatUtils formatting in log files (MeteorDevelopment#4061)

commit e5b64cc
Author: panpanpro888 <[email protected]>
Date:   Sun Sep 10 22:30:58 2023 +0300

    Add a CPS variable to Meteor Starscript (MeteorDevelopment#4057)

commit b1aa34f
Author: RacoonDog <[email protected]>
Date:   Sun Sep 10 15:25:38 2023 -0400

    Highlight antixrayheuristics in red in .server plugins command (MeteorDevelopment#4060)

commit dbf27d3
Author: The Raccoon <[email protected]>
Date:   Sat Sep 9 11:08:04 2023 -0500

    Improve MiddleClickExtra (MeteorDevelopment#4029)

commit d768fc8
Author: Wide-Cat <[email protected]>
Date:   Fri Sep 8 17:46:57 2023 +0100

    refactor

commit c8cf97a
Author: Wide-Cat <[email protected]>
Date:   Fri Sep 8 17:41:13 2023 +0100

    Fix xray with indium

commit 74deeea
Author: Wide-Cat <[email protected]>
Date:   Wed Sep 6 20:58:18 2023 +0100

    cleanup blockutils

commit 30bbdca
Author: zyktex <[email protected]>
Date:   Wed Sep 6 21:32:39 2023 +0200

    Fix NPE caused by ChatHudMixin

commit 14dd21b
Author: supakeks <[email protected]>
Date:   Wed Sep 6 14:21:16 2023 -0400

    Added rotations to Nuker and improved block breaking on strict servers.

commit 40dbfbd
Author: Mana <[email protected]>
Date:   Sun Sep 3 09:32:07 2023 +0800

    thing

commit 7d30a0e
Author: Mana <[email protected]>
Date:   Sun Sep 3 00:36:48 2023 +0800

    make yaw lock of bounce efly optional and fixed typo

commit 1505263
Author: Big Iron <[email protected]>
Date:   Sat Sep 2 22:24:20 2023 +0200

    Refactor AutoMount (MeteorDevelopment#4034)

commit 3af641e
Author: RacoonDog <[email protected]>
Date:   Sat Sep 2 16:19:14 2023 -0400

    improve anti afk (MeteorDevelopment#4033)

commit 7d4645a
Author: supakeks <[email protected]>
Date:   Sat Sep 2 10:05:58 2023 -0400

    Improved ElytraFly Recast mode (MeteorDevelopment#4010)

commit 0b32e28
Author: 19MisterX98 <[email protected]>
Date:   Tue Aug 29 20:15:46 2023 +0200

    Fix fastuse when item is in offhand (MeteorDevelopment#4019)

commit e066654
Author: 19MisterX98 <[email protected]>
Date:   Sun Aug 27 18:12:38 2023 +0200

    Fix Block ESP (MeteorDevelopment#4009)

commit ce32561
Author: The Raccoon <[email protected]>
Date:   Fri Aug 25 08:06:25 2023 -0500

    Add quickSwap() Action (MeteorDevelopment#3985)

commit cf6e9b4
Author: thebest9178 <[email protected]>
Date:   Thu Aug 24 18:26:01 2023 +0000

    Liquid filler fixes (MeteorDevelopment#3968)

commit 1f42816
Author: Cryo <[email protected]>
Date:   Thu Aug 24 14:09:31 2023 -0400

    Offhand Rewrite (MeteorDevelopment#3975)

commit c48e8d1
Author: Wide-Cat <[email protected]>
Date:   Tue Aug 22 18:13:15 2023 +0100

    Update AutoTool

commit 4bcaff4
Author: Mana <[email protected]>
Date:   Tue Aug 22 11:21:07 2023 +0800

    make pitch setting use a float instead of an int

commit 68ccada
Author: Cryo <[email protected]>
Date:   Tue Aug 22 05:22:30 2023 -0700

    Sprint Improvements (MeteorDevelopment#3976)

commit fb573b5
Author: supakeks <[email protected]>
Date:   Mon Aug 21 19:12:48 2023 -0400

    Add Recast mode to Elytra Fly (MeteorDevelopment#3980)

commit c178e97
Author: MineGame159 <[email protected]>
Date:   Mon Aug 21 21:39:35 2023 +0200

    Revert "Fix + improve launch method (MeteorDevelopment#3983)" - Don't use AWT

    This reverts commit d752b5b.

commit d752b5b
Author: Patrick <[email protected]>
Date:   Mon Aug 21 21:10:06 2023 +0200

    Fix + improve launch method (MeteorDevelopment#3983)

commit 9ffca3f
Author: Patrick <[email protected]>
Date:   Mon Aug 21 19:37:39 2023 +0200

    Fix Infinite Chat Box

commit 775939d
Author: Wide-Cat <[email protected]>
Date:   Mon Aug 21 17:35:39 2023 +0100

    add option to hand view to disable the eating animation

commit 1101e84
Author: DesiCow <[email protected]>
Date:   Sat Feb 4 21:41:59 2023 +0530

    Better Auto Eat threshold
    Select "health", "hunger", "any", "both" thresholds to trigger auto eat.

commit 7c00a9c
Author: DesiCow <[email protected]>
Date:   Mon Aug 21 00:41:40 2023 +0530

    AutoTool : Prefer Fortune for ores and crops option (MeteorDevelopment#3212)

commit b1643d7
Author: MineGame159 <[email protected]>
Date:   Wed Aug 16 00:18:52 2023 +0200

    Improve Future compatibility

commit 8cabb2a
Author: Wide-Cat <[email protected]>
Date:   Tue Aug 15 19:47:57 2023 +0100

    Improve speed mine

commit f7c14c6
Author: Wide-Cat <[email protected]>
Date:   Tue Aug 15 17:57:30 2023 +0100

    Hopefully fix compatibility with future

commit 712d948
Author: Wide-Cat <[email protected]>
Date:   Mon Aug 14 16:08:49 2023 +0100

    Improve block placing

commit 74478bc
Author: MineGame159 <[email protected]>
Date:   Mon Aug 14 13:06:42 2023 +0200

    cope

commit 135dade
Author: MineGame159 <[email protected]>
Date:   Mon Aug 14 13:02:52 2023 +0200

    Rewrite Better Chat Player Heads, now with a way for addons to register custom prefix heads

commit a712a30
Author: thebest9178 <[email protected]>
Date:   Sat Aug 12 20:07:30 2023 -0700

    Fixed PotionTimers getting stuck invisible in the hud editor if all
    effects are hidden.

commit b74432e
Author: Jaranamo1 <[email protected]>
Date:   Sun Aug 13 11:48:26 2023 +0100

    Improve AnchorAura (MeteorDevelopment#3677)

commit a3e1271
Author: RacoonDog <[email protected]>
Date:   Mon May 15 23:22:29 2023 -0400

    Update MeteorExecutor.java

commit ffb62c4
Author: RacoonDog <[email protected]>
Date:   Sat Aug 12 17:36:53 2023 -0400

    Mark sodium <0.5.0 incompatible (MeteorDevelopment#3945)

commit 17f634c
Author: RacoonDog <[email protected]>
Date:   Sat Aug 12 14:14:45 2023 -0400

    Better Chat optimisations (MeteorDevelopment#3942)

commit 96ba7da
Author: Fiz-Victor <[email protected]>
Date:   Sun Jul 16 13:56:37 2023 +0800

    Added bundle packet support
    Regenerated PacketUtil

commit 4a5b958
Author: DAM <[email protected]>
Date:   Mon Jun 12 19:36:53 2023 +0200

    VClip normal tp if distance > 200

commit f0dafbe
Author: Mersid <[email protected]>
Date:   Sat Aug 12 07:04:04 2023 -0700

    Fix rainbow colour not working for friends (MeteorDevelopment#3741)

commit bee3569
Author: Trolman <[email protected]>
Date:   Wed Jun 21 15:39:02 2023 +0200

    Spawn eggs can be placed in the air

commit 899cffd
Author: etianl <[email protected]>
Date:   Sun Jul 9 00:34:36 2023 -0700

    Make Jesus work on Blocks Other than Source

    This edit makes the Jesus work on blocks other than the source as well as waterlogged blocks.

commit 790c858
Author: etianl <[email protected]>
Date:   Sat Jul 1 15:34:44 2023 -0700

    Fixed Jesus On Blocks Other Than Liquid Source

    Jesus was murdering me when I was walking on any lava other than source blocks, by causing the character to dip into it. This smol change fixes that

commit 7191d38
Author: thebest9178 <[email protected]>
Date:   Fri Aug 11 03:52:02 2023 -0700

    Added Hidden Effects
    Added Show Ambient

commit 953c071
Author: thebest9178 <[email protected]>
Date:   Fri Aug 11 03:25:50 2023 -0700

    Added options for flat and rainbow colours.
    Made the default potion timers text not appear when the player has any
    effects.

commit 7da4a4f
Author: RacoonDog <[email protected]>
Date:   Fri Aug 11 08:00:24 2023 -0400

    Optimise anti spam (MeteorDevelopment#3932)

    the J

commit 6799f8e
Author: RacoonDog <[email protected]>
Date:   Thu Aug 10 15:43:27 2023 -0400

    patch 1.20 compat

commit f66f53e
Author: Wikinger8 <[email protected]>
Date:   Thu Aug 10 02:37:32 2023 +0200

    Fixed InventoryTweaks crash (MeteorDevelopment#3928)

commit 65509bb
Author: auto <[email protected]>
Date:   Wed Aug 9 18:28:27 2023 -0400

    Update BuildHeight to new height limit

commit d72c41c
Author: hellidox <[email protected]>
Date:   Wed Aug 9 17:08:04 2023 -0500

    Update Swarm default port (MeteorDevelopment#3796)

commit 101542b
Author: Big Iron <[email protected]>
Date:   Thu Aug 10 00:06:23 2023 +0200

    Add excavator module (MeteorDevelopment#3873)

commit bad942f
Author: Wide-Cat <[email protected]>
Date:   Wed Aug 9 22:42:42 2023 +0100

    Fix bedaura not breaking beds

    This has been broken for over a year 💀

commit ea89e35
Author: Patrick <[email protected]>
Date:   Wed Aug 9 17:14:13 2023 +0200

    Add whitelist to Slippy (MeteorDevelopment#3902)

commit aa0f33e
Author: o0sh4d0w0o <[email protected]>
Date:   Sat Jul 22 23:39:58 2023 +0200

    Fixed slider double decimalPlaces (currently not supported)

commit f2fa112
Author: thebest9178 <[email protected]>
Date:   Wed Aug 9 14:50:51 2023 +0000

    Add ignoreFriends to Hitboxes (MeteorDevelopment#3914)

commit 5736f9d
Author: RacoonDog <[email protected]>
Date:   Wed Aug 9 10:40:47 2023 -0400

    make health optional for nametags (MeteorDevelopment#3898)

commit 3e3f296
Author: RacoonDog <[email protected]>
Date:   Sun Aug 6 15:07:25 2023 -0400

    reconnect desync patch

commit e517a9a
Author: Fiz-Victor <[email protected]>
Date:   Fri Aug 4 19:07:46 2023 +0800

    Small fix for game crashing when authme is installed and getting kicked

commit 6b430c0
Author: thebest9178 <[email protected]>
Date:   Fri Aug 4 01:00:03 2023 -0700

    Fixed trail pause when stationary

commit 2507af6
Author: thebest9178 <[email protected]>
Date:   Wed Aug 9 12:30:03 2023 +0000

    Added ignoreSelf to tracers (MeteorDevelopment#3913)

    Co-authored-by: thebest9178 <[email protected]>

commit 081b97c
Author: thebest9178 <[email protected]>
Date:   Mon Jul 17 09:42:11 2023 +0000

    Fix typo in StashFinder

commit 0c28f37
Author: OnlyRain233 <[email protected]>
Date:   Mon Aug 7 01:32:12 2023 +0800

    Fix Luminous in FullBright and weird lighting when xray enabled (MeteorDevelopment#3920)

commit bb14113
Author: MineGame159 <[email protected]>
Date:   Sun Aug 6 14:40:06 2023 +0200

    Actually fixed now

commit e2a3dc4
Author: MineGame159 <[email protected]>
Date:   Sun Aug 6 14:03:22 2023 +0200

    Updated to Sodium 0.5.0

commit 77a9e14
Author: RacoonDog <[email protected]>
Date:   Fri Jul 28 11:14:27 2023 -0400

    Update GameOptionsMixin.java

commit 4586315
Author: Wide-Cat <[email protected]>
Date:   Sun Jul 23 17:59:10 2023 +0100

    Add an option to hide the hud while in guis (MeteorDevelopment#3875)

commit a52b91a
Author: Wide-Cat <[email protected]>
Date:   Sat Jul 22 23:10:06 2023 +0100

    Add texture rotations to no render (MeteorDevelopment#3869)

commit 5c3d7a0
Author: Wide-Cat <[email protected]>
Date:   Sat Jul 22 16:27:19 2023 +0100

    fix compatibility with camera utils

commit dd0f6d2
Author: Wide-Cat <[email protected]>
Date:   Mon Jul 17 15:54:14 2023 +0100

    fix better tooltip crash

commit 5e29429
Author: OnlyRain233 <[email protected]>
Date:   Thu Jul 13 04:27:40 2023 +0800

    Fix Reach not working in creative (MeteorDevelopment#3826)

commit 9a36f0a
Author: xNasuni <[email protected]>
Date:   Wed Jul 12 16:20:24 2023 -0400

    no gravity entities with correct trajectory and accurate multishot crossbow trajectories (MeteorDevelopment#3818)

commit c6e2764
Author: tyrannus <[email protected]>
Date:   Tue Jul 11 00:52:38 2023 +0200

    Fixed anchor below y 0 (MeteorDevelopment#3824)

    Co-authored-by: tyrannus00 <[email protected]>

commit 66e0b88
Author: Wide-Cat <[email protected]>
Date:   Fri Jun 30 11:45:11 2023 +0100

    Fix anti spam (MeteorDevelopment#3794)

commit 12b4b41
Author: MineGame159 <[email protected]>
Date:   Thu Jun 29 23:28:22 2023 +0200

    Simplify color modification from previous commit

commit 0ea98e5
Author: Wide-Cat <[email protected]>
Date:   Thu Jun 29 21:20:11 2023 +0100

    updated xray to work with latest fabric api

commit e2854ce
Author: MineGame159 <[email protected]>
Date:   Wed Jun 28 23:59:27 2023 +0200

    Fix random sneaking and collisions

commit f990472
Author: Wide-Cat <[email protected]>
Date:   Tue Jun 27 15:06:27 2023 +0100

    Make autosign work with hanging signs
tyrannus00 pushed a commit to tyrannus00/meteor-client that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants