Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TejasLamba2006 committed Jul 9, 2024
2 parents c43bb43 + 679297f commit 39cc36c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/keystrokesmod/module/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void register() {
this.addModule(panic = new Panic());
this.addModule(slotHandler = new SlotHandler());
this.addModule(staffDetector = new StaffDetector());
this.addModule(new AutoWeapon());
this.addModule(new AutoWeapon());
this.addModule(autoRespawn = new AutoRespawn());

antiBot.enable();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/keystrokesmod/module/impl/movement/Fly.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Fly() {
this.registerSetting(verticalSpeed = new SliderSetting("Vertical speed", 2.0, 0.0, 9.0, 0.1, canChangeSpeed));
this.registerSetting(maxBalance = new SliderSetting("Max balance", 6000, 3000, 30000, 1000, "ms", balanceMode));
this.registerSetting(autoDisable = new ButtonSetting("Auto disable", true, balanceMode));
this.registerSetting(motionMultiplier = new SliderSetting("Motion multiplier", 1.0, 0.8, 1.1, 0.05, new ModeOnly(mode, 6)));
this.registerSetting(motionMultiplier = new SliderSetting("Motion multiplier", 1.0, 0.8, 1.2, 0.05, new ModeOnly(mode, 6)));
this.registerSetting(showBPS = new ButtonSetting("Show BPS", false));
this.registerSetting(stopMotion = new ButtonSetting("Stop motion", false));
}
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/keystrokesmod/module/impl/world/AutoWeapon.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package keystrokesmod.module.impl.world;

import keystrokesmod.event.PreMotionEvent;
import keystrokesmod.event.PreUpdateEvent;
import keystrokesmod.module.Module;
import keystrokesmod.module.impl.other.SlotHandler;
import keystrokesmod.module.setting.impl.ButtonSetting;
Expand All @@ -16,15 +18,17 @@
public class AutoWeapon extends Module {
private final SliderSetting hoverDelay;
private final ButtonSetting swap;
private final ButtonSetting ignoreTeammates;
private int previousSlot = -1;
private int ticksHovered;
private Entity currentEntity;
public AutoWeapon() {
super("AutoWeapon", category.world);
this.registerSetting(hoverDelay = new SliderSetting("Hover delay", 0.0, 0.0, 20.0, 1.0));
this.registerSetting(swap = new ButtonSetting("Swap to previous slot", true));
this.registerSetting(ignoreTeammates = new ButtonSetting("Ignore teammates", true));
this.registerSetting(new DescriptionSetting("Configure your weapons in the Settings tab."));
}
}

public void onDisable() {
resetVariables();
Expand All @@ -38,26 +42,24 @@ public void setSlot(final int currentItem) {
}

@SubscribeEvent
public void onTick(TickEvent.RenderTickEvent e) {
if (Utils.nullCheck() || !mc.inGameHasFocus || mc.currentScreen != null) {
public void onPreMotion(PreMotionEvent e) {
if (!Utils.nullCheck() || !mc.inGameHasFocus || mc.currentScreen != null) {
resetSlot();
resetVariables();
return;
}
Entity hoveredEntity = mc.objectMouseOver != null ? mc.objectMouseOver.entityHit : null;
if (!(hoveredEntity instanceof Entity)) {
if (!(hoveredEntity instanceof EntityLivingBase)
|| (hoveredEntity instanceof EntityPlayer && AntiBot.isBot(hoveredEntity))
|| (hoveredEntity instanceof EntityPlayer && Utils.isFriended((EntityPlayer) hoveredEntity))
|| (ignoreTeammates.isToggled() && Utils.isTeamMate(hoveredEntity))
) {
resetSlot();
resetVariables();
return;
}
ticksHovered = hoveredEntity.equals(currentEntity) ? ticksHovered + 1 : 0;
if (hoveredEntity instanceof EntityLivingBase
&& !AntiBot.isBot(hoveredEntity)
&& (!(hoveredEntity instanceof EntityPlayer) || Utils.isFriended((EntityPlayer) hoveredEntity))
&& !Utils.isTeamMate(hoveredEntity)
) {
currentEntity = hoveredEntity;
}
currentEntity = hoveredEntity;

if (hoverDelay.getInput() == 0 || ticksHovered > hoverDelay.getInput()) {
int slot = Utils.getWeapon();
Expand Down

0 comments on commit 39cc36c

Please sign in to comment.