From 14c68eb5ba16774f581d95a39e64a7b303954ffc Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Sat, 26 Sep 2026 17:05:36 +1200 Subject: migration to 26.2 - run migrateMappings with old loom then bring it back to new --- .../arslaansmagichax/commands/CrashCommand.java | 49 ++++++ .../arslaansmagichax/commands/HackGive.java | 45 +++++ .../arslaansmagichax/commands/HackSetblock.java | 78 +++++++++ .../arslaansmagichax/commands/HackTP.java | 181 +++++++++++++++++++++ .../arslaansmagichax/commands/HackXP.java | 30 ++++ .../commands/ModuleSuggestionProvider.java | 26 +++ .../commands/ModuleToggleCommand.java | 44 +++++ 7 files changed, 453 insertions(+) create mode 100644 src/main/java/com/arslaancodes/arslaansmagichax/commands/CrashCommand.java create mode 100644 src/main/java/com/arslaancodes/arslaansmagichax/commands/HackGive.java create mode 100644 src/main/java/com/arslaancodes/arslaansmagichax/commands/HackSetblock.java create mode 100644 src/main/java/com/arslaancodes/arslaansmagichax/commands/HackTP.java create mode 100644 src/main/java/com/arslaancodes/arslaansmagichax/commands/HackXP.java create mode 100644 src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleSuggestionProvider.java create mode 100644 src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleToggleCommand.java (limited to 'src/main/java/com/arslaancodes/arslaansmagichax/commands') diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/commands/CrashCommand.java b/src/main/java/com/arslaancodes/arslaansmagichax/commands/CrashCommand.java new file mode 100644 index 0000000..09be43c --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/commands/CrashCommand.java @@ -0,0 +1,49 @@ +package com.arslaancodes.arslaansmagichax.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.client.Minecraft; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; + +public class CrashCommand { + public static void register(CommandDispatcher dispatcher, CommandBuildContext access) { + dispatcher.register(ClientCommandManager.literal("surprise") + .executes(CrashCommand::run) + ); + } + + private static int run(CommandContext ctx) { + Minecraft client = Minecraft.getInstance(); + + client.execute(() -> { + client.player.playSound( + SoundEvent.createVariableRangeEvent(ResourceLocation.parse("minecraft:entity.evoker.prepare_wololo")), + 1.0f, // volume + 1.0f // pitch + ); + }); + + new Thread(() -> { + try { Thread.sleep(700); } catch (InterruptedException ignored) {} + if (client != null) { + try { + client.player = null; + client.cameraEntity = null; + client.screen = null; + client.hitResult = null; + client.crosshairPickEntity = null; + } catch (Throwable ignored) {} + } + Runtime.getRuntime().halt(1); + }, "surprise-halt-thread").start(); + + return 1; + } +} diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackGive.java b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackGive.java new file mode 100644 index 0000000..db36136 --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackGive.java @@ -0,0 +1,45 @@ +package com.arslaancodes.arslaansmagichax.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.client.Minecraft; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +public class HackGive { + public static void register(CommandDispatcher dispatcher, CommandBuildContext access) { + dispatcher.register(ClientCommandManager.literal("hackgive") + .then(ClientCommandManager.argument("item", StringArgumentType.string()) + .then(ClientCommandManager.argument("amount", IntegerArgumentType.integer(1)) + .executes(HackGive::run) + ) + ) + ); + } + + private static int run(CommandContext context) throws CommandSyntaxException { + Minecraft client = Minecraft.getInstance(); + if (client.level == null || client.player == null) return 0; + + String itemId = StringArgumentType.getString(context, "item"); + int amount = IntegerArgumentType.getInteger(context, "amount"); + Item item = BuiltInRegistries.ITEM.getValue(ResourceLocation.parse(itemId)); + if (item == null) { + context.getSource().sendError(Component.literal("Unknown item: " + itemId)); + return 0; + } + + ItemStack stack = new ItemStack(item, amount); + client.player.getInventory().add(stack); + return 1; + } +} diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackSetblock.java b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackSetblock.java new file mode 100644 index 0000000..a26d0e9 --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackSetblock.java @@ -0,0 +1,78 @@ +package com.arslaancodes.arslaansmagichax.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.context.CommandContext; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.client.Minecraft; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; + +public class HackSetblock { + public static void register(CommandDispatcher dispatcher, CommandBuildContext access) { + dispatcher.register(ClientCommandManager.literal("hacksetblock") + .then(ClientCommandManager.argument("block", StringArgumentType.string()) + // Case: just block -> place at player's feet + .executes(HackSetblock::runAtFeet) + + // Case: block + xyz -> place at given position + .then(ClientCommandManager.argument("x", IntegerArgumentType.integer()) + .then(ClientCommandManager.argument("y", IntegerArgumentType.integer()) + .then(ClientCommandManager.argument("z", IntegerArgumentType.integer()) + .executes(HackSetblock::runAtPos) + ) + ) + ) + ) + ); + } + + private static int runAtFeet(CommandContext context) { + Minecraft client = Minecraft.getInstance(); + if (client.level == null || client.player == null) return 0; + + String blockId = StringArgumentType.getString(context, "block"); + Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId)); + if (block == null) { + context.getSource().sendError(Component.literal("Unknown block: " + blockId)); + return 0; + } + + BlockPos pos = client.player.blockPosition(); + BlockState blockState = block.defaultBlockState(); + + client.level.setBlockAndUpdate(pos, blockState); + + return 1; + } + + private static int runAtPos(CommandContext context) { + Minecraft client = Minecraft.getInstance(); + if (client.level == null) return 0; + + String blockId = StringArgumentType.getString(context, "block"); + int x = IntegerArgumentType.getInteger(context, "x"); + int y = IntegerArgumentType.getInteger(context, "y"); + int z = IntegerArgumentType.getInteger(context, "z"); + + Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId)); + if (block == null) { + context.getSource().sendError(Component.literal("Unknown block: " + blockId)); + return 0; + } + + BlockPos pos = new BlockPos(x, y, z); + BlockState blockState = block.defaultBlockState(); + + client.level.setBlockAndUpdate(pos, blockState); + + return 1; + } +} diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackTP.java b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackTP.java new file mode 100644 index 0000000..6c376ab --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackTP.java @@ -0,0 +1,181 @@ +package com.arslaancodes.arslaansmagichax.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.minecraft.client.Minecraft; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.level.Level; +import java.util.LinkedList; +import java.util.Queue; + +public class HackTP { + private static final Queue stepQueue = new LinkedList<>(); + private static int packetsPerTick = 5; + + public static BlockPos findClosestAirNearPosition(int x, int y, int z) { + Level world = Minecraft.getInstance().level; + if (world == null) return null; + + for (int blockY = y; blockY <= world.getHeight(); blockY++) { + BlockPos pos = new BlockPos(x, blockY, z); + if (world.getBlockState(pos).isAir() && world.getBlockState(pos.above()).isAir()) { + return pos; + } + } + + for (int blockY = y; blockY >= 0; blockY--) { + BlockPos pos = new BlockPos(x, blockY, z); + if (world.getBlockState(pos).isAir() && world.getBlockState(pos.above()).isAir()) { + return pos; + } + } + return null; + } + + private static int computeSafePacketsPerTick(int requestedSpeed) { + final int STEP_HORIZ = 2; + final double SAFE_HORIZ = 8.5; // server maximum horizontal move + + int allowed = (int) Math.floor(SAFE_HORIZ / STEP_HORIZ); + if (allowed < 1) allowed = 1; + + return Math.max(1, Math.min(requestedSpeed, allowed)); + } + + private static double parseCoordinate(String arg, double current) { + if (arg.startsWith("c")) { + if (arg.length() == 1) return current; + return current + Double.parseDouble(arg.substring(1)); + } else { + return Double.parseDouble(arg); + } + } + + public static void register(CommandDispatcher dispatcher, CommandBuildContext access) { + dispatcher.register(ClientCommandManager.literal("hacktp") + .then(ClientCommandManager.argument("x", StringArgumentType.word()) + .then(ClientCommandManager.argument("y", StringArgumentType.word()) + .then(ClientCommandManager.argument("z", StringArgumentType.word()) + .then(ClientCommandManager.argument("speed", IntegerArgumentType.integer(0, 25)) + .executes(HackTP::run) + ) + ) + ) + ) + ); + +// ClientTickEvents.END_CLIENT_TICK.register(client -> { +// if (!stepQueue.isEmpty() && client.player != null) { +// double[] pos = stepQueue.poll(); +// +// client.getNetworkHandler().sendPacket( +// new PlayerMoveC2SPacket.PositionAndOnGround(pos[0], pos[1], pos[2], true, client.player.horizontalCollision) +// ); +// +// client.player.setPos(pos[0], pos[1], pos[2]); +// +// client.player.sendMessage(Text.literal("Teleported to " + pos[0] + " " + pos[1] + " " + pos[2]), false); +// } +// }); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (!stepQueue.isEmpty() && client.player != null) { + for (int i = 0; i < packetsPerTick && !stepQueue.isEmpty(); i++) { + double[] pos = stepQueue.poll(); + +// client.getNetworkHandler().sendPacket( +// new PlayerMoveC2SPacket.PositionAndOnGround( +// pos[0], pos[1], pos[2], true, client.player.horizontalCollision +// ) +// ); + + client.player.setPosRaw(pos[0], pos[1], pos[2]); + + client.player.displayClientMessage(Component.literal("Teleported to " + pos[0] + " " + pos[1] + " " + pos[2] + " with packetsPerTick/speed " + packetsPerTick), false); + } + } + }); + } + + private static int run(CommandContext context) throws CommandSyntaxException { + int speed = IntegerArgumentType.getInteger(context, "speed"); + + LocalPlayer player = context.getSource().getPlayer(); + if (player == null) { + context.getSource().sendFeedback(Component.literal("No player found.")); + return -1; + } + + double currentX = player.getX(); + double currentY = player.getY(); + double currentZ = player.getZ(); + + String xArg = context.getArgument("x", String.class); + String yArg = context.getArgument("y", String.class); + String zArg = context.getArgument("z", String.class); + + double targetX = parseCoordinate(xArg, currentX); + double targetY = parseCoordinate(yArg, currentY); + double targetZ = parseCoordinate(zArg, currentZ); + + if (speed < 1) { + packetsPerTick = computeSafePacketsPerTick(packetsPerTick); + } else { + packetsPerTick = computeSafePacketsPerTick(speed); + } + + context.getSource().sendFeedback(Component.literal("Using " + packetsPerTick + " packets/tick (requested " + speed + ")")); + + int stepX = (targetX > currentX) ? 2 : -2; + int stepY = (targetY > currentY) ? 2 : -2; + int stepZ = (targetZ > currentZ) ? 2 : -2; + + for (int i = 1; i <= 8; i++) { + stepQueue.add(new double[]{currentX, currentY, currentZ}); // I don't know how this works but it makes Y more reliable (go through more blocks on the Y axis?) + } + while ((stepY > 0 && currentY < targetY) || (stepY < 0 && currentY > targetY)) { + currentY += stepY; + if ((stepY > 0 && currentY > targetY) || (stepY < 0 && currentY < targetY)) currentY = targetY; + stepQueue.add(new double[]{currentX, currentY, currentZ}); + context.getSource().sendFeedback(Component.literal( + "Queued teleport to " + currentX + " " + currentY + " " + currentZ + )); + } + + while ((stepX > 0 && currentX < targetX) || (stepX < 0 && currentX > targetX)) { + currentX += stepX; + if ((stepX > 0 && currentX > targetX) || (stepX < 0 && currentX < targetX)) currentX = targetX; + + BlockPos airPos = findClosestAirNearPosition((int) currentX, (int) currentY, (int) currentZ); + if (airPos != null) currentY = airPos.getY(); + + stepQueue.add(new double[]{currentX, currentY, currentZ}); + context.getSource().sendFeedback(Component.literal( + "Queued teleport to " + currentX + " " + currentY + " " + currentZ + )); + } + + while ((stepZ > 0 && currentZ < targetZ) || (stepZ < 0 && currentZ > targetZ)) { + currentZ += stepZ; + if ((stepZ > 0 && currentZ > targetZ) || (stepZ < 0 && currentZ < targetZ)) currentZ = targetZ; + + BlockPos airPos = findClosestAirNearPosition((int) currentX, (int) currentY, (int) currentZ); + if (airPos != null) currentY = airPos.getY(); + + stepQueue.add(new double[]{currentX, currentY, currentZ}); + context.getSource().sendFeedback(Component.literal( + "Queued teleport to " + currentX + " " + currentY + " " + currentZ + )); + } + + return 1; + } +} diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackXP.java b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackXP.java new file mode 100644 index 0000000..024f5c4 --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/commands/HackXP.java @@ -0,0 +1,30 @@ +package com.arslaancodes.arslaansmagichax.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.client.Minecraft; +import net.minecraft.commands.CommandBuildContext; + +public class HackXP { + public static void register(CommandDispatcher dispatcher, CommandBuildContext access) { + dispatcher.register(ClientCommandManager.literal("hackxp") + .then(ClientCommandManager.argument("xp", IntegerArgumentType.integer()) + .executes(HackXP::run) + ) + ); + } + + private static int run(CommandContext context) throws CommandSyntaxException { + int xp = IntegerArgumentType.getInteger(context,"xp"); + + if (Minecraft.getInstance().player == null) return -1; + Minecraft.getInstance().player.experienceLevel += xp; + + return 1; + } +} diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleSuggestionProvider.java b/src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleSuggestionProvider.java new file mode 100644 index 0000000..881ddd6 --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleSuggestionProvider.java @@ -0,0 +1,26 @@ +package com.arslaancodes.arslaansmagichax.commands; + +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.suggestion.SuggestionProvider; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import com.arslaancodes.arslaansmagichax.modules.Module; +import com.arslaancodes.arslaansmagichax.modules.ModuleManager; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class ModuleSuggestionProvider implements SuggestionProvider { + @Override + public CompletableFuture getSuggestions(CommandContext context, SuggestionsBuilder builder) throws CommandSyntaxException { + List modules = ModuleManager.getAllModules(); + + for (Module module : modules) { + builder.suggest(module.getName()); + } + + return builder.buildFuture(); + } +} \ No newline at end of file diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleToggleCommand.java b/src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleToggleCommand.java new file mode 100644 index 0000000..60e6b52 --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/commands/ModuleToggleCommand.java @@ -0,0 +1,44 @@ +package com.arslaancodes.arslaansmagichax.commands; + +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.commands.CommandBuildContext; +import net.minecraft.network.chat.Component; +import com.arslaancodes.arslaansmagichax.modules.ModuleManager; + +public class ModuleToggleCommand { + public static void register(CommandDispatcher dispatcher, CommandBuildContext access) { + dispatcher.register( + ClientCommandManager.literal("module") + .then( + ClientCommandManager.literal("toggle") + .then( + ClientCommandManager.argument("moduleName", StringArgumentType.word()) + .suggests(new ModuleSuggestionProvider()) + .executes(ModuleToggleCommand::run) + ) + ) + ); + } + + private static int run(CommandContext context) throws CommandSyntaxException { + String moduleName = StringArgumentType.getString(context, "moduleName"); + + ModuleManager.getAllModules().stream() + .filter(m -> m.getName().equalsIgnoreCase(moduleName)) + .findFirst() + .ifPresentOrElse(module -> { + module.toggle(); + context.getSource().sendFeedback(Component.literal( + "Toggled module " + module.getName() + " to " + (module.isEnabled() ? "ON" : "OFF") + )); + }, () -> context.getSource().sendError(Component.literal("Module not found: " + moduleName))); + + return 1; + } +} -- cgit v1.2.3