This commit is contained in:
Cloudburst
2021-06-12 19:54:43 +02:00
parent 0ca7ec87dd
commit 2d1381a648
5 changed files with 67 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import java.lang.invoke.MethodHandles;
import cloudburst.rejects.commands.*; import cloudburst.rejects.commands.*;
import cloudburst.rejects.gui.hud.*; import cloudburst.rejects.gui.hud.*;
import cloudburst.rejects.modules.*; import cloudburst.rejects.modules.*;
import cloudburst.rejects.utils.Utils;
public class MeteorRejectsAddon extends MeteorAddon { public class MeteorRejectsAddon extends MeteorAddon {
public static final Logger LOG = LogManager.getLogger(); public static final Logger LOG = LogManager.getLogger();
@@ -27,6 +28,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
LOG.info("Initializing Meteor Rejects Addon"); LOG.info("Initializing Meteor Rejects Addon");
MeteorClient.EVENT_BUS.registerLambdaFactory("cloudburst.rejects", (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())); MeteorClient.EVENT_BUS.registerLambdaFactory("cloudburst.rejects", (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup()));
Utils.init();
Modules modules = Modules.get(); Modules modules = Modules.get();
modules.add(new AntiBot()); modules.add(new AntiBot());
@@ -71,6 +73,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
hud.elements.add(new AppleHud(hud)); hud.elements.add(new AppleHud(hud));
hud.elements.add(new CrystalHud(hud)); hud.elements.add(new CrystalHud(hud));
hud.elements.add(new ExpHud(hud)); hud.elements.add(new ExpHud(hud));
hud.elements.add(new CpsHud(hud));
GuiThemes.add(new MeteorRoundedGuiTheme()); GuiThemes.add(new MeteorRoundedGuiTheme());
} }

View File

@@ -0,0 +1,16 @@
package cloudburst.rejects.gui.hud;
import cloudburst.rejects.utils.Utils;
import minegame159.meteorclient.systems.modules.render.hud.HUD;
import minegame159.meteorclient.systems.modules.render.hud.modules.DoubleTextHudElement;
public class CpsHud extends DoubleTextHudElement {
public CpsHud(HUD hud) {
super(hud, "cps", "Displays your CPS.", "CPS: ", false);
}
@Override
protected String getRight() {
return Integer.toString(Utils.CPS);
}
}

View File

@@ -0,0 +1,23 @@
package cloudburst.rejects.mixin;
import net.minecraft.client.MinecraftClient;
import cloudburst.rejects.utils.Utils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* Injects the CPS counter.
*/
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin
{
@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;doAttack()V"))
private void onAttack(CallbackInfo ci)
{
Utils.CPS++;
}
}

View File

@@ -0,0 +1,24 @@
package cloudburst.rejects.utils;
import java.util.Timer;
import java.util.TimerTask;
public class Utils {
public static int CPS = 0;
public static void init() {
new Timer().scheduleAtFixedRate(newTimerTaskFromLambda(() -> CPS = 0), 0, 1000);
}
public static TimerTask newTimerTaskFromLambda(Runnable runnable)
{
return new TimerTask()
{
@Override
public void run()
{
runnable.run();
}
};
}
}

View File

@@ -10,6 +10,7 @@
"StructureVoidBlockMixin", "StructureVoidBlockMixin",
"TitleScreenMixin", "TitleScreenMixin",
"LivingEntityRendererMixin", "LivingEntityRendererMixin",
"MinecraftClientMixin",
"GameRendererMixin", "GameRendererMixin",
"ToastManagerMixin" "ToastManagerMixin"
], ],