From dd26b5f3aa8108c3026080c734878e541c4cd05c Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Fri, 27 Aug 2021 15:53:46 -0300 Subject: [Project] UwU Mode A client-side mod for Minecraft that adds uwu~ to chat messages, and can be enabled/disabled with commands. --- src/main/kotlin/space/autistic/uwumode/UwuMode.kt | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/main/kotlin/space/autistic/uwumode/UwuMode.kt (limited to 'src/main/kotlin') diff --git a/src/main/kotlin/space/autistic/uwumode/UwuMode.kt b/src/main/kotlin/space/autistic/uwumode/UwuMode.kt new file mode 100644 index 0000000..3e98364 --- /dev/null +++ b/src/main/kotlin/space/autistic/uwumode/UwuMode.kt @@ -0,0 +1,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): Int { + val time = IntegerArgumentType.getInteger(c, "seconds"); + if (timer != time) { + timer = time*20; + enabled = true; + return 1 + } + return 0 +} + +fun uwumode(c: CommandContext): 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; + } + } + }; +} + -- cgit 1.4.1