aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2021-10-20 19:24:45 +0300
committerSHsuperCM <shsupercm@gmail.com>2021-10-20 19:24:45 +0300
commit56ac94e144b991da6206dd1bc4d67cfbd14dc781 (patch)
tree4e945a1dd999e5011427623f686dca1e404b7c35
parentff6d92d435c18dfae308bec82ebe1d1cefb2cfb9 (diff)
downloadCITResewn-56ac94e144b991da6206dd1bc4d67cfbd14dc781.tar.gz
CITResewn-56ac94e144b991da6206dd1bc4d67cfbd14dc781.tar.bz2
CITResewn-56ac94e144b991da6206dd1bc4d67cfbd14dc781.zip
Added citresewn command
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java4
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java33
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/core/ChatScreenMixin.java23
-rw-r--r--src/main/resources/citresewn.mixins.json1
4 files changed, 59 insertions, 2 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java
index 9ee05e4..e53ba52 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java
@@ -3,8 +3,6 @@ package shcm.shsupercm.fabric.citresewn;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-import net.fabricmc.loader.api.FabricLoader;
-import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
@@ -26,6 +24,8 @@ public class CITResewn implements ClientModInitializer {
INSTANCE = this;
config = CITResewnConfig.read();
+
+ CITResewnCommand.register();
}
public static void info(String message) {
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java
new file mode 100644
index 0000000..483cbfb
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewnCommand.java
@@ -0,0 +1,33 @@
+package shcm.shsupercm.fabric.citresewn;
+
+import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
+import net.fabricmc.loader.api.FabricLoader;
+import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
+
+import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
+import static net.minecraft.text.Text.of;
+
+public class CITResewnCommand {
+ public static boolean openConfig = false;
+
+ public static void register() {
+ ClientCommandManager.DISPATCHER.register(literal("citresewn")
+ .executes(context -> {
+ context.getSource().sendFeedback(of("CIT Resewn v" + FabricLoader.getInstance().getModContainer("citresewn").get().getMetadata().getVersion() + ":"));
+ boolean active = CITResewnConfig.INSTANCE().enabled && CITResewn.INSTANCE.activeCITs != null;
+ context.getSource().sendFeedback(of(" Active: " + (active ? "yes" : "no")));
+ if (active) {
+ context.getSource().sendFeedback(of(" Loaded: " + CITResewn.INSTANCE.activeCITs.cits.size() + " CITs from " + CITResewn.INSTANCE.activeCITs.packs.size() + " resourcepacks"));
+ }
+ context.getSource().sendFeedback(of(" "));
+
+ return 1;
+ })
+ .then(literal("config")
+ .executes(context -> {
+ openConfig = true;
+
+ return 1;
+ })));
+ }
+}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/core/ChatScreenMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/core/ChatScreenMixin.java
new file mode 100644
index 0000000..cdd9eb1
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/core/ChatScreenMixin.java
@@ -0,0 +1,23 @@
+package shcm.shsupercm.fabric.citresewn.mixin.core;
+
+import net.minecraft.client.gui.screen.ChatScreen;
+import net.minecraft.client.gui.screen.Screen;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.ModifyArg;
+import shcm.shsupercm.fabric.citresewn.OptionalCompat;
+
+import static shcm.shsupercm.fabric.citresewn.CITResewnCommand.openConfig;
+
+@Mixin(ChatScreen.class)
+public class ChatScreenMixin {
+ @ModifyArg(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V"))
+ public Screen redirectConfigScreen(Screen original) {
+ if (original == null && openConfig) {
+ openConfig = false;
+ return OptionalCompat.getModConfigScreenFactory().apply(null);
+ }
+
+ return original;
+ }
+}
diff --git a/src/main/resources/citresewn.mixins.json b/src/main/resources/citresewn.mixins.json
index 7567ac4..179a3bf 100644
--- a/src/main/resources/citresewn.mixins.json
+++ b/src/main/resources/citresewn.mixins.json
@@ -23,6 +23,7 @@
"cititem.ItemStackMixin",
"cititem.JsonUnbakedModelAccessor",
"cititem.ModelLoaderMixin",
+ "core.ChatScreenMixin",
"core.GroupResourcePackAccessor",
"core.ModelLoaderMixin",
"core.NbtCompoundAccessor",