summary refs log tree commit diff stats
path: root/src/main
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2021-08-27 15:53:46 -0300
committerSoniEx2 <endermoneymod@gmail.com>2021-08-27 15:53:46 -0300
commitdd26b5f3aa8108c3026080c734878e541c4cd05c (patch)
treedc16b2c4d3927cb44245a66e8a41ed7d005aeae4 /src/main
[Project] UwU Mode HEAD fabric-1.17.x default
A client-side mod for Minecraft that adds uwu~ to chat messages, and can
be enabled/disabled with commands.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/space/autistic/uwumode/mixin/UwuMixin.java25
-rw-r--r--src/main/kotlin/space/autistic/uwumode/UwuMode.kt65
-rw-r--r--src/main/resources/fabric.mod.json35
-rw-r--r--src/main/resources/uwumode.mixins.json13
4 files changed, 138 insertions, 0 deletions
diff --git a/src/main/java/space/autistic/uwumode/mixin/UwuMixin.java b/src/main/java/space/autistic/uwumode/mixin/UwuMixin.java
new file mode 100644
index 0000000..6719747
--- /dev/null
+++ b/src/main/java/space/autistic/uwumode/mixin/UwuMixin.java
@@ -0,0 +1,25 @@
+package space.autistic.uwumode.mixin;
+
+import net.minecraft.client.network.ClientPlayerEntity;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.ModifyVariable;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import space.autistic.uwumode.UwuModeKt;
+
+@Mixin(ClientPlayerEntity.class)
+public class UwuMixin {
+    @ModifyVariable(at = @At(value = "HEAD"), method = "sendChatMessage(Ljava/lang/String;)V", argsOnly = true)
+    private String sendChatMessage(String chatMessage) {
+        if (UwuModeKt.getEnabled()) {
+            if (!chatMessage.startsWith("/")) {
+                return chatMessage + " uwu~";
+            }
+        }
+        return chatMessage;
+    }
+}
+
+// vim: expandtab sw=4
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<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;
+            }
+        }
+    };
+}
+
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
new file mode 100644
index 0000000..485459c
--- /dev/null
+++ b/src/main/resources/fabric.mod.json
@@ -0,0 +1,35 @@
+{
+  "schemaVersion": 1,
+  "id": "uwumode",
+  "version": "${version}",
+
+  "name": "UwU Mode",
+  "description": "Makes your messages end in uwu, with consent.",
+  "authors": [
+    "SoniEx2"
+  ],
+  "contact": {
+    "homepage": "https://autistic.space/",
+    "sources": "https://soniex2.autistic.space/git-repos/uwumode.git"
+  },
+
+  "license": "AGPL-3.0-or-later",
+
+  "environment": "*",
+  "entrypoints": {
+    "client": [
+      "space.autistic.uwumode.UwuModeKt::init"
+    ]
+  },
+  "mixins": [
+    "uwumode.mixins.json"
+  ],
+  "depends": {
+    "fabricloader": ">=0.8.7",
+    "fabric": "*",
+    "fabric-language-kotlin": "*",
+    "minecraft": "1.17.x"
+  },
+  "suggests": {
+  }
+}
diff --git a/src/main/resources/uwumode.mixins.json b/src/main/resources/uwumode.mixins.json
new file mode 100644
index 0000000..4eb19dc
--- /dev/null
+++ b/src/main/resources/uwumode.mixins.json
@@ -0,0 +1,13 @@
+{
+  "required": true,
+  "package": "space.autistic.uwumode.mixin",
+  "compatibilityLevel": "JAVA_8",
+  "mixins": [
+  ],
+  "client": [
+    "UwuMixin"
+  ],
+  "injectors": {
+    "defaultRequire": 1
+  }
+}