Adds AutoClicker, also fixes text component bug

This commit is contained in:
noil 2021-02-19 21:10:28 -05:00
parent 172bc7a1af
commit 711a97168a
4 changed files with 110 additions and 0 deletions

View File

@ -4,6 +4,8 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.texture.Texture;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.api.util.Timer;
import me.rigamortis.seppuku.impl.gui.hud.component.ColorsComponent;
import me.rigamortis.seppuku.impl.gui.hud.component.module.ModuleListComponent;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
@ -86,6 +88,32 @@ public class TextComponent extends HudComponent {
}
}
@Override
public void mouseClick(int mouseX, int mouseY, int button) {
super.mouseClick(mouseX, mouseY, button);
if (this.isMouseInside(mouseX, mouseY)) {
for (HudComponent hudComponent : Seppuku.INSTANCE.getHudManager().getComponentList()) {
if (hudComponent instanceof ModuleListComponent) {
final ModuleListComponent moduleListComponent = (ModuleListComponent) hudComponent;
if (moduleListComponent.getCurrentSettings() != null) {
for (HudComponent moduleComponent : moduleListComponent.getCurrentSettings().components) {
if (moduleComponent instanceof TextComponent && !this.getName().equals(moduleComponent.getName())) {
((TextComponent) moduleComponent).focused = false;
}
}
}
} else if (hudComponent instanceof ColorsComponent) {
final ColorsComponent colorsComponent = (ColorsComponent) hudComponent;
if (colorsComponent.getCurrentColorComponent() != null) {
if (!this.getName().equals(colorsComponent.getName())) {
colorsComponent.getCurrentColorComponent().focused = false;
}
}
}
}
}
}
@Override
public void mouseRelease(int mouseX, int mouseY, int button) {
super.mouseRelease(mouseX, mouseY, button);

View File

@ -340,6 +340,8 @@ public final class ColorsComponent extends ResizableHudComponent {
}
if (this.isMouseInside(mouseX, mouseY) && this.currentColorComponent != null) {
this.currentColorComponent.mouseClick(mouseX, mouseY, button);
final boolean insideSpectrum =
mouseX >= this.getX() + this.getW() / 4 + this.getW() / 16 &&
mouseY >= this.getY() + this.getH() / 2 + 10 &&
@ -427,4 +429,12 @@ public final class ColorsComponent extends ResizableHudComponent {
public int getTotalHeight() {
return totalHeight;
}
public ColorComponent getCurrentColorComponent() {
return currentColorComponent;
}
public void setCurrentColorComponent(ColorComponent currentColorComponent) {
this.currentColorComponent = currentColorComponent;
}
}

View File

@ -168,6 +168,7 @@ public final class ModuleManager {
add(new NoteBotModule());
add(new BurrowModule());
add(new AutoTorchModule());
add(new AutoClickerModule());
// p2w experience
if (Seppuku.INSTANCE.getCapeManager().hasCape())

View File

@ -0,0 +1,71 @@
package me.rigamortis.seppuku.impl.module.combat;
import me.rigamortis.seppuku.api.event.minecraft.EventRunTick;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.Timer;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import org.lwjgl.input.Mouse;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
/**
* @author noil
*/
public final class AutoClickerModule extends Module {
private final Value<Float> clicksPerSecond = new Value<Float>("Speed", new String[]{"Speed", "S"}, "Clicks per second to automatically click.", 8.0f, 1.0f, 15.0f, 0.1f);
private final Value<Boolean> randomize = new Value<Boolean>("Randomize", new String[]{"Random", "R"}, "Randomizes the clicks per second.", true);
private final Value<Boolean> onlyWeapons = new Value<Boolean>("OnlyWeapons", new String[]{"OnlyWep", "OW"}, "When enabled, will only auto click with chosen held weapons.", true);
private final Value<List<Item>> weapons = new Value<List<Item>>("Weapons", new String[]{"Wep", "Items", "WI", "I", "W"}, "Choose which items to automatically click with");
//private final Value<Boolean> humanize = new Value<Boolean>("Humanize", new String[]{"Human", "h"}, "Humanizes the clicks per second.", false);
private final Timer timer = new Timer();
public AutoClickerModule() {
super("AutoClicker", new String[]{"AutoClick", "Clicker", "AutoAttack"}, "Automatically clicks the mouse while mouse is held down.", "NONE", -1, ModuleType.COMBAT);
this.weapons.setValue(new ArrayList<>());
this.weapons.getValue().add(Items.DIAMOND_SWORD);
this.weapons.getValue().add(Items.IRON_SWORD);
this.weapons.getValue().add(Items.GOLDEN_SWORD);
this.weapons.getValue().add(Items.STONE_SWORD);
this.weapons.getValue().add(Items.WOODEN_SWORD);
}
@Listener
public void onRunTick(EventRunTick event) {
if (Minecraft.getMinecraft().inGameHasFocus && Minecraft.getMinecraft().currentScreen == null && Minecraft.getMinecraft().player != null)
if (Mouse.isButtonDown(0)) {
if (this.onlyWeapons.getValue()) {
if (!this.weapons.getValue().contains(Minecraft.getMinecraft().player.getHeldItemMainhand().getItem())) {
return;
}
}
double cps = generateCPS();
if (this.timer.passed(1000.0f / cps)) {
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode(), true);
KeyBinding.onTick(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode());
this.timer.reset();
} else {
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode(), false);
}
}
}
private double generateCPS() {
double cps;
if (this.randomize.getValue()) {
double randomNumber = ThreadLocalRandom.current().nextDouble(-2.0D, 2.0D);
cps = this.clicksPerSecond.getValue() + (float) randomNumber;
} else {
cps = this.clicksPerSecond.getValue();
}
return Math.abs(cps);
}
}