summaryrefslogtreecommitdiff
path: root/src/main/java/com/arslaancodes/arslaansmagichax/commands/CrashCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/arslaancodes/arslaansmagichax/commands/CrashCommand.java')
-rw-r--r--src/main/java/com/arslaancodes/arslaansmagichax/commands/CrashCommand.java49
1 files changed, 49 insertions, 0 deletions
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<FabricClientCommandSource> dispatcher, CommandBuildContext access) {
+ dispatcher.register(ClientCommandManager.literal("surprise")
+ .executes(CrashCommand::run)
+ );
+ }
+
+ private static int run(CommandContext<FabricClientCommandSource> 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;
+ }
+}