Skip to content

Commit

Permalink
MCA Module
Browse files Browse the repository at this point in the history
  • Loading branch information
cvs0 committed Aug 7, 2024
1 parent 973efd0 commit 57116d3
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/main/java/net/aoba/module/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down Expand Up @@ -461,6 +463,14 @@ public static boolean swapBack() {
return result;
}

public static FindItemResult find(Item... items) {
return find(itemStack -> {
for (Item item : items) {
if (itemStack.getItem() == item) return true;
}
return false;
});
}

public static void rotatePitch(float degrees) {
MinecraftClient client = MinecraftClient.getInstance();
Expand All @@ -477,4 +487,11 @@ public static void rotatePitch(float degrees) {
client.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(player.getYaw(), newPitch, player.isOnGround()));
}
}

public static void sendChatMessage(String message) {
MinecraftClient mc = MinecraftClient.getInstance();
if (mc.inGameHud != null) {
mc.inGameHud.getChatHud().addMessage(Text.of(Formatting.DARK_PURPLE + "[" + Formatting.LIGHT_PURPLE + "Aoba" + Formatting.DARK_PURPLE + "] " + Formatting.RESET + message));
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/net/aoba/module/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.InputUtil.Key;

import javax.tools.Tool;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -115,6 +114,7 @@ public class ModuleManager implements KeyDownListener {
public Module tooltips = new Tooltips();
public Module antihunger = new AntiHunger();
public Module expthrower = new EXPThrower();
public Module mcf = new MCA();

public ModuleManager(List<IAddon> addons) {
addModule(aimbot);
Expand Down Expand Up @@ -185,6 +185,7 @@ public ModuleManager(List<IAddon> addons) {
addModule(tooltips);
addModule(antihunger);
addModule(expthrower);
addModule(mcf);

addons.stream().filter(Objects::nonNull).forEach(addon -> {
try {
Expand Down
87 changes: 87 additions & 0 deletions src/main/java/net/aoba/module/modules/misc/MCA.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package net.aoba.module.modules.misc;

import net.aoba.Aoba;
import net.aoba.event.events.MouseClickEvent;
import net.aoba.event.listeners.MouseClickListener;
import net.aoba.module.Category;
import net.aoba.module.Module;
import net.aoba.settings.types.EnumSetting;
import net.aoba.settings.types.KeybindSetting;
import net.aoba.utils.FindItemResult;
import net.aoba.utils.types.MouseAction;
import net.aoba.utils.types.MouseButton;
import net.minecraft.client.util.InputUtil;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.util.Hand;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.injection.invoke.util.InvokeUtil;

public class MCA extends Module implements MouseClickListener {
private final EnumSetting<Mode> mode = new EnumSetting<>("mca_mode", "Mode", "The mode for the action to run when the middle mouse button is clicked.", Mode.FRIEND);

private int selectedSlot;

public MCA() {
super(new KeybindSetting("key.mca", "MCA Key", InputUtil.fromKeyCode(GLFW.GLFW_KEY_UNKNOWN, 0)));

this.setName("MCA");
this.setCategory(Category.of("misc"));
this.setDescription("Middle Click Action");

this.addSetting(mode);
}

@Override
public void onDisable() {
Aoba.getInstance().eventManager.RemoveListener(MouseClickListener.class, this);
}

@Override
public void onEnable() {
Aoba.getInstance().eventManager.AddListener(MouseClickListener.class, this);
}

@Override
public void onToggle() {

}

@Override
public void OnMouseClick(MouseClickEvent mouseClickEvent) {
if (mouseClickEvent.button == MouseButton.MIDDLE && mouseClickEvent.action == MouseAction.DOWN) {
if (mode.getValue() == Mode.FRIEND) {
if (MC.targetedEntity == null) return;
if (!(MC.targetedEntity instanceof PlayerEntity player)) return;

if (!Aoba.getInstance().friendsList.contains(player)) {
Aoba.getInstance().friendsList.addFriend(player);
mouseClickEvent.cancel();

sendChatMessage("Added " + player.getName().getString() + " to friends list.");
} else {
Aoba.getInstance().friendsList.removeFriend(player);
mouseClickEvent.cancel();

sendChatMessage("Removed " + player.getName().getString() + " from friends list.");
}
} else if (mode.getValue() == Mode.PEARL) {
FindItemResult result = find(Items.ENDER_PEARL);

if (!result.found() || !result.isHotbar()) return;

selectedSlot = MC.player.getInventory().selectedSlot;

if (!result.isMainHand()) {
swap(result.slot(), false);

MC.interactionManager.interactItem(MC.player, Hand.MAIN_HAND);
}
}
}
}

public enum Mode {
FRIEND, PEARL
}
}

0 comments on commit 57116d3

Please sign in to comment.