summary refs log tree commit diff stats
path: root/src/main/kotlin/space/autistic/uwumode/UwuMode.kt
blob: 3e983644999063f8d743b76a6a689ccff9d1a55b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package space.autistic.uwumode

import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.context.CommandContext;

import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;

// For support join https://discord.gg/v6v4pMv

var enabled = false
var timer = 0

fun uwutimer(c: CommandContext<FabricClientCommandSource>): Int {
    val time = IntegerArgumentType.getInteger(c, "seconds");
    if (timer != time) {
        timer = time*20;
        enabled = true;
        return 1
    }
    return 0
}

fun uwumode(c: CommandContext<FabricClientCommandSource>): Int {
    val enable = BoolArgumentType.getBool(c, "enable");
    if (timer > 0 || enabled != enable) {
        timer = 0;
        enabled = enable;
        return 1
    }
    return 0
}

@Suppress("unused")
fun init() {
    // This mod is client-only, so this is the client init.

    ClientCommandManager.DISPATCHER.register(
        ClientCommandManager.literal("uwu")
        .then(
            ClientCommandManager.argument(
                "seconds",
                IntegerArgumentType.integer(0, 0x7FFFFFFF/20)
            ).executes(::uwutimer)
        )
        .then(
            ClientCommandManager.argument(
                "enable",
                BoolArgumentType.bool()
            ).executes(::uwumode)
        )
    );

    ClientTickEvents.START_CLIENT_TICK.register {
        if (timer > 0) {
            --timer;
            if (timer == 0) {
                enabled = false;
            }
        }
    };
}